diff --git a/ruoyi-admin/pom.xml b/bmw-admin/pom.xml similarity index 100% rename from ruoyi-admin/pom.xml rename to bmw-admin/pom.xml diff --git a/bmw-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/bmw-admin/src/main/java/com/ruoyi/RuoYiApplication.java new file mode 100644 index 000000000..21eb95ee0 --- /dev/null +++ b/bmw-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -0,0 +1,21 @@ +package com.ruoyi; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * 启动程序 + * + * @author ruoyi + */ +@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) +public class RuoYiApplication +{ + public static void main(String[] args) + { + // System.setProperty("spring.devtools.restart.enabled", "false"); + SpringApplication.run(RuoYiApplication.class, args); + System.out.println("启动成功"); + } +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiServletInitializer.java b/bmw-admin/src/main/java/com/ruoyi/RuoYiServletInitializer.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/RuoYiServletInitializer.java rename to bmw-admin/src/main/java/com/ruoyi/RuoYiServletInitializer.java index 9d82a2378..6de67dc76 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiServletInitializer.java +++ b/bmw-admin/src/main/java/com/ruoyi/RuoYiServletInitializer.java @@ -1,18 +1,18 @@ -package com.ruoyi; - -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; - -/** - * web容器中进行部署 - * - * @author ruoyi - */ -public class RuoYiServletInitializer extends SpringBootServletInitializer -{ - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) - { - return application.sources(RuoYiApplication.class); - } -} +package com.ruoyi; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +/** + * web容器中进行部署 + * + * @author ruoyi + */ +public class RuoYiServletInitializer extends SpringBootServletInitializer +{ + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) + { + return application.sources(RuoYiApplication.class); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java similarity index 97% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index fa80f5f10..7a049e1ee 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -1,91 +1,91 @@ -package com.ruoyi.web.controller.common; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.common.config.Global; -import com.ruoyi.common.config.ServerConfig; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.file.FileUploadUtils; -import com.ruoyi.common.utils.file.FileUtils; - -/** - * 通用请求处理 - * - * @author ruoyi - */ -@Controller -public class CommonController -{ - private static final Logger log = LoggerFactory.getLogger(CommonController.class); - - @Autowired - private ServerConfig serverConfig; - - /** - * 通用下载请求 - * - * @param fileName 文件名称 - * @param delete 是否删除 - */ - @GetMapping("common/download") - public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) - { - try - { - if (!FileUtils.isValidFilename(fileName)) - { - throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); - } - String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); - String filePath = Global.getDownloadPath() + fileName; - - response.setCharacterEncoding("utf-8"); - response.setContentType("multipart/form-data"); - response.setHeader("Content-Disposition", - "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName)); - FileUtils.writeBytes(filePath, response.getOutputStream()); - if (delete) - { - FileUtils.deleteFile(filePath); - } - } - catch (Exception e) - { - log.error("下载文件失败", e); - } - } - - /** - * 通用上传请求 - */ - @PostMapping("/common/upload") - @ResponseBody - public AjaxResult uploadFile(MultipartFile file) throws Exception - { - try - { - // 上传文件路径 - String filePath = Global.getUploadPath(); - // 上传并返回新文件名称 - String fileName = FileUploadUtils.upload(filePath, file); - String url = serverConfig.getUrl() + fileName; - AjaxResult ajax = AjaxResult.success(); - ajax.put("fileName", fileName); - ajax.put("url", url); - return ajax; - } - catch (Exception e) - { - return AjaxResult.error(e.getMessage()); - } - } -} +package com.ruoyi.web.controller.common; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.config.Global; +import com.ruoyi.common.config.ServerConfig; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.file.FileUtils; + +/** + * 通用请求处理 + * + * @author ruoyi + */ +@Controller +public class CommonController +{ + private static final Logger log = LoggerFactory.getLogger(CommonController.class); + + @Autowired + private ServerConfig serverConfig; + + /** + * 通用下载请求 + * + * @param fileName 文件名称 + * @param delete 是否删除 + */ + @GetMapping("common/download") + public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) + { + try + { + if (!FileUtils.isValidFilename(fileName)) + { + throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); + } + String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); + String filePath = Global.getDownloadPath() + fileName; + + response.setCharacterEncoding("utf-8"); + response.setContentType("multipart/form-data"); + response.setHeader("Content-Disposition", + "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName)); + FileUtils.writeBytes(filePath, response.getOutputStream()); + if (delete) + { + FileUtils.deleteFile(filePath); + } + } + catch (Exception e) + { + log.error("下载文件失败", e); + } + } + + /** + * 通用上传请求 + */ + @PostMapping("/common/upload") + @ResponseBody + public AjaxResult uploadFile(MultipartFile file) throws Exception + { + try + { + // 上传文件路径 + String filePath = Global.getUploadPath(); + // 上传并返回新文件名称 + String fileName = FileUploadUtils.upload(filePath, file); + String url = serverConfig.getUrl() + fileName; + AjaxResult ajax = AjaxResult.success(); + ajax.put("fileName", fileName); + ajax.put("url", url); + return ajax; + } + catch (Exception e) + { + return AjaxResult.error(e.getMessage()); + } + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoDialogController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoDialogController.java similarity index 94% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoDialogController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoDialogController.java index 78d6da74b..cf52245f0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoDialogController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoDialogController.java @@ -1,80 +1,80 @@ -package com.ruoyi.web.controller.demo.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * 模态窗口 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/demo/modal") -public class DemoDialogController -{ - private String prefix = "demo/modal"; - - /** - * 模态窗口 - */ - @GetMapping("/dialog") - public String dialog() - { - return prefix + "/dialog"; - } - - /** - * 弹层组件 - */ - @GetMapping("/layer") - public String layer() - { - return prefix + "/layer"; - } - - /** - * 表单 - */ - @GetMapping("/form") - public String form() - { - return prefix + "/form"; - } - - /** - * 表格 - */ - @GetMapping("/table") - public String table() - { - return prefix + "/table"; - } - - /** - * 表格check - */ - @GetMapping("/check") - public String check() - { - return prefix + "/table/check"; - } - - /** - * 表格radio - */ - @GetMapping("/radio") - public String radio() - { - return prefix + "/table/radio"; - } - - /** - * 表格回传父窗体 - */ - @GetMapping("/parent") - public String parent() - { - return prefix + "/table/parent"; - } -} +package com.ruoyi.web.controller.demo.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * 模态窗口 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/demo/modal") +public class DemoDialogController +{ + private String prefix = "demo/modal"; + + /** + * 模态窗口 + */ + @GetMapping("/dialog") + public String dialog() + { + return prefix + "/dialog"; + } + + /** + * 弹层组件 + */ + @GetMapping("/layer") + public String layer() + { + return prefix + "/layer"; + } + + /** + * 表单 + */ + @GetMapping("/form") + public String form() + { + return prefix + "/form"; + } + + /** + * 表格 + */ + @GetMapping("/table") + public String table() + { + return prefix + "/table"; + } + + /** + * 表格check + */ + @GetMapping("/check") + public String check() + { + return prefix + "/table/check"; + } + + /** + * 表格radio + */ + @GetMapping("/radio") + public String radio() + { + return prefix + "/table/radio"; + } + + /** + * 表格回传父窗体 + */ + @GetMapping("/parent") + public String parent() + { + return prefix + "/table/parent"; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoFormController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoFormController.java similarity index 94% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoFormController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoFormController.java index fb43aa73f..65f732b46 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoFormController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoFormController.java @@ -1,261 +1,261 @@ -package com.ruoyi.web.controller.demo.controller; - -import java.util.ArrayList; -import java.util.List; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.core.domain.AjaxResult; - -/** - * 表单相关 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/demo/form") -public class DemoFormController -{ - private String prefix = "demo/form"; - - private final static List users = new ArrayList(); - { - users.add(new UserFormModel(1, "1000001", "测试1", "15888888888")); - users.add(new UserFormModel(2, "1000002", "测试2", "15666666666")); - users.add(new UserFormModel(3, "1000003", "测试3", "15666666666")); - users.add(new UserFormModel(4, "1000004", "测试4", "15666666666")); - users.add(new UserFormModel(5, "1000005", "测试5", "15666666666")); - } - - /** - * 按钮页 - */ - @GetMapping("/button") - public String button() - { - return prefix + "/button"; - } - - /** - * 下拉框 - */ - @GetMapping("/select") - public String select() - { - return prefix + "/select"; - } - - /** - * 表单校验 - */ - @GetMapping("/validate") - public String validate() - { - return prefix + "/validate"; - } - - /** - * 功能扩展(包含文件上传) - */ - @GetMapping("/jasny") - public String jasny() - { - return prefix + "/jasny"; - } - - /** - * 拖动排序 - */ - @GetMapping("/sortable") - public String sortable() - { - return prefix + "/sortable"; - } - - /** - * 选项卡 & 面板 - */ - @GetMapping("/tabs_panels") - public String tabs_panels() - { - return prefix + "/tabs_panels"; - } - - /** - * 栅格 - */ - @GetMapping("/grid") - public String grid() - { - return prefix + "/grid"; - } - - /** - * 表单向导 - */ - @GetMapping("/wizard") - public String wizard() - { - return prefix + "/wizard"; - } - - /** - * 文件上传 - */ - @GetMapping("/upload") - public String upload() - { - return prefix + "/upload"; - } - - /** - * 日期和时间页 - */ - @GetMapping("/datetime") - public String datetime() - { - return prefix + "/datetime"; - } - - /** - * 左右互选组件 - */ - @GetMapping("/duallistbox") - public String duallistbox() - { - return prefix + "/duallistbox"; - } - - /** - * 基本表单 - */ - @GetMapping("/basic") - public String basic() - { - return prefix + "/basic"; - } - - /** - * 卡片列表 - */ - @GetMapping("/cards") - public String cards() - { - return prefix + "/cards"; - } - - /** - * summernote 富文本编辑器 - */ - @GetMapping("/summernote") - public String summernote() - { - return prefix + "/summernote"; - } - - /** - * 搜索自动补全 - */ - @GetMapping("/autocomplete") - public String autocomplete() - { - return prefix + "/autocomplete"; - } - - /** - * 获取用户数据 - */ - @GetMapping("/userModel") - @ResponseBody - public AjaxResult userModel() - { - AjaxResult ajax = new AjaxResult(); - - ajax.put("code", 200); - ajax.put("value", users); - return ajax; - } - - /** - * 获取数据集合 - */ - @GetMapping("/collection") - @ResponseBody - public AjaxResult collection() - { - String[] array = { "ruoyi 1", "ruoyi 2", "ruoyi 3", "ruoyi 4", "ruoyi 5" }; - AjaxResult ajax = new AjaxResult(); - ajax.put("value", array); - return ajax; - } -} - -class UserFormModel -{ - /** 用户ID */ - private int userId; - - /** 用户编号 */ - private String userCode; - - /** 用户姓名 */ - private String userName; - - /** 用户手机 */ - private String userPhone; - - public UserFormModel() - { - - } - - public UserFormModel(int userId, String userCode, String userName, String userPhone) - { - this.userId = userId; - this.userCode = userCode; - this.userName = userName; - this.userPhone = userPhone; - } - - public int getUserId() - { - return userId; - } - - public void setUserId(int userId) - { - this.userId = userId; - } - - public String getUserCode() - { - return userCode; - } - - public void setUserCode(String userCode) - { - this.userCode = userCode; - } - - public String getUserName() - { - return userName; - } - - public void setUserName(String userName) - { - this.userName = userName; - } - - public String getUserPhone() - { - return userPhone; - } - - public void setUserPhone(String userPhone) - { - this.userPhone = userPhone; - } - -} +package com.ruoyi.web.controller.demo.controller; + +import java.util.ArrayList; +import java.util.List; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.core.domain.AjaxResult; + +/** + * 表单相关 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/demo/form") +public class DemoFormController +{ + private String prefix = "demo/form"; + + private final static List users = new ArrayList(); + { + users.add(new UserFormModel(1, "1000001", "测试1", "15888888888")); + users.add(new UserFormModel(2, "1000002", "测试2", "15666666666")); + users.add(new UserFormModel(3, "1000003", "测试3", "15666666666")); + users.add(new UserFormModel(4, "1000004", "测试4", "15666666666")); + users.add(new UserFormModel(5, "1000005", "测试5", "15666666666")); + } + + /** + * 按钮页 + */ + @GetMapping("/button") + public String button() + { + return prefix + "/button"; + } + + /** + * 下拉框 + */ + @GetMapping("/select") + public String select() + { + return prefix + "/select"; + } + + /** + * 表单校验 + */ + @GetMapping("/validate") + public String validate() + { + return prefix + "/validate"; + } + + /** + * 功能扩展(包含文件上传) + */ + @GetMapping("/jasny") + public String jasny() + { + return prefix + "/jasny"; + } + + /** + * 拖动排序 + */ + @GetMapping("/sortable") + public String sortable() + { + return prefix + "/sortable"; + } + + /** + * 选项卡 & 面板 + */ + @GetMapping("/tabs_panels") + public String tabs_panels() + { + return prefix + "/tabs_panels"; + } + + /** + * 栅格 + */ + @GetMapping("/grid") + public String grid() + { + return prefix + "/grid"; + } + + /** + * 表单向导 + */ + @GetMapping("/wizard") + public String wizard() + { + return prefix + "/wizard"; + } + + /** + * 文件上传 + */ + @GetMapping("/upload") + public String upload() + { + return prefix + "/upload"; + } + + /** + * 日期和时间页 + */ + @GetMapping("/datetime") + public String datetime() + { + return prefix + "/datetime"; + } + + /** + * 左右互选组件 + */ + @GetMapping("/duallistbox") + public String duallistbox() + { + return prefix + "/duallistbox"; + } + + /** + * 基本表单 + */ + @GetMapping("/basic") + public String basic() + { + return prefix + "/basic"; + } + + /** + * 卡片列表 + */ + @GetMapping("/cards") + public String cards() + { + return prefix + "/cards"; + } + + /** + * summernote 富文本编辑器 + */ + @GetMapping("/summernote") + public String summernote() + { + return prefix + "/summernote"; + } + + /** + * 搜索自动补全 + */ + @GetMapping("/autocomplete") + public String autocomplete() + { + return prefix + "/autocomplete"; + } + + /** + * 获取用户数据 + */ + @GetMapping("/userModel") + @ResponseBody + public AjaxResult userModel() + { + AjaxResult ajax = new AjaxResult(); + + ajax.put("code", 200); + ajax.put("value", users); + return ajax; + } + + /** + * 获取数据集合 + */ + @GetMapping("/collection") + @ResponseBody + public AjaxResult collection() + { + String[] array = { "ruoyi 1", "ruoyi 2", "ruoyi 3", "ruoyi 4", "ruoyi 5" }; + AjaxResult ajax = new AjaxResult(); + ajax.put("value", array); + return ajax; + } +} + +class UserFormModel +{ + /** 用户ID */ + private int userId; + + /** 用户编号 */ + private String userCode; + + /** 用户姓名 */ + private String userName; + + /** 用户手机 */ + private String userPhone; + + public UserFormModel() + { + + } + + public UserFormModel(int userId, String userCode, String userName, String userPhone) + { + this.userId = userId; + this.userCode = userCode; + this.userName = userName; + this.userPhone = userPhone; + } + + public int getUserId() + { + return userId; + } + + public void setUserId(int userId) + { + this.userId = userId; + } + + public String getUserCode() + { + return userCode; + } + + public void setUserCode(String userCode) + { + this.userCode = userCode; + } + + public String getUserName() + { + return userName; + } + + public void setUserName(String userName) + { + this.userName = userName; + } + + public String getUserPhone() + { + return userPhone; + } + + public void setUserPhone(String userPhone) + { + this.userPhone = userPhone; + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoIconController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoIconController.java similarity index 95% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoIconController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoIconController.java index 490c3e061..b6884cc1e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoIconController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoIconController.java @@ -1,35 +1,35 @@ -package com.ruoyi.web.controller.demo.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * 图标相关 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/demo/icon") -public class DemoIconController -{ - private String prefix = "demo/icon"; - - /** - * FontAwesome图标 - */ - @GetMapping("/fontawesome") - public String fontAwesome() - { - return prefix + "/fontawesome"; - } - - /** - * Glyphicons图标 - */ - @GetMapping("/glyphicons") - public String glyphicons() - { - return prefix + "/glyphicons"; - } -} +package com.ruoyi.web.controller.demo.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * 图标相关 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/demo/icon") +public class DemoIconController +{ + private String prefix = "demo/icon"; + + /** + * FontAwesome图标 + */ + @GetMapping("/fontawesome") + public String fontAwesome() + { + return prefix + "/fontawesome"; + } + + /** + * Glyphicons图标 + */ + @GetMapping("/glyphicons") + public String glyphicons() + { + return prefix + "/glyphicons"; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java similarity index 97% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java index 8c35b23eb..703d860df 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java @@ -1,303 +1,303 @@ -package com.ruoyi.web.controller.demo.controller; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.PageDomain; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.core.page.TableSupport; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.web.controller.demo.domain.UserOperateModel; - -/** - * 操作控制 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/demo/operate") -public class DemoOperateController extends BaseController -{ - private String prefix = "demo/operate"; - - private final static Map users = new LinkedHashMap(); - { - users.put(1, new UserOperateModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0")); - users.put(2, new UserOperateModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1")); - users.put(3, new UserOperateModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1")); - users.put(4, new UserOperateModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1")); - users.put(5, new UserOperateModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1")); - users.put(6, new UserOperateModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1")); - users.put(7, new UserOperateModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1")); - users.put(8, new UserOperateModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1")); - users.put(9, new UserOperateModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1")); - users.put(10, new UserOperateModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1")); - users.put(11, new UserOperateModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1")); - users.put(12, new UserOperateModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1")); - users.put(13, new UserOperateModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1")); - users.put(14, new UserOperateModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1")); - users.put(15, new UserOperateModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1")); - users.put(16, new UserOperateModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1")); - users.put(17, new UserOperateModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1")); - users.put(18, new UserOperateModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1")); - users.put(19, new UserOperateModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1")); - users.put(20, new UserOperateModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1")); - users.put(21, new UserOperateModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1")); - users.put(22, new UserOperateModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1")); - users.put(23, new UserOperateModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1")); - users.put(24, new UserOperateModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1")); - users.put(25, new UserOperateModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1")); - users.put(26, new UserOperateModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1")); - } - - /** - * 表格 - */ - @GetMapping("/table") - public String table() - { - return prefix + "/table"; - } - - /** - * 其他 - */ - @GetMapping("/other") - public String other() - { - return prefix + "/other"; - } - - /** - * 查询数据 - */ - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(UserOperateModel userModel) - { - TableDataInfo rspData = new TableDataInfo(); - List userList = new ArrayList(users.values()); - // 查询条件过滤 - if (StringUtils.isNotEmpty(userModel.getSearchValue())) - { - userList.clear(); - for (Map.Entry entry : users.entrySet()) - { - if (entry.getValue().getUserName().equals(userModel.getSearchValue())) - { - userList.add(entry.getValue()); - } - } - } - PageDomain pageDomain = TableSupport.buildPageRequest(); - if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) - { - rspData.setRows(userList); - rspData.setTotal(userList.size()); - return rspData; - } - Integer pageNum = (pageDomain.getPageNum() - 1) * 10; - Integer pageSize = pageDomain.getPageNum() * 10; - if (pageSize > userList.size()) - { - pageSize = userList.size(); - } - rspData.setRows(userList.subList(pageNum, pageSize)); - rspData.setTotal(userList.size()); - return rspData; - } - - /** - * 新增用户 - */ - @GetMapping("/add") - public String add(ModelMap mmap) - { - return prefix + "/add"; - } - - /** - * 新增保存用户 - */ - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(UserOperateModel user) - { - Integer userId = users.size() + 1; - user.setUserId(userId); - return AjaxResult.success(users.put(userId, user)); - } - - /** - * 修改用户 - */ - @GetMapping("/edit/{userId}") - public String edit(@PathVariable("userId") Integer userId, ModelMap mmap) - { - mmap.put("user", users.get(userId)); - return prefix + "/edit"; - } - - /** - * 修改保存用户 - */ - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(UserOperateModel user) - { - return AjaxResult.success(users.put(user.getUserId(), user)); - } - - /** - * 导出 - */ - @PostMapping("/export") - @ResponseBody - public AjaxResult export(UserOperateModel user) - { - List list = new ArrayList(users.values()); - ExcelUtil util = new ExcelUtil(UserOperateModel.class); - return util.exportExcel(list, "用户数据"); - } - - /** - * 下载模板 - */ - @GetMapping("/importTemplate") - @ResponseBody - public AjaxResult importTemplate() - { - ExcelUtil util = new ExcelUtil(UserOperateModel.class); - return util.importTemplateExcel("用户数据"); - } - - /** - * 导入数据 - */ - @PostMapping("/importData") - @ResponseBody - public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception - { - ExcelUtil util = new ExcelUtil(UserOperateModel.class); - List userList = util.importExcel(file.getInputStream()); - String message = importUser(userList, updateSupport); - return AjaxResult.success(message); - } - - /** - * 删除用户 - */ - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - Integer[] userIds = Convert.toIntArray(ids); - for (Integer userId : userIds) - { - users.remove(userId); - } - return AjaxResult.success(); - } - - /** - * 查看详细 - */ - @GetMapping("/detail/{userId}") - public String detail(@PathVariable("userId") Integer userId, ModelMap mmap) - { - mmap.put("user", users.get(userId)); - return prefix + "/detail"; - } - - @PostMapping("/clean") - @ResponseBody - public AjaxResult clean() - { - users.clear(); - return success(); - } - - /** - * 导入用户数据 - * - * @param userList 用户数据列表 - * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 - * @return 结果 - */ - public String importUser(List userList, Boolean isUpdateSupport) - { - if (StringUtils.isNull(userList) || userList.size() == 0) - { - throw new BusinessException("导入用户数据不能为空!"); - } - int successNum = 0; - int failureNum = 0; - StringBuilder successMsg = new StringBuilder(); - StringBuilder failureMsg = new StringBuilder(); - for (UserOperateModel user : userList) - { - try - { - // 验证是否存在这个用户 - boolean userFlag = false; - for (Map.Entry entry : users.entrySet()) - { - if (entry.getValue().getUserName().equals(user.getUserName())) - { - userFlag = true; - break; - } - } - if (!userFlag) - { - Integer userId = users.size() + 1; - user.setUserId(userId); - users.put(userId, user); - successNum++; - successMsg.append("
" + successNum + "、用户 " + user.getUserName() + " 导入成功"); - } - else if (isUpdateSupport) - { - users.put(user.getUserId(), user); - successNum++; - successMsg.append("
" + successNum + "、用户 " + user.getUserName() + " 更新成功"); - } - else - { - failureNum++; - failureMsg.append("
" + failureNum + "、用户 " + user.getUserName() + " 已存在"); - } - } - catch (Exception e) - { - failureNum++; - String msg = "
" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; - failureMsg.append(msg + e.getMessage()); - } - } - if (failureNum > 0) - { - failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); - throw new BusinessException(failureMsg.toString()); - } - else - { - successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); - } - return successMsg.toString(); - } -} +package com.ruoyi.web.controller.demo.controller; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.page.TableSupport; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.web.controller.demo.domain.UserOperateModel; + +/** + * 操作控制 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/demo/operate") +public class DemoOperateController extends BaseController +{ + private String prefix = "demo/operate"; + + private final static Map users = new LinkedHashMap(); + { + users.put(1, new UserOperateModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0")); + users.put(2, new UserOperateModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1")); + users.put(3, new UserOperateModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1")); + users.put(4, new UserOperateModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1")); + users.put(5, new UserOperateModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1")); + users.put(6, new UserOperateModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1")); + users.put(7, new UserOperateModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1")); + users.put(8, new UserOperateModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1")); + users.put(9, new UserOperateModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1")); + users.put(10, new UserOperateModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1")); + users.put(11, new UserOperateModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1")); + users.put(12, new UserOperateModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1")); + users.put(13, new UserOperateModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1")); + users.put(14, new UserOperateModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1")); + users.put(15, new UserOperateModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1")); + users.put(16, new UserOperateModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1")); + users.put(17, new UserOperateModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1")); + users.put(18, new UserOperateModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1")); + users.put(19, new UserOperateModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1")); + users.put(20, new UserOperateModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1")); + users.put(21, new UserOperateModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1")); + users.put(22, new UserOperateModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1")); + users.put(23, new UserOperateModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1")); + users.put(24, new UserOperateModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1")); + users.put(25, new UserOperateModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1")); + users.put(26, new UserOperateModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1")); + } + + /** + * 表格 + */ + @GetMapping("/table") + public String table() + { + return prefix + "/table"; + } + + /** + * 其他 + */ + @GetMapping("/other") + public String other() + { + return prefix + "/other"; + } + + /** + * 查询数据 + */ + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(UserOperateModel userModel) + { + TableDataInfo rspData = new TableDataInfo(); + List userList = new ArrayList(users.values()); + // 查询条件过滤 + if (StringUtils.isNotEmpty(userModel.getSearchValue())) + { + userList.clear(); + for (Map.Entry entry : users.entrySet()) + { + if (entry.getValue().getUserName().equals(userModel.getSearchValue())) + { + userList.add(entry.getValue()); + } + } + } + PageDomain pageDomain = TableSupport.buildPageRequest(); + if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) + { + rspData.setRows(userList); + rspData.setTotal(userList.size()); + return rspData; + } + Integer pageNum = (pageDomain.getPageNum() - 1) * 10; + Integer pageSize = pageDomain.getPageNum() * 10; + if (pageSize > userList.size()) + { + pageSize = userList.size(); + } + rspData.setRows(userList.subList(pageNum, pageSize)); + rspData.setTotal(userList.size()); + return rspData; + } + + /** + * 新增用户 + */ + @GetMapping("/add") + public String add(ModelMap mmap) + { + return prefix + "/add"; + } + + /** + * 新增保存用户 + */ + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(UserOperateModel user) + { + Integer userId = users.size() + 1; + user.setUserId(userId); + return AjaxResult.success(users.put(userId, user)); + } + + /** + * 修改用户 + */ + @GetMapping("/edit/{userId}") + public String edit(@PathVariable("userId") Integer userId, ModelMap mmap) + { + mmap.put("user", users.get(userId)); + return prefix + "/edit"; + } + + /** + * 修改保存用户 + */ + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(UserOperateModel user) + { + return AjaxResult.success(users.put(user.getUserId(), user)); + } + + /** + * 导出 + */ + @PostMapping("/export") + @ResponseBody + public AjaxResult export(UserOperateModel user) + { + List list = new ArrayList(users.values()); + ExcelUtil util = new ExcelUtil(UserOperateModel.class); + return util.exportExcel(list, "用户数据"); + } + + /** + * 下载模板 + */ + @GetMapping("/importTemplate") + @ResponseBody + public AjaxResult importTemplate() + { + ExcelUtil util = new ExcelUtil(UserOperateModel.class); + return util.importTemplateExcel("用户数据"); + } + + /** + * 导入数据 + */ + @PostMapping("/importData") + @ResponseBody + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception + { + ExcelUtil util = new ExcelUtil(UserOperateModel.class); + List userList = util.importExcel(file.getInputStream()); + String message = importUser(userList, updateSupport); + return AjaxResult.success(message); + } + + /** + * 删除用户 + */ + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + Integer[] userIds = Convert.toIntArray(ids); + for (Integer userId : userIds) + { + users.remove(userId); + } + return AjaxResult.success(); + } + + /** + * 查看详细 + */ + @GetMapping("/detail/{userId}") + public String detail(@PathVariable("userId") Integer userId, ModelMap mmap) + { + mmap.put("user", users.get(userId)); + return prefix + "/detail"; + } + + @PostMapping("/clean") + @ResponseBody + public AjaxResult clean() + { + users.clear(); + return success(); + } + + /** + * 导入用户数据 + * + * @param userList 用户数据列表 + * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @return 结果 + */ + public String importUser(List userList, Boolean isUpdateSupport) + { + if (StringUtils.isNull(userList) || userList.size() == 0) + { + throw new BusinessException("导入用户数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + for (UserOperateModel user : userList) + { + try + { + // 验证是否存在这个用户 + boolean userFlag = false; + for (Map.Entry entry : users.entrySet()) + { + if (entry.getValue().getUserName().equals(user.getUserName())) + { + userFlag = true; + break; + } + } + if (!userFlag) + { + Integer userId = users.size() + 1; + user.setUserId(userId); + users.put(userId, user); + successNum++; + successMsg.append("
" + successNum + "、用户 " + user.getUserName() + " 导入成功"); + } + else if (isUpdateSupport) + { + users.put(user.getUserId(), user); + successNum++; + successMsg.append("
" + successNum + "、用户 " + user.getUserName() + " 更新成功"); + } + else + { + failureNum++; + failureMsg.append("
" + failureNum + "、用户 " + user.getUserName() + " 已存在"); + } + } + catch (Exception e) + { + failureNum++; + String msg = "
" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; + failureMsg.append(msg + e.getMessage()); + } + } + if (failureNum > 0) + { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new BusinessException(failureMsg.toString()); + } + else + { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoReportController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoReportController.java similarity index 94% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoReportController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoReportController.java index 318e8f08b..610100874 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoReportController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoReportController.java @@ -1,53 +1,53 @@ -package com.ruoyi.web.controller.demo.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * 报表 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/demo/report") -public class DemoReportController -{ - private String prefix = "demo/report"; - - /** - * 百度ECharts - */ - @GetMapping("/echarts") - public String echarts() - { - return prefix + "/echarts"; - } - - /** - * 图表插件 - */ - @GetMapping("/peity") - public String peity() - { - return prefix + "/peity"; - } - - /** - * 线状图插件 - */ - @GetMapping("/sparkline") - public String sparkline() - { - return prefix + "/sparkline"; - } - - /** - * 图表组合 - */ - @GetMapping("/metrics") - public String metrics() - { - return prefix + "/metrics"; - } -} +package com.ruoyi.web.controller.demo.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * 报表 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/demo/report") +public class DemoReportController +{ + private String prefix = "demo/report"; + + /** + * 百度ECharts + */ + @GetMapping("/echarts") + public String echarts() + { + return prefix + "/echarts"; + } + + /** + * 图表插件 + */ + @GetMapping("/peity") + public String peity() + { + return prefix + "/peity"; + } + + /** + * 线状图插件 + */ + @GetMapping("/sparkline") + public String sparkline() + { + return prefix + "/sparkline"; + } + + /** + * 图表组合 + */ + @GetMapping("/metrics") + public String metrics() + { + return prefix + "/metrics"; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java index a698896a9..ebb7b3975 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java @@ -1,385 +1,385 @@ -package com.ruoyi.web.controller.demo.controller; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.page.PageDomain; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.core.page.TableSupport; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.StringUtils; - -/** - * 表格相关 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/demo/table") -public class DemoTableController extends BaseController -{ - private String prefix = "demo/table"; - - private final static List users = new ArrayList(); - { - users.add(new UserTableModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0")); - users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1")); - users.add(new UserTableModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1")); - users.add(new UserTableModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1")); - users.add(new UserTableModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1")); - users.add(new UserTableModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1")); - users.add(new UserTableModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1")); - users.add(new UserTableModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1")); - users.add(new UserTableModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1")); - users.add(new UserTableModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1")); - users.add(new UserTableModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1")); - users.add(new UserTableModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1")); - users.add(new UserTableModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1")); - users.add(new UserTableModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1")); - users.add(new UserTableModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1")); - users.add(new UserTableModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1")); - users.add(new UserTableModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1")); - users.add(new UserTableModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1")); - users.add(new UserTableModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1")); - users.add(new UserTableModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1")); - users.add(new UserTableModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1")); - users.add(new UserTableModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1")); - users.add(new UserTableModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1")); - users.add(new UserTableModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1")); - users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1")); - users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1")); - } - - /** - * 搜索相关 - */ - @GetMapping("/search") - public String search() - { - return prefix + "/search"; - } - - /** - * 数据汇总 - */ - @GetMapping("/footer") - public String footer() - { - return prefix + "/footer"; - } - - /** - * 组合表头 - */ - @GetMapping("/groupHeader") - public String groupHeader() - { - return prefix + "/groupHeader"; - } - - /** - * 表格导出 - */ - @GetMapping("/export") - public String export() - { - return prefix + "/export"; - } - - /** - * 翻页记住选择 - */ - @GetMapping("/remember") - public String remember() - { - return prefix + "/remember"; - } - - /** - * 跳转至指定页 - */ - @GetMapping("/pageGo") - public String pageGo() - { - return prefix + "/pageGo"; - } - - /** - * 自定义查询参数 - */ - @GetMapping("/params") - public String params() - { - return prefix + "/params"; - } - - /** - * 多表格 - */ - @GetMapping("/multi") - public String multi() - { - return prefix + "/multi"; - } - - /** - * 点击按钮加载表格 - */ - @GetMapping("/button") - public String button() - { - return prefix + "/button"; - } - - /** - * 表格冻结列 - */ - @GetMapping("/fixedColumns") - public String fixedColumns() - { - return prefix + "/fixedColumns"; - } - - /** - * 自定义触发事件 - */ - @GetMapping("/event") - public String event() - { - return prefix + "/event"; - } - - /** - * 表格细节视图 - */ - @GetMapping("/detail") - public String detail() - { - return prefix + "/detail"; - } - - /** - * 表格图片预览 - */ - @GetMapping("/image") - public String image() - { - return prefix + "/image"; - } - - /** - * 动态增删改查 - */ - @GetMapping("/curd") - public String curd() - { - return prefix + "/curd"; - } - - /** - * 表格拖拽操作 - */ - @GetMapping("/reorder") - public String reorder() - { - return prefix + "/reorder"; - } - - /** - * 表格其他操作 - */ - @GetMapping("/other") - public String other() - { - return prefix + "/other"; - } - - /** - * 查询数据 - */ - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(UserTableModel userModel) - { - TableDataInfo rspData = new TableDataInfo(); - List userList = new ArrayList(Arrays.asList(new UserTableModel[users.size()])); - Collections.copy(userList, users); - // 查询条件过滤 - if (StringUtils.isNotEmpty(userModel.getUserName())) - { - userList.clear(); - for (UserTableModel user : users) - { - if (user.getUserName().equals(userModel.getUserName())) - { - userList.add(user); - } - } - } - PageDomain pageDomain = TableSupport.buildPageRequest(); - if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) - { - rspData.setRows(userList); - rspData.setTotal(userList.size()); - return rspData; - } - Integer pageNum = (pageDomain.getPageNum() - 1) * 10; - Integer pageSize = pageDomain.getPageNum() * 10; - if (pageSize > userList.size()) - { - pageSize = userList.size(); - } - rspData.setRows(userList.subList(pageNum, pageSize)); - rspData.setTotal(userList.size()); - return rspData; - } -} - -class UserTableModel -{ - /** 用户ID */ - private int userId; - - /** 用户编号 */ - private String userCode; - - /** 用户姓名 */ - private String userName; - - /** 用户性别 */ - private String userSex; - - /** 用户手机 */ - private String userPhone; - - /** 用户邮箱 */ - private String userEmail; - - /** 用户余额 */ - private double userBalance; - - /** 用户状态(0正常 1停用) */ - private String status; - - /** 创建时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date createTime; - - public UserTableModel() - { - - } - - public UserTableModel(int userId, String userCode, String userName, String userSex, String userPhone, - String userEmail, double userBalance, String status) - { - this.userId = userId; - this.userCode = userCode; - this.userName = userName; - this.userSex = userSex; - this.userPhone = userPhone; - this.userEmail = userEmail; - this.userBalance = userBalance; - this.status = status; - this.createTime = DateUtils.getNowDate(); - } - - public int getUserId() - { - return userId; - } - - public void setUserId(int userId) - { - this.userId = userId; - } - - public String getUserCode() - { - return userCode; - } - - public void setUserCode(String userCode) - { - this.userCode = userCode; - } - - public String getUserName() - { - return userName; - } - - public void setUserName(String userName) - { - this.userName = userName; - } - - public String getUserSex() - { - return userSex; - } - - public void setUserSex(String userSex) - { - this.userSex = userSex; - } - - public String getUserPhone() - { - return userPhone; - } - - public void setUserPhone(String userPhone) - { - this.userPhone = userPhone; - } - - public String getUserEmail() - { - return userEmail; - } - - public void setUserEmail(String userEmail) - { - this.userEmail = userEmail; - } - - public double getUserBalance() - { - return userBalance; - } - - public void setUserBalance(double userBalance) - { - this.userBalance = userBalance; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public Date getCreateTime() - { - return createTime; - } - - public void setCreateTime(Date createTime) - { - this.createTime = createTime; - } -} +package com.ruoyi.web.controller.demo.controller; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.page.TableSupport; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; + +/** + * 表格相关 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/demo/table") +public class DemoTableController extends BaseController +{ + private String prefix = "demo/table"; + + private final static List users = new ArrayList(); + { + users.add(new UserTableModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0")); + users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1")); + users.add(new UserTableModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1")); + users.add(new UserTableModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1")); + users.add(new UserTableModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1")); + users.add(new UserTableModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1")); + users.add(new UserTableModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1")); + users.add(new UserTableModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1")); + users.add(new UserTableModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1")); + users.add(new UserTableModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1")); + users.add(new UserTableModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1")); + users.add(new UserTableModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1")); + users.add(new UserTableModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1")); + users.add(new UserTableModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1")); + users.add(new UserTableModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1")); + users.add(new UserTableModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1")); + users.add(new UserTableModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1")); + users.add(new UserTableModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1")); + users.add(new UserTableModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1")); + users.add(new UserTableModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1")); + users.add(new UserTableModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1")); + users.add(new UserTableModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1")); + users.add(new UserTableModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1")); + users.add(new UserTableModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1")); + users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1")); + users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1")); + } + + /** + * 搜索相关 + */ + @GetMapping("/search") + public String search() + { + return prefix + "/search"; + } + + /** + * 数据汇总 + */ + @GetMapping("/footer") + public String footer() + { + return prefix + "/footer"; + } + + /** + * 组合表头 + */ + @GetMapping("/groupHeader") + public String groupHeader() + { + return prefix + "/groupHeader"; + } + + /** + * 表格导出 + */ + @GetMapping("/export") + public String export() + { + return prefix + "/export"; + } + + /** + * 翻页记住选择 + */ + @GetMapping("/remember") + public String remember() + { + return prefix + "/remember"; + } + + /** + * 跳转至指定页 + */ + @GetMapping("/pageGo") + public String pageGo() + { + return prefix + "/pageGo"; + } + + /** + * 自定义查询参数 + */ + @GetMapping("/params") + public String params() + { + return prefix + "/params"; + } + + /** + * 多表格 + */ + @GetMapping("/multi") + public String multi() + { + return prefix + "/multi"; + } + + /** + * 点击按钮加载表格 + */ + @GetMapping("/button") + public String button() + { + return prefix + "/button"; + } + + /** + * 表格冻结列 + */ + @GetMapping("/fixedColumns") + public String fixedColumns() + { + return prefix + "/fixedColumns"; + } + + /** + * 自定义触发事件 + */ + @GetMapping("/event") + public String event() + { + return prefix + "/event"; + } + + /** + * 表格细节视图 + */ + @GetMapping("/detail") + public String detail() + { + return prefix + "/detail"; + } + + /** + * 表格图片预览 + */ + @GetMapping("/image") + public String image() + { + return prefix + "/image"; + } + + /** + * 动态增删改查 + */ + @GetMapping("/curd") + public String curd() + { + return prefix + "/curd"; + } + + /** + * 表格拖拽操作 + */ + @GetMapping("/reorder") + public String reorder() + { + return prefix + "/reorder"; + } + + /** + * 表格其他操作 + */ + @GetMapping("/other") + public String other() + { + return prefix + "/other"; + } + + /** + * 查询数据 + */ + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(UserTableModel userModel) + { + TableDataInfo rspData = new TableDataInfo(); + List userList = new ArrayList(Arrays.asList(new UserTableModel[users.size()])); + Collections.copy(userList, users); + // 查询条件过滤 + if (StringUtils.isNotEmpty(userModel.getUserName())) + { + userList.clear(); + for (UserTableModel user : users) + { + if (user.getUserName().equals(userModel.getUserName())) + { + userList.add(user); + } + } + } + PageDomain pageDomain = TableSupport.buildPageRequest(); + if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) + { + rspData.setRows(userList); + rspData.setTotal(userList.size()); + return rspData; + } + Integer pageNum = (pageDomain.getPageNum() - 1) * 10; + Integer pageSize = pageDomain.getPageNum() * 10; + if (pageSize > userList.size()) + { + pageSize = userList.size(); + } + rspData.setRows(userList.subList(pageNum, pageSize)); + rspData.setTotal(userList.size()); + return rspData; + } +} + +class UserTableModel +{ + /** 用户ID */ + private int userId; + + /** 用户编号 */ + private String userCode; + + /** 用户姓名 */ + private String userName; + + /** 用户性别 */ + private String userSex; + + /** 用户手机 */ + private String userPhone; + + /** 用户邮箱 */ + private String userEmail; + + /** 用户余额 */ + private double userBalance; + + /** 用户状态(0正常 1停用) */ + private String status; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + public UserTableModel() + { + + } + + public UserTableModel(int userId, String userCode, String userName, String userSex, String userPhone, + String userEmail, double userBalance, String status) + { + this.userId = userId; + this.userCode = userCode; + this.userName = userName; + this.userSex = userSex; + this.userPhone = userPhone; + this.userEmail = userEmail; + this.userBalance = userBalance; + this.status = status; + this.createTime = DateUtils.getNowDate(); + } + + public int getUserId() + { + return userId; + } + + public void setUserId(int userId) + { + this.userId = userId; + } + + public String getUserCode() + { + return userCode; + } + + public void setUserCode(String userCode) + { + this.userCode = userCode; + } + + public String getUserName() + { + return userName; + } + + public void setUserName(String userName) + { + this.userName = userName; + } + + public String getUserSex() + { + return userSex; + } + + public void setUserSex(String userSex) + { + this.userSex = userSex; + } + + public String getUserPhone() + { + return userPhone; + } + + public void setUserPhone(String userPhone) + { + this.userPhone = userPhone; + } + + public String getUserEmail() + { + return userEmail; + } + + public void setUserEmail(String userEmail) + { + this.userEmail = userEmail; + } + + public double getUserBalance() + { + return userBalance; + } + + public void setUserBalance(double userBalance) + { + this.userBalance = userBalance; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public Date getCreateTime() + { + return createTime; + } + + public void setCreateTime(Date createTime) + { + this.createTime = createTime; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/domain/UserOperateModel.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/domain/UserOperateModel.java similarity index 95% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/domain/UserOperateModel.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/demo/domain/UserOperateModel.java index ac95abf2f..e7ec0564a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/domain/UserOperateModel.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/demo/domain/UserOperateModel.java @@ -1,147 +1,147 @@ -package com.ruoyi.web.controller.demo.domain; - -import java.util.Date; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.annotation.Excel.Type; -import com.ruoyi.common.core.domain.BaseEntity; -import com.ruoyi.common.utils.DateUtils; - -public class UserOperateModel extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - private int userId; - - @Excel(name = "用户编号") - private String userCode; - - @Excel(name = "用户姓名") - private String userName; - - @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") - private String userSex; - - @Excel(name = "用户手机") - private String userPhone; - - @Excel(name = "用户邮箱") - private String userEmail; - - @Excel(name = "用户余额") - private double userBalance; - - @Excel(name = "用户状态", readConverterExp = "0=正常,1=停用") - private String status; - - @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) - private Date createTime; - - public UserOperateModel() - { - - } - - public UserOperateModel(int userId, String userCode, String userName, String userSex, String userPhone, - String userEmail, double userBalance, String status) - { - this.userId = userId; - this.userCode = userCode; - this.userName = userName; - this.userSex = userSex; - this.userPhone = userPhone; - this.userEmail = userEmail; - this.userBalance = userBalance; - this.status = status; - this.createTime = DateUtils.getNowDate(); - } - - public int getUserId() - { - return userId; - } - - public void setUserId(int userId) - { - this.userId = userId; - } - - public String getUserCode() - { - return userCode; - } - - public void setUserCode(String userCode) - { - this.userCode = userCode; - } - - public String getUserName() - { - return userName; - } - - public void setUserName(String userName) - { - this.userName = userName; - } - - public String getUserSex() - { - return userSex; - } - - public void setUserSex(String userSex) - { - this.userSex = userSex; - } - - public String getUserPhone() - { - return userPhone; - } - - public void setUserPhone(String userPhone) - { - this.userPhone = userPhone; - } - - public String getUserEmail() - { - return userEmail; - } - - public void setUserEmail(String userEmail) - { - this.userEmail = userEmail; - } - - public double getUserBalance() - { - return userBalance; - } - - public void setUserBalance(double userBalance) - { - this.userBalance = userBalance; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public Date getCreateTime() - { - return createTime; - } - - public void setCreateTime(Date createTime) - { - this.createTime = createTime; - } +package com.ruoyi.web.controller.demo.domain; + +import java.util.Date; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.Type; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.DateUtils; + +public class UserOperateModel extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + private int userId; + + @Excel(name = "用户编号") + private String userCode; + + @Excel(name = "用户姓名") + private String userName; + + @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") + private String userSex; + + @Excel(name = "用户手机") + private String userPhone; + + @Excel(name = "用户邮箱") + private String userEmail; + + @Excel(name = "用户余额") + private double userBalance; + + @Excel(name = "用户状态", readConverterExp = "0=正常,1=停用") + private String status; + + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) + private Date createTime; + + public UserOperateModel() + { + + } + + public UserOperateModel(int userId, String userCode, String userName, String userSex, String userPhone, + String userEmail, double userBalance, String status) + { + this.userId = userId; + this.userCode = userCode; + this.userName = userName; + this.userSex = userSex; + this.userPhone = userPhone; + this.userEmail = userEmail; + this.userBalance = userBalance; + this.status = status; + this.createTime = DateUtils.getNowDate(); + } + + public int getUserId() + { + return userId; + } + + public void setUserId(int userId) + { + this.userId = userId; + } + + public String getUserCode() + { + return userCode; + } + + public void setUserCode(String userCode) + { + this.userCode = userCode; + } + + public String getUserName() + { + return userName; + } + + public void setUserName(String userName) + { + this.userName = userName; + } + + public String getUserSex() + { + return userSex; + } + + public void setUserSex(String userSex) + { + this.userSex = userSex; + } + + public String getUserPhone() + { + return userPhone; + } + + public void setUserPhone(String userPhone) + { + this.userPhone = userPhone; + } + + public String getUserEmail() + { + return userEmail; + } + + public void setUserEmail(String userEmail) + { + this.userEmail = userEmail; + } + + public double getUserBalance() + { + return userBalance; + } + + public void setUserBalance(double userBalance) + { + this.userBalance = userBalance; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public Date getCreateTime() + { + return createTime; + } + + public void setCreateTime(Date createTime) + { + this.createTime = createTime; + } } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/DruidController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/DruidController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/DruidController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/DruidController.java index b2647893c..336bf8f10 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/DruidController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/DruidController.java @@ -1,26 +1,26 @@ -package com.ruoyi.web.controller.monitor; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import com.ruoyi.common.core.controller.BaseController; - -/** - * druid 监控 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/monitor/data") -public class DruidController extends BaseController -{ - private String prefix = "/druid"; - - @RequiresPermissions("monitor:data:view") - @GetMapping() - public String index() - { - return redirect(prefix + "/index"); - } -} +package com.ruoyi.web.controller.monitor; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.core.controller.BaseController; + +/** + * druid 监控 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/monitor/data") +public class DruidController extends BaseController +{ + private String prefix = "/druid"; + + @RequiresPermissions("monitor:data:view") + @GetMapping() + public String index() + { + return redirect(prefix + "/index"); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java index 764197d39..386b5c7da 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java @@ -1,31 +1,31 @@ -package com.ruoyi.web.controller.monitor; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.framework.web.domain.Server; - -/** - * 服务器监控 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/monitor/server") -public class ServerController extends BaseController -{ - private String prefix = "monitor/server"; - - @RequiresPermissions("monitor:server:view") - @GetMapping() - public String server(ModelMap mmap) throws Exception - { - Server server = new Server(); - server.copyTo(); - mmap.put("server", server); - return prefix + "/server"; - } -} +package com.ruoyi.web.controller.monitor; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.framework.web.domain.Server; + +/** + * 服务器监控 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/monitor/server") +public class ServerController extends BaseController +{ + private String prefix = "monitor/server"; + + @RequiresPermissions("monitor:server:view") + @GetMapping() + public String server(ModelMap mmap) throws Exception + { + Server server = new Server(); + server.copyTo(); + mmap.put("server", server); + return prefix + "/server"; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java similarity index 97% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java index 6f04cab78..37dd717e7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java @@ -1,80 +1,80 @@ -package com.ruoyi.web.controller.monitor; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.system.domain.SysLogininfor; -import com.ruoyi.system.service.ISysLogininforService; - -/** - * 系统访问记录 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/monitor/logininfor") -public class SysLogininforController extends BaseController -{ - private String prefix = "monitor/logininfor"; - - @Autowired - private ISysLogininforService logininforService; - - @RequiresPermissions("monitor:logininfor:view") - @GetMapping() - public String logininfor() - { - return prefix + "/logininfor"; - } - - @RequiresPermissions("monitor:logininfor:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysLogininfor logininfor) - { - startPage(); - List list = logininforService.selectLogininforList(logininfor); - return getDataTable(list); - } - - @Log(title = "登陆日志", businessType = BusinessType.EXPORT) - @RequiresPermissions("monitor:logininfor:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysLogininfor logininfor) - { - List list = logininforService.selectLogininforList(logininfor); - ExcelUtil util = new ExcelUtil(SysLogininfor.class); - return util.exportExcel(list, "登陆日志"); - } - - @RequiresPermissions("monitor:logininfor:remove") - @Log(title = "登陆日志", businessType = BusinessType.DELETE) - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(logininforService.deleteLogininforByIds(ids)); - } - - @RequiresPermissions("monitor:logininfor:remove") - @Log(title = "登陆日志", businessType = BusinessType.CLEAN) - @PostMapping("/clean") - @ResponseBody - public AjaxResult clean() - { - logininforService.cleanLogininfor(); - return success(); - } -} +package com.ruoyi.web.controller.monitor; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.service.ISysLogininforService; + +/** + * 系统访问记录 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/monitor/logininfor") +public class SysLogininforController extends BaseController +{ + private String prefix = "monitor/logininfor"; + + @Autowired + private ISysLogininforService logininforService; + + @RequiresPermissions("monitor:logininfor:view") + @GetMapping() + public String logininfor() + { + return prefix + "/logininfor"; + } + + @RequiresPermissions("monitor:logininfor:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysLogininfor logininfor) + { + startPage(); + List list = logininforService.selectLogininforList(logininfor); + return getDataTable(list); + } + + @Log(title = "登陆日志", businessType = BusinessType.EXPORT) + @RequiresPermissions("monitor:logininfor:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysLogininfor logininfor) + { + List list = logininforService.selectLogininforList(logininfor); + ExcelUtil util = new ExcelUtil(SysLogininfor.class); + return util.exportExcel(list, "登陆日志"); + } + + @RequiresPermissions("monitor:logininfor:remove") + @Log(title = "登陆日志", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(logininforService.deleteLogininforByIds(ids)); + } + + @RequiresPermissions("monitor:logininfor:remove") + @Log(title = "登陆日志", businessType = BusinessType.CLEAN) + @PostMapping("/clean") + @ResponseBody + public AjaxResult clean() + { + logininforService.cleanLogininfor(); + return success(); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java index 468866e18..bde7c26a4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java @@ -1,89 +1,89 @@ -package com.ruoyi.web.controller.monitor; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.system.domain.SysOperLog; -import com.ruoyi.system.service.ISysOperLogService; - -/** - * 操作日志记录 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/monitor/operlog") -public class SysOperlogController extends BaseController -{ - private String prefix = "monitor/operlog"; - - @Autowired - private ISysOperLogService operLogService; - - @RequiresPermissions("monitor:operlog:view") - @GetMapping() - public String operlog() - { - return prefix + "/operlog"; - } - - @RequiresPermissions("monitor:operlog:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysOperLog operLog) - { - startPage(); - List list = operLogService.selectOperLogList(operLog); - return getDataTable(list); - } - - @Log(title = "操作日志", businessType = BusinessType.EXPORT) - @RequiresPermissions("monitor:operlog:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysOperLog operLog) - { - List list = operLogService.selectOperLogList(operLog); - ExcelUtil util = new ExcelUtil(SysOperLog.class); - return util.exportExcel(list, "操作日志"); - } - - @RequiresPermissions("monitor:operlog:remove") - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(operLogService.deleteOperLogByIds(ids)); - } - - @RequiresPermissions("monitor:operlog:detail") - @GetMapping("/detail/{operId}") - public String detail(@PathVariable("operId") Long operId, ModelMap mmap) - { - mmap.put("operLog", operLogService.selectOperLogById(operId)); - return prefix + "/detail"; - } - - @Log(title = "操作日志", businessType = BusinessType.CLEAN) - @RequiresPermissions("monitor:operlog:remove") - @PostMapping("/clean") - @ResponseBody - public AjaxResult clean() - { - operLogService.cleanOperLog(); - return success(); - } -} +package com.ruoyi.web.controller.monitor; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.service.ISysOperLogService; + +/** + * 操作日志记录 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/monitor/operlog") +public class SysOperlogController extends BaseController +{ + private String prefix = "monitor/operlog"; + + @Autowired + private ISysOperLogService operLogService; + + @RequiresPermissions("monitor:operlog:view") + @GetMapping() + public String operlog() + { + return prefix + "/operlog"; + } + + @RequiresPermissions("monitor:operlog:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysOperLog operLog) + { + startPage(); + List list = operLogService.selectOperLogList(operLog); + return getDataTable(list); + } + + @Log(title = "操作日志", businessType = BusinessType.EXPORT) + @RequiresPermissions("monitor:operlog:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysOperLog operLog) + { + List list = operLogService.selectOperLogList(operLog); + ExcelUtil util = new ExcelUtil(SysOperLog.class); + return util.exportExcel(list, "操作日志"); + } + + @RequiresPermissions("monitor:operlog:remove") + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(operLogService.deleteOperLogByIds(ids)); + } + + @RequiresPermissions("monitor:operlog:detail") + @GetMapping("/detail/{operId}") + public String detail(@PathVariable("operId") Long operId, ModelMap mmap) + { + mmap.put("operLog", operLogService.selectOperLogById(operId)); + return prefix + "/detail"; + } + + @Log(title = "操作日志", businessType = BusinessType.CLEAN) + @RequiresPermissions("monitor:operlog:remove") + @PostMapping("/clean") + @ResponseBody + public AjaxResult clean() + { + operLogService.cleanOperLog(); + return success(); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java similarity index 97% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java index c3ea3ad72..a77f64f22 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java @@ -1,114 +1,114 @@ -package com.ruoyi.web.controller.monitor; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.enums.OnlineStatus; -import com.ruoyi.framework.shiro.session.OnlineSession; -import com.ruoyi.framework.shiro.session.OnlineSessionDAO; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysUserOnline; -import com.ruoyi.system.service.ISysUserOnlineService; - -/** - * 在线用户监控 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/monitor/online") -public class SysUserOnlineController extends BaseController -{ - private String prefix = "monitor/online"; - - @Autowired - private ISysUserOnlineService userOnlineService; - - @Autowired - private OnlineSessionDAO onlineSessionDAO; - - @RequiresPermissions("monitor:online:view") - @GetMapping() - public String online() - { - return prefix + "/online"; - } - - @RequiresPermissions("monitor:online:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysUserOnline userOnline) - { - startPage(); - List list = userOnlineService.selectUserOnlineList(userOnline); - return getDataTable(list); - } - - @RequiresPermissions("monitor:online:batchForceLogout") - @Log(title = "在线用户", businessType = BusinessType.FORCE) - @PostMapping("/batchForceLogout") - @ResponseBody - public AjaxResult batchForceLogout(@RequestParam("ids[]") String[] ids) - { - for (String sessionId : ids) - { - SysUserOnline online = userOnlineService.selectOnlineById(sessionId); - if (online == null) - { - return error("用户已下线"); - } - OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId()); - if (onlineSession == null) - { - return error("用户已下线"); - } - if (sessionId.equals(ShiroUtils.getSessionId())) - { - return error("当前登陆用户无法强退"); - } - onlineSession.setStatus(OnlineStatus.off_line); - onlineSessionDAO.update(onlineSession); - online.setStatus(OnlineStatus.off_line); - userOnlineService.saveOnline(online); - } - return success(); - } - - @RequiresPermissions("monitor:online:forceLogout") - @Log(title = "在线用户", businessType = BusinessType.FORCE) - @PostMapping("/forceLogout") - @ResponseBody - public AjaxResult forceLogout(String sessionId) - { - SysUserOnline online = userOnlineService.selectOnlineById(sessionId); - if (sessionId.equals(ShiroUtils.getSessionId())) - { - return error("当前登陆用户无法强退"); - } - if (online == null) - { - return error("用户已下线"); - } - OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId()); - if (onlineSession == null) - { - return error("用户已下线"); - } - onlineSession.setStatus(OnlineStatus.off_line); - onlineSessionDAO.update(onlineSession); - online.setStatus(OnlineStatus.off_line); - userOnlineService.saveOnline(online); - return success(); - } -} +package com.ruoyi.web.controller.monitor; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.enums.OnlineStatus; +import com.ruoyi.framework.shiro.session.OnlineSession; +import com.ruoyi.framework.shiro.session.OnlineSessionDAO; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysUserOnline; +import com.ruoyi.system.service.ISysUserOnlineService; + +/** + * 在线用户监控 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/monitor/online") +public class SysUserOnlineController extends BaseController +{ + private String prefix = "monitor/online"; + + @Autowired + private ISysUserOnlineService userOnlineService; + + @Autowired + private OnlineSessionDAO onlineSessionDAO; + + @RequiresPermissions("monitor:online:view") + @GetMapping() + public String online() + { + return prefix + "/online"; + } + + @RequiresPermissions("monitor:online:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysUserOnline userOnline) + { + startPage(); + List list = userOnlineService.selectUserOnlineList(userOnline); + return getDataTable(list); + } + + @RequiresPermissions("monitor:online:batchForceLogout") + @Log(title = "在线用户", businessType = BusinessType.FORCE) + @PostMapping("/batchForceLogout") + @ResponseBody + public AjaxResult batchForceLogout(@RequestParam("ids[]") String[] ids) + { + for (String sessionId : ids) + { + SysUserOnline online = userOnlineService.selectOnlineById(sessionId); + if (online == null) + { + return error("用户已下线"); + } + OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId()); + if (onlineSession == null) + { + return error("用户已下线"); + } + if (sessionId.equals(ShiroUtils.getSessionId())) + { + return error("当前登陆用户无法强退"); + } + onlineSession.setStatus(OnlineStatus.off_line); + onlineSessionDAO.update(onlineSession); + online.setStatus(OnlineStatus.off_line); + userOnlineService.saveOnline(online); + } + return success(); + } + + @RequiresPermissions("monitor:online:forceLogout") + @Log(title = "在线用户", businessType = BusinessType.FORCE) + @PostMapping("/forceLogout") + @ResponseBody + public AjaxResult forceLogout(String sessionId) + { + SysUserOnline online = userOnlineService.selectOnlineById(sessionId); + if (sessionId.equals(ShiroUtils.getSessionId())) + { + return error("当前登陆用户无法强退"); + } + if (online == null) + { + return error("用户已下线"); + } + OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId()); + if (onlineSession == null) + { + return error("用户已下线"); + } + onlineSession.setStatus(OnlineStatus.off_line); + onlineSessionDAO.update(onlineSession); + online.setStatus(OnlineStatus.off_line); + userOnlineService.saveOnline(online); + return success(); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysCaptchaController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysCaptchaController.java similarity index 97% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysCaptchaController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysCaptchaController.java index 230cc3b29..739c46934 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysCaptchaController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysCaptchaController.java @@ -1,92 +1,92 @@ -package com.ruoyi.web.controller.system; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import javax.annotation.Resource; -import javax.imageio.ImageIO; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.servlet.ModelAndView; -import com.google.code.kaptcha.Constants; -import com.google.code.kaptcha.Producer; -import com.ruoyi.common.core.controller.BaseController; - -/** - * 图片验证码(支持算术形式) - * - * @author ruoyi - */ -@Controller -@RequestMapping("/captcha") -public class SysCaptchaController extends BaseController -{ - @Resource(name = "captchaProducer") - private Producer captchaProducer; - - @Resource(name = "captchaProducerMath") - private Producer captchaProducerMath; - - /** - * 验证码生成 - */ - @GetMapping(value = "/captchaImage") - public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response) - { - ServletOutputStream out = null; - try - { - HttpSession session = request.getSession(); - response.setDateHeader("Expires", 0); - response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); - response.addHeader("Cache-Control", "post-check=0, pre-check=0"); - response.setHeader("Pragma", "no-cache"); - response.setContentType("image/jpeg"); - - String type = request.getParameter("type"); - String capStr = null; - String code = null; - BufferedImage bi = null; - if ("math".equals(type)) - { - String capText = captchaProducerMath.createText(); - capStr = capText.substring(0, capText.lastIndexOf("@")); - code = capText.substring(capText.lastIndexOf("@") + 1); - bi = captchaProducerMath.createImage(capStr); - } - else if ("char".equals(type)) - { - capStr = code = captchaProducer.createText(); - bi = captchaProducer.createImage(capStr); - } - session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code); - out = response.getOutputStream(); - ImageIO.write(bi, "jpg", out); - out.flush(); - - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - try - { - if (out != null) - { - out.close(); - } - } - catch (IOException e) - { - e.printStackTrace(); - } - } - return null; - } +package com.ruoyi.web.controller.system; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; +import com.google.code.kaptcha.Constants; +import com.google.code.kaptcha.Producer; +import com.ruoyi.common.core.controller.BaseController; + +/** + * 图片验证码(支持算术形式) + * + * @author ruoyi + */ +@Controller +@RequestMapping("/captcha") +public class SysCaptchaController extends BaseController +{ + @Resource(name = "captchaProducer") + private Producer captchaProducer; + + @Resource(name = "captchaProducerMath") + private Producer captchaProducerMath; + + /** + * 验证码生成 + */ + @GetMapping(value = "/captchaImage") + public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response) + { + ServletOutputStream out = null; + try + { + HttpSession session = request.getSession(); + response.setDateHeader("Expires", 0); + response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); + response.addHeader("Cache-Control", "post-check=0, pre-check=0"); + response.setHeader("Pragma", "no-cache"); + response.setContentType("image/jpeg"); + + String type = request.getParameter("type"); + String capStr = null; + String code = null; + BufferedImage bi = null; + if ("math".equals(type)) + { + String capText = captchaProducerMath.createText(); + capStr = capText.substring(0, capText.lastIndexOf("@")); + code = capText.substring(capText.lastIndexOf("@") + 1); + bi = captchaProducerMath.createImage(capStr); + } + else if ("char".equals(type)) + { + capStr = code = captchaProducer.createText(); + bi = captchaProducer.createImage(capStr); + } + session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code); + out = response.getOutputStream(); + ImageIO.write(bi, "jpg", out); + out.flush(); + + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + try + { + if (out != null) + { + out.close(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + return null; + } } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java index 139469d25..0ea117f9f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java @@ -1,144 +1,144 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysConfig; -import com.ruoyi.system.service.ISysConfigService; - -/** - * 参数配置 信息操作处理 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/config") -public class SysConfigController extends BaseController -{ - private String prefix = "system/config"; - - @Autowired - private ISysConfigService configService; - - @RequiresPermissions("system:config:view") - @GetMapping() - public String config() - { - return prefix + "/config"; - } - - /** - * 查询参数配置列表 - */ - @RequiresPermissions("system:config:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysConfig config) - { - startPage(); - List list = configService.selectConfigList(config); - return getDataTable(list); - } - - @Log(title = "参数管理", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:config:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysConfig config) - { - List list = configService.selectConfigList(config); - ExcelUtil util = new ExcelUtil(SysConfig.class); - return util.exportExcel(list, "参数数据"); - } - - /** - * 新增参数配置 - */ - @GetMapping("/add") - public String add() - { - return prefix + "/add"; - } - - /** - * 新增保存参数配置 - */ - @RequiresPermissions("system:config:add") - @Log(title = "参数管理", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysConfig config) - { - if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) - { - return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); - } - config.setCreateBy(ShiroUtils.getLoginName()); - return toAjax(configService.insertConfig(config)); - } - - /** - * 修改参数配置 - */ - @GetMapping("/edit/{configId}") - public String edit(@PathVariable("configId") Long configId, ModelMap mmap) - { - mmap.put("config", configService.selectConfigById(configId)); - return prefix + "/edit"; - } - - /** - * 修改保存参数配置 - */ - @RequiresPermissions("system:config:edit") - @Log(title = "参数管理", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysConfig config) - { - if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) - { - return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); - } - config.setUpdateBy(ShiroUtils.getLoginName()); - return toAjax(configService.updateConfig(config)); - } - - /** - * 删除参数配置 - */ - @RequiresPermissions("system:config:remove") - @Log(title = "参数管理", businessType = BusinessType.DELETE) - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(configService.deleteConfigByIds(ids)); - } - - /** - * 校验参数键名 - */ - @PostMapping("/checkConfigKeyUnique") - @ResponseBody - public String checkConfigKeyUnique(SysConfig config) - { - return configService.checkConfigKeyUnique(config); - } -} +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysConfig; +import com.ruoyi.system.service.ISysConfigService; + +/** + * 参数配置 信息操作处理 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/config") +public class SysConfigController extends BaseController +{ + private String prefix = "system/config"; + + @Autowired + private ISysConfigService configService; + + @RequiresPermissions("system:config:view") + @GetMapping() + public String config() + { + return prefix + "/config"; + } + + /** + * 查询参数配置列表 + */ + @RequiresPermissions("system:config:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysConfig config) + { + startPage(); + List list = configService.selectConfigList(config); + return getDataTable(list); + } + + @Log(title = "参数管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:config:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysConfig config) + { + List list = configService.selectConfigList(config); + ExcelUtil util = new ExcelUtil(SysConfig.class); + return util.exportExcel(list, "参数数据"); + } + + /** + * 新增参数配置 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存参数配置 + */ + @RequiresPermissions("system:config:add") + @Log(title = "参数管理", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysConfig config) + { + if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) + { + return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(configService.insertConfig(config)); + } + + /** + * 修改参数配置 + */ + @GetMapping("/edit/{configId}") + public String edit(@PathVariable("configId") Long configId, ModelMap mmap) + { + mmap.put("config", configService.selectConfigById(configId)); + return prefix + "/edit"; + } + + /** + * 修改保存参数配置 + */ + @RequiresPermissions("system:config:edit") + @Log(title = "参数管理", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysConfig config) + { + if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) + { + return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(configService.updateConfig(config)); + } + + /** + * 删除参数配置 + */ + @RequiresPermissions("system:config:remove") + @Log(title = "参数管理", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(configService.deleteConfigByIds(ids)); + } + + /** + * 校验参数键名 + */ + @PostMapping("/checkConfigKeyUnique") + @ResponseBody + public String checkConfigKeyUnique(SysConfig config) + { + return configService.checkConfigKeyUnique(config); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index bb17d9f3b..5f7227be1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -1,180 +1,180 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.Ztree; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysDept; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.service.ISysDeptService; - -/** - * 部门信息 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/dept") -public class SysDeptController extends BaseController -{ - private String prefix = "system/dept"; - - @Autowired - private ISysDeptService deptService; - - @RequiresPermissions("system:dept:view") - @GetMapping() - public String dept() - { - return prefix + "/dept"; - } - - @RequiresPermissions("system:dept:list") - @PostMapping("/list") - @ResponseBody - public List list(SysDept dept) - { - List deptList = deptService.selectDeptList(dept); - return deptList; - } - - /** - * 新增部门 - */ - @GetMapping("/add/{parentId}") - public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) - { - mmap.put("dept", deptService.selectDeptById(parentId)); - return prefix + "/add"; - } - - /** - * 新增保存部门 - */ - @Log(title = "部门管理", businessType = BusinessType.INSERT) - @RequiresPermissions("system:dept:add") - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysDept dept) - { - if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) - { - return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); - } - dept.setCreateBy(ShiroUtils.getLoginName()); - return toAjax(deptService.insertDept(dept)); - } - - /** - * 修改 - */ - @GetMapping("/edit/{deptId}") - public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) - { - SysDept dept = deptService.selectDeptById(deptId); - if (StringUtils.isNotNull(dept) && 100L == deptId) - { - dept.setParentName("无"); - } - mmap.put("dept", dept); - return prefix + "/edit"; - } - - /** - * 保存 - */ - @Log(title = "部门管理", businessType = BusinessType.UPDATE) - @RequiresPermissions("system:dept:edit") - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysDept dept) - { - if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) - { - return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); - } - else if (dept.getParentId().equals(dept.getDeptId())) - { - return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); - } - dept.setUpdateBy(ShiroUtils.getLoginName()); - return toAjax(deptService.updateDept(dept)); - } - - /** - * 删除 - */ - @Log(title = "部门管理", businessType = BusinessType.DELETE) - @RequiresPermissions("system:dept:remove") - @GetMapping("/remove/{deptId}") - @ResponseBody - public AjaxResult remove(@PathVariable("deptId") Long deptId) - { - if (deptService.selectDeptCount(deptId) > 0) - { - return AjaxResult.warn("存在下级部门,不允许删除"); - } - if (deptService.checkDeptExistUser(deptId)) - { - return AjaxResult.warn("部门存在用户,不允许删除"); - } - return toAjax(deptService.deleteDeptById(deptId)); - } - - /** - * 校验部门名称 - */ - @PostMapping("/checkDeptNameUnique") - @ResponseBody - public String checkDeptNameUnique(SysDept dept) - { - return deptService.checkDeptNameUnique(dept); - } - - /** - * 选择部门树 - */ - @GetMapping("/selectDeptTree/{deptId}") - public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap) - { - mmap.put("dept", deptService.selectDeptById(deptId)); - return prefix + "/tree"; - } - - /** - * 加载部门列表树 - */ - @GetMapping("/treeData") - @ResponseBody - public List treeData() - { - List ztrees = deptService.selectDeptTree(new SysDept()); - return ztrees; - } - - /** - * 加载角色部门(数据权限)列表树 - */ - @GetMapping("/roleDeptTreeData") - @ResponseBody - public List deptTreeData(SysRole role) - { - List ztrees = deptService.roleDeptTreeData(role); - return ztrees; - } -} +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysDept; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.service.ISysDeptService; + +/** + * 部门信息 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/dept") +public class SysDeptController extends BaseController +{ + private String prefix = "system/dept"; + + @Autowired + private ISysDeptService deptService; + + @RequiresPermissions("system:dept:view") + @GetMapping() + public String dept() + { + return prefix + "/dept"; + } + + @RequiresPermissions("system:dept:list") + @PostMapping("/list") + @ResponseBody + public List list(SysDept dept) + { + List deptList = deptService.selectDeptList(dept); + return deptList; + } + + /** + * 新增部门 + */ + @GetMapping("/add/{parentId}") + public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) + { + mmap.put("dept", deptService.selectDeptById(parentId)); + return prefix + "/add"; + } + + /** + * 新增保存部门 + */ + @Log(title = "部门管理", businessType = BusinessType.INSERT) + @RequiresPermissions("system:dept:add") + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysDept dept) + { + if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) + { + return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + } + dept.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(deptService.insertDept(dept)); + } + + /** + * 修改 + */ + @GetMapping("/edit/{deptId}") + public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) + { + SysDept dept = deptService.selectDeptById(deptId); + if (StringUtils.isNotNull(dept) && 100L == deptId) + { + dept.setParentName("无"); + } + mmap.put("dept", dept); + return prefix + "/edit"; + } + + /** + * 保存 + */ + @Log(title = "部门管理", businessType = BusinessType.UPDATE) + @RequiresPermissions("system:dept:edit") + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysDept dept) + { + if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) + { + return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); + } + else if (dept.getParentId().equals(dept.getDeptId())) + { + return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); + } + dept.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(deptService.updateDept(dept)); + } + + /** + * 删除 + */ + @Log(title = "部门管理", businessType = BusinessType.DELETE) + @RequiresPermissions("system:dept:remove") + @GetMapping("/remove/{deptId}") + @ResponseBody + public AjaxResult remove(@PathVariable("deptId") Long deptId) + { + if (deptService.selectDeptCount(deptId) > 0) + { + return AjaxResult.warn("存在下级部门,不允许删除"); + } + if (deptService.checkDeptExistUser(deptId)) + { + return AjaxResult.warn("部门存在用户,不允许删除"); + } + return toAjax(deptService.deleteDeptById(deptId)); + } + + /** + * 校验部门名称 + */ + @PostMapping("/checkDeptNameUnique") + @ResponseBody + public String checkDeptNameUnique(SysDept dept) + { + return deptService.checkDeptNameUnique(dept); + } + + /** + * 选择部门树 + */ + @GetMapping("/selectDeptTree/{deptId}") + public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap) + { + mmap.put("dept", deptService.selectDeptById(deptId)); + return prefix + "/tree"; + } + + /** + * 加载部门列表树 + */ + @GetMapping("/treeData") + @ResponseBody + public List treeData() + { + List ztrees = deptService.selectDeptTree(new SysDept()); + return ztrees; + } + + /** + * 加载角色部门(数据权限)列表树 + */ + @GetMapping("/roleDeptTreeData") + @ResponseBody + public List deptTreeData(SysRole role) + { + List ztrees = deptService.roleDeptTreeData(role); + return ztrees; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java index 945109858..ae7aa9278 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -1,120 +1,120 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysDictData; -import com.ruoyi.system.service.ISysDictDataService; - -/** - * 数据字典信息 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/dict/data") -public class SysDictDataController extends BaseController -{ - private String prefix = "system/dict/data"; - - @Autowired - private ISysDictDataService dictDataService; - - @RequiresPermissions("system:dict:view") - @GetMapping() - public String dictData() - { - return prefix + "/data"; - } - - @PostMapping("/list") - @RequiresPermissions("system:dict:list") - @ResponseBody - public TableDataInfo list(SysDictData dictData) - { - startPage(); - List list = dictDataService.selectDictDataList(dictData); - return getDataTable(list); - } - - @Log(title = "字典数据", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:dict:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysDictData dictData) - { - List list = dictDataService.selectDictDataList(dictData); - ExcelUtil util = new ExcelUtil(SysDictData.class); - return util.exportExcel(list, "字典数据"); - } - - /** - * 新增字典类型 - */ - @GetMapping("/add/{dictType}") - public String add(@PathVariable("dictType") String dictType, ModelMap mmap) - { - mmap.put("dictType", dictType); - return prefix + "/add"; - } - - /** - * 新增保存字典类型 - */ - @Log(title = "字典数据", businessType = BusinessType.INSERT) - @RequiresPermissions("system:dict:add") - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysDictData dict) - { - dict.setCreateBy(ShiroUtils.getLoginName()); - return toAjax(dictDataService.insertDictData(dict)); - } - - /** - * 修改字典类型 - */ - @GetMapping("/edit/{dictCode}") - public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap) - { - mmap.put("dict", dictDataService.selectDictDataById(dictCode)); - return prefix + "/edit"; - } - - /** - * 修改保存字典类型 - */ - @Log(title = "字典数据", businessType = BusinessType.UPDATE) - @RequiresPermissions("system:dict:edit") - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysDictData dict) - { - dict.setUpdateBy(ShiroUtils.getLoginName()); - return toAjax(dictDataService.updateDictData(dict)); - } - - @Log(title = "字典数据", businessType = BusinessType.DELETE) - @RequiresPermissions("system:dict:remove") - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(dictDataService.deleteDictDataByIds(ids)); - } -} +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysDictData; +import com.ruoyi.system.service.ISysDictDataService; + +/** + * 数据字典信息 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/dict/data") +public class SysDictDataController extends BaseController +{ + private String prefix = "system/dict/data"; + + @Autowired + private ISysDictDataService dictDataService; + + @RequiresPermissions("system:dict:view") + @GetMapping() + public String dictData() + { + return prefix + "/data"; + } + + @PostMapping("/list") + @RequiresPermissions("system:dict:list") + @ResponseBody + public TableDataInfo list(SysDictData dictData) + { + startPage(); + List list = dictDataService.selectDictDataList(dictData); + return getDataTable(list); + } + + @Log(title = "字典数据", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:dict:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysDictData dictData) + { + List list = dictDataService.selectDictDataList(dictData); + ExcelUtil util = new ExcelUtil(SysDictData.class); + return util.exportExcel(list, "字典数据"); + } + + /** + * 新增字典类型 + */ + @GetMapping("/add/{dictType}") + public String add(@PathVariable("dictType") String dictType, ModelMap mmap) + { + mmap.put("dictType", dictType); + return prefix + "/add"; + } + + /** + * 新增保存字典类型 + */ + @Log(title = "字典数据", businessType = BusinessType.INSERT) + @RequiresPermissions("system:dict:add") + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysDictData dict) + { + dict.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(dictDataService.insertDictData(dict)); + } + + /** + * 修改字典类型 + */ + @GetMapping("/edit/{dictCode}") + public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap) + { + mmap.put("dict", dictDataService.selectDictDataById(dictCode)); + return prefix + "/edit"; + } + + /** + * 修改保存字典类型 + */ + @Log(title = "字典数据", businessType = BusinessType.UPDATE) + @RequiresPermissions("system:dict:edit") + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysDictData dict) + { + dict.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(dictDataService.updateDictData(dict)); + } + + @Log(title = "字典数据", businessType = BusinessType.DELETE) + @RequiresPermissions("system:dict:remove") + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(dictDataService.deleteDictDataByIds(ids)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java index 05ee08caa..6bd7e710c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java @@ -1,158 +1,158 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysDictType; -import com.ruoyi.system.service.ISysDictTypeService; - -/** - * 数据字典信息 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/dict") -public class SysDictTypeController extends BaseController -{ - private String prefix = "system/dict/type"; - - @Autowired - private ISysDictTypeService dictTypeService; - - @RequiresPermissions("system:dict:view") - @GetMapping() - public String dictType() - { - return prefix + "/type"; - } - - @PostMapping("/list") - @RequiresPermissions("system:dict:list") - @ResponseBody - public TableDataInfo list(SysDictType dictType) - { - startPage(); - List list = dictTypeService.selectDictTypeList(dictType); - return getDataTable(list); - } - - @Log(title = "字典类型", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:dict:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysDictType dictType) - { - - List list = dictTypeService.selectDictTypeList(dictType); - ExcelUtil util = new ExcelUtil(SysDictType.class); - return util.exportExcel(list, "字典类型"); - } - - /** - * 新增字典类型 - */ - @GetMapping("/add") - public String add() - { - return prefix + "/add"; - } - - /** - * 新增保存字典类型 - */ - @Log(title = "字典类型", businessType = BusinessType.INSERT) - @RequiresPermissions("system:dict:add") - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysDictType dict) - { - if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) - { - return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); - } - dict.setCreateBy(ShiroUtils.getLoginName()); - return toAjax(dictTypeService.insertDictType(dict)); - } - - /** - * 修改字典类型 - */ - @GetMapping("/edit/{dictId}") - public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap) - { - mmap.put("dict", dictTypeService.selectDictTypeById(dictId)); - return prefix + "/edit"; - } - - /** - * 修改保存字典类型 - */ - @Log(title = "字典类型", businessType = BusinessType.UPDATE) - @RequiresPermissions("system:dict:edit") - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysDictType dict) - { - if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) - { - return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); - } - dict.setUpdateBy(ShiroUtils.getLoginName()); - return toAjax(dictTypeService.updateDictType(dict)); - } - - @Log(title = "字典类型", businessType = BusinessType.DELETE) - @RequiresPermissions("system:dict:remove") - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - try - { - return toAjax(dictTypeService.deleteDictTypeByIds(ids)); - } - catch (Exception e) - { - return error(e.getMessage()); - } - } - - /** - * 查询字典详细 - */ - @RequiresPermissions("system:dict:list") - @GetMapping("/detail/{dictId}") - public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap) - { - mmap.put("dict", dictTypeService.selectDictTypeById(dictId)); - mmap.put("dictList", dictTypeService.selectDictTypeAll()); - return "system/dict/data/data"; - } - - /** - * 校验字典类型 - */ - @PostMapping("/checkDictTypeUnique") - @ResponseBody - public String checkDictTypeUnique(SysDictType dictType) - { - return dictTypeService.checkDictTypeUnique(dictType); - } -} +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysDictType; +import com.ruoyi.system.service.ISysDictTypeService; + +/** + * 数据字典信息 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/dict") +public class SysDictTypeController extends BaseController +{ + private String prefix = "system/dict/type"; + + @Autowired + private ISysDictTypeService dictTypeService; + + @RequiresPermissions("system:dict:view") + @GetMapping() + public String dictType() + { + return prefix + "/type"; + } + + @PostMapping("/list") + @RequiresPermissions("system:dict:list") + @ResponseBody + public TableDataInfo list(SysDictType dictType) + { + startPage(); + List list = dictTypeService.selectDictTypeList(dictType); + return getDataTable(list); + } + + @Log(title = "字典类型", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:dict:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysDictType dictType) + { + + List list = dictTypeService.selectDictTypeList(dictType); + ExcelUtil util = new ExcelUtil(SysDictType.class); + return util.exportExcel(list, "字典类型"); + } + + /** + * 新增字典类型 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存字典类型 + */ + @Log(title = "字典类型", businessType = BusinessType.INSERT) + @RequiresPermissions("system:dict:add") + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysDictType dict) + { + if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) + { + return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + dict.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(dictTypeService.insertDictType(dict)); + } + + /** + * 修改字典类型 + */ + @GetMapping("/edit/{dictId}") + public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap) + { + mmap.put("dict", dictTypeService.selectDictTypeById(dictId)); + return prefix + "/edit"; + } + + /** + * 修改保存字典类型 + */ + @Log(title = "字典类型", businessType = BusinessType.UPDATE) + @RequiresPermissions("system:dict:edit") + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysDictType dict) + { + if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) + { + return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); + } + dict.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(dictTypeService.updateDictType(dict)); + } + + @Log(title = "字典类型", businessType = BusinessType.DELETE) + @RequiresPermissions("system:dict:remove") + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + try + { + return toAjax(dictTypeService.deleteDictTypeByIds(ids)); + } + catch (Exception e) + { + return error(e.getMessage()); + } + } + + /** + * 查询字典详细 + */ + @RequiresPermissions("system:dict:list") + @GetMapping("/detail/{dictId}") + public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap) + { + mmap.put("dict", dictTypeService.selectDictTypeById(dictId)); + mmap.put("dictList", dictTypeService.selectDictTypeAll()); + return "system/dict/data/data"; + } + + /** + * 校验字典类型 + */ + @PostMapping("/checkDictTypeUnique") + @ResponseBody + public String checkDictTypeUnique(SysDictType dictType) + { + return dictTypeService.checkDictTypeUnique(dictType); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java index 3c736270a..f9c0c9fdf 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysIndexController.java @@ -1,48 +1,48 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import com.ruoyi.common.config.Global; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysMenu; -import com.ruoyi.system.domain.SysUser; -import com.ruoyi.system.service.ISysMenuService; - -/** - * 首页 业务处理 - * - * @author ruoyi - */ -@Controller -public class SysIndexController extends BaseController -{ - @Autowired - private ISysMenuService menuService; - - // 系统首页 - @GetMapping("/index") - public String index(ModelMap mmap) - { - // 取身份信息 - SysUser user = ShiroUtils.getSysUser(); - // 根据用户id取出菜单 - List menus = menuService.selectMenusByUser(user); - mmap.put("menus", menus); - mmap.put("user", user); - mmap.put("copyrightYear", Global.getCopyrightYear()); - mmap.put("demoEnabled", Global.isDemoEnabled()); - return "index"; - } - - // 系统介绍 - @GetMapping("/system/main") - public String main(ModelMap mmap) - { - mmap.put("version", Global.getVersion()); - return "main"; - } -} +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import com.ruoyi.common.config.Global; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysMenu; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.service.ISysMenuService; + +/** + * 首页 业务处理 + * + * @author ruoyi + */ +@Controller +public class SysIndexController extends BaseController +{ + @Autowired + private ISysMenuService menuService; + + // 系统首页 + @GetMapping("/index") + public String index(ModelMap mmap) + { + // 取身份信息 + SysUser user = ShiroUtils.getSysUser(); + // 根据用户id取出菜单 + List menus = menuService.selectMenusByUser(user); + mmap.put("menus", menus); + mmap.put("user", user); + mmap.put("copyrightYear", Global.getCopyrightYear()); + mmap.put("demoEnabled", Global.isDemoEnabled()); + return "index"; + } + + // 系统介绍 + @GetMapping("/system/main") + public String main(ModelMap mmap) + { + mmap.put("version", Global.getVersion()); + return "main"; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java similarity index 100% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java index 3615c7599..d1a4e5336 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java @@ -1,196 +1,196 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.Ztree; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysMenu; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.service.ISysMenuService; - -/** - * 菜单信息 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/menu") -public class SysMenuController extends BaseController -{ - private String prefix = "system/menu"; - - @Autowired - private ISysMenuService menuService; - - @RequiresPermissions("system:menu:view") - @GetMapping() - public String menu() - { - return prefix + "/menu"; - } - - @RequiresPermissions("system:menu:list") - @PostMapping("/list") - @ResponseBody - public List list(SysMenu menu) - { - Long userId = ShiroUtils.getUserId(); - List menuList = menuService.selectMenuList(menu, userId); - return menuList; - } - - /** - * 删除菜单 - */ - @Log(title = "菜单管理", businessType = BusinessType.DELETE) - @RequiresPermissions("system:menu:remove") - @GetMapping("/remove/{menuId}") - @ResponseBody - public AjaxResult remove(@PathVariable("menuId") Long menuId) - { - if (menuService.selectCountMenuByParentId(menuId) > 0) - { - return AjaxResult.warn("存在子菜单,不允许删除"); - } - if (menuService.selectCountRoleMenuByMenuId(menuId) > 0) - { - return AjaxResult.warn("菜单已分配,不允许删除"); - } - ShiroUtils.clearCachedAuthorizationInfo(); - return toAjax(menuService.deleteMenuById(menuId)); - } - - /** - * 新增 - */ - @GetMapping("/add/{parentId}") - public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) - { - SysMenu menu = null; - if (0L != parentId) - { - menu = menuService.selectMenuById(parentId); - } - else - { - menu = new SysMenu(); - menu.setMenuId(0L); - menu.setMenuName("主目录"); - } - mmap.put("menu", menu); - return prefix + "/add"; - } - - /** - * 新增保存菜单 - */ - @Log(title = "菜单管理", businessType = BusinessType.INSERT) - @RequiresPermissions("system:menu:add") - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysMenu menu) - { - if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) - { - return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); - } - menu.setCreateBy(ShiroUtils.getLoginName()); - ShiroUtils.clearCachedAuthorizationInfo(); - return toAjax(menuService.insertMenu(menu)); - } - - /** - * 修改菜单 - */ - @GetMapping("/edit/{menuId}") - public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap) - { - mmap.put("menu", menuService.selectMenuById(menuId)); - return prefix + "/edit"; - } - - /** - * 修改保存菜单 - */ - @Log(title = "菜单管理", businessType = BusinessType.UPDATE) - @RequiresPermissions("system:menu:edit") - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysMenu menu) - { - if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) - { - return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); - } - menu.setUpdateBy(ShiroUtils.getLoginName()); - ShiroUtils.clearCachedAuthorizationInfo(); - return toAjax(menuService.updateMenu(menu)); - } - - /** - * 选择菜单图标 - */ - @GetMapping("/icon") - public String icon() - { - return prefix + "/icon"; - } - - /** - * 校验菜单名称 - */ - @PostMapping("/checkMenuNameUnique") - @ResponseBody - public String checkMenuNameUnique(SysMenu menu) - { - return menuService.checkMenuNameUnique(menu); - } - - /** - * 加载角色菜单列表树 - */ - @GetMapping("/roleMenuTreeData") - @ResponseBody - public List roleMenuTreeData(SysRole role) - { - Long userId = ShiroUtils.getUserId(); - List ztrees = menuService.roleMenuTreeData(role, userId); - return ztrees; - } - - /** - * 加载所有菜单列表树 - */ - @GetMapping("/menuTreeData") - @ResponseBody - public List menuTreeData() - { - Long userId = ShiroUtils.getUserId(); - List ztrees = menuService.menuTreeData(userId); - return ztrees; - } - - /** - * 选择菜单树 - */ - @GetMapping("/selectMenuTree/{menuId}") - public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap) - { - mmap.put("menu", menuService.selectMenuById(menuId)); - return prefix + "/tree"; - } +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysMenu; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.service.ISysMenuService; + +/** + * 菜单信息 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/menu") +public class SysMenuController extends BaseController +{ + private String prefix = "system/menu"; + + @Autowired + private ISysMenuService menuService; + + @RequiresPermissions("system:menu:view") + @GetMapping() + public String menu() + { + return prefix + "/menu"; + } + + @RequiresPermissions("system:menu:list") + @PostMapping("/list") + @ResponseBody + public List list(SysMenu menu) + { + Long userId = ShiroUtils.getUserId(); + List menuList = menuService.selectMenuList(menu, userId); + return menuList; + } + + /** + * 删除菜单 + */ + @Log(title = "菜单管理", businessType = BusinessType.DELETE) + @RequiresPermissions("system:menu:remove") + @GetMapping("/remove/{menuId}") + @ResponseBody + public AjaxResult remove(@PathVariable("menuId") Long menuId) + { + if (menuService.selectCountMenuByParentId(menuId) > 0) + { + return AjaxResult.warn("存在子菜单,不允许删除"); + } + if (menuService.selectCountRoleMenuByMenuId(menuId) > 0) + { + return AjaxResult.warn("菜单已分配,不允许删除"); + } + ShiroUtils.clearCachedAuthorizationInfo(); + return toAjax(menuService.deleteMenuById(menuId)); + } + + /** + * 新增 + */ + @GetMapping("/add/{parentId}") + public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) + { + SysMenu menu = null; + if (0L != parentId) + { + menu = menuService.selectMenuById(parentId); + } + else + { + menu = new SysMenu(); + menu.setMenuId(0L); + menu.setMenuName("主目录"); + } + mmap.put("menu", menu); + return prefix + "/add"; + } + + /** + * 新增保存菜单 + */ + @Log(title = "菜单管理", businessType = BusinessType.INSERT) + @RequiresPermissions("system:menu:add") + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysMenu menu) + { + if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) + { + return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); + } + menu.setCreateBy(ShiroUtils.getLoginName()); + ShiroUtils.clearCachedAuthorizationInfo(); + return toAjax(menuService.insertMenu(menu)); + } + + /** + * 修改菜单 + */ + @GetMapping("/edit/{menuId}") + public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap) + { + mmap.put("menu", menuService.selectMenuById(menuId)); + return prefix + "/edit"; + } + + /** + * 修改保存菜单 + */ + @Log(title = "菜单管理", businessType = BusinessType.UPDATE) + @RequiresPermissions("system:menu:edit") + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysMenu menu) + { + if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) + { + return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); + } + menu.setUpdateBy(ShiroUtils.getLoginName()); + ShiroUtils.clearCachedAuthorizationInfo(); + return toAjax(menuService.updateMenu(menu)); + } + + /** + * 选择菜单图标 + */ + @GetMapping("/icon") + public String icon() + { + return prefix + "/icon"; + } + + /** + * 校验菜单名称 + */ + @PostMapping("/checkMenuNameUnique") + @ResponseBody + public String checkMenuNameUnique(SysMenu menu) + { + return menuService.checkMenuNameUnique(menu); + } + + /** + * 加载角色菜单列表树 + */ + @GetMapping("/roleMenuTreeData") + @ResponseBody + public List roleMenuTreeData(SysRole role) + { + Long userId = ShiroUtils.getUserId(); + List ztrees = menuService.roleMenuTreeData(role, userId); + return ztrees; + } + + /** + * 加载所有菜单列表树 + */ + @GetMapping("/menuTreeData") + @ResponseBody + public List menuTreeData() + { + Long userId = ShiroUtils.getUserId(); + List ztrees = menuService.menuTreeData(userId); + return ztrees; + } + + /** + * 选择菜单树 + */ + @GetMapping("/selectMenuTree/{menuId}") + public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap) + { + mmap.put("menu", menuService.selectMenuById(menuId)); + return prefix + "/tree"; + } } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java index 671dc11e3..c7f654e50 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java @@ -1,112 +1,112 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysNotice; -import com.ruoyi.system.service.ISysNoticeService; - -/** - * 公告 信息操作处理 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/notice") -public class SysNoticeController extends BaseController -{ - private String prefix = "system/notice"; - - @Autowired - private ISysNoticeService noticeService; - - @RequiresPermissions("system:notice:view") - @GetMapping() - public String notice() - { - return prefix + "/notice"; - } - - /** - * 查询公告列表 - */ - @RequiresPermissions("system:notice:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysNotice notice) - { - startPage(); - List list = noticeService.selectNoticeList(notice); - return getDataTable(list); - } - - /** - * 新增公告 - */ - @GetMapping("/add") - public String add() - { - return prefix + "/add"; - } - - /** - * 新增保存公告 - */ - @RequiresPermissions("system:notice:add") - @Log(title = "通知公告", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(SysNotice notice) - { - notice.setCreateBy(ShiroUtils.getLoginName()); - return toAjax(noticeService.insertNotice(notice)); - } - - /** - * 修改公告 - */ - @GetMapping("/edit/{noticeId}") - public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap) - { - mmap.put("notice", noticeService.selectNoticeById(noticeId)); - return prefix + "/edit"; - } - - /** - * 修改保存公告 - */ - @RequiresPermissions("system:notice:edit") - @Log(title = "通知公告", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(SysNotice notice) - { - notice.setUpdateBy(ShiroUtils.getLoginName()); - return toAjax(noticeService.updateNotice(notice)); - } - - /** - * 删除公告 - */ - @RequiresPermissions("system:notice:remove") - @Log(title = "通知公告", businessType = BusinessType.DELETE) - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(noticeService.deleteNoticeByIds(ids)); - } -} +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.service.ISysNoticeService; + +/** + * 公告 信息操作处理 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/notice") +public class SysNoticeController extends BaseController +{ + private String prefix = "system/notice"; + + @Autowired + private ISysNoticeService noticeService; + + @RequiresPermissions("system:notice:view") + @GetMapping() + public String notice() + { + return prefix + "/notice"; + } + + /** + * 查询公告列表 + */ + @RequiresPermissions("system:notice:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysNotice notice) + { + startPage(); + List list = noticeService.selectNoticeList(notice); + return getDataTable(list); + } + + /** + * 新增公告 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存公告 + */ + @RequiresPermissions("system:notice:add") + @Log(title = "通知公告", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(SysNotice notice) + { + notice.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(noticeService.insertNotice(notice)); + } + + /** + * 修改公告 + */ + @GetMapping("/edit/{noticeId}") + public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap) + { + mmap.put("notice", noticeService.selectNoticeById(noticeId)); + return prefix + "/edit"; + } + + /** + * 修改保存公告 + */ + @RequiresPermissions("system:notice:edit") + @Log(title = "通知公告", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(SysNotice notice) + { + notice.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(noticeService.updateNotice(notice)); + } + + /** + * 删除公告 + */ + @RequiresPermissions("system:notice:remove") + @Log(title = "通知公告", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(noticeService.deleteNoticeByIds(ids)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java index d6db9fdf0..7091f5d77 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java @@ -1,163 +1,163 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysPost; -import com.ruoyi.system.service.ISysPostService; - -/** - * 岗位信息操作处理 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/post") -public class SysPostController extends BaseController -{ - private String prefix = "system/post"; - - @Autowired - private ISysPostService postService; - - @RequiresPermissions("system:post:view") - @GetMapping() - public String operlog() - { - return prefix + "/post"; - } - - @RequiresPermissions("system:post:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysPost post) - { - startPage(); - List list = postService.selectPostList(post); - return getDataTable(list); - } - - @Log(title = "岗位管理", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:post:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysPost post) - { - List list = postService.selectPostList(post); - ExcelUtil util = new ExcelUtil(SysPost.class); - return util.exportExcel(list, "岗位数据"); - } - - @RequiresPermissions("system:post:remove") - @Log(title = "岗位管理", businessType = BusinessType.DELETE) - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - try - { - return toAjax(postService.deletePostByIds(ids)); - } - catch (Exception e) - { - return error(e.getMessage()); - } - } - - /** - * 新增岗位 - */ - @GetMapping("/add") - public String add() - { - return prefix + "/add"; - } - - /** - * 新增保存岗位 - */ - @RequiresPermissions("system:post:add") - @Log(title = "岗位管理", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysPost post) - { - if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) - { - return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); - } - else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) - { - return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); - } - post.setCreateBy(ShiroUtils.getLoginName()); - return toAjax(postService.insertPost(post)); - } - - /** - * 修改岗位 - */ - @GetMapping("/edit/{postId}") - public String edit(@PathVariable("postId") Long postId, ModelMap mmap) - { - mmap.put("post", postService.selectPostById(postId)); - return prefix + "/edit"; - } - - /** - * 修改保存岗位 - */ - @RequiresPermissions("system:post:edit") - @Log(title = "岗位管理", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysPost post) - { - if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) - { - return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); - } - else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) - { - return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); - } - post.setUpdateBy(ShiroUtils.getLoginName()); - return toAjax(postService.updatePost(post)); - } - - /** - * 校验岗位名称 - */ - @PostMapping("/checkPostNameUnique") - @ResponseBody - public String checkPostNameUnique(SysPost post) - { - return postService.checkPostNameUnique(post); - } - - /** - * 校验岗位编码 - */ - @PostMapping("/checkPostCodeUnique") - @ResponseBody - public String checkPostCodeUnique(SysPost post) - { - return postService.checkPostCodeUnique(post); - } -} +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.service.ISysPostService; + +/** + * 岗位信息操作处理 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/post") +public class SysPostController extends BaseController +{ + private String prefix = "system/post"; + + @Autowired + private ISysPostService postService; + + @RequiresPermissions("system:post:view") + @GetMapping() + public String operlog() + { + return prefix + "/post"; + } + + @RequiresPermissions("system:post:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysPost post) + { + startPage(); + List list = postService.selectPostList(post); + return getDataTable(list); + } + + @Log(title = "岗位管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:post:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysPost post) + { + List list = postService.selectPostList(post); + ExcelUtil util = new ExcelUtil(SysPost.class); + return util.exportExcel(list, "岗位数据"); + } + + @RequiresPermissions("system:post:remove") + @Log(title = "岗位管理", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + try + { + return toAjax(postService.deletePostByIds(ids)); + } + catch (Exception e) + { + return error(e.getMessage()); + } + } + + /** + * 新增岗位 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存岗位 + */ + @RequiresPermissions("system:post:add") + @Log(title = "岗位管理", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysPost post) + { + if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) + { + return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + } + else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) + { + return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + } + post.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(postService.insertPost(post)); + } + + /** + * 修改岗位 + */ + @GetMapping("/edit/{postId}") + public String edit(@PathVariable("postId") Long postId, ModelMap mmap) + { + mmap.put("post", postService.selectPostById(postId)); + return prefix + "/edit"; + } + + /** + * 修改保存岗位 + */ + @RequiresPermissions("system:post:edit") + @Log(title = "岗位管理", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysPost post) + { + if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) + { + return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); + } + else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) + { + return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + } + post.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(postService.updatePost(post)); + } + + /** + * 校验岗位名称 + */ + @PostMapping("/checkPostNameUnique") + @ResponseBody + public String checkPostNameUnique(SysPost post) + { + return postService.checkPostNameUnique(post); + } + + /** + * 校验岗位编码 + */ + @PostMapping("/checkPostCodeUnique") + @ResponseBody + public String checkPostCodeUnique(SysPost post) + { + return postService.checkPostCodeUnique(post); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java index f8a462dda..59127b0c5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -1,173 +1,173 @@ -package com.ruoyi.web.controller.system; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.config.Global; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.file.FileUploadUtils; -import com.ruoyi.framework.shiro.service.SysPasswordService; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysUser; -import com.ruoyi.system.service.ISysUserService; - -/** - * 个人信息 业务处理 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/user/profile") -public class SysProfileController extends BaseController -{ - private static final Logger log = LoggerFactory.getLogger(SysProfileController.class); - - private String prefix = "system/user/profile"; - - @Autowired - private ISysUserService userService; - - @Autowired - private SysPasswordService passwordService; - - /** - * 个人信息 - */ - @GetMapping() - public String profile(ModelMap mmap) - { - SysUser user = ShiroUtils.getSysUser(); - mmap.put("user", user); - mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId())); - mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId())); - return prefix + "/profile"; - } - - @GetMapping("/checkPassword") - @ResponseBody - public boolean checkPassword(String password) - { - SysUser user = ShiroUtils.getSysUser(); - if (passwordService.matches(user, password)) - { - return true; - } - return false; - } - - @GetMapping("/resetPwd") - public String resetPwd(ModelMap mmap) - { - SysUser user = ShiroUtils.getSysUser(); - mmap.put("user", userService.selectUserById(user.getUserId())); - return prefix + "/resetPwd"; - } - - @Log(title = "重置密码", businessType = BusinessType.UPDATE) - @PostMapping("/resetPwd") - @ResponseBody - public AjaxResult resetPwd(String oldPassword, String newPassword) - { - SysUser user = ShiroUtils.getSysUser(); - if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword)) - { - user.setSalt(ShiroUtils.randomSalt()); - user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt())); - if (userService.resetUserPwd(user) > 0) - { - ShiroUtils.setSysUser(userService.selectUserById(user.getUserId())); - return success(); - } - return error(); - } - else - { - return error("修改密码失败,旧密码错误"); - } - } - - /** - * 修改用户 - */ - @GetMapping("/edit") - public String edit(ModelMap mmap) - { - SysUser user = ShiroUtils.getSysUser(); - mmap.put("user", userService.selectUserById(user.getUserId())); - return prefix + "/edit"; - } - - /** - * 修改头像 - */ - @GetMapping("/avatar") - public String avatar(ModelMap mmap) - { - SysUser user = ShiroUtils.getSysUser(); - mmap.put("user", userService.selectUserById(user.getUserId())); - return prefix + "/avatar"; - } - - /** - * 修改用户 - */ - @Log(title = "个人信息", businessType = BusinessType.UPDATE) - @PostMapping("/update") - @ResponseBody - public AjaxResult update(SysUser user) - { - SysUser currentUser = ShiroUtils.getSysUser(); - currentUser.setUserName(user.getUserName()); - currentUser.setEmail(user.getEmail()); - currentUser.setPhonenumber(user.getPhonenumber()); - currentUser.setSex(user.getSex()); - if (userService.updateUserInfo(currentUser) > 0) - { - ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId())); - return success(); - } - return error(); - } - - /** - * 保存头像 - */ - @Log(title = "个人信息", businessType = BusinessType.UPDATE) - @PostMapping("/updateAvatar") - @ResponseBody - public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file) - { - SysUser currentUser = ShiroUtils.getSysUser(); - try - { - if (!file.isEmpty()) - { - String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file); - currentUser.setAvatar(avatar); - if (userService.updateUserInfo(currentUser) > 0) - { - ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId())); - return success(); - } - } - return error(); - } - catch (Exception e) - { - log.error("修改头像失败!", e); - return error(e.getMessage()); - } - } -} +package com.ruoyi.web.controller.system; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.config.Global; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.framework.shiro.service.SysPasswordService; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.service.ISysUserService; + +/** + * 个人信息 业务处理 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/user/profile") +public class SysProfileController extends BaseController +{ + private static final Logger log = LoggerFactory.getLogger(SysProfileController.class); + + private String prefix = "system/user/profile"; + + @Autowired + private ISysUserService userService; + + @Autowired + private SysPasswordService passwordService; + + /** + * 个人信息 + */ + @GetMapping() + public String profile(ModelMap mmap) + { + SysUser user = ShiroUtils.getSysUser(); + mmap.put("user", user); + mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId())); + mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId())); + return prefix + "/profile"; + } + + @GetMapping("/checkPassword") + @ResponseBody + public boolean checkPassword(String password) + { + SysUser user = ShiroUtils.getSysUser(); + if (passwordService.matches(user, password)) + { + return true; + } + return false; + } + + @GetMapping("/resetPwd") + public String resetPwd(ModelMap mmap) + { + SysUser user = ShiroUtils.getSysUser(); + mmap.put("user", userService.selectUserById(user.getUserId())); + return prefix + "/resetPwd"; + } + + @Log(title = "重置密码", businessType = BusinessType.UPDATE) + @PostMapping("/resetPwd") + @ResponseBody + public AjaxResult resetPwd(String oldPassword, String newPassword) + { + SysUser user = ShiroUtils.getSysUser(); + if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword)) + { + user.setSalt(ShiroUtils.randomSalt()); + user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt())); + if (userService.resetUserPwd(user) > 0) + { + ShiroUtils.setSysUser(userService.selectUserById(user.getUserId())); + return success(); + } + return error(); + } + else + { + return error("修改密码失败,旧密码错误"); + } + } + + /** + * 修改用户 + */ + @GetMapping("/edit") + public String edit(ModelMap mmap) + { + SysUser user = ShiroUtils.getSysUser(); + mmap.put("user", userService.selectUserById(user.getUserId())); + return prefix + "/edit"; + } + + /** + * 修改头像 + */ + @GetMapping("/avatar") + public String avatar(ModelMap mmap) + { + SysUser user = ShiroUtils.getSysUser(); + mmap.put("user", userService.selectUserById(user.getUserId())); + return prefix + "/avatar"; + } + + /** + * 修改用户 + */ + @Log(title = "个人信息", businessType = BusinessType.UPDATE) + @PostMapping("/update") + @ResponseBody + public AjaxResult update(SysUser user) + { + SysUser currentUser = ShiroUtils.getSysUser(); + currentUser.setUserName(user.getUserName()); + currentUser.setEmail(user.getEmail()); + currentUser.setPhonenumber(user.getPhonenumber()); + currentUser.setSex(user.getSex()); + if (userService.updateUserInfo(currentUser) > 0) + { + ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId())); + return success(); + } + return error(); + } + + /** + * 保存头像 + */ + @Log(title = "个人信息", businessType = BusinessType.UPDATE) + @PostMapping("/updateAvatar") + @ResponseBody + public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file) + { + SysUser currentUser = ShiroUtils.getSysUser(); + try + { + if (!file.isEmpty()) + { + String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file); + currentUser.setAvatar(avatar); + if (userService.updateUserInfo(currentUser) > 0) + { + ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId())); + return success(); + } + } + return error(); + } + catch (Exception e) + { + log.error("修改头像失败!", e); + return error(e.getMessage()); + } + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java index 66532db82..8aaeecd37 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java @@ -1,301 +1,301 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.domain.SysUser; -import com.ruoyi.system.domain.SysUserRole; -import com.ruoyi.system.service.ISysRoleService; -import com.ruoyi.system.service.ISysUserService; - -/** - * 角色信息 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/role") -public class SysRoleController extends BaseController -{ - private String prefix = "system/role"; - - @Autowired - private ISysRoleService roleService; - - @Autowired - private ISysUserService userService; - - @RequiresPermissions("system:role:view") - @GetMapping() - public String role() - { - return prefix + "/role"; - } - - @RequiresPermissions("system:role:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysRole role) - { - startPage(); - List list = roleService.selectRoleList(role); - return getDataTable(list); - } - - @Log(title = "角色管理", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:role:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysRole role) - { - List list = roleService.selectRoleList(role); - ExcelUtil util = new ExcelUtil(SysRole.class); - return util.exportExcel(list, "角色数据"); - } - - /** - * 新增角色 - */ - @GetMapping("/add") - public String add() - { - return prefix + "/add"; - } - - /** - * 新增保存角色 - */ - @RequiresPermissions("system:role:add") - @Log(title = "角色管理", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysRole role) - { - if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) - { - return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); - } - else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) - { - return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); - } - role.setCreateBy(ShiroUtils.getLoginName()); - ShiroUtils.clearCachedAuthorizationInfo(); - return toAjax(roleService.insertRole(role)); - - } - - /** - * 修改角色 - */ - @GetMapping("/edit/{roleId}") - public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap) - { - mmap.put("role", roleService.selectRoleById(roleId)); - return prefix + "/edit"; - } - - /** - * 修改保存角色 - */ - @RequiresPermissions("system:role:edit") - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysRole role) - { - if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) - { - return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); - } - else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) - { - return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); - } - role.setUpdateBy(ShiroUtils.getLoginName()); - ShiroUtils.clearCachedAuthorizationInfo(); - return toAjax(roleService.updateRole(role)); - } - - /** - * 角色分配数据权限 - */ - @GetMapping("/authDataScope/{roleId}") - public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap) - { - mmap.put("role", roleService.selectRoleById(roleId)); - return prefix + "/dataScope"; - } - - /** - * 保存角色分配数据权限 - */ - @RequiresPermissions("system:role:edit") - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @PostMapping("/authDataScope") - @ResponseBody - public AjaxResult authDataScopeSave(SysRole role) - { - role.setUpdateBy(ShiroUtils.getLoginName()); - if (roleService.authDataScope(role) > 0) - { - ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId())); - return success(); - } - return error(); - } - - @RequiresPermissions("system:role:remove") - @Log(title = "角色管理", businessType = BusinessType.DELETE) - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - try - { - return toAjax(roleService.deleteRoleByIds(ids)); - } - catch (Exception e) - { - return error(e.getMessage()); - } - } - - /** - * 校验角色名称 - */ - @PostMapping("/checkRoleNameUnique") - @ResponseBody - public String checkRoleNameUnique(SysRole role) - { - return roleService.checkRoleNameUnique(role); - } - - /** - * 校验角色权限 - */ - @PostMapping("/checkRoleKeyUnique") - @ResponseBody - public String checkRoleKeyUnique(SysRole role) - { - return roleService.checkRoleKeyUnique(role); - } - - /** - * 选择菜单树 - */ - @GetMapping("/selectMenuTree") - public String selectMenuTree() - { - return prefix + "/tree"; - } - - /** - * 角色状态修改 - */ - @Log(title = "角色管理", businessType = BusinessType.UPDATE) - @RequiresPermissions("system:role:edit") - @PostMapping("/changeStatus") - @ResponseBody - public AjaxResult changeStatus(SysRole role) - { - return toAjax(roleService.changeStatus(role)); - } - - /** - * 分配用户 - */ - @RequiresPermissions("system:role:edit") - @GetMapping("/authUser/{roleId}") - public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap) - { - mmap.put("role", roleService.selectRoleById(roleId)); - return prefix + "/authUser"; - } - - /** - * 查询已分配用户角色列表 - */ - @RequiresPermissions("system:role:list") - @PostMapping("/authUser/allocatedList") - @ResponseBody - public TableDataInfo allocatedList(SysUser user) - { - startPage(); - List list = userService.selectAllocatedList(user); - return getDataTable(list); - } - - /** - * 取消授权 - */ - @Log(title = "角色管理", businessType = BusinessType.GRANT) - @PostMapping("/authUser/cancel") - @ResponseBody - public AjaxResult cancelAuthUser(SysUserRole userRole) - { - return toAjax(roleService.deleteAuthUser(userRole)); - } - - /** - * 批量取消授权 - */ - @Log(title = "角色管理", businessType = BusinessType.GRANT) - @PostMapping("/authUser/cancelAll") - @ResponseBody - public AjaxResult cancelAuthUserAll(Long roleId, String userIds) - { - return toAjax(roleService.deleteAuthUsers(roleId, userIds)); - } - - /** - * 选择用户 - */ - @GetMapping("/authUser/selectUser/{roleId}") - public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap) - { - mmap.put("role", roleService.selectRoleById(roleId)); - return prefix + "/selectUser"; - } - - /** - * 查询未分配用户角色列表 - */ - @RequiresPermissions("system:role:list") - @PostMapping("/authUser/unallocatedList") - @ResponseBody - public TableDataInfo unallocatedList(SysUser user) - { - startPage(); - List list = userService.selectUnallocatedList(user); - return getDataTable(list); - } - - /** - * 批量选择用户授权 - */ - @Log(title = "角色管理", businessType = BusinessType.GRANT) - @PostMapping("/authUser/selectAll") - @ResponseBody - public AjaxResult selectAuthUserAll(Long roleId, String userIds) - { - return toAjax(roleService.insertAuthUsers(roleId, userIds)); - } +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; + +/** + * 角色信息 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/role") +public class SysRoleController extends BaseController +{ + private String prefix = "system/role"; + + @Autowired + private ISysRoleService roleService; + + @Autowired + private ISysUserService userService; + + @RequiresPermissions("system:role:view") + @GetMapping() + public String role() + { + return prefix + "/role"; + } + + @RequiresPermissions("system:role:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysRole role) + { + startPage(); + List list = roleService.selectRoleList(role); + return getDataTable(list); + } + + @Log(title = "角色管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:role:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysRole role) + { + List list = roleService.selectRoleList(role); + ExcelUtil util = new ExcelUtil(SysRole.class); + return util.exportExcel(list, "角色数据"); + } + + /** + * 新增角色 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存角色 + */ + @RequiresPermissions("system:role:add") + @Log(title = "角色管理", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysRole role) + { + if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) + { + return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); + } + else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) + { + return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); + } + role.setCreateBy(ShiroUtils.getLoginName()); + ShiroUtils.clearCachedAuthorizationInfo(); + return toAjax(roleService.insertRole(role)); + + } + + /** + * 修改角色 + */ + @GetMapping("/edit/{roleId}") + public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap) + { + mmap.put("role", roleService.selectRoleById(roleId)); + return prefix + "/edit"; + } + + /** + * 修改保存角色 + */ + @RequiresPermissions("system:role:edit") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysRole role) + { + if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) + { + return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); + } + else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) + { + return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); + } + role.setUpdateBy(ShiroUtils.getLoginName()); + ShiroUtils.clearCachedAuthorizationInfo(); + return toAjax(roleService.updateRole(role)); + } + + /** + * 角色分配数据权限 + */ + @GetMapping("/authDataScope/{roleId}") + public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap) + { + mmap.put("role", roleService.selectRoleById(roleId)); + return prefix + "/dataScope"; + } + + /** + * 保存角色分配数据权限 + */ + @RequiresPermissions("system:role:edit") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PostMapping("/authDataScope") + @ResponseBody + public AjaxResult authDataScopeSave(SysRole role) + { + role.setUpdateBy(ShiroUtils.getLoginName()); + if (roleService.authDataScope(role) > 0) + { + ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId())); + return success(); + } + return error(); + } + + @RequiresPermissions("system:role:remove") + @Log(title = "角色管理", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + try + { + return toAjax(roleService.deleteRoleByIds(ids)); + } + catch (Exception e) + { + return error(e.getMessage()); + } + } + + /** + * 校验角色名称 + */ + @PostMapping("/checkRoleNameUnique") + @ResponseBody + public String checkRoleNameUnique(SysRole role) + { + return roleService.checkRoleNameUnique(role); + } + + /** + * 校验角色权限 + */ + @PostMapping("/checkRoleKeyUnique") + @ResponseBody + public String checkRoleKeyUnique(SysRole role) + { + return roleService.checkRoleKeyUnique(role); + } + + /** + * 选择菜单树 + */ + @GetMapping("/selectMenuTree") + public String selectMenuTree() + { + return prefix + "/tree"; + } + + /** + * 角色状态修改 + */ + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @RequiresPermissions("system:role:edit") + @PostMapping("/changeStatus") + @ResponseBody + public AjaxResult changeStatus(SysRole role) + { + return toAjax(roleService.changeStatus(role)); + } + + /** + * 分配用户 + */ + @RequiresPermissions("system:role:edit") + @GetMapping("/authUser/{roleId}") + public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap) + { + mmap.put("role", roleService.selectRoleById(roleId)); + return prefix + "/authUser"; + } + + /** + * 查询已分配用户角色列表 + */ + @RequiresPermissions("system:role:list") + @PostMapping("/authUser/allocatedList") + @ResponseBody + public TableDataInfo allocatedList(SysUser user) + { + startPage(); + List list = userService.selectAllocatedList(user); + return getDataTable(list); + } + + /** + * 取消授权 + */ + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PostMapping("/authUser/cancel") + @ResponseBody + public AjaxResult cancelAuthUser(SysUserRole userRole) + { + return toAjax(roleService.deleteAuthUser(userRole)); + } + + /** + * 批量取消授权 + */ + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PostMapping("/authUser/cancelAll") + @ResponseBody + public AjaxResult cancelAuthUserAll(Long roleId, String userIds) + { + return toAjax(roleService.deleteAuthUsers(roleId, userIds)); + } + + /** + * 选择用户 + */ + @GetMapping("/authUser/selectUser/{roleId}") + public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap) + { + mmap.put("role", roleService.selectRoleById(roleId)); + return prefix + "/selectUser"; + } + + /** + * 查询未分配用户角色列表 + */ + @RequiresPermissions("system:role:list") + @PostMapping("/authUser/unallocatedList") + @ResponseBody + public TableDataInfo unallocatedList(SysUser user) + { + startPage(); + List list = userService.selectUnallocatedList(user); + return getDataTable(list); + } + + /** + * 批量选择用户授权 + */ + @Log(title = "角色管理", businessType = BusinessType.GRANT) + @PostMapping("/authUser/selectAll") + @ResponseBody + public AjaxResult selectAuthUserAll(Long roleId, String userIds) + { + return toAjax(roleService.insertAuthUsers(roleId, userIds)); + } } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java similarity index 97% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 4a98acf7e..490c4fe17 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -1,263 +1,263 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.shiro.service.SysPasswordService; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysUser; -import com.ruoyi.system.service.ISysPostService; -import com.ruoyi.system.service.ISysRoleService; -import com.ruoyi.system.service.ISysUserService; - -/** - * 用户信息 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/system/user") -public class SysUserController extends BaseController -{ - private String prefix = "system/user"; - - @Autowired - private ISysUserService userService; - - @Autowired - private ISysRoleService roleService; - - @Autowired - private ISysPostService postService; - - @Autowired - private SysPasswordService passwordService; - - @RequiresPermissions("system:user:view") - @GetMapping() - public String user() - { - return prefix + "/user"; - } - - @RequiresPermissions("system:user:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysUser user) - { - startPage(); - List list = userService.selectUserList(user); - return getDataTable(list); - } - - @Log(title = "用户管理", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:user:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysUser user) - { - List list = userService.selectUserList(user); - ExcelUtil util = new ExcelUtil(SysUser.class); - return util.exportExcel(list, "用户数据"); - } - - @Log(title = "用户管理", businessType = BusinessType.IMPORT) - @RequiresPermissions("system:user:import") - @PostMapping("/importData") - @ResponseBody - public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception - { - ExcelUtil util = new ExcelUtil(SysUser.class); - List userList = util.importExcel(file.getInputStream()); - String operName = ShiroUtils.getSysUser().getLoginName(); - String message = userService.importUser(userList, updateSupport, operName); - return AjaxResult.success(message); - } - - @RequiresPermissions("system:user:view") - @GetMapping("/importTemplate") - @ResponseBody - public AjaxResult importTemplate() - { - ExcelUtil util = new ExcelUtil(SysUser.class); - return util.importTemplateExcel("用户数据"); - } - - /** - * 新增用户 - */ - @GetMapping("/add") - public String add(ModelMap mmap) - { - mmap.put("roles", roleService.selectRoleAll()); - mmap.put("posts", postService.selectPostAll()); - return prefix + "/add"; - } - - /** - * 新增保存用户 - */ - @RequiresPermissions("system:user:add") - @Log(title = "用户管理", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysUser user) - { - if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))) - { - return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在"); - } - else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) - { - return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在"); - } - else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) - { - return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在"); - } - user.setSalt(ShiroUtils.randomSalt()); - user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); - user.setCreateBy(ShiroUtils.getLoginName()); - return toAjax(userService.insertUser(user)); - } - - /** - * 修改用户 - */ - @GetMapping("/edit/{userId}") - public String edit(@PathVariable("userId") Long userId, ModelMap mmap) - { - mmap.put("user", userService.selectUserById(userId)); - mmap.put("roles", roleService.selectRolesByUserId(userId)); - mmap.put("posts", postService.selectPostsByUserId(userId)); - return prefix + "/edit"; - } - - /** - * 修改保存用户 - */ - @RequiresPermissions("system:user:edit") - @Log(title = "用户管理", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysUser user) - { - if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) - { - return error("不允许修改超级管理员用户"); - } - else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) - { - return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在"); - } - else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) - { - return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在"); - } - user.setUpdateBy(ShiroUtils.getLoginName()); - return toAjax(userService.updateUser(user)); - } - - @RequiresPermissions("system:user:resetPwd") - @Log(title = "重置密码", businessType = BusinessType.UPDATE) - @GetMapping("/resetPwd/{userId}") - public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap) - { - mmap.put("user", userService.selectUserById(userId)); - return prefix + "/resetPwd"; - } - - @RequiresPermissions("system:user:resetPwd") - @Log(title = "重置密码", businessType = BusinessType.UPDATE) - @PostMapping("/resetPwd") - @ResponseBody - public AjaxResult resetPwdSave(SysUser user) - { - user.setSalt(ShiroUtils.randomSalt()); - user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); - if (userService.resetUserPwd(user) > 0) - { - if (ShiroUtils.getUserId() == user.getUserId()) - { - ShiroUtils.setSysUser(userService.selectUserById(user.getUserId())); - } - return success(); - } - return error(); - } - - @RequiresPermissions("system:user:remove") - @Log(title = "用户管理", businessType = BusinessType.DELETE) - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - try - { - return toAjax(userService.deleteUserByIds(ids)); - } - catch (Exception e) - { - return error(e.getMessage()); - } - } - - /** - * 校验用户名 - */ - @PostMapping("/checkLoginNameUnique") - @ResponseBody - public String checkLoginNameUnique(SysUser user) - { - return userService.checkLoginNameUnique(user.getLoginName()); - } - - /** - * 校验手机号码 - */ - @PostMapping("/checkPhoneUnique") - @ResponseBody - public String checkPhoneUnique(SysUser user) - { - return userService.checkPhoneUnique(user); - } - - /** - * 校验email邮箱 - */ - @PostMapping("/checkEmailUnique") - @ResponseBody - public String checkEmailUnique(SysUser user) - { - return userService.checkEmailUnique(user); - } - - /** - * 用户状态修改 - */ - @Log(title = "用户管理", businessType = BusinessType.UPDATE) - @RequiresPermissions("system:user:edit") - @PostMapping("/changeStatus") - @ResponseBody - public AjaxResult changeStatus(SysUser user) - { - return toAjax(userService.changeStatus(user)); - } +package com.ruoyi.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.framework.shiro.service.SysPasswordService; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.service.ISysPostService; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; + +/** + * 用户信息 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/system/user") +public class SysUserController extends BaseController +{ + private String prefix = "system/user"; + + @Autowired + private ISysUserService userService; + + @Autowired + private ISysRoleService roleService; + + @Autowired + private ISysPostService postService; + + @Autowired + private SysPasswordService passwordService; + + @RequiresPermissions("system:user:view") + @GetMapping() + public String user() + { + return prefix + "/user"; + } + + @RequiresPermissions("system:user:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysUser user) + { + startPage(); + List list = userService.selectUserList(user); + return getDataTable(list); + } + + @Log(title = "用户管理", businessType = BusinessType.EXPORT) + @RequiresPermissions("system:user:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysUser user) + { + List list = userService.selectUserList(user); + ExcelUtil util = new ExcelUtil(SysUser.class); + return util.exportExcel(list, "用户数据"); + } + + @Log(title = "用户管理", businessType = BusinessType.IMPORT) + @RequiresPermissions("system:user:import") + @PostMapping("/importData") + @ResponseBody + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception + { + ExcelUtil util = new ExcelUtil(SysUser.class); + List userList = util.importExcel(file.getInputStream()); + String operName = ShiroUtils.getSysUser().getLoginName(); + String message = userService.importUser(userList, updateSupport, operName); + return AjaxResult.success(message); + } + + @RequiresPermissions("system:user:view") + @GetMapping("/importTemplate") + @ResponseBody + public AjaxResult importTemplate() + { + ExcelUtil util = new ExcelUtil(SysUser.class); + return util.importTemplateExcel("用户数据"); + } + + /** + * 新增用户 + */ + @GetMapping("/add") + public String add(ModelMap mmap) + { + mmap.put("roles", roleService.selectRoleAll()); + mmap.put("posts", postService.selectPostAll()); + return prefix + "/add"; + } + + /** + * 新增保存用户 + */ + @RequiresPermissions("system:user:add") + @Log(title = "用户管理", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysUser user) + { + if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))) + { + return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在"); + } + else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) + { + return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在"); + } + else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) + { + return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在"); + } + user.setSalt(ShiroUtils.randomSalt()); + user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); + user.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(userService.insertUser(user)); + } + + /** + * 修改用户 + */ + @GetMapping("/edit/{userId}") + public String edit(@PathVariable("userId") Long userId, ModelMap mmap) + { + mmap.put("user", userService.selectUserById(userId)); + mmap.put("roles", roleService.selectRolesByUserId(userId)); + mmap.put("posts", postService.selectPostsByUserId(userId)); + return prefix + "/edit"; + } + + /** + * 修改保存用户 + */ + @RequiresPermissions("system:user:edit") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysUser user) + { + if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) + { + return error("不允许修改超级管理员用户"); + } + else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) + { + return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在"); + } + else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) + { + return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在"); + } + user.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(userService.updateUser(user)); + } + + @RequiresPermissions("system:user:resetPwd") + @Log(title = "重置密码", businessType = BusinessType.UPDATE) + @GetMapping("/resetPwd/{userId}") + public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap) + { + mmap.put("user", userService.selectUserById(userId)); + return prefix + "/resetPwd"; + } + + @RequiresPermissions("system:user:resetPwd") + @Log(title = "重置密码", businessType = BusinessType.UPDATE) + @PostMapping("/resetPwd") + @ResponseBody + public AjaxResult resetPwdSave(SysUser user) + { + user.setSalt(ShiroUtils.randomSalt()); + user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); + if (userService.resetUserPwd(user) > 0) + { + if (ShiroUtils.getUserId() == user.getUserId()) + { + ShiroUtils.setSysUser(userService.selectUserById(user.getUserId())); + } + return success(); + } + return error(); + } + + @RequiresPermissions("system:user:remove") + @Log(title = "用户管理", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + try + { + return toAjax(userService.deleteUserByIds(ids)); + } + catch (Exception e) + { + return error(e.getMessage()); + } + } + + /** + * 校验用户名 + */ + @PostMapping("/checkLoginNameUnique") + @ResponseBody + public String checkLoginNameUnique(SysUser user) + { + return userService.checkLoginNameUnique(user.getLoginName()); + } + + /** + * 校验手机号码 + */ + @PostMapping("/checkPhoneUnique") + @ResponseBody + public String checkPhoneUnique(SysUser user) + { + return userService.checkPhoneUnique(user); + } + + /** + * 校验email邮箱 + */ + @PostMapping("/checkEmailUnique") + @ResponseBody + public String checkEmailUnique(SysUser user) + { + return userService.checkEmailUnique(user); + } + + /** + * 用户状态修改 + */ + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @RequiresPermissions("system:user:edit") + @PostMapping("/changeStatus") + @ResponseBody + public AjaxResult changeStatus(SysUser user) + { + return toAjax(userService.changeStatus(user)); + } } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/BuildController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/tool/BuildController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/BuildController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/tool/BuildController.java index 53ce0f1ba..4d3c1287a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/BuildController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/tool/BuildController.java @@ -1,26 +1,26 @@ -package com.ruoyi.web.controller.tool; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import com.ruoyi.common.core.controller.BaseController; - -/** - * build 表单构建 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/tool/build") -public class BuildController extends BaseController -{ - private String prefix = "tool/build"; - - @RequiresPermissions("tool:build:view") - @GetMapping() - public String build() - { - return prefix + "/build"; - } -} +package com.ruoyi.web.controller.tool; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.core.controller.BaseController; + +/** + * build 表单构建 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/tool/build") +public class BuildController extends BaseController +{ + private String prefix = "tool/build"; + + @RequiresPermissions("tool:build:view") + @GetMapping() + public String build() + { + return prefix + "/build"; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java index cfa748f30..7a3bf225e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java @@ -1,24 +1,24 @@ -package com.ruoyi.web.controller.tool; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import com.ruoyi.common.core.controller.BaseController; - -/** - * swagger 接口 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/tool/swagger") -public class SwaggerController extends BaseController -{ - @RequiresPermissions("tool:swagger:view") - @GetMapping() - public String index() - { - return redirect("/swagger-ui.html"); - } -} +package com.ruoyi.web.controller.tool; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.core.controller.BaseController; + +/** + * swagger 接口 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/tool/swagger") +public class SwaggerController extends BaseController +{ + @RequiresPermissions("tool:swagger:view") + @GetMapping() + public String index() + { + return redirect("/swagger-ui.html"); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java b/bmw-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java similarity index 96% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java rename to bmw-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java index bddbe7789..4b1c3dea1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java @@ -1,175 +1,175 @@ -package com.ruoyi.web.controller.tool; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.utils.StringUtils; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiOperation; - -/** - * swagger 用户测试方法 - * - * @author ruoyi - */ -@Api("用户信息管理") -@RestController -@RequestMapping("/test/user") -public class TestController extends BaseController -{ - private final static Map users = new LinkedHashMap(); - { - users.put(1, new UserEntity(1, "admin", "admin123", "15888888888")); - users.put(2, new UserEntity(2, "ry", "admin123", "15666666666")); - } - - @ApiOperation("获取用户列表") - @GetMapping("/list") - public AjaxResult userList() - { - List userList = new ArrayList(users.values()); - return AjaxResult.success(userList); - } - - @ApiOperation("获取用户详细") - @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") - @GetMapping("/{userId}") - public AjaxResult getUser(@PathVariable Integer userId) - { - if (!users.isEmpty() && users.containsKey(userId)) - { - return AjaxResult.success(users.get(userId)); - } - else - { - return error("用户不存在"); - } - } - - @ApiOperation("新增用户") - @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") - @PostMapping("/save") - public AjaxResult save(UserEntity user) - { - if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) - { - return error("用户ID不能为空"); - } - return AjaxResult.success(users.put(user.getUserId(), user)); - } - - @ApiOperation("更新用户") - @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") - @PutMapping("/update") - public AjaxResult update(UserEntity user) - { - if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) - { - return error("用户ID不能为空"); - } - if (users.isEmpty() || !users.containsKey(user.getUserId())) - { - return error("用户不存在"); - } - users.remove(user.getUserId()); - return AjaxResult.success(users.put(user.getUserId(), user)); - } - - @ApiOperation("删除用户信息") - @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") - @DeleteMapping("/{userId}") - public AjaxResult delete(@PathVariable Integer userId) - { - if (!users.isEmpty() && users.containsKey(userId)) - { - users.remove(userId); - return success(); - } - else - { - return error("用户不存在"); - } - } -} - -@ApiModel("用户实体") -class UserEntity -{ - @ApiModelProperty("用户ID") - private Integer userId; - - @ApiModelProperty("用户名称") - private String username; - - @ApiModelProperty("用户密码") - private String password; - - @ApiModelProperty("用户手机") - private String mobile; - - public UserEntity() - { - - } - - public UserEntity(Integer userId, String username, String password, String mobile) - { - this.userId = userId; - this.username = username; - this.password = password; - this.mobile = mobile; - } - - public Integer getUserId() - { - return userId; - } - - public void setUserId(Integer userId) - { - this.userId = userId; - } - - public String getUsername() - { - return username; - } - - public void setUsername(String username) - { - this.username = username; - } - - public String getPassword() - { - return password; - } - - public void setPassword(String password) - { - this.password = password; - } - - public String getMobile() - { - return mobile; - } - - public void setMobile(String mobile) - { - this.mobile = mobile; - } -} +package com.ruoyi.web.controller.tool; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.StringUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiOperation; + +/** + * swagger 用户测试方法 + * + * @author ruoyi + */ +@Api("用户信息管理") +@RestController +@RequestMapping("/test/user") +public class TestController extends BaseController +{ + private final static Map users = new LinkedHashMap(); + { + users.put(1, new UserEntity(1, "admin", "admin123", "15888888888")); + users.put(2, new UserEntity(2, "ry", "admin123", "15666666666")); + } + + @ApiOperation("获取用户列表") + @GetMapping("/list") + public AjaxResult userList() + { + List userList = new ArrayList(users.values()); + return AjaxResult.success(userList); + } + + @ApiOperation("获取用户详细") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") + @GetMapping("/{userId}") + public AjaxResult getUser(@PathVariable Integer userId) + { + if (!users.isEmpty() && users.containsKey(userId)) + { + return AjaxResult.success(users.get(userId)); + } + else + { + return error("用户不存在"); + } + } + + @ApiOperation("新增用户") + @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") + @PostMapping("/save") + public AjaxResult save(UserEntity user) + { + if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) + { + return error("用户ID不能为空"); + } + return AjaxResult.success(users.put(user.getUserId(), user)); + } + + @ApiOperation("更新用户") + @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") + @PutMapping("/update") + public AjaxResult update(UserEntity user) + { + if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) + { + return error("用户ID不能为空"); + } + if (users.isEmpty() || !users.containsKey(user.getUserId())) + { + return error("用户不存在"); + } + users.remove(user.getUserId()); + return AjaxResult.success(users.put(user.getUserId(), user)); + } + + @ApiOperation("删除用户信息") + @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path") + @DeleteMapping("/{userId}") + public AjaxResult delete(@PathVariable Integer userId) + { + if (!users.isEmpty() && users.containsKey(userId)) + { + users.remove(userId); + return success(); + } + else + { + return error("用户不存在"); + } + } +} + +@ApiModel("用户实体") +class UserEntity +{ + @ApiModelProperty("用户ID") + private Integer userId; + + @ApiModelProperty("用户名称") + private String username; + + @ApiModelProperty("用户密码") + private String password; + + @ApiModelProperty("用户手机") + private String mobile; + + public UserEntity() + { + + } + + public UserEntity(Integer userId, String username, String password, String mobile) + { + this.userId = userId; + this.username = username; + this.password = password; + this.mobile = mobile; + } + + public Integer getUserId() + { + return userId; + } + + public void setUserId(Integer userId) + { + this.userId = userId; + } + + public String getUsername() + { + return username; + } + + public void setUsername(String username) + { + this.username = username; + } + + public String getPassword() + { + return password; + } + + public void setPassword(String password) + { + this.password = password; + } + + public String getMobile() + { + return mobile; + } + + public void setMobile(String mobile) + { + this.mobile = mobile; + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/bmw-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java similarity index 97% rename from ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java rename to bmw-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java index 43353914a..c08f21a0b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java +++ b/bmw-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -1,62 +1,62 @@ -package com.ruoyi.web.core.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import com.ruoyi.common.config.Global; -import io.swagger.annotations.ApiOperation; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - * Swagger2的接口配置 - * - * @author ruoyi - */ -@Configuration -@EnableSwagger2 -public class SwaggerConfig -{ - /** - * 创建API - */ - @Bean - public Docket createRestApi() - { - return new Docket(DocumentationType.SWAGGER_2) - // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) - .apiInfo(apiInfo()) - // 设置哪些接口暴露给Swagger展示 - .select() - // 扫描所有有注解的api,用这种方式更灵活 - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - // 扫描指定包中的swagger注解 - //.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) - // 扫描所有 .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 添加摘要信息 - */ - private ApiInfo apiInfo() - { - // 用ApiInfoBuilder进行定制 - return new ApiInfoBuilder() - // 设置标题 - .title("标题:若依管理系统_接口文档") - // 描述 - .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") - // 作者信息 - .contact(new Contact(Global.getName(), null, null)) - // 版本 - .version("版本号:" + Global.getVersion()) - .build(); - } -} +package com.ruoyi.web.core.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import com.ruoyi.common.config.Global; +import io.swagger.annotations.ApiOperation; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * Swagger2的接口配置 + * + * @author ruoyi + */ +@Configuration +@EnableSwagger2 +public class SwaggerConfig +{ + /** + * 创建API + */ + @Bean + public Docket createRestApi() + { + return new Docket(DocumentationType.SWAGGER_2) + // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) + .apiInfo(apiInfo()) + // 设置哪些接口暴露给Swagger展示 + .select() + // 扫描所有有注解的api,用这种方式更灵活 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + // 扫描指定包中的swagger注解 + //.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) + // 扫描所有 .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); + } + + /** + * 添加摘要信息 + */ + private ApiInfo apiInfo() + { + // 用ApiInfoBuilder进行定制 + return new ApiInfoBuilder() + // 设置标题 + .title("标题:若依管理系统_接口文档") + // 描述 + .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") + // 作者信息 + .contact(new Contact(Global.getName(), null, null)) + // 版本 + .version("版本号:" + Global.getVersion()) + .build(); + } +} diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/bmw-admin/src/main/resources/application-druid.yml similarity index 88% rename from ruoyi-admin/src/main/resources/application-druid.yml rename to bmw-admin/src/main/resources/application-druid.yml index d69c66d27..57ae58a64 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/bmw-admin/src/main/resources/application-druid.yml @@ -1,57 +1,57 @@ -# 数据源配置 -spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: - url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: password - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: - login-password: - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: +# 数据源配置 +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://localhost:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: 123456 + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: + login-password: + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: multi-statement-allow: true \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/application.yml b/bmw-admin/src/main/resources/application.yml similarity index 95% rename from ruoyi-admin/src/main/resources/application.yml rename to bmw-admin/src/main/resources/application.yml index 288e8fdf4..5decc25f4 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/bmw-admin/src/main/resources/application.yml @@ -1,130 +1,130 @@ -# 项目相关配置 -ruoyi: - # 名称 - name: RuoYi - # 版本 - version: 3.4.0 - # 版权年份 - copyrightYear: 2019 - # 实例演示开关 - demoEnabled: true - # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: D:/ruoyi/uploadPath - # 获取ip地址开关 - addressEnabled: true - -# 开发环境配置 -server: - # 服务器的HTTP端口,默认为80 - port: 80 - servlet: - # 应用的访问路径 - context-path: / - tomcat: - # tomcat的URI编码 - uri-encoding: UTF-8 - # tomcat最大线程数,默认为200 - max-threads: 800 - # Tomcat启动初始化的线程数,默认值25 - min-spare-threads: 30 - -# 日志配置 -logging: - level: - com.ruoyi: debug - org.springframework: warn - -# 用户配置 -user: - password: - # 密码错误{maxRetryCount}次锁定10分钟 - maxRetryCount: 5 - -# Spring配置 -spring: - # 模板引擎 - thymeleaf: - mode: HTML - encoding: utf-8 - # 禁用缓存 - cache: false - # 资源信息 - messages: - # 国际化资源文件路径 - basename: static/i18n/messages - jackson: - time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss - profiles: - active: druid - # 文件上传 - servlet: - multipart: - # 单个文件大小 - max-file-size: 10MB - # 设置总上传的文件大小 - max-request-size: 20MB - # 服务模块 - devtools: - restart: - # 热部署开关 - enabled: true - -# MyBatis -mybatis: - # 搜索指定包别名 - typeAliasesPackage: com.ruoyi - # 配置mapper的扫描,找到所有的mapper.xml映射文件 - mapperLocations: classpath*:mapper/**/*Mapper.xml - # 加载全局的配置文件 - configLocation: classpath:mybatis/mybatis-config.xml - -# PageHelper分页插件 -pagehelper: - helperDialect: mysql - reasonable: true - supportMethodsArguments: true - params: count=countSql - -# Shiro -shiro: - user: - # 登录地址 - loginUrl: /login - # 权限认证失败地址 - unauthorizedUrl: /unauth - # 首页地址 - indexUrl: /index - # 验证码开关 - captchaEnabled: true - # 验证码类型 math 数组计算 char 字符 - captchaType: math - cookie: - # 设置Cookie的域名 默认空,即当前访问的域名 - domain: - # 设置cookie的有效访问路径 - path: / - # 设置HttpOnly属性 - httpOnly: true - # 设置Cookie的过期时间,天为单位 - maxAge: 30 - session: - # Session超时时间(默认30分钟) - expireTime: 30 - # 同步session到数据库的周期(默认1分钟) - dbSyncPeriod: 1 - # 相隔多久检查一次session的有效性,默认就是10分钟 - validationInterval: 10 - # 同一个用户最大会话数,比如2的意思是同一个账号允许最多同时两个人登录(默认-1不限制) - maxSession: -1 - # 踢出之前登录的/之后登录的用户,默认踢出之前登录的用户 - kickoutAfter: false - -# 防止XSS攻击 -xss: - # 过滤开关 - enabled: true - # 排除链接(多个用逗号分隔) - excludes: /system/notice/* - # 匹配链接 - urlPatterns: /system/*,/monitor/*,/tool/* +# 项目相关配置 +ruoyi: + # 名称 + name: RuoYi + # 版本 + version: 3.4.0 + # 版权年份 + copyrightYear: 2019 + # 实例演示开关 + demoEnabled: true + # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) + profile: D:/ruoyi/uploadPath + # 获取ip地址开关 + addressEnabled: true + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为80 + port: 80 + servlet: + # 应用的访问路径 + context-path: /bmw + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # tomcat最大线程数,默认为200 + max-threads: 800 + # Tomcat启动初始化的线程数,默认值25 + min-spare-threads: 30 + +# 日志配置 +logging: + level: + com.ruoyi: debug + org.springframework: warn + +# 用户配置 +user: + password: + # 密码错误{maxRetryCount}次锁定10分钟 + maxRetryCount: 5 + +# Spring配置 +spring: + # 模板引擎 + thymeleaf: + mode: HTML + encoding: utf-8 + # 禁用缓存 + cache: false + # 资源信息 + messages: + # 国际化资源文件路径 + basename: static/i18n/messages + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + profiles: + active: druid + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 + devtools: + restart: + # 热部署开关 + enabled: true + +# MyBatis +mybatis: + # 搜索指定包别名 + typeAliasesPackage: com.ruoyi + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/**/*Mapper.xml + # 加载全局的配置文件 + configLocation: classpath:mybatis/mybatis-config.xml + +# PageHelper分页插件 +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql + +# Shiro +shiro: + user: + # 登录地址 + loginUrl: /login + # 权限认证失败地址 + unauthorizedUrl: /unauth + # 首页地址 + indexUrl: /index + # 验证码开关 + captchaEnabled: true + # 验证码类型 math 数组计算 char 字符 + captchaType: math + cookie: + # 设置Cookie的域名 默认空,即当前访问的域名 + domain: + # 设置cookie的有效访问路径 + path: / + # 设置HttpOnly属性 + httpOnly: true + # 设置Cookie的过期时间,天为单位 + maxAge: 30 + session: + # Session超时时间(默认30分钟) + expireTime: 30 + # 同步session到数据库的周期(默认1分钟) + dbSyncPeriod: 1 + # 相隔多久检查一次session的有效性,默认就是10分钟 + validationInterval: 10 + # 同一个用户最大会话数,比如2的意思是同一个账号允许最多同时两个人登录(默认-1不限制) + maxSession: -1 + # 踢出之前登录的/之后登录的用户,默认踢出之前登录的用户 + kickoutAfter: false + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: true + # 排除链接(多个用逗号分隔) + excludes: /system/notice/* + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* diff --git a/ruoyi-admin/src/main/resources/banner.txt b/bmw-admin/src/main/resources/banner.txt similarity index 98% rename from ruoyi-admin/src/main/resources/banner.txt rename to bmw-admin/src/main/resources/banner.txt index 94662592f..0931cb844 100644 --- a/ruoyi-admin/src/main/resources/banner.txt +++ b/bmw-admin/src/main/resources/banner.txt @@ -1,24 +1,24 @@ -Application Version: ${ruoyi.version} -Spring Boot Version: ${spring-boot.version} -//////////////////////////////////////////////////////////////////// -// _ooOoo_ // -// o8888888o // -// 88" . "88 // -// (| ^_^ |) // -// O\ = /O // -// ____/`---'\____ // -// .' \\| |// `. // -// / \\||| : |||// \ // -// / _||||| -:- |||||- \ // -// | | \\\ - /// | | // -// | \_| ''\---/'' | | // -// \ .-\__ `-` ___/-. / // -// ___`. .' /--.--\ `. . ___ // -// ."" '< `.___\_<|>_/___.' >'"". // -// | | : `- \`.;`\ _ /`;.`/ - ` : | | // -// \ \ `-. \_ __\ /__ _/ .-` / / // -// ========`-.____`-.___\_____/___.-`____.-'======== // -// `=---=' // -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // -// 佛祖保佑 永不宕机 永无BUG // +Application Version: ${ruoyi.version} +Spring Boot Version: ${spring-boot.version} +//////////////////////////////////////////////////////////////////// +// _ooOoo_ // +// o8888888o // +// 88" . "88 // +// (| ^_^ |) // +// O\ = /O // +// ____/`---'\____ // +// .' \\| |// `. // +// / \\||| : |||// \ // +// / _||||| -:- |||||- \ // +// | | \\\ - /// | | // +// | \_| ''\---/'' | | // +// \ .-\__ `-` ___/-. / // +// ___`. .' /--.--\ `. . ___ // +// ."" '< `.___\_<|>_/___.' >'"". // +// | | : `- \`.;`\ _ /`;.`/ - ` : | | // +// \ \ `-. \_ __\ /__ _/ .-` / / // +// ========`-.____`-.___\_____/___.-`____.-'======== // +// `=---=' // +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// 佛祖保佑 永不宕机 永无BUG // //////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/ehcache/ehcache-shiro.xml b/bmw-admin/src/main/resources/ehcache/ehcache-shiro.xml similarity index 96% rename from ruoyi-admin/src/main/resources/ehcache/ehcache-shiro.xml rename to bmw-admin/src/main/resources/ehcache/ehcache-shiro.xml index 66c01c30b..d40baf240 100644 --- a/ruoyi-admin/src/main/resources/ehcache/ehcache-shiro.xml +++ b/bmw-admin/src/main/resources/ehcache/ehcache-shiro.xml @@ -1,38 +1,38 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/logback.xml b/bmw-admin/src/main/resources/logback.xml similarity index 97% rename from ruoyi-admin/src/main/resources/logback.xml rename to bmw-admin/src/main/resources/logback.xml index d69a57207..a360583fa 100644 --- a/ruoyi-admin/src/main/resources/logback.xml +++ b/bmw-admin/src/main/resources/logback.xml @@ -1,93 +1,93 @@ - - - - - - - - - - - ${log.pattern} - - - - - - ${log.path}/sys-info.log - - - - ${log.path}/sys-info.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - INFO - - ACCEPT - - DENY - - - - - ${log.path}/sys-error.log - - - - ${log.path}/sys-error.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - ERROR - - ACCEPT - - DENY - - - - - - ${log.path}/sys-user.log - - - ${log.path}/sys-user.%d{yyyy-MM-dd}.log - - 60 - - - ${log.pattern} - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/sys-info.log + + + + ${log.path}/sys-info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/sys-error.log + + + + ${log.path}/sys-error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + ${log.path}/sys-user.log + + + ${log.path}/sys-user.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml b/bmw-admin/src/main/resources/mybatis/mybatis-config.xml similarity index 100% rename from ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml rename to bmw-admin/src/main/resources/mybatis/mybatis-config.xml diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/beautifyhtml/beautifyhtml.js b/bmw-admin/src/main/resources/static/ajax/libs/beautifyhtml/beautifyhtml.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/beautifyhtml/beautifyhtml.js rename to bmw-admin/src/main/resources/static/ajax/libs/beautifyhtml/beautifyhtml.js index 4f7dd9273..ea69dece1 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/beautifyhtml/beautifyhtml.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/beautifyhtml/beautifyhtml.js @@ -1,617 +1,617 @@ -/*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */ -/* - - The MIT License (MIT) - - Copyright (c) 2007-2013 Einar Lielmanis and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - - - Style HTML ---------------- - - Written by Nochum Sossonko, (nsossonko@hotmail.com) - - Based on code initially developed by: Einar Lielmanis, - http://jsbeautifier.org/ - - Usage: - style_html(html_source); - - style_html(html_source, options); - - The options are: - indent_size (default 4) — indentation size, - indent_char (default space) — character to indent with, - max_char (default 250) - maximum amount of characters per line (0 = disable) - brace_style (default "collapse") - "collapse" | "expand" | "end-expand" - put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line. - unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted - indent_scripts (default normal) - "keep"|"separate"|"normal" - - e.g. - - style_html(html_source, { - 'indent_size': 2, - 'indent_char': ' ', - 'max_char': 78, - 'brace_style': 'expand', - 'unformatted': ['a', 'sub', 'sup', 'b', 'i', 'u'] - }); -*/ - -(function() { - - function style_html(html_source, options, js_beautify, css_beautify) { - //Wrapper function to invoke all the necessary constructors and deal with the output. - - var multi_parser, - indent_size, - indent_character, - max_char, - brace_style, - unformatted; - - options = options || {}; - indent_size = options.indent_size || 4; - indent_character = options.indent_char || ' '; - brace_style = options.brace_style || 'collapse'; - max_char = options.max_char === 0 ? Infinity : options.max_char || 250; - unformatted = options.unformatted || ['a', 'span', 'bdo', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'q', 'sub', 'sup', 'tt', 'i', 'b', 'big', 'small', 'u', 's', 'strike', 'font', 'ins', 'del', 'pre', 'address', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']; - - function Parser() { - - this.pos = 0; //Parser position - this.token = ''; - this.current_mode = 'CONTENT'; //reflects the current Parser mode: TAG/CONTENT - this.tags = { //An object to hold tags, their position, and their parent-tags, initiated with default values - parent: 'parent1', - parentcount: 1, - parent1: '' - }; - this.tag_type = ''; - this.token_text = this.last_token = this.last_text = this.token_type = ''; - - this.Utils = { //Uilities made available to the various functions - whitespace: "\n\r\t ".split(''), - single_token: 'br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed,?php,?,?='.split(','), //all the single tags for HTML - extra_liners: 'head,body,/html'.split(','), //for tags that need a line of whitespace before them - in_array: function (what, arr) { - for (var i=0; i= this.input.length) { - return content.length?content.join(''):['', 'TK_EOF']; - } - - input_char = this.input.charAt(this.pos); - this.pos++; - this.line_char_count++; - - if (this.Utils.in_array(input_char, this.Utils.whitespace)) { - if (content.length) { - space = true; - } - this.line_char_count--; - continue; //don't want to insert unnecessary space - } - else if (space) { - if (this.line_char_count >= this.max_char) { //insert a line when the max_char is reached - content.push('\n'); - for (var i=0; i', 'igm'); - reg_match.lastIndex = this.pos; - var reg_array = reg_match.exec(this.input); - var end_script = reg_array?reg_array.index:this.input.length; //absolute end of script - if(this.pos < end_script) { //get everything in between the script tags - content = this.input.substring(this.pos, end_script); - this.pos = end_script; - } - return content; - }; - - this.record_tag = function (tag){ //function to record a tag and its parent in this.tags Object - if (this.tags[tag + 'count']) { //check for the existence of this tag type - this.tags[tag + 'count']++; - this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level - } - else { //otherwise initialize this tag type - this.tags[tag + 'count'] = 1; - this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level - } - this.tags[tag + this.tags[tag + 'count'] + 'parent'] = this.tags.parent; //set the parent (i.e. in the case of a div this.tags.div1parent) - this.tags.parent = tag + this.tags[tag + 'count']; //and make this the current parent (i.e. in the case of a div 'div1') - }; - - this.retrieve_tag = function (tag) { //function to retrieve the opening tag to the corresponding closer - if (this.tags[tag + 'count']) { //if the openener is not in the Object we ignore it - var temp_parent = this.tags.parent; //check to see if it's a closable tag. - while (temp_parent) { //till we reach '' (the initial value); - if (tag + this.tags[tag + 'count'] === temp_parent) { //if this is it use it - break; - } - temp_parent = this.tags[temp_parent + 'parent']; //otherwise keep on climbing up the DOM Tree - } - if (temp_parent) { //if we caught something - this.indent_level = this.tags[tag + this.tags[tag + 'count']]; //set the indent_level accordingly - this.tags.parent = this.tags[temp_parent + 'parent']; //and set the current parent - } - delete this.tags[tag + this.tags[tag + 'count'] + 'parent']; //delete the closed tags parent reference... - delete this.tags[tag + this.tags[tag + 'count']]; //...and the tag itself - if (this.tags[tag + 'count'] === 1) { - delete this.tags[tag + 'count']; - } - else { - this.tags[tag + 'count']--; - } - } - }; - - this.get_tag = function (peek) { //function to get a full tag and parse its type - var input_char = '', - content = [], - comment = '', - space = false, - tag_start, tag_end, - orig_pos = this.pos, - orig_line_char_count = this.line_char_count; - - peek = peek !== undefined ? peek : false; - - do { - if (this.pos >= this.input.length) { - if (peek) { - this.pos = orig_pos; - this.line_char_count = orig_line_char_count; - } - return content.length?content.join(''):['', 'TK_EOF']; - } - - input_char = this.input.charAt(this.pos); - this.pos++; - this.line_char_count++; - - if (this.Utils.in_array(input_char, this.Utils.whitespace)) { //don't want to insert unnecessary space - space = true; - this.line_char_count--; - continue; - } - - if (input_char === "'" || input_char === '"') { - if (!content[1] || content[1] !== '!') { //if we're in a comment strings don't get treated specially - input_char += this.get_unformatted(input_char); - space = true; - } - } - - if (input_char === '=') { //no space before = - space = false; - } - - if (content.length && content[content.length-1] !== '=' && input_char !== '>' && space) { - //no space after = or before > - if (this.line_char_count >= this.max_char) { - this.print_newline(false, content); - this.line_char_count = 0; - } - else { - content.push(' '); - this.line_char_count++; - } - space = false; - } - if (input_char === '<') { - tag_start = this.pos - 1; - } - content.push(input_char); //inserts character at-a-time (or string) - } while (input_char !== '>'); - - var tag_complete = content.join(''); - var tag_index; - if (tag_complete.indexOf(' ') !== -1) { //if there's whitespace, thats where the tag name ends - tag_index = tag_complete.indexOf(' '); - } - else { //otherwise go with the tag ending - tag_index = tag_complete.indexOf('>'); - } - var tag_check = tag_complete.substring(1, tag_index).toLowerCase(); - if (tag_complete.charAt(tag_complete.length-2) === '/' || - this.Utils.in_array(tag_check, this.Utils.single_token)) { //if this tag name is a single tag type (either in the list or has a closing /) - if ( ! peek) { - this.tag_type = 'SINGLE'; - } - } - else if (tag_check === 'script') { //for later script handling - if ( ! peek) { - this.record_tag(tag_check); - this.tag_type = 'SCRIPT'; - } - } - else if (tag_check === 'style') { //for future style handling (for now it justs uses get_content) - if ( ! peek) { - this.record_tag(tag_check); - this.tag_type = 'STYLE'; - } - } - else if (this.is_unformatted(tag_check, unformatted)) { // do not reformat the "unformatted" tags - comment = this.get_unformatted('', tag_complete); //...delegate to get_unformatted function - content.push(comment); - // Preserve collapsed whitespace either before or after this tag. - if (tag_start > 0 && this.Utils.in_array(this.input.charAt(tag_start - 1), this.Utils.whitespace)){ - content.splice(0, 0, this.input.charAt(tag_start - 1)); - } - tag_end = this.pos - 1; - if (this.Utils.in_array(this.input.charAt(tag_end + 1), this.Utils.whitespace)){ - content.push(this.input.charAt(tag_end + 1)); - } - this.tag_type = 'SINGLE'; - } - else if (tag_check.charAt(0) === '!') { //peek for so... - comment = this.get_unformatted('-->', tag_complete); //...delegate to get_unformatted - content.push(comment); - } - if ( ! peek) { - this.tag_type = 'START'; - } - } - else if (tag_check.indexOf('[endif') !== -1) {//peek for ', tag_complete); - content.push(comment); - this.tag_type = 'SINGLE'; - } - } - else if ( ! peek) { - if (tag_check.charAt(0) === '/') { //this tag is a double tag so check for tag-ending - this.retrieve_tag(tag_check.substring(1)); //remove it and all ancestors - this.tag_type = 'END'; - } - else { //otherwise it's a start-tag - this.record_tag(tag_check); //push it on the tag stack - this.tag_type = 'START'; - } - if (this.Utils.in_array(tag_check, this.Utils.extra_liners)) { //check if this double needs an extra line - this.print_newline(true, this.output); - } - } - - if (peek) { - this.pos = orig_pos; - this.line_char_count = orig_line_char_count; - } - - return content.join(''); //returns fully formatted tag - }; - - this.get_unformatted = function (delimiter, orig_tag) { //function to return unformatted content in its entirety - - if (orig_tag && orig_tag.toLowerCase().indexOf(delimiter) !== -1) { - return ''; - } - var input_char = ''; - var content = ''; - var space = true; - do { - - if (this.pos >= this.input.length) { - return content; - } - - input_char = this.input.charAt(this.pos); - this.pos++; - - if (this.Utils.in_array(input_char, this.Utils.whitespace)) { - if (!space) { - this.line_char_count--; - continue; - } - if (input_char === '\n' || input_char === '\r') { - content += '\n'; - /* Don't change tab indention for unformatted blocks. If using code for html editing, this will greatly affect
 tags if they are specified in the 'unformatted array'
-                for (var i=0; i]*>\s*$/);
-
-            // if next_tag comes back but is not an isolated tag, then
-            // let's treat the 'a' tag as having content
-            // and respect the unformatted option
-            if (!tag || this.Utils.in_array(tag, unformatted)){
-                return true;
-            } else {
-                return false;
-            }
-        };
-
-        this.printer = function (js_source, indent_character, indent_size, max_char, brace_style) { //handles input/output and some other printing functions
-
-          this.input = js_source || ''; //gets the input for the Parser
-          this.output = [];
-          this.indent_character = indent_character;
-          this.indent_string = '';
-          this.indent_size = indent_size;
-          this.brace_style = brace_style;
-          this.indent_level = 0;
-          this.max_char = max_char;
-          this.line_char_count = 0; //count to see if max_char was exceeded
-
-          for (var i=0; i 0) {
-              this.indent_level--;
-            }
-          };
-        };
-        return this;
-      }
-
-      /*_____________________--------------------_____________________*/
-
-      multi_parser = new Parser(); //wrapping functions Parser
-      multi_parser.printer(html_source, indent_character, indent_size, max_char, brace_style); //initialize starting values
-
-      while (true) {
-          var t = multi_parser.get_token();
-          multi_parser.token_text = t[0];
-          multi_parser.token_type = t[1];
-
-        if (multi_parser.token_type === 'TK_EOF') {
-          break;
-        }
-
-        switch (multi_parser.token_type) {
-          case 'TK_TAG_START':
-            multi_parser.print_newline(false, multi_parser.output);
-            multi_parser.print_token(multi_parser.token_text);
-            multi_parser.indent();
-            multi_parser.current_mode = 'CONTENT';
-            break;
-          case 'TK_TAG_STYLE':
-          case 'TK_TAG_SCRIPT':
-            multi_parser.print_newline(false, multi_parser.output);
-            multi_parser.print_token(multi_parser.token_text);
-            multi_parser.current_mode = 'CONTENT';
-            break;
-          case 'TK_TAG_END':
-            //Print new line only if the tag has no content and has child
-            if (multi_parser.last_token === 'TK_CONTENT' && multi_parser.last_text === '') {
-                var tag_name = multi_parser.token_text.match(/\w+/)[0];
-                var tag_extracted_from_last_output = multi_parser.output[multi_parser.output.length -1].match(/<\s*(\w+)/);
-                if (tag_extracted_from_last_output === null || tag_extracted_from_last_output[1] !== tag_name) {
-                    multi_parser.print_newline(true, multi_parser.output);
-                }
-            }
-            multi_parser.print_token(multi_parser.token_text);
-            multi_parser.current_mode = 'CONTENT';
-            break;
-          case 'TK_TAG_SINGLE':
-            // Don't add a newline before elements that should remain unformatted.
-            var tag_check = multi_parser.token_text.match(/^\s*<([a-z]+)/i);
-            if (!tag_check || !multi_parser.Utils.in_array(tag_check[1], unformatted)){
-                multi_parser.print_newline(false, multi_parser.output);
-            }
-            multi_parser.print_token(multi_parser.token_text);
-            multi_parser.current_mode = 'CONTENT';
-            break;
-          case 'TK_CONTENT':
-            if (multi_parser.token_text !== '') {
-              multi_parser.print_token(multi_parser.token_text);
-            }
-            multi_parser.current_mode = 'TAG';
-            break;
-          case 'TK_STYLE':
-          case 'TK_SCRIPT':
-            if (multi_parser.token_text !== '') {
-              multi_parser.output.push('\n');
-              var text = multi_parser.token_text,
-                  _beautifier,
-                  script_indent_level = 1;
-              if (multi_parser.token_type === 'TK_SCRIPT') {
-                _beautifier = typeof js_beautify === 'function' && js_beautify;
-              } else if (multi_parser.token_type === 'TK_STYLE') {
-                _beautifier = typeof css_beautify === 'function' && css_beautify;
-              }
-
-              if (options.indent_scripts === "keep") {
-                script_indent_level = 0;
-              } else if (options.indent_scripts === "separate") {
-                script_indent_level = -multi_parser.indent_level;
-              }
-
-              var indentation = multi_parser.get_full_indent(script_indent_level);
-              if (_beautifier) {
-                // call the Beautifier if avaliable
-                text = _beautifier(text.replace(/^\s*/, indentation), options);
-              } else {
-                // simply indent the string otherwise
-                var white = text.match(/^\s*/)[0];
-                var _level = white.match(/[^\n\r]*$/)[0].split(multi_parser.indent_string).length - 1;
-                var reindent = multi_parser.get_full_indent(script_indent_level -_level);
-                text = text.replace(/^\s*/, indentation)
-                       .replace(/\r\n|\r|\n/g, '\n' + reindent)
-                       .replace(/\s*$/, '');
-              }
-              if (text) {
-                multi_parser.print_token(text);
-                multi_parser.print_newline(true, multi_parser.output);
-              }
-            }
-            multi_parser.current_mode = 'TAG';
-            break;
-        }
-        multi_parser.last_token = multi_parser.token_type;
-        multi_parser.last_text = multi_parser.token_text;
-      }
-      return multi_parser.output.join('');
-    }
-
-    // If we're running a web page and don't have either of the above, add our one global
-    window.html_beautify = function(html_source, options) {
-        return style_html(html_source, options, window.js_beautify, window.css_beautify);
-    };
-
-}());
+/*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
+/*
+
+  The MIT License (MIT)
+
+  Copyright (c) 2007-2013 Einar Lielmanis and contributors.
+
+  Permission is hereby granted, free of charge, to any person
+  obtaining a copy of this software and associated documentation files
+  (the "Software"), to deal in the Software without restriction,
+  including without limitation the rights to use, copy, modify, merge,
+  publish, distribute, sublicense, and/or sell copies of the Software,
+  and to permit persons to whom the Software is furnished to do so,
+  subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be
+  included in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+
+
+ Style HTML
+---------------
+
+  Written by Nochum Sossonko, (nsossonko@hotmail.com)
+
+  Based on code initially developed by: Einar Lielmanis, 
+    http://jsbeautifier.org/
+
+  Usage:
+    style_html(html_source);
+
+    style_html(html_source, options);
+
+  The options are:
+    indent_size (default 4)          — indentation size,
+    indent_char (default space)      — character to indent with,
+    max_char (default 250)            -  maximum amount of characters per line (0 = disable)
+    brace_style (default "collapse") - "collapse" | "expand" | "end-expand"
+            put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.
+    unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
+    indent_scripts (default normal)  - "keep"|"separate"|"normal"
+
+    e.g.
+
+    style_html(html_source, {
+      'indent_size': 2,
+      'indent_char': ' ',
+      'max_char': 78,
+      'brace_style': 'expand',
+      'unformatted': ['a', 'sub', 'sup', 'b', 'i', 'u']
+    });
+*/
+
+(function() {
+
+    function style_html(html_source, options, js_beautify, css_beautify) {
+    //Wrapper function to invoke all the necessary constructors and deal with the output.
+
+      var multi_parser,
+          indent_size,
+          indent_character,
+          max_char,
+          brace_style,
+          unformatted;
+
+      options = options || {};
+      indent_size = options.indent_size || 4;
+      indent_character = options.indent_char || ' ';
+      brace_style = options.brace_style || 'collapse';
+      max_char = options.max_char === 0 ? Infinity : options.max_char || 250;
+      unformatted = options.unformatted || ['a', 'span', 'bdo', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'q', 'sub', 'sup', 'tt', 'i', 'b', 'big', 'small', 'u', 's', 'strike', 'font', 'ins', 'del', 'pre', 'address', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
+
+      function Parser() {
+
+        this.pos = 0; //Parser position
+        this.token = '';
+        this.current_mode = 'CONTENT'; //reflects the current Parser mode: TAG/CONTENT
+        this.tags = { //An object to hold tags, their position, and their parent-tags, initiated with default values
+          parent: 'parent1',
+          parentcount: 1,
+          parent1: ''
+        };
+        this.tag_type = '';
+        this.token_text = this.last_token = this.last_text = this.token_type = '';
+
+        this.Utils = { //Uilities made available to the various functions
+          whitespace: "\n\r\t ".split(''),
+          single_token: 'br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed,?php,?,?='.split(','), //all the single tags for HTML
+          extra_liners: 'head,body,/html'.split(','), //for tags that need a line of whitespace before them
+          in_array: function (what, arr) {
+            for (var i=0; i= this.input.length) {
+              return content.length?content.join(''):['', 'TK_EOF'];
+            }
+
+            input_char = this.input.charAt(this.pos);
+            this.pos++;
+            this.line_char_count++;
+
+            if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
+              if (content.length) {
+                space = true;
+              }
+              this.line_char_count--;
+              continue; //don't want to insert unnecessary space
+            }
+            else if (space) {
+              if (this.line_char_count >= this.max_char) { //insert a line when the max_char is reached
+                content.push('\n');
+                for (var i=0; i', 'igm');
+          reg_match.lastIndex = this.pos;
+          var reg_array = reg_match.exec(this.input);
+          var end_script = reg_array?reg_array.index:this.input.length; //absolute end of script
+          if(this.pos < end_script) { //get everything in between the script tags
+            content = this.input.substring(this.pos, end_script);
+            this.pos = end_script;
+          }
+          return content;
+        };
+
+        this.record_tag = function (tag){ //function to record a tag and its parent in this.tags Object
+          if (this.tags[tag + 'count']) { //check for the existence of this tag type
+            this.tags[tag + 'count']++;
+            this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
+          }
+          else { //otherwise initialize this tag type
+            this.tags[tag + 'count'] = 1;
+            this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
+          }
+          this.tags[tag + this.tags[tag + 'count'] + 'parent'] = this.tags.parent; //set the parent (i.e. in the case of a div this.tags.div1parent)
+          this.tags.parent = tag + this.tags[tag + 'count']; //and make this the current parent (i.e. in the case of a div 'div1')
+        };
+
+        this.retrieve_tag = function (tag) { //function to retrieve the opening tag to the corresponding closer
+          if (this.tags[tag + 'count']) { //if the openener is not in the Object we ignore it
+            var temp_parent = this.tags.parent; //check to see if it's a closable tag.
+            while (temp_parent) { //till we reach '' (the initial value);
+              if (tag + this.tags[tag + 'count'] === temp_parent) { //if this is it use it
+                break;
+              }
+              temp_parent = this.tags[temp_parent + 'parent']; //otherwise keep on climbing up the DOM Tree
+            }
+            if (temp_parent) { //if we caught something
+              this.indent_level = this.tags[tag + this.tags[tag + 'count']]; //set the indent_level accordingly
+              this.tags.parent = this.tags[temp_parent + 'parent']; //and set the current parent
+            }
+            delete this.tags[tag + this.tags[tag + 'count'] + 'parent']; //delete the closed tags parent reference...
+            delete this.tags[tag + this.tags[tag + 'count']]; //...and the tag itself
+            if (this.tags[tag + 'count'] === 1) {
+              delete this.tags[tag + 'count'];
+            }
+            else {
+              this.tags[tag + 'count']--;
+            }
+          }
+        };
+
+        this.get_tag = function (peek) { //function to get a full tag and parse its type
+          var input_char = '',
+              content = [],
+              comment = '',
+              space = false,
+              tag_start, tag_end,
+              orig_pos = this.pos,
+              orig_line_char_count = this.line_char_count;
+
+          peek = peek !== undefined ? peek : false;
+
+          do {
+            if (this.pos >= this.input.length) {
+              if (peek) {
+                this.pos = orig_pos;
+                this.line_char_count = orig_line_char_count;
+              }
+              return content.length?content.join(''):['', 'TK_EOF'];
+            }
+
+            input_char = this.input.charAt(this.pos);
+            this.pos++;
+            this.line_char_count++;
+
+            if (this.Utils.in_array(input_char, this.Utils.whitespace)) { //don't want to insert unnecessary space
+              space = true;
+              this.line_char_count--;
+              continue;
+            }
+
+            if (input_char === "'" || input_char === '"') {
+              if (!content[1] || content[1] !== '!') { //if we're in a comment strings don't get treated specially
+                input_char += this.get_unformatted(input_char);
+                space = true;
+              }
+            }
+
+            if (input_char === '=') { //no space before =
+              space = false;
+            }
+
+            if (content.length && content[content.length-1] !== '=' && input_char !== '>' && space) {
+                //no space after = or before >
+              if (this.line_char_count >= this.max_char) {
+                this.print_newline(false, content);
+                this.line_char_count = 0;
+              }
+              else {
+                content.push(' ');
+                this.line_char_count++;
+              }
+              space = false;
+            }
+            if (input_char === '<') {
+              tag_start = this.pos - 1;
+            }
+            content.push(input_char); //inserts character at-a-time (or string)
+          } while (input_char !== '>');
+
+          var tag_complete = content.join('');
+          var tag_index;
+          if (tag_complete.indexOf(' ') !== -1) { //if there's whitespace, thats where the tag name ends
+            tag_index = tag_complete.indexOf(' ');
+          }
+          else { //otherwise go with the tag ending
+            tag_index = tag_complete.indexOf('>');
+          }
+          var tag_check = tag_complete.substring(1, tag_index).toLowerCase();
+          if (tag_complete.charAt(tag_complete.length-2) === '/' ||
+            this.Utils.in_array(tag_check, this.Utils.single_token)) { //if this tag name is a single tag type (either in the list or has a closing /)
+            if ( ! peek) {
+              this.tag_type = 'SINGLE';
+            }
+          }
+          else if (tag_check === 'script') { //for later script handling
+            if ( ! peek) {
+              this.record_tag(tag_check);
+              this.tag_type = 'SCRIPT';
+            }
+          }
+          else if (tag_check === 'style') { //for future style handling (for now it justs uses get_content)
+            if ( ! peek) {
+              this.record_tag(tag_check);
+              this.tag_type = 'STYLE';
+            }
+          }
+          else if (this.is_unformatted(tag_check, unformatted)) { // do not reformat the "unformatted" tags
+            comment = this.get_unformatted('', tag_complete); //...delegate to get_unformatted function
+            content.push(comment);
+            // Preserve collapsed whitespace either before or after this tag.
+            if (tag_start > 0 && this.Utils.in_array(this.input.charAt(tag_start - 1), this.Utils.whitespace)){
+                content.splice(0, 0, this.input.charAt(tag_start - 1));
+            }
+            tag_end = this.pos - 1;
+            if (this.Utils.in_array(this.input.charAt(tag_end + 1), this.Utils.whitespace)){
+                content.push(this.input.charAt(tag_end + 1));
+            }
+            this.tag_type = 'SINGLE';
+          }
+          else if (tag_check.charAt(0) === '!') { //peek for  so...
+                comment = this.get_unformatted('-->', tag_complete); //...delegate to get_unformatted
+                content.push(comment);
+              }
+              if ( ! peek) {
+                this.tag_type = 'START';
+              }
+            }
+            else if (tag_check.indexOf('[endif') !== -1) {//peek for ', tag_complete);
+              content.push(comment);
+              this.tag_type = 'SINGLE';
+            }
+          }
+          else if ( ! peek) {
+            if (tag_check.charAt(0) === '/') { //this tag is a double tag so check for tag-ending
+              this.retrieve_tag(tag_check.substring(1)); //remove it and all ancestors
+              this.tag_type = 'END';
+            }
+            else { //otherwise it's a start-tag
+              this.record_tag(tag_check); //push it on the tag stack
+              this.tag_type = 'START';
+            }
+            if (this.Utils.in_array(tag_check, this.Utils.extra_liners)) { //check if this double needs an extra line
+              this.print_newline(true, this.output);
+            }
+          }
+
+          if (peek) {
+            this.pos = orig_pos;
+            this.line_char_count = orig_line_char_count;
+          }
+
+          return content.join(''); //returns fully formatted tag
+        };
+
+        this.get_unformatted = function (delimiter, orig_tag) { //function to return unformatted content in its entirety
+
+          if (orig_tag && orig_tag.toLowerCase().indexOf(delimiter) !== -1) {
+            return '';
+          }
+          var input_char = '';
+          var content = '';
+          var space = true;
+          do {
+
+            if (this.pos >= this.input.length) {
+              return content;
+            }
+
+            input_char = this.input.charAt(this.pos);
+            this.pos++;
+
+            if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
+              if (!space) {
+                this.line_char_count--;
+                continue;
+              }
+              if (input_char === '\n' || input_char === '\r') {
+                content += '\n';
+                /*  Don't change tab indention for unformatted blocks.  If using code for html editing, this will greatly affect 
 tags if they are specified in the 'unformatted array'
+                for (var i=0; i]*>\s*$/);
+
+            // if next_tag comes back but is not an isolated tag, then
+            // let's treat the 'a' tag as having content
+            // and respect the unformatted option
+            if (!tag || this.Utils.in_array(tag, unformatted)){
+                return true;
+            } else {
+                return false;
+            }
+        };
+
+        this.printer = function (js_source, indent_character, indent_size, max_char, brace_style) { //handles input/output and some other printing functions
+
+          this.input = js_source || ''; //gets the input for the Parser
+          this.output = [];
+          this.indent_character = indent_character;
+          this.indent_string = '';
+          this.indent_size = indent_size;
+          this.brace_style = brace_style;
+          this.indent_level = 0;
+          this.max_char = max_char;
+          this.line_char_count = 0; //count to see if max_char was exceeded
+
+          for (var i=0; i 0) {
+              this.indent_level--;
+            }
+          };
+        };
+        return this;
+      }
+
+      /*_____________________--------------------_____________________*/
+
+      multi_parser = new Parser(); //wrapping functions Parser
+      multi_parser.printer(html_source, indent_character, indent_size, max_char, brace_style); //initialize starting values
+
+      while (true) {
+          var t = multi_parser.get_token();
+          multi_parser.token_text = t[0];
+          multi_parser.token_type = t[1];
+
+        if (multi_parser.token_type === 'TK_EOF') {
+          break;
+        }
+
+        switch (multi_parser.token_type) {
+          case 'TK_TAG_START':
+            multi_parser.print_newline(false, multi_parser.output);
+            multi_parser.print_token(multi_parser.token_text);
+            multi_parser.indent();
+            multi_parser.current_mode = 'CONTENT';
+            break;
+          case 'TK_TAG_STYLE':
+          case 'TK_TAG_SCRIPT':
+            multi_parser.print_newline(false, multi_parser.output);
+            multi_parser.print_token(multi_parser.token_text);
+            multi_parser.current_mode = 'CONTENT';
+            break;
+          case 'TK_TAG_END':
+            //Print new line only if the tag has no content and has child
+            if (multi_parser.last_token === 'TK_CONTENT' && multi_parser.last_text === '') {
+                var tag_name = multi_parser.token_text.match(/\w+/)[0];
+                var tag_extracted_from_last_output = multi_parser.output[multi_parser.output.length -1].match(/<\s*(\w+)/);
+                if (tag_extracted_from_last_output === null || tag_extracted_from_last_output[1] !== tag_name) {
+                    multi_parser.print_newline(true, multi_parser.output);
+                }
+            }
+            multi_parser.print_token(multi_parser.token_text);
+            multi_parser.current_mode = 'CONTENT';
+            break;
+          case 'TK_TAG_SINGLE':
+            // Don't add a newline before elements that should remain unformatted.
+            var tag_check = multi_parser.token_text.match(/^\s*<([a-z]+)/i);
+            if (!tag_check || !multi_parser.Utils.in_array(tag_check[1], unformatted)){
+                multi_parser.print_newline(false, multi_parser.output);
+            }
+            multi_parser.print_token(multi_parser.token_text);
+            multi_parser.current_mode = 'CONTENT';
+            break;
+          case 'TK_CONTENT':
+            if (multi_parser.token_text !== '') {
+              multi_parser.print_token(multi_parser.token_text);
+            }
+            multi_parser.current_mode = 'TAG';
+            break;
+          case 'TK_STYLE':
+          case 'TK_SCRIPT':
+            if (multi_parser.token_text !== '') {
+              multi_parser.output.push('\n');
+              var text = multi_parser.token_text,
+                  _beautifier,
+                  script_indent_level = 1;
+              if (multi_parser.token_type === 'TK_SCRIPT') {
+                _beautifier = typeof js_beautify === 'function' && js_beautify;
+              } else if (multi_parser.token_type === 'TK_STYLE') {
+                _beautifier = typeof css_beautify === 'function' && css_beautify;
+              }
+
+              if (options.indent_scripts === "keep") {
+                script_indent_level = 0;
+              } else if (options.indent_scripts === "separate") {
+                script_indent_level = -multi_parser.indent_level;
+              }
+
+              var indentation = multi_parser.get_full_indent(script_indent_level);
+              if (_beautifier) {
+                // call the Beautifier if avaliable
+                text = _beautifier(text.replace(/^\s*/, indentation), options);
+              } else {
+                // simply indent the string otherwise
+                var white = text.match(/^\s*/)[0];
+                var _level = white.match(/[^\n\r]*$/)[0].split(multi_parser.indent_string).length - 1;
+                var reindent = multi_parser.get_full_indent(script_indent_level -_level);
+                text = text.replace(/^\s*/, indentation)
+                       .replace(/\r\n|\r|\n/g, '\n' + reindent)
+                       .replace(/\s*$/, '');
+              }
+              if (text) {
+                multi_parser.print_token(text);
+                multi_parser.print_newline(true, multi_parser.output);
+              }
+            }
+            multi_parser.current_mode = 'TAG';
+            break;
+        }
+        multi_parser.last_token = multi_parser.token_type;
+        multi_parser.last_text = multi_parser.token_text;
+      }
+      return multi_parser.output.join('');
+    }
+
+    // If we're running a web page and don't have either of the above, add our one global
+    window.html_beautify = function(html_source, options) {
+        return style_html(html_source, options, window.js_beautify, window.css_beautify);
+    };
+
+}());
diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/blockUI/jquery.blockUI.js b/bmw-admin/src/main/resources/static/ajax/libs/blockUI/jquery.blockUI.js
similarity index 97%
rename from ruoyi-admin/src/main/resources/static/ajax/libs/blockUI/jquery.blockUI.js
rename to bmw-admin/src/main/resources/static/ajax/libs/blockUI/jquery.blockUI.js
index 8a9d70893..552613d96 100644
--- a/ruoyi-admin/src/main/resources/static/ajax/libs/blockUI/jquery.blockUI.js
+++ b/bmw-admin/src/main/resources/static/ajax/libs/blockUI/jquery.blockUI.js
@@ -1,620 +1,620 @@
-/*!
- * jQuery blockUI plugin
- * Version 2.70.0-2014.11.23
- * Requires jQuery v1.7 or later
- *
- * Examples at: http://malsup.com/jquery/block/
- * Copyright (c) 2007-2013 M. Alsup
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- *
- * Thanks to Amir-Hossein Sobhi for some excellent contributions!
- */
-
-;(function() {
-/*jshint eqeqeq:false curly:false latedef:false */
-"use strict";
-
-	function setup($) {
-		$.fn._fadeIn = $.fn.fadeIn;
-
-		var noOp = $.noop || function() {};
-
-		// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
-		// confusing userAgent strings on Vista)
-		var msie = /MSIE/.test(navigator.userAgent);
-		var ie6  = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent);
-		var mode = document.documentMode || 0;
-		var setExpr = $.isFunction( document.createElement('div').style.setExpression );
-
-		// global $ methods for blocking/unblocking the entire page
-		$.blockUI   = function(opts) { install(window, opts); };
-		$.unblockUI = function(opts) { remove(window, opts); };
-
-		// convenience method for quick growl-like notifications  (http://www.google.com/search?q=growl)
-		$.growlUI = function(title, message, timeout, onClose) {
-			var $m = $('
'); - if (title) $m.append('

'+title+'

'); - if (message) $m.append('

'+message+'

'); - if (timeout === undefined) timeout = 3000; - - // Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications - var callBlock = function(opts) { - opts = opts || {}; - - $.blockUI({ - message: $m, - fadeIn : typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700, - fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000, - timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout, - centerY: false, - showOverlay: false, - onUnblock: onClose, - css: $.blockUI.defaults.growlCSS - }); - }; - - callBlock(); - var nonmousedOpacity = $m.css('opacity'); - $m.mouseover(function() { - callBlock({ - fadeIn: 0, - timeout: 30000 - }); - - var displayBlock = $('.blockMsg'); - displayBlock.stop(); // cancel fadeout if it has started - displayBlock.fadeTo(300, 1); // make it easier to read the message by removing transparency - }).mouseout(function() { - $('.blockMsg').fadeOut(1000); - }); - // End konapun additions - }; - - // plugin method for blocking element content - $.fn.block = function(opts) { - if ( this[0] === window ) { - $.blockUI( opts ); - return this; - } - var fullOpts = $.extend({}, $.blockUI.defaults, opts || {}); - this.each(function() { - var $el = $(this); - if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked')) - return; - $el.unblock({ fadeOut: 0 }); - }); - - return this.each(function() { - if ($.css(this,'position') == 'static') { - this.style.position = 'relative'; - $(this).data('blockUI.static', true); - } - this.style.zoom = 1; // force 'hasLayout' in ie - install(this, opts); - }); - }; - - // plugin method for unblocking element content - $.fn.unblock = function(opts) { - if ( this[0] === window ) { - $.unblockUI( opts ); - return this; - } - return this.each(function() { - remove(this, opts); - }); - }; - - $.blockUI.version = 2.70; // 2nd generation blocking at no extra cost! - - // override these in your code to change the default behavior and style - $.blockUI.defaults = { - // message displayed when blocking (use null for no message) - message: '
加载中......
', - - title: null, // title string; only used when theme == true - draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded) - - theme: false, // set to true to use with jQuery UI themes - - // styles for the message when blocking; if you wish to disable - // these and use an external stylesheet then do this in your code: - // $.blockUI.defaults.css = {}; - css: { - padding: 0, - margin: 0, - width: '30%', - top: '40%', - left: '35%', - textAlign: 'center', - color: '#000', - border: '0px', - backgroundColor:'transparent', - cursor: 'wait' - }, - - // minimal style set used when themes are used - themedCSS: { - width: '30%', - top: '40%', - left: '35%' - }, - - // styles for the overlay - overlayCSS: { - backgroundColor: '#000', - opacity: 0.6, - cursor: 'wait' - }, - - // style to replace wait cursor before unblocking to correct issue - // of lingering wait cursor - cursorReset: 'default', - - // styles applied when using $.growlUI - growlCSS: { - width: '350px', - top: '10px', - left: '', - right: '10px', - border: 'none', - padding: '5px', - opacity: 0.6, - cursor: 'default', - color: '#fff', - backgroundColor: '#000', - '-webkit-border-radius':'10px', - '-moz-border-radius': '10px', - 'border-radius': '10px' - }, - - // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w - // (hat tip to Jorge H. N. de Vasconcelos) - /*jshint scripturl:true */ - iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank', - - // force usage of iframe in non-IE browsers (handy for blocking applets) - forceIframe: false, - - // z-index for the blocking overlay - baseZ: 1000, - - // set these to true to have the message automatically centered - centerX: true, // <-- only effects element blocking (page block controlled via css above) - centerY: true, - - // allow body element to be stetched in ie6; this makes blocking look better - // on "short" pages. disable if you wish to prevent changes to the body height - allowBodyStretch: true, - - // enable if you want key and mouse events to be disabled for content that is blocked - bindEvents: true, - - // be default blockUI will supress tab navigation from leaving blocking content - // (if bindEvents is true) - constrainTabKey: true, - - // fadeIn time in millis; set to 0 to disable fadeIn on block - fadeIn: 200, - - // fadeOut time in millis; set to 0 to disable fadeOut on unblock - fadeOut: 400, - - // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock - timeout: 0, - - // disable if you don't want to show the overlay - showOverlay: true, - - // if true, focus will be placed in the first available input field when - // page blocking - focusInput: true, - - // elements that can receive focus - focusableElements: ':input:enabled:visible', - - // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) - // no longer needed in 2012 - // applyPlatformOpacityRules: true, - - // callback method invoked when fadeIn has completed and blocking message is visible - onBlock: null, - - // callback method invoked when unblocking has completed; the callback is - // passed the element that has been unblocked (which is the window object for page - // blocks) and the options that were passed to the unblock call: - // onUnblock(element, options) - onUnblock: null, - - // callback method invoked when the overlay area is clicked. - // setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used. - onOverlayClick: null, - - // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493 - quirksmodeOffsetHack: 4, - - // class name of the message block - blockMsgClass: 'blockMsg', - - // if it is already blocked, then ignore it (don't unblock and reblock) - ignoreIfBlocked: false - }; - - // private data and functions follow... - - var pageBlock = null; - var pageBlockEls = []; - - function install(el, opts) { - var css, themedCSS; - var full = (el == window); - var msg = (opts && opts.message !== undefined ? opts.message : undefined); - opts = $.extend({}, $.blockUI.defaults, opts || {}); - - if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked')) - return; - - opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {}); - css = $.extend({}, $.blockUI.defaults.css, opts.css || {}); - if (opts.onOverlayClick) - opts.overlayCSS.cursor = 'pointer'; - - themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {}); - msg = msg === undefined ? opts.message : msg; - - // remove the current block (if there is one) - if (full && pageBlock) - remove(window, {fadeOut:0}); - - // if an existing element is being used as the blocking content then we capture - // its current place in the DOM (and current display style) so we can restore - // it when we unblock - if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) { - var node = msg.jquery ? msg[0] : msg; - var data = {}; - $(el).data('blockUI.history', data); - data.el = node; - data.parent = node.parentNode; - data.display = node.style.display; - data.position = node.style.position; - if (data.parent) - data.parent.removeChild(node); - } - - $(el).data('blockUI.onUnblock', opts.onUnblock); - var z = opts.baseZ; - - // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform; - // layer1 is the iframe layer which is used to supress bleed through of underlying content - // layer2 is the overlay layer which has opacity and a wait cursor (by default) - // layer3 is the message content that is displayed while blocking - var lyr1, lyr2, lyr3, s; - if (msie || opts.forceIframe) - lyr1 = $(''); - else - lyr1 = $(''); - - if (opts.theme) - lyr2 = $(''); - else - lyr2 = $(''); - - if (opts.theme && full) { - s = ''; - } - else if (opts.theme) { - s = ''; - } - else if (full) { - s = ''; - } - else { - s = ''; - } - lyr3 = $(s); - - // if we have a message, style it - if (msg) { - if (opts.theme) { - lyr3.css(themedCSS); - lyr3.addClass('ui-widget-content'); - } - else - lyr3.css(css); - } - - // style the overlay - if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/) - lyr2.css(opts.overlayCSS); - lyr2.css('position', full ? 'fixed' : 'absolute'); - - // make iframe layer transparent in IE - if (msie || opts.forceIframe) - lyr1.css('opacity',0.0); - - //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el); - var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el); - $.each(layers, function() { - this.appendTo($par); - }); - - if (opts.theme && opts.draggable && $.fn.draggable) { - lyr3.draggable({ - handle: '.ui-dialog-titlebar', - cancel: 'li' - }); - } - - // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling) - var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0); - if (ie6 || expr) { - // give body 100% height - if (full && opts.allowBodyStretch && $.support.boxModel) - $('html,body').css('height','100%'); - - // fix ie6 issue when blocked element has a border width - if ((ie6 || !$.support.boxModel) && !full) { - var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth'); - var fixT = t ? '(0 - '+t+')' : 0; - var fixL = l ? '(0 - '+l+')' : 0; - } - - // simulate fixed position - $.each(layers, function(i,o) { - var s = o[0].style; - s.position = 'absolute'; - if (i < 2) { - if (full) - s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'); - else - s.setExpression('height','this.parentNode.offsetHeight + "px"'); - if (full) - s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'); - else - s.setExpression('width','this.parentNode.offsetWidth + "px"'); - if (fixL) s.setExpression('left', fixL); - if (fixT) s.setExpression('top', fixT); - } - else if (opts.centerY) { - if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'); - s.marginTop = 0; - } - else if (!opts.centerY && full) { - var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0; - var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"'; - s.setExpression('top',expression); - } - }); - } - - // show the message - if (msg) { - if (opts.theme) - lyr3.find('.ui-widget-content').append(msg); - else - lyr3.append(msg); - if (msg.jquery || msg.nodeType) - $(msg).show(); - } - - if ((msie || opts.forceIframe) && opts.showOverlay) - lyr1.show(); // opacity is zero - if (opts.fadeIn) { - var cb = opts.onBlock ? opts.onBlock : noOp; - var cb1 = (opts.showOverlay && !msg) ? cb : noOp; - var cb2 = msg ? cb : noOp; - if (opts.showOverlay) - lyr2._fadeIn(opts.fadeIn, cb1); - if (msg) - lyr3._fadeIn(opts.fadeIn, cb2); - } - else { - if (opts.showOverlay) - lyr2.show(); - if (msg) - lyr3.show(); - if (opts.onBlock) - opts.onBlock.bind(lyr3)(); - } - - // bind key and mouse events - bind(1, el, opts); - - if (full) { - pageBlock = lyr3[0]; - pageBlockEls = $(opts.focusableElements,pageBlock); - if (opts.focusInput) - setTimeout(focus, 20); - } - else - center(lyr3[0], opts.centerX, opts.centerY); - - if (opts.timeout) { - // auto-unblock - var to = setTimeout(function() { - if (full) - $.unblockUI(opts); - else - $(el).unblock(opts); - }, opts.timeout); - $(el).data('blockUI.timeout', to); - } - } - - // remove the block - function remove(el, opts) { - var count; - var full = (el == window); - var $el = $(el); - var data = $el.data('blockUI.history'); - var to = $el.data('blockUI.timeout'); - if (to) { - clearTimeout(to); - $el.removeData('blockUI.timeout'); - } - opts = $.extend({}, $.blockUI.defaults, opts || {}); - bind(0, el, opts); // unbind events - - if (opts.onUnblock === null) { - opts.onUnblock = $el.data('blockUI.onUnblock'); - $el.removeData('blockUI.onUnblock'); - } - - var els; - if (full) // crazy selector to handle odd field errors in ie6/7 - els = $('body').children().filter('.blockUI').add('body > .blockUI'); - else - els = $el.find('>.blockUI'); - - // fix cursor issue - if ( opts.cursorReset ) { - if ( els.length > 1 ) - els[1].style.cursor = opts.cursorReset; - if ( els.length > 2 ) - els[2].style.cursor = opts.cursorReset; - } - - if (full) - pageBlock = pageBlockEls = null; - - if (opts.fadeOut) { - count = els.length; - els.stop().fadeOut(opts.fadeOut, function() { - if ( --count === 0) - reset(els,data,opts,el); - }); - } - else - reset(els, data, opts, el); - } - - // move blocking element back into the DOM where it started - function reset(els,data,opts,el) { - var $el = $(el); - if ( $el.data('blockUI.isBlocked') ) - return; - - els.each(function(i,o) { - // remove via DOM calls so we don't lose event handlers - if (this.parentNode) - this.parentNode.removeChild(this); - }); - - if (data && data.el) { - data.el.style.display = data.display; - data.el.style.position = data.position; - data.el.style.cursor = 'default'; // #59 - if (data.parent) - data.parent.appendChild(data.el); - $el.removeData('blockUI.history'); - } - - if ($el.data('blockUI.static')) { - $el.css('position', 'static'); // #22 - } - - if (typeof opts.onUnblock == 'function') - opts.onUnblock(el,opts); - - // fix issue in Safari 6 where block artifacts remain until reflow - var body = $(document.body), w = body.width(), cssW = body[0].style.width; - body.width(w-1).width(w); - body[0].style.width = cssW; - } - - // bind/unbind the handler - function bind(b, el, opts) { - var full = el == window, $el = $(el); - - // don't bother unbinding if there is nothing to unbind - if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked'))) - return; - - $el.data('blockUI.isBlocked', b); - - // don't bind events when overlay is not in use or if bindEvents is false - if (!full || !opts.bindEvents || (b && !opts.showOverlay)) - return; - - // bind anchors and inputs for mouse and key events - var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove'; - if (b) - $(document).bind(events, opts, handler); - else - $(document).unbind(events, handler); - - // former impl... - // var $e = $('a,:input'); - // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler); - } - - // event handler to suppress keyboard/mouse events when blocking - function handler(e) { - // allow tab navigation (conditionally) - if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) { - if (pageBlock && e.data.constrainTabKey) { - var els = pageBlockEls; - var fwd = !e.shiftKey && e.target === els[els.length-1]; - var back = e.shiftKey && e.target === els[0]; - if (fwd || back) { - setTimeout(function(){focus(back);},10); - return false; - } - } - } - var opts = e.data; - var target = $(e.target); - if (target.hasClass('blockOverlay') && opts.onOverlayClick) - opts.onOverlayClick(e); - - // allow events within the message content - if (target.parents('div.' + opts.blockMsgClass).length > 0) - return true; - - // allow events for content that is not being blocked - return target.parents().children().filter('div.blockUI').length === 0; - } - - function focus(back) { - if (!pageBlockEls) - return; - var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0]; - if (e) - e.focus(); - } - - function center(el, x, y) { - var p = el.parentNode, s = el.style; - var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth'); - var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth'); - if (x) s.left = l > 0 ? (l+'px') : '0'; - if (y) s.top = t > 0 ? (t+'px') : '0'; - } - - function sz(el, p) { - return parseInt($.css(el,p),10)||0; - } - - } - - - /*global define:true */ - if (typeof define === 'function' && define.amd && define.amd.jQuery) { - define(['jquery'], setup); - } else { - setup(jQuery); - } - +/*! + * jQuery blockUI plugin + * Version 2.70.0-2014.11.23 + * Requires jQuery v1.7 or later + * + * Examples at: http://malsup.com/jquery/block/ + * Copyright (c) 2007-2013 M. Alsup + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Thanks to Amir-Hossein Sobhi for some excellent contributions! + */ + +;(function() { +/*jshint eqeqeq:false curly:false latedef:false */ +"use strict"; + + function setup($) { + $.fn._fadeIn = $.fn.fadeIn; + + var noOp = $.noop || function() {}; + + // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle + // confusing userAgent strings on Vista) + var msie = /MSIE/.test(navigator.userAgent); + var ie6 = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent); + var mode = document.documentMode || 0; + var setExpr = $.isFunction( document.createElement('div').style.setExpression ); + + // global $ methods for blocking/unblocking the entire page + $.blockUI = function(opts) { install(window, opts); }; + $.unblockUI = function(opts) { remove(window, opts); }; + + // convenience method for quick growl-like notifications (http://www.google.com/search?q=growl) + $.growlUI = function(title, message, timeout, onClose) { + var $m = $('
'); + if (title) $m.append('

'+title+'

'); + if (message) $m.append('

'+message+'

'); + if (timeout === undefined) timeout = 3000; + + // Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications + var callBlock = function(opts) { + opts = opts || {}; + + $.blockUI({ + message: $m, + fadeIn : typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700, + fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000, + timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout, + centerY: false, + showOverlay: false, + onUnblock: onClose, + css: $.blockUI.defaults.growlCSS + }); + }; + + callBlock(); + var nonmousedOpacity = $m.css('opacity'); + $m.mouseover(function() { + callBlock({ + fadeIn: 0, + timeout: 30000 + }); + + var displayBlock = $('.blockMsg'); + displayBlock.stop(); // cancel fadeout if it has started + displayBlock.fadeTo(300, 1); // make it easier to read the message by removing transparency + }).mouseout(function() { + $('.blockMsg').fadeOut(1000); + }); + // End konapun additions + }; + + // plugin method for blocking element content + $.fn.block = function(opts) { + if ( this[0] === window ) { + $.blockUI( opts ); + return this; + } + var fullOpts = $.extend({}, $.blockUI.defaults, opts || {}); + this.each(function() { + var $el = $(this); + if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked')) + return; + $el.unblock({ fadeOut: 0 }); + }); + + return this.each(function() { + if ($.css(this,'position') == 'static') { + this.style.position = 'relative'; + $(this).data('blockUI.static', true); + } + this.style.zoom = 1; // force 'hasLayout' in ie + install(this, opts); + }); + }; + + // plugin method for unblocking element content + $.fn.unblock = function(opts) { + if ( this[0] === window ) { + $.unblockUI( opts ); + return this; + } + return this.each(function() { + remove(this, opts); + }); + }; + + $.blockUI.version = 2.70; // 2nd generation blocking at no extra cost! + + // override these in your code to change the default behavior and style + $.blockUI.defaults = { + // message displayed when blocking (use null for no message) + message: '
加载中......
', + + title: null, // title string; only used when theme == true + draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded) + + theme: false, // set to true to use with jQuery UI themes + + // styles for the message when blocking; if you wish to disable + // these and use an external stylesheet then do this in your code: + // $.blockUI.defaults.css = {}; + css: { + padding: 0, + margin: 0, + width: '30%', + top: '40%', + left: '35%', + textAlign: 'center', + color: '#000', + border: '0px', + backgroundColor:'transparent', + cursor: 'wait' + }, + + // minimal style set used when themes are used + themedCSS: { + width: '30%', + top: '40%', + left: '35%' + }, + + // styles for the overlay + overlayCSS: { + backgroundColor: '#000', + opacity: 0.6, + cursor: 'wait' + }, + + // style to replace wait cursor before unblocking to correct issue + // of lingering wait cursor + cursorReset: 'default', + + // styles applied when using $.growlUI + growlCSS: { + width: '350px', + top: '10px', + left: '', + right: '10px', + border: 'none', + padding: '5px', + opacity: 0.6, + cursor: 'default', + color: '#fff', + backgroundColor: '#000', + '-webkit-border-radius':'10px', + '-moz-border-radius': '10px', + 'border-radius': '10px' + }, + + // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w + // (hat tip to Jorge H. N. de Vasconcelos) + /*jshint scripturl:true */ + iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank', + + // force usage of iframe in non-IE browsers (handy for blocking applets) + forceIframe: false, + + // z-index for the blocking overlay + baseZ: 1000, + + // set these to true to have the message automatically centered + centerX: true, // <-- only effects element blocking (page block controlled via css above) + centerY: true, + + // allow body element to be stetched in ie6; this makes blocking look better + // on "short" pages. disable if you wish to prevent changes to the body height + allowBodyStretch: true, + + // enable if you want key and mouse events to be disabled for content that is blocked + bindEvents: true, + + // be default blockUI will supress tab navigation from leaving blocking content + // (if bindEvents is true) + constrainTabKey: true, + + // fadeIn time in millis; set to 0 to disable fadeIn on block + fadeIn: 200, + + // fadeOut time in millis; set to 0 to disable fadeOut on unblock + fadeOut: 400, + + // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock + timeout: 0, + + // disable if you don't want to show the overlay + showOverlay: true, + + // if true, focus will be placed in the first available input field when + // page blocking + focusInput: true, + + // elements that can receive focus + focusableElements: ':input:enabled:visible', + + // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) + // no longer needed in 2012 + // applyPlatformOpacityRules: true, + + // callback method invoked when fadeIn has completed and blocking message is visible + onBlock: null, + + // callback method invoked when unblocking has completed; the callback is + // passed the element that has been unblocked (which is the window object for page + // blocks) and the options that were passed to the unblock call: + // onUnblock(element, options) + onUnblock: null, + + // callback method invoked when the overlay area is clicked. + // setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used. + onOverlayClick: null, + + // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493 + quirksmodeOffsetHack: 4, + + // class name of the message block + blockMsgClass: 'blockMsg', + + // if it is already blocked, then ignore it (don't unblock and reblock) + ignoreIfBlocked: false + }; + + // private data and functions follow... + + var pageBlock = null; + var pageBlockEls = []; + + function install(el, opts) { + var css, themedCSS; + var full = (el == window); + var msg = (opts && opts.message !== undefined ? opts.message : undefined); + opts = $.extend({}, $.blockUI.defaults, opts || {}); + + if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked')) + return; + + opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {}); + css = $.extend({}, $.blockUI.defaults.css, opts.css || {}); + if (opts.onOverlayClick) + opts.overlayCSS.cursor = 'pointer'; + + themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {}); + msg = msg === undefined ? opts.message : msg; + + // remove the current block (if there is one) + if (full && pageBlock) + remove(window, {fadeOut:0}); + + // if an existing element is being used as the blocking content then we capture + // its current place in the DOM (and current display style) so we can restore + // it when we unblock + if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) { + var node = msg.jquery ? msg[0] : msg; + var data = {}; + $(el).data('blockUI.history', data); + data.el = node; + data.parent = node.parentNode; + data.display = node.style.display; + data.position = node.style.position; + if (data.parent) + data.parent.removeChild(node); + } + + $(el).data('blockUI.onUnblock', opts.onUnblock); + var z = opts.baseZ; + + // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform; + // layer1 is the iframe layer which is used to supress bleed through of underlying content + // layer2 is the overlay layer which has opacity and a wait cursor (by default) + // layer3 is the message content that is displayed while blocking + var lyr1, lyr2, lyr3, s; + if (msie || opts.forceIframe) + lyr1 = $(''); + else + lyr1 = $(''); + + if (opts.theme) + lyr2 = $(''); + else + lyr2 = $(''); + + if (opts.theme && full) { + s = ''; + } + else if (opts.theme) { + s = ''; + } + else if (full) { + s = ''; + } + else { + s = ''; + } + lyr3 = $(s); + + // if we have a message, style it + if (msg) { + if (opts.theme) { + lyr3.css(themedCSS); + lyr3.addClass('ui-widget-content'); + } + else + lyr3.css(css); + } + + // style the overlay + if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/) + lyr2.css(opts.overlayCSS); + lyr2.css('position', full ? 'fixed' : 'absolute'); + + // make iframe layer transparent in IE + if (msie || opts.forceIframe) + lyr1.css('opacity',0.0); + + //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el); + var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el); + $.each(layers, function() { + this.appendTo($par); + }); + + if (opts.theme && opts.draggable && $.fn.draggable) { + lyr3.draggable({ + handle: '.ui-dialog-titlebar', + cancel: 'li' + }); + } + + // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling) + var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0); + if (ie6 || expr) { + // give body 100% height + if (full && opts.allowBodyStretch && $.support.boxModel) + $('html,body').css('height','100%'); + + // fix ie6 issue when blocked element has a border width + if ((ie6 || !$.support.boxModel) && !full) { + var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth'); + var fixT = t ? '(0 - '+t+')' : 0; + var fixL = l ? '(0 - '+l+')' : 0; + } + + // simulate fixed position + $.each(layers, function(i,o) { + var s = o[0].style; + s.position = 'absolute'; + if (i < 2) { + if (full) + s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'); + else + s.setExpression('height','this.parentNode.offsetHeight + "px"'); + if (full) + s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'); + else + s.setExpression('width','this.parentNode.offsetWidth + "px"'); + if (fixL) s.setExpression('left', fixL); + if (fixT) s.setExpression('top', fixT); + } + else if (opts.centerY) { + if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'); + s.marginTop = 0; + } + else if (!opts.centerY && full) { + var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0; + var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"'; + s.setExpression('top',expression); + } + }); + } + + // show the message + if (msg) { + if (opts.theme) + lyr3.find('.ui-widget-content').append(msg); + else + lyr3.append(msg); + if (msg.jquery || msg.nodeType) + $(msg).show(); + } + + if ((msie || opts.forceIframe) && opts.showOverlay) + lyr1.show(); // opacity is zero + if (opts.fadeIn) { + var cb = opts.onBlock ? opts.onBlock : noOp; + var cb1 = (opts.showOverlay && !msg) ? cb : noOp; + var cb2 = msg ? cb : noOp; + if (opts.showOverlay) + lyr2._fadeIn(opts.fadeIn, cb1); + if (msg) + lyr3._fadeIn(opts.fadeIn, cb2); + } + else { + if (opts.showOverlay) + lyr2.show(); + if (msg) + lyr3.show(); + if (opts.onBlock) + opts.onBlock.bind(lyr3)(); + } + + // bind key and mouse events + bind(1, el, opts); + + if (full) { + pageBlock = lyr3[0]; + pageBlockEls = $(opts.focusableElements,pageBlock); + if (opts.focusInput) + setTimeout(focus, 20); + } + else + center(lyr3[0], opts.centerX, opts.centerY); + + if (opts.timeout) { + // auto-unblock + var to = setTimeout(function() { + if (full) + $.unblockUI(opts); + else + $(el).unblock(opts); + }, opts.timeout); + $(el).data('blockUI.timeout', to); + } + } + + // remove the block + function remove(el, opts) { + var count; + var full = (el == window); + var $el = $(el); + var data = $el.data('blockUI.history'); + var to = $el.data('blockUI.timeout'); + if (to) { + clearTimeout(to); + $el.removeData('blockUI.timeout'); + } + opts = $.extend({}, $.blockUI.defaults, opts || {}); + bind(0, el, opts); // unbind events + + if (opts.onUnblock === null) { + opts.onUnblock = $el.data('blockUI.onUnblock'); + $el.removeData('blockUI.onUnblock'); + } + + var els; + if (full) // crazy selector to handle odd field errors in ie6/7 + els = $('body').children().filter('.blockUI').add('body > .blockUI'); + else + els = $el.find('>.blockUI'); + + // fix cursor issue + if ( opts.cursorReset ) { + if ( els.length > 1 ) + els[1].style.cursor = opts.cursorReset; + if ( els.length > 2 ) + els[2].style.cursor = opts.cursorReset; + } + + if (full) + pageBlock = pageBlockEls = null; + + if (opts.fadeOut) { + count = els.length; + els.stop().fadeOut(opts.fadeOut, function() { + if ( --count === 0) + reset(els,data,opts,el); + }); + } + else + reset(els, data, opts, el); + } + + // move blocking element back into the DOM where it started + function reset(els,data,opts,el) { + var $el = $(el); + if ( $el.data('blockUI.isBlocked') ) + return; + + els.each(function(i,o) { + // remove via DOM calls so we don't lose event handlers + if (this.parentNode) + this.parentNode.removeChild(this); + }); + + if (data && data.el) { + data.el.style.display = data.display; + data.el.style.position = data.position; + data.el.style.cursor = 'default'; // #59 + if (data.parent) + data.parent.appendChild(data.el); + $el.removeData('blockUI.history'); + } + + if ($el.data('blockUI.static')) { + $el.css('position', 'static'); // #22 + } + + if (typeof opts.onUnblock == 'function') + opts.onUnblock(el,opts); + + // fix issue in Safari 6 where block artifacts remain until reflow + var body = $(document.body), w = body.width(), cssW = body[0].style.width; + body.width(w-1).width(w); + body[0].style.width = cssW; + } + + // bind/unbind the handler + function bind(b, el, opts) { + var full = el == window, $el = $(el); + + // don't bother unbinding if there is nothing to unbind + if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked'))) + return; + + $el.data('blockUI.isBlocked', b); + + // don't bind events when overlay is not in use or if bindEvents is false + if (!full || !opts.bindEvents || (b && !opts.showOverlay)) + return; + + // bind anchors and inputs for mouse and key events + var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove'; + if (b) + $(document).bind(events, opts, handler); + else + $(document).unbind(events, handler); + + // former impl... + // var $e = $('a,:input'); + // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler); + } + + // event handler to suppress keyboard/mouse events when blocking + function handler(e) { + // allow tab navigation (conditionally) + if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) { + if (pageBlock && e.data.constrainTabKey) { + var els = pageBlockEls; + var fwd = !e.shiftKey && e.target === els[els.length-1]; + var back = e.shiftKey && e.target === els[0]; + if (fwd || back) { + setTimeout(function(){focus(back);},10); + return false; + } + } + } + var opts = e.data; + var target = $(e.target); + if (target.hasClass('blockOverlay') && opts.onOverlayClick) + opts.onOverlayClick(e); + + // allow events within the message content + if (target.parents('div.' + opts.blockMsgClass).length > 0) + return true; + + // allow events for content that is not being blocked + return target.parents().children().filter('div.blockUI').length === 0; + } + + function focus(back) { + if (!pageBlockEls) + return; + var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0]; + if (e) + e.focus(); + } + + function center(el, x, y) { + var p = el.parentNode, s = el.style; + var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth'); + var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth'); + if (x) s.left = l > 0 ? (l+'px') : '0'; + if (y) s.top = t > 0 ? (t+'px') : '0'; + } + + function sz(el, p) { + return parseInt($.css(el,p),10)||0; + } + + } + + + /*global define:true */ + if (typeof define === 'function' && define.amd && define.amd.jQuery) { + define(['jquery'], setup); + } else { + setup(jQuery); + } + })(); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.css b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.css similarity index 95% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.css rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.css index caf22a23e..25e8694a8 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.css @@ -1,550 +1,550 @@ -/*! - * bootstrap-fileinput v5.0.4 - * http://plugins.krajee.com/file-input - * - * Krajee default styling for bootstrap-fileinput. - * - * Author: Kartik Visweswaran - * Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com - * - * Licensed under the BSD-3-Clause - * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md - */ -.file-loading input[type=file], input[type=file].file-loading { - width: 0; - height: 0; -} - -.file-no-browse { - position: absolute; - left: 50%; - bottom: 20%; - width: 1px; - height: 1px; - font-size: 0; - opacity: 0; - border: none; - background: none; - outline: none; - box-shadow: none; -} - -.kv-hidden, .file-caption-icon, .file-zoom-dialog .modal-header:before, .file-zoom-dialog .modal-header:after, .file-input-new .file-preview, .file-input-new .close, .file-input-new .glyphicon-file, .file-input-new .fileinput-remove-button, .file-input-new .fileinput-upload-button, .file-input-new .no-browse .input-group-btn, .file-input-ajax-new .fileinput-remove-button, .file-input-ajax-new .fileinput-upload-button, .file-input-ajax-new .no-browse .input-group-btn, .hide-content .kv-file-content, .is-locked .fileinput-upload-button, .is-locked .fileinput-remove-button { - display: none; -} - -.btn-file input[type=file], .file-caption-icon, .file-preview .fileinput-remove, .krajee-default .file-thumb-progress, .file-zoom-dialog .btn-navigate, .file-zoom-dialog .floating-buttons { - position: absolute; -} - -.file-caption-icon .kv-caption-icon { - line-height: inherit; -} - -.file-input, .file-loading:before, .btn-file, .file-caption, .file-preview, .krajee-default.file-preview-frame, .krajee-default .file-thumbnail-footer, .file-zoom-dialog .modal-dialog { - position: relative; -} - -.file-error-message pre, .file-error-message ul, .krajee-default .file-actions, .krajee-default .file-other-error { - text-align: left; -} - -.file-error-message pre, .file-error-message ul { - margin: 0; -} - -.krajee-default .file-drag-handle, .krajee-default .file-upload-indicator { - float: left; - margin-top: 10px; - width: 16px; - height: 16px; -} - -.krajee-default .file-thumb-progress .progress, .krajee-default .file-thumb-progress .progress-bar { - height: 11px; - font-family: Verdana, Helvetica, sans-serif; - font-size: 9px; -} - -.krajee-default .file-thumb-progress .progress, .kv-upload-progress .progress { - background-color: #ccc; -} - -.krajee-default .file-caption-info, .krajee-default .file-size-info { - display: block; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - width: 160px; - height: 15px; - margin: auto; -} - -.file-zoom-content > .file-object.type-video, .file-zoom-content > .file-object.type-flash, .file-zoom-content > .file-object.type-image { - max-width: 100%; - max-height: 100%; - width: auto; -} - -.file-zoom-content > .file-object.type-video, .file-zoom-content > .file-object.type-flash { - height: 100%; -} - -.file-zoom-content > .file-object.type-pdf, .file-zoom-content > .file-object.type-html, .file-zoom-content > .file-object.type-text, .file-zoom-content > .file-object.type-default { - width: 100%; -} - -.file-loading:before { - content: " Loading..."; - display: inline-block; - padding-left: 20px; - line-height: 16px; - font-size: 13px; - font-variant: small-caps; - color: #999; - background: transparent url(loading.gif) top left no-repeat; -} - -.file-object { - margin: 0 0 -5px 0; - padding: 0; -} - -.btn-file { - overflow: hidden; -} - -.btn-file input[type=file] { - top: 0; - left: 0; - min-width: 100%; - min-height: 100%; - text-align: right; - opacity: 0; - background: none repeat scroll 0 0 transparent; - cursor: inherit; - display: block; -} - -.btn-file ::-ms-browse { - font-size: 10000px; - width: 100%; - height: 100%; -} - -.file-caption .file-caption-name { - width: 100%; - margin: 0; - padding: 0; - box-shadow: none; - border: none; - background: none; - outline: none; -} - -.file-caption.icon-visible .file-caption-icon { - display: inline-block; -} - -.file-caption.icon-visible .file-caption-name { - padding-left: 15px; -} - -.file-caption-icon { - left: 8px; -} - -.file-error-message { - color: #a94442; - background-color: #f2dede; - margin: 5px; - border: 1px solid #ebccd1; - border-radius: 4px; - padding: 15px; -} - -.file-error-message pre { - margin: 5px 0; -} - -.file-caption-disabled { - background-color: #eee; - cursor: not-allowed; - opacity: 1; -} - -.file-preview { - border-radius: 5px; - border: 1px solid #ddd; - padding: 8px; - width: 100%; - margin-bottom: 5px; -} - -.file-preview .btn-xs { - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} - -.file-preview .fileinput-remove { - top: 1px; - right: 1px; - line-height: 10px; -} - -.file-preview .clickable { - cursor: pointer; -} - -.file-preview-image { - font: 40px Impact, Charcoal, sans-serif; - color: #008000; -} - -.krajee-default.file-preview-frame { - margin: 8px; - border: 1px solid rgba(0,0,0,0.2); - box-shadow: 0 0 10px 0 rgba(0,0,0,0.2); - padding: 6px; - float: left; - text-align: center; -} - -.krajee-default.file-preview-frame .kv-file-content { - width: 213px; - height: 160px; -} - -.krajee-default .file-preview-other-frame { - display: flex; - align-items: center; - justify-content: center; -} - -.krajee-default.file-preview-frame .kv-file-content.kv-pdf-rendered { - width: 400px; -} - -.krajee-default.file-preview-frame[data-template="audio"] .kv-file-content { - width: 240px; - height: 55px; -} - -.krajee-default.file-preview-frame .file-thumbnail-footer { - height: 70px; -} - -.krajee-default.file-preview-frame:not(.file-preview-error):hover { - border: 1px solid rgba(0,0,0,0.3); - box-shadow: 0 0 10px 0 rgba(0,0,0,0.4); -} - -.krajee-default .file-preview-text { - display: block; - color: #428bca; - border: 1px solid #ddd; - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - outline: none; - padding: 8px; - resize: none; -} - -.krajee-default .file-preview-html { - border: 1px solid #ddd; - padding: 8px; - overflow: auto; -} - -.krajee-default .file-other-icon { - font-size: 6em; - line-height: 1; -} - -.krajee-default .file-footer-buttons { - float: right; -} - -.krajee-default .file-footer-caption { - display: block; - text-align: center; - padding-top: 4px; - font-size: 11px; - color: #777; - margin-bottom: 30px; -} - -.file-upload-stats { - font-size: 10px; - text-align: center; - width: 100%; -} - -.kv-upload-progress .file-upload-stats { - font-size: 12px; - margin: -10px 0 5px; -} - -.krajee-default .file-preview-error { - opacity: 0.65; - box-shadow: none; -} - -.krajee-default .file-thumb-progress { - height: 11px; - top: 37px; - left: 0; - right: 0; -} - -.krajee-default.kvsortable-ghost { - background: #e1edf7; - border: 2px solid #a1abff; -} - -.krajee-default .file-preview-other:hover { - opacity: 0.8; -} - -.krajee-default .file-preview-frame:not(.file-preview-error) .file-footer-caption:hover { - color: #000; -} - -.kv-upload-progress .progress { - height: 20px; - margin: 10px 0; - overflow: hidden; -} - -.kv-upload-progress .progress-bar { - height: 20px; - font-family: Verdana, Helvetica, sans-serif; -} - -/*noinspection CssOverwrittenProperties*/ -.file-zoom-dialog .file-other-icon { - font-size: 22em; - font-size: 50vmin; -} - -.file-zoom-dialog .modal-dialog { - width: auto; -} - -.file-zoom-dialog .modal-header { - display: flex; - align-items: center; - justify-content: space-between; -} - -.file-zoom-dialog .btn-navigate { - padding: 0; - margin: 0; - background: transparent; - text-decoration: none; - outline: none; - opacity: 0.7; - top: 45%; - font-size: 4em; - color: #1c94c4; -} - -.file-zoom-dialog .btn-navigate:not([disabled]):hover { - outline: none; - box-shadow: none; - opacity: 0.6; -} - -.file-zoom-dialog .floating-buttons { - top: 5px; - right: 10px; -} - -.file-zoom-dialog .btn-navigate[disabled] { - opacity: 0.3; -} - -.file-zoom-dialog .btn-prev { - left: 1px; -} - -.file-zoom-dialog .btn-next { - right: 1px; -} - -.file-zoom-dialog .kv-zoom-title { - font-weight: 300; - color: #999; - max-width: 50%; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} - -.file-input-new .no-browse .form-control { - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; -} - -.file-input-ajax-new .no-browse .form-control { - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; -} - -.file-caption-main { - width: 100%; -} - -.file-thumb-loading { - background: transparent url(loading.gif) no-repeat scroll center center content-box !important; -} - -.file-drop-zone { - border: 1px dashed #aaa; - border-radius: 4px; - text-align: center; - vertical-align: middle; - margin: 12px 15px 12px 12px; - padding: 5px; -} - -.file-drop-zone.clickable:hover { - border: 2px dashed #999; -} - -.file-drop-zone.clickable:focus { - border: 2px solid #5acde2; -} - -.file-drop-zone .file-preview-thumbnails { - cursor: default; -} - -.file-drop-zone-title { - color: #aaa; - font-size: 1.6em; - padding: 85px 10px; - cursor: default; -} - -.file-highlighted { - border: 2px dashed #999 !important; - background-color: #eee; -} - -.file-uploading { - background: url(../img/loading-sm.gif) no-repeat center bottom 10px; - opacity: 0.65; -} - -.file-zoom-fullscreen .modal-dialog { - min-width: 100%; - margin: 0; -} - -.file-zoom-fullscreen .modal-content { - border-radius: 0; - box-shadow: none; - min-height: 100vh; -} - -.file-zoom-fullscreen .modal-body { - overflow-y: auto; -} - -.floating-buttons { - z-index: 3000; -} - -.floating-buttons .btn-kv { - margin-left: 3px; - z-index: 3000; -} - -.kv-zoom-actions .btn-kv { - margin-left: 3px; -} - -.file-zoom-content { - height: 480px; - text-align: center; -} - -.file-zoom-content .file-preview-image { - max-height: 100%; -} - -.file-zoom-content .file-preview-video { - max-height: 100%; -} - -.file-zoom-content > .file-object.type-image { - height: auto; - min-height: inherit; -} - -.file-zoom-content > .file-object.type-audio { - width: auto; - height: 30px; -} - -@media (min-width: 576px) { - .file-zoom-dialog .modal-dialog { - max-width: 500px; - } -} - -@media (min-width: 992px) { - .file-zoom-dialog .modal-lg { - max-width: 800px; - } -} - -@media (max-width: 767px) { - .file-preview-thumbnails { - display: flex; - justify-content: center; - align-items: center; - flex-direction: column; - } - - .file-zoom-dialog .modal-header { - flex-direction: column; - } -} - -@media (max-width: 350px) { - .krajee-default.file-preview-frame:not([data-template="audio"]) .kv-file-content { - width: 160px; - } -} - -@media (max-width: 420px) { - .krajee-default.file-preview-frame .kv-file-content.kv-pdf-rendered { - width: 100%; - } -} - -.file-loading[dir=rtl]:before { - background: transparent url(loading.gif) top right no-repeat; - padding-left: 0; - padding-right: 20px; -} - -.file-sortable .file-drag-handle { - cursor: move; - opacity: 1; -} - -.file-sortable .file-drag-handle:hover { - opacity: 0.7; -} - -.clickable .file-drop-zone-title { - cursor: pointer; -} - -.file-preview-initial.sortable-chosen { - background-color: #d9edf7; +/*! + * bootstrap-fileinput v5.0.4 + * http://plugins.krajee.com/file-input + * + * Krajee default styling for bootstrap-fileinput. + * + * Author: Kartik Visweswaran + * Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com + * + * Licensed under the BSD-3-Clause + * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md + */ +.file-loading input[type=file], input[type=file].file-loading { + width: 0; + height: 0; +} + +.file-no-browse { + position: absolute; + left: 50%; + bottom: 20%; + width: 1px; + height: 1px; + font-size: 0; + opacity: 0; + border: none; + background: none; + outline: none; + box-shadow: none; +} + +.kv-hidden, .file-caption-icon, .file-zoom-dialog .modal-header:before, .file-zoom-dialog .modal-header:after, .file-input-new .file-preview, .file-input-new .close, .file-input-new .glyphicon-file, .file-input-new .fileinput-remove-button, .file-input-new .fileinput-upload-button, .file-input-new .no-browse .input-group-btn, .file-input-ajax-new .fileinput-remove-button, .file-input-ajax-new .fileinput-upload-button, .file-input-ajax-new .no-browse .input-group-btn, .hide-content .kv-file-content, .is-locked .fileinput-upload-button, .is-locked .fileinput-remove-button { + display: none; +} + +.btn-file input[type=file], .file-caption-icon, .file-preview .fileinput-remove, .krajee-default .file-thumb-progress, .file-zoom-dialog .btn-navigate, .file-zoom-dialog .floating-buttons { + position: absolute; +} + +.file-caption-icon .kv-caption-icon { + line-height: inherit; +} + +.file-input, .file-loading:before, .btn-file, .file-caption, .file-preview, .krajee-default.file-preview-frame, .krajee-default .file-thumbnail-footer, .file-zoom-dialog .modal-dialog { + position: relative; +} + +.file-error-message pre, .file-error-message ul, .krajee-default .file-actions, .krajee-default .file-other-error { + text-align: left; +} + +.file-error-message pre, .file-error-message ul { + margin: 0; +} + +.krajee-default .file-drag-handle, .krajee-default .file-upload-indicator { + float: left; + margin-top: 10px; + width: 16px; + height: 16px; +} + +.krajee-default .file-thumb-progress .progress, .krajee-default .file-thumb-progress .progress-bar { + height: 11px; + font-family: Verdana, Helvetica, sans-serif; + font-size: 9px; +} + +.krajee-default .file-thumb-progress .progress, .kv-upload-progress .progress { + background-color: #ccc; +} + +.krajee-default .file-caption-info, .krajee-default .file-size-info { + display: block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 160px; + height: 15px; + margin: auto; +} + +.file-zoom-content > .file-object.type-video, .file-zoom-content > .file-object.type-flash, .file-zoom-content > .file-object.type-image { + max-width: 100%; + max-height: 100%; + width: auto; +} + +.file-zoom-content > .file-object.type-video, .file-zoom-content > .file-object.type-flash { + height: 100%; +} + +.file-zoom-content > .file-object.type-pdf, .file-zoom-content > .file-object.type-html, .file-zoom-content > .file-object.type-text, .file-zoom-content > .file-object.type-default { + width: 100%; +} + +.file-loading:before { + content: " Loading..."; + display: inline-block; + padding-left: 20px; + line-height: 16px; + font-size: 13px; + font-variant: small-caps; + color: #999; + background: transparent url(loading.gif) top left no-repeat; +} + +.file-object { + margin: 0 0 -5px 0; + padding: 0; +} + +.btn-file { + overflow: hidden; +} + +.btn-file input[type=file] { + top: 0; + left: 0; + min-width: 100%; + min-height: 100%; + text-align: right; + opacity: 0; + background: none repeat scroll 0 0 transparent; + cursor: inherit; + display: block; +} + +.btn-file ::-ms-browse { + font-size: 10000px; + width: 100%; + height: 100%; +} + +.file-caption .file-caption-name { + width: 100%; + margin: 0; + padding: 0; + box-shadow: none; + border: none; + background: none; + outline: none; +} + +.file-caption.icon-visible .file-caption-icon { + display: inline-block; +} + +.file-caption.icon-visible .file-caption-name { + padding-left: 15px; +} + +.file-caption-icon { + left: 8px; +} + +.file-error-message { + color: #a94442; + background-color: #f2dede; + margin: 5px; + border: 1px solid #ebccd1; + border-radius: 4px; + padding: 15px; +} + +.file-error-message pre { + margin: 5px 0; +} + +.file-caption-disabled { + background-color: #eee; + cursor: not-allowed; + opacity: 1; +} + +.file-preview { + border-radius: 5px; + border: 1px solid #ddd; + padding: 8px; + width: 100%; + margin-bottom: 5px; +} + +.file-preview .btn-xs { + padding: 1px 5px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} + +.file-preview .fileinput-remove { + top: 1px; + right: 1px; + line-height: 10px; +} + +.file-preview .clickable { + cursor: pointer; +} + +.file-preview-image { + font: 40px Impact, Charcoal, sans-serif; + color: #008000; +} + +.krajee-default.file-preview-frame { + margin: 8px; + border: 1px solid rgba(0,0,0,0.2); + box-shadow: 0 0 10px 0 rgba(0,0,0,0.2); + padding: 6px; + float: left; + text-align: center; +} + +.krajee-default.file-preview-frame .kv-file-content { + width: 213px; + height: 160px; +} + +.krajee-default .file-preview-other-frame { + display: flex; + align-items: center; + justify-content: center; +} + +.krajee-default.file-preview-frame .kv-file-content.kv-pdf-rendered { + width: 400px; +} + +.krajee-default.file-preview-frame[data-template="audio"] .kv-file-content { + width: 240px; + height: 55px; +} + +.krajee-default.file-preview-frame .file-thumbnail-footer { + height: 70px; +} + +.krajee-default.file-preview-frame:not(.file-preview-error):hover { + border: 1px solid rgba(0,0,0,0.3); + box-shadow: 0 0 10px 0 rgba(0,0,0,0.4); +} + +.krajee-default .file-preview-text { + display: block; + color: #428bca; + border: 1px solid #ddd; + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + outline: none; + padding: 8px; + resize: none; +} + +.krajee-default .file-preview-html { + border: 1px solid #ddd; + padding: 8px; + overflow: auto; +} + +.krajee-default .file-other-icon { + font-size: 6em; + line-height: 1; +} + +.krajee-default .file-footer-buttons { + float: right; +} + +.krajee-default .file-footer-caption { + display: block; + text-align: center; + padding-top: 4px; + font-size: 11px; + color: #777; + margin-bottom: 30px; +} + +.file-upload-stats { + font-size: 10px; + text-align: center; + width: 100%; +} + +.kv-upload-progress .file-upload-stats { + font-size: 12px; + margin: -10px 0 5px; +} + +.krajee-default .file-preview-error { + opacity: 0.65; + box-shadow: none; +} + +.krajee-default .file-thumb-progress { + height: 11px; + top: 37px; + left: 0; + right: 0; +} + +.krajee-default.kvsortable-ghost { + background: #e1edf7; + border: 2px solid #a1abff; +} + +.krajee-default .file-preview-other:hover { + opacity: 0.8; +} + +.krajee-default .file-preview-frame:not(.file-preview-error) .file-footer-caption:hover { + color: #000; +} + +.kv-upload-progress .progress { + height: 20px; + margin: 10px 0; + overflow: hidden; +} + +.kv-upload-progress .progress-bar { + height: 20px; + font-family: Verdana, Helvetica, sans-serif; +} + +/*noinspection CssOverwrittenProperties*/ +.file-zoom-dialog .file-other-icon { + font-size: 22em; + font-size: 50vmin; +} + +.file-zoom-dialog .modal-dialog { + width: auto; +} + +.file-zoom-dialog .modal-header { + display: flex; + align-items: center; + justify-content: space-between; +} + +.file-zoom-dialog .btn-navigate { + padding: 0; + margin: 0; + background: transparent; + text-decoration: none; + outline: none; + opacity: 0.7; + top: 45%; + font-size: 4em; + color: #1c94c4; +} + +.file-zoom-dialog .btn-navigate:not([disabled]):hover { + outline: none; + box-shadow: none; + opacity: 0.6; +} + +.file-zoom-dialog .floating-buttons { + top: 5px; + right: 10px; +} + +.file-zoom-dialog .btn-navigate[disabled] { + opacity: 0.3; +} + +.file-zoom-dialog .btn-prev { + left: 1px; +} + +.file-zoom-dialog .btn-next { + right: 1px; +} + +.file-zoom-dialog .kv-zoom-title { + font-weight: 300; + color: #999; + max-width: 50%; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.file-input-new .no-browse .form-control { + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; +} + +.file-input-ajax-new .no-browse .form-control { + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; +} + +.file-caption-main { + width: 100%; +} + +.file-thumb-loading { + background: transparent url(loading.gif) no-repeat scroll center center content-box !important; +} + +.file-drop-zone { + border: 1px dashed #aaa; + border-radius: 4px; + text-align: center; + vertical-align: middle; + margin: 12px 15px 12px 12px; + padding: 5px; +} + +.file-drop-zone.clickable:hover { + border: 2px dashed #999; +} + +.file-drop-zone.clickable:focus { + border: 2px solid #5acde2; +} + +.file-drop-zone .file-preview-thumbnails { + cursor: default; +} + +.file-drop-zone-title { + color: #aaa; + font-size: 1.6em; + padding: 85px 10px; + cursor: default; +} + +.file-highlighted { + border: 2px dashed #999 !important; + background-color: #eee; +} + +.file-uploading { + background: url(../img/loading-sm.gif) no-repeat center bottom 10px; + opacity: 0.65; +} + +.file-zoom-fullscreen .modal-dialog { + min-width: 100%; + margin: 0; +} + +.file-zoom-fullscreen .modal-content { + border-radius: 0; + box-shadow: none; + min-height: 100vh; +} + +.file-zoom-fullscreen .modal-body { + overflow-y: auto; +} + +.floating-buttons { + z-index: 3000; +} + +.floating-buttons .btn-kv { + margin-left: 3px; + z-index: 3000; +} + +.kv-zoom-actions .btn-kv { + margin-left: 3px; +} + +.file-zoom-content { + height: 480px; + text-align: center; +} + +.file-zoom-content .file-preview-image { + max-height: 100%; +} + +.file-zoom-content .file-preview-video { + max-height: 100%; +} + +.file-zoom-content > .file-object.type-image { + height: auto; + min-height: inherit; +} + +.file-zoom-content > .file-object.type-audio { + width: auto; + height: 30px; +} + +@media (min-width: 576px) { + .file-zoom-dialog .modal-dialog { + max-width: 500px; + } +} + +@media (min-width: 992px) { + .file-zoom-dialog .modal-lg { + max-width: 800px; + } +} + +@media (max-width: 767px) { + .file-preview-thumbnails { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + } + + .file-zoom-dialog .modal-header { + flex-direction: column; + } +} + +@media (max-width: 350px) { + .krajee-default.file-preview-frame:not([data-template="audio"]) .kv-file-content { + width: 160px; + } +} + +@media (max-width: 420px) { + .krajee-default.file-preview-frame .kv-file-content.kv-pdf-rendered { + width: 100%; + } +} + +.file-loading[dir=rtl]:before { + background: transparent url(loading.gif) top right no-repeat; + padding-left: 0; + padding-right: 20px; +} + +.file-sortable .file-drag-handle { + cursor: move; + opacity: 1; +} + +.file-sortable .file-drag-handle:hover { + opacity: 0.7; +} + +.clickable .file-drop-zone-title { + cursor: pointer; +} + +.file-preview-initial.sortable-chosen { + background-color: #d9edf7; } \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.js index c0723da97..56245011e 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.js @@ -1,5697 +1,5697 @@ -/*! - * bootstrap-fileinput v5.0.4 - * http://plugins.krajee.com/file-input - * - * Author: Kartik Visweswaran - * Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com - * - * Licensed under the BSD-3-Clause - * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md - */ -(function (factory) { - 'use strict'; - //noinspection JSUnresolvedVariable - if (typeof define === 'function' && define.amd) { // jshint ignore:line - // AMD. Register as an anonymous module. - define(['jquery'], factory); // jshint ignore:line - } else { // noinspection JSUnresolvedVariable - if (typeof module === 'object' && module.exports) { // jshint ignore:line - // Node/CommonJS - // noinspection JSUnresolvedVariable - module.exports = factory(require('jquery')); // jshint ignore:line - } else { - // Browser globals - factory(window.jQuery); - } - } -}(function ($) { - 'use strict'; - - $.fn.fileinputLocales = {}; - $.fn.fileinputThemes = {}; - - String.prototype.setTokens = function (replacePairs) { - var str = this.toString(), key, re; - for (key in replacePairs) { - if (replacePairs.hasOwnProperty(key)) { - re = new RegExp('\{' + key + '\}', 'g'); - str = str.replace(re, replacePairs[key]); - } - } - return str; - }; - - var $h, FileInput; - - // fileinput helper object for all global variables and internal helper methods - //noinspection JSUnresolvedVariable - $h = { - FRAMES: '.kv-preview-thumb', - SORT_CSS: 'file-sortable', - OBJECT_PARAMS: '\n' + - '\n' + - '\n' + - '\n' + - '\n' + - '\n', - DEFAULT_PREVIEW: '
\n' + - '{previewFileIcon}\n' + - '
', - MODAL_ID: 'kvFileinputModal', - MODAL_EVENTS: ['show', 'shown', 'hide', 'hidden', 'loaded'], - logMessages: { - ajaxError: '{status}: {error}. Error Details: {text}.', - badDroppedFiles: 'Error scanning dropped files!', - badExifParser: 'Error loading the piexif.js library. {details}', - badInputType: 'The input "type" must be set to "file" for initializing the "bootstrap-fileinput" plugin.', - exifWarning: 'To avoid this warning, either set "autoOrientImage" to "false" OR ensure you have loaded ' + - 'the "piexif.js" library correctly on your page before the "fileinput.js" script.', - invalidChunkSize: 'Invalid upload chunk size: "{chunkSize}". Resumable uploads are disabled.', - invalidThumb: 'Invalid thumb frame with id: "{id}".', - noResumableSupport: 'The browser does not support resumable or chunk uploads.', - noUploadUrl: 'The "uploadUrl" is not set. Ajax uploads and resumable uploads have been disabled.', - retryStatus: 'Retrying upload for chunk # {chunk} for {filename}... retry # {retry}.' - }, - objUrl: window.URL || window.webkitURL, - now: function () { - return new Date(); - }, - round: function (num) { - num = parseFloat(num); - return isNaN(num) ? 0 : Math.floor(Math.round(num)); - }, - getFileRelativePath: function (file) { - /** @namespace file.relativePath */ - /** @namespace file.webkitRelativePath */ - return String(file.relativePath || file.webkitRelativePath || $h.getFileName(file) || null); - - }, - getFileId: function (file, generateFileId) { - var relativePath = $h.getFileRelativePath(file); - if (typeof generateFileId === 'function') { - return generateFileId(file); - } - if (!file) { - return null; - } - if (!relativePath) { - return null; - } - return (file.size + '_' + relativePath.replace(/\s/img, '_')); - }, - getElapsed: function (seconds) { - var delta = seconds, out = '', result = {}, structure = { - year: 31536000, - month: 2592000, - week: 604800, // uncomment row to ignore - day: 86400, // feel free to add your own row - hour: 3600, - minute: 60, - second: 1 - }; - Object.keys(structure).forEach(function (key) { - result[key] = Math.floor(delta / structure[key]); - delta -= result[key] * structure[key]; - }); - $.each(result, function (key, value) { - if (value > 0) { - out += (out ? ' ' : '') + value + key.substring(0, 1); - } - }); - return out; - }, - debounce: function (func, delay) { - var inDebounce; - return function () { - var args = arguments, context = this; - clearTimeout(inDebounce); - inDebounce = setTimeout(function () { - func.apply(context, args); - }, delay); - }; - }, - stopEvent: function (e) { - e.stopPropagation(); - e.preventDefault(); - }, - getFileName: function (file) { - /** @namespace file.fileName */ - return file ? (file.fileName || file.name || '') : ''; // some confusion in different versions of Firefox - }, - createObjectURL: function (data) { - if ($h.objUrl && $h.objUrl.createObjectURL && data) { - return $h.objUrl.createObjectURL(data); - } - return ''; - }, - revokeObjectURL: function (data) { - if ($h.objUrl && $h.objUrl.revokeObjectURL && data) { - $h.objUrl.revokeObjectURL(data); - } - }, - compare: function (input, str, exact) { - return input !== undefined && (exact ? input === str : input.match(str)); - }, - isIE: function (ver) { - var div, status; - // check for IE versions < 11 - if (navigator.appName !== 'Microsoft Internet Explorer') { - return false; - } - if (ver === 10) { - return new RegExp('msie\\s' + ver, 'i').test(navigator.userAgent); - } - div = document.createElement('div'); - div.innerHTML = ''; - status = div.getElementsByTagName('i').length; - document.body.appendChild(div); - div.parentNode.removeChild(div); - return status; - }, - canAssignFilesToInput: function () { - var input = document.createElement('input'); - try { - input.type = 'file'; - input.files = null; - return true; - } catch (err) { - return false; - } - }, - getDragDropFolders: function (items) { - var i, item, len = items ? items.length : 0, folders = 0; - if (len > 0 && items[0].webkitGetAsEntry()) { - for (i = 0; i < len; i++) { - item = items[i].webkitGetAsEntry(); - if (item && item.isDirectory) { - folders++; - } - } - } - return folders; - }, - initModal: function ($modal) { - var $body = $('body'); - if ($body.length) { - $modal.appendTo($body); - } - }, - isEmpty: function (value, trim) { - return value === undefined || value === null || value.length === 0 || (trim && $.trim(value) === ''); - }, - isArray: function (a) { - return Array.isArray(a) || Object.prototype.toString.call(a) === '[object Array]'; - }, - ifSet: function (needle, haystack, def) { - def = def || ''; - return (haystack && typeof haystack === 'object' && needle in haystack) ? haystack[needle] : def; - }, - cleanArray: function (arr) { - if (!(arr instanceof Array)) { - arr = []; - } - return arr.filter(function (e) { - return (e !== undefined && e !== null); - }); - }, - spliceArray: function (arr, index, reverseOrder) { - var i, j = 0, out = [], newArr; - if (!(arr instanceof Array)) { - return []; - } - newArr = $.extend(true, [], arr); - if (reverseOrder) { - newArr.reverse(); - } - for (i = 0; i < newArr.length; i++) { - if (i !== index) { - out[j] = newArr[i]; - j++; - } - } - if (reverseOrder) { - out.reverse(); - } - return out; - }, - getNum: function (num, def) { - def = def || 0; - if (typeof num === 'number') { - return num; - } - if (typeof num === 'string') { - num = parseFloat(num); - } - return isNaN(num) ? def : num; - }, - hasFileAPISupport: function () { - return !!(window.File && window.FileReader); - }, - hasDragDropSupport: function () { - var div = document.createElement('div'); - /** @namespace div.draggable */ - /** @namespace div.ondragstart */ - /** @namespace div.ondrop */ - return !$h.isIE(9) && - (div.draggable !== undefined || (div.ondragstart !== undefined && div.ondrop !== undefined)); - }, - hasFileUploadSupport: function () { - return $h.hasFileAPISupport() && window.FormData; - }, - hasBlobSupport: function () { - try { - return !!window.Blob && Boolean(new Blob()); - } catch (e) { - return false; - } - }, - hasArrayBufferViewSupport: function () { - try { - return new Blob([new Uint8Array(100)]).size === 100; - } catch (e) { - return false; - } - }, - hasResumableUploadSupport: function () { - /** @namespace Blob.prototype.webkitSlice */ - /** @namespace Blob.prototype.mozSlice */ - return $h.hasFileUploadSupport() && $h.hasBlobSupport() && $h.hasArrayBufferViewSupport() && - (!!Blob.prototype.webkitSlice || !!Blob.prototype.mozSlice || !!Blob.prototype.slice || false); - }, - dataURI2Blob: function (dataURI) { - //noinspection JSUnresolvedVariable - var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || - window.MSBlobBuilder, canBlob = $h.hasBlobSupport(), byteStr, arrayBuffer, intArray, i, mimeStr, bb, - canProceed = (canBlob || BlobBuilder) && window.atob && window.ArrayBuffer && window.Uint8Array; - if (!canProceed) { - return null; - } - if (dataURI.split(',')[0].indexOf('base64') >= 0) { - byteStr = atob(dataURI.split(',')[1]); - } else { - byteStr = decodeURIComponent(dataURI.split(',')[1]); - } - arrayBuffer = new ArrayBuffer(byteStr.length); - intArray = new Uint8Array(arrayBuffer); - for (i = 0; i < byteStr.length; i += 1) { - intArray[i] = byteStr.charCodeAt(i); - } - mimeStr = dataURI.split(',')[0].split(':')[1].split(';')[0]; - if (canBlob) { - return new Blob([$h.hasArrayBufferViewSupport() ? intArray : arrayBuffer], {type: mimeStr}); - } - bb = new BlobBuilder(); - bb.append(arrayBuffer); - return bb.getBlob(mimeStr); - }, - arrayBuffer2String: function (buffer) { - //noinspection JSUnresolvedVariable - if (window.TextDecoder) { - // noinspection JSUnresolvedFunction - return new TextDecoder('utf-8').decode(buffer); - } - var array = Array.prototype.slice.apply(new Uint8Array(buffer)), out = '', i = 0, len, c, char2, char3; - len = array.length; - while (i < len) { - c = array[i++]; - switch (c >> 4) { // jshint ignore:line - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - // 0xxxxxxx - out += String.fromCharCode(c); - break; - case 12: - case 13: - // 110x xxxx 10xx xxxx - char2 = array[i++]; - out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); // jshint ignore:line - break; - case 14: - // 1110 xxxx 10xx xxxx 10xx xxxx - char2 = array[i++]; - char3 = array[i++]; - out += String.fromCharCode(((c & 0x0F) << 12) | // jshint ignore:line - ((char2 & 0x3F) << 6) | // jshint ignore:line - ((char3 & 0x3F) << 0)); // jshint ignore:line - break; - } - } - return out; - }, - isHtml: function (str) { - var a = document.createElement('div'); - a.innerHTML = str; - for (var c = a.childNodes, i = c.length; i--;) { - if (c[i].nodeType === 1) { - return true; - } - } - return false; - }, - isSvg: function (str) { - return str.match(/^\s*<\?xml/i) && (str.match(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - }, - replaceTags: function (str, tags) { - var out = str; - if (!tags) { - return out; - } - $.each(tags, function (key, value) { - if (typeof value === 'function') { - value = value(); - } - out = out.split(key).join(value); - }); - return out; - }, - cleanMemory: function ($thumb) { - var data = $thumb.is('img') ? $thumb.attr('src') : $thumb.find('source').attr('src'); - $h.revokeObjectURL(data); - }, - findFileName: function (filePath) { - var sepIndex = filePath.lastIndexOf('/'); - if (sepIndex === -1) { - sepIndex = filePath.lastIndexOf('\\'); - } - return filePath.split(filePath.substring(sepIndex, sepIndex + 1)).pop(); - }, - checkFullScreen: function () { - //noinspection JSUnresolvedVariable - return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || - document.msFullscreenElement; - }, - toggleFullScreen: function (maximize) { - var doc = document, de = doc.documentElement; - if (de && maximize && !$h.checkFullScreen()) { - /** @namespace document.requestFullscreen */ - /** @namespace document.msRequestFullscreen */ - /** @namespace document.mozRequestFullScreen */ - /** @namespace document.webkitRequestFullscreen */ - /** @namespace Element.ALLOW_KEYBOARD_INPUT */ - if (de.requestFullscreen) { - de.requestFullscreen(); - } else { - if (de.msRequestFullscreen) { - de.msRequestFullscreen(); - } else { - if (de.mozRequestFullScreen) { - de.mozRequestFullScreen(); - } else { - if (de.webkitRequestFullscreen) { - de.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); - } - } - } - } - } else { - /** @namespace document.exitFullscreen */ - /** @namespace document.msExitFullscreen */ - /** @namespace document.mozCancelFullScreen */ - /** @namespace document.webkitExitFullscreen */ - if (doc.exitFullscreen) { - doc.exitFullscreen(); - } else { - if (doc.msExitFullscreen) { - doc.msExitFullscreen(); - } else { - if (doc.mozCancelFullScreen) { - doc.mozCancelFullScreen(); - } else { - if (doc.webkitExitFullscreen) { - doc.webkitExitFullscreen(); - } - } - } - } - } - }, - moveArray: function (arr, oldIndex, newIndex, reverseOrder) { - var newArr = $.extend(true, [], arr); - if (reverseOrder) { - newArr.reverse(); - } - if (newIndex >= newArr.length) { - var k = newIndex - newArr.length; - while ((k--) + 1) { - newArr.push(undefined); - } - } - newArr.splice(newIndex, 0, newArr.splice(oldIndex, 1)[0]); - if (reverseOrder) { - newArr.reverse(); - } - return newArr; - }, - cleanZoomCache: function ($el) { - var $cache = $el.closest('.kv-zoom-cache-theme'); - if (!$cache.length) { - $cache = $el.closest('.kv-zoom-cache'); - } - $cache.remove(); - }, - closeButton: function (css) { - css = css ? 'close ' + css : 'close'; - return ''; - }, - getRotation: function (value) { - switch (value) { - case 2: - return 'rotateY(180deg)'; - case 3: - return 'rotate(180deg)'; - case 4: - return 'rotate(180deg) rotateY(180deg)'; - case 5: - return 'rotate(270deg) rotateY(180deg)'; - case 6: - return 'rotate(90deg)'; - case 7: - return 'rotate(90deg) rotateY(180deg)'; - case 8: - return 'rotate(270deg)'; - default: - return ''; - } - }, - setTransform: function (el, val) { - if (!el) { - return; - } - el.style.transform = val; - el.style.webkitTransform = val; - el.style['-moz-transform'] = val; - el.style['-ms-transform'] = val; - el.style['-o-transform'] = val; - } - }; - FileInput = function (element, options) { - var self = this; - self.$element = $(element); - self.$parent = self.$element.parent(); - if (!self._validate()) { - return; - } - self.isPreviewable = $h.hasFileAPISupport(); - self.isIE9 = $h.isIE(9); - self.isIE10 = $h.isIE(10); - if (self.isPreviewable || self.isIE9) { - self._init(options); - self._listen(); - } - self.$element.removeClass('file-loading'); - }; - //noinspection JSUnusedGlobalSymbols - FileInput.prototype = { - constructor: FileInput, - _cleanup: function () { - var self = this; - self.reader = null; - self.clearFileStack(); - self.fileBatchCompleted = true; - self.isError = false; - self.cancelling = false; - self.paused = false; - self.lastProgress = 0; - self._initAjax(); - }, - _initAjax: function () { - var self = this; - self.ajaxQueue = []; - self.ajaxRequests = []; - self.ajaxQueueIntervalId = null; - self.ajaxCurrentThreads = 0; - self.ajaxAborted = false; - }, - _init: function (options, refreshMode) { - var self = this, f, $el = self.$element, $cont, t, tmp; - self.options = options; - $.each(options, function (key, value) { - switch (key) { - case 'minFileCount': - case 'maxFileCount': - case 'minFileSize': - case 'maxFileSize': - case 'maxFilePreviewSize': - case 'resizeImageQuality': - case 'resizeIfSizeMoreThan': - case 'progressUploadThreshold': - case 'initialPreviewCount': - case 'zoomModalHeight': - case 'minImageHeight': - case 'maxImageHeight': - case 'minImageWidth': - case 'maxImageWidth': - self[key] = $h.getNum(value); - break; - default: - self[key] = value; - break; - } - }); - if (self.rtl) { // swap buttons for rtl - tmp = self.previewZoomButtonIcons.prev; - self.previewZoomButtonIcons.prev = self.previewZoomButtonIcons.next; - self.previewZoomButtonIcons.next = tmp; - } - // validate chunk threads to not exceed maxAjaxThreads - if (!isNaN(self.maxAjaxThreads) && self.maxAjaxThreads < self.resumableUploadOptions.maxThreads) { - self.resumableUploadOptions.maxThreads = self.maxAjaxThreads; - } - self._initFileManager(); - if (typeof self.autoOrientImage === 'function') { - self.autoOrientImage = self.autoOrientImage(); - } - if (typeof self.autoOrientImageInitial === 'function') { - self.autoOrientImageInitial = self.autoOrientImageInitial(); - } - if (!refreshMode) { - self._cleanup(); - } - self.$form = $el.closest('form'); - self._initTemplateDefaults(); - self.uploadFileAttr = !$h.isEmpty($el.attr('name')) ? $el.attr('name') : 'file_data'; - t = self._getLayoutTemplate('progress'); - self.progressTemplate = t.replace('{class}', self.progressClass); - self.progressInfoTemplate = t.replace('{class}', self.progressInfoClass); - self.progressPauseTemplate = t.replace('{class}', self.progressPauseClass); - self.progressCompleteTemplate = t.replace('{class}', self.progressCompleteClass); - self.progressErrorTemplate = t.replace('{class}', self.progressErrorClass); - self.isDisabled = $el.attr('disabled') || $el.attr('readonly'); - if (self.isDisabled) { - $el.attr('disabled', true); - } - self.isClickable = self.browseOnZoneClick && self.showPreview && - (self.dropZoneEnabled || !$h.isEmpty(self.defaultPreviewContent)); - self.isAjaxUpload = $h.hasFileUploadSupport() && !$h.isEmpty(self.uploadUrl); - self.dropZoneEnabled = $h.hasDragDropSupport() && self.dropZoneEnabled; - if (!self.isAjaxUpload) { - self.dropZoneEnabled = self.dropZoneEnabled && $h.canAssignFilesToInput(); - } - self.slug = typeof options.slugCallback === 'function' ? options.slugCallback : self._slugDefault; - self.mainTemplate = self.showCaption ? self._getLayoutTemplate('main1') : self._getLayoutTemplate('main2'); - self.captionTemplate = self._getLayoutTemplate('caption'); - self.previewGenericTemplate = self._getPreviewTemplate('generic'); - if (!self.imageCanvas && self.resizeImage && (self.maxImageWidth || self.maxImageHeight)) { - self.imageCanvas = document.createElement('canvas'); - self.imageCanvasContext = self.imageCanvas.getContext('2d'); - } - if ($h.isEmpty($el.attr('id'))) { - $el.attr('id', $h.uniqId()); - } - self.namespace = '.fileinput_' + $el.attr('id').replace(/-/g, '_'); - if (self.$container === undefined) { - self.$container = self._createContainer(); - } else { - self._refreshContainer(); - } - $cont = self.$container; - self.$dropZone = $cont.find('.file-drop-zone'); - self.$progress = $cont.find('.kv-upload-progress'); - self.$btnUpload = $cont.find('.fileinput-upload'); - self.$captionContainer = $h.getElement(options, 'elCaptionContainer', $cont.find('.file-caption')); - self.$caption = $h.getElement(options, 'elCaptionText', $cont.find('.file-caption-name')); - if (!$h.isEmpty(self.msgPlaceholder)) { - f = $el.attr('multiple') ? self.filePlural : self.fileSingle; - self.$caption.attr('placeholder', self.msgPlaceholder.replace('{files}', f)); - } - self.$captionIcon = self.$captionContainer.find('.file-caption-icon'); - self.$previewContainer = $h.getElement(options, 'elPreviewContainer', $cont.find('.file-preview')); - self.$preview = $h.getElement(options, 'elPreviewImage', $cont.find('.file-preview-thumbnails')); - self.$previewStatus = $h.getElement(options, 'elPreviewStatus', $cont.find('.file-preview-status')); - self.$errorContainer = $h.getElement(options, 'elErrorContainer', - self.$previewContainer.find('.kv-fileinput-error')); - self._validateDisabled(); - if (!$h.isEmpty(self.msgErrorClass)) { - $h.addCss(self.$errorContainer, self.msgErrorClass); - } - if (!refreshMode) { - self.$errorContainer.hide(); - self.previewInitId = 'preview-' + $h.uniqId(); - self._initPreviewCache(); - self._initPreview(true); - self._initPreviewActions(); - if (self.$parent.hasClass('file-loading')) { - self.$container.insertBefore(self.$parent); - self.$parent.remove(); - } - } else { - if (!self._errorsExist()) { - self.$errorContainer.hide(); - } - } - self._setFileDropZoneTitle(); - if ($el.attr('disabled')) { - self.disable(); - } - self._initZoom(); - if (self.hideThumbnailContent) { - $h.addCss(self.$preview, 'hide-content'); - } - }, - _initFileManager: function () { - var self = this; - self.fileManager = { - stack: {}, - processed: [], - errors: [], - loadedImages: {}, - totalImages: 0, - totalFiles: null, - totalSize: null, - uploadedSize: 0, - stats: {}, - initStats: function (id) { - var data = {started: $h.now().getTime()}; - if (id) { - self.fileManager.stats[id] = data; - } else { - self.fileManager.stats = data; - } - }, - getUploadStats: function (id, loaded, total) { - var fm = self.fileManager, started = id ? fm.stats[id] && fm.stats[id].started || null : null; - if (!started) { - started = $h.now().getTime(); - } - var elapsed = ($h.now().getTime() - started) / 1000, - speeds = ['B/s', 'KB/s', 'MB/s', 'GB/s', 'TB/s', 'PB/s', 'EB/s', 'ZB/s', 'YB/s'], - bps = elapsed ? loaded / elapsed : 0, bitrate = self._getSize(bps, speeds), - pendingBytes = total - loaded, - out = { - fileId: id, - started: started, - elapsed: elapsed, - loaded: loaded, - total: total, - bps: bps, - bitrate: bitrate, - pendingBytes: pendingBytes - }; - if (id) { - fm.stats[id] = out; - } else { - fm.stats = out; - } - return out; - }, - exists: function (id) { - return $.inArray(id, self.fileManager.getIdList()) !== -1; - }, - count: function () { - return self.fileManager.getIdList().length; - }, - total: function () { - var fm = self.fileManager; - if (!fm.totalFiles) { - fm.totalFiles = fm.count(); - } - return fm.totalFiles; - }, - getTotalSize: function () { - var fm = self.fileManager; - if (fm.totalSize) { - return fm.totalSize; - } - fm.totalSize = 0; - $.each(self.fileManager.stack, function (id, f) { - var size = parseFloat(f.size); - fm.totalSize += isNaN(size) ? 0 : size; - }); - return fm.totalSize; - }, - add: function (file, id) { - if (!id) { - id = self.fileManager.getId(file); - } - if (!id) { - return; - } - self.fileManager.stack[id] = { - file: file, - name: $h.getFileName(file), - relativePath: $h.getFileRelativePath(file), - size: file.size, - nameFmt: self._getFileName(file, ''), - sizeFmt: self._getSize(file.size) - }; - }, - remove: function ($thumb) { - var id = $thumb.attr('data-fileid'); - if (id) { - self.fileManager.removeFile(id); - } - }, - removeFile: function (id) { - delete self.fileManager.stack[id]; - delete self.fileManager.loadedImages[id]; - }, - move: function (idFrom, idTo) { - var result = {}, stack = self.fileManager.stack; - if (!idFrom && !idTo || idFrom === idTo) { - return; - } - $.each(stack, function (k, v) { - if (k !== idFrom) { - result[k] = v; - } - if (k === idTo) { - result[idFrom] = stack[idFrom]; - } - }); - self.fileManager.stack = result; - }, - list: function () { - var files = []; - $.each(self.fileManager.stack, function (k, v) { - if (v && v.file) { - files.push(v.file); - } - }); - return files; - }, - isPending: function (id) { - return $.inArray(id, self.fileManager.processed) === -1 && self.fileManager.exists(id); - }, - isProcessed: function () { - var processed = true, fm = self.fileManager; - $.each(fm.stack, function (id) { - if (fm.isPending(id)) { - processed = false; - } - }); - return processed; - }, - clear: function () { - var fm = self.fileManager; - fm.totalFiles = null; - fm.totalSize = null; - fm.uploadedSize = 0; - fm.stack = {}; - fm.errors = []; - fm.processed = []; - fm.stats = {}; - fm.clearImages(); - }, - clearImages: function () { - self.fileManager.loadedImages = {}; - self.fileManager.totalImages = 0; - }, - addImage: function (id, config) { - self.fileManager.loadedImages[id] = config; - }, - removeImage: function (id) { - delete self.fileManager.loadedImages[id]; - }, - getImageIdList: function () { - return Object.keys(self.fileManager.loadedImages); - }, - getImageCount: function () { - return self.fileManager.getImageIdList().length; - }, - getId: function (file) { - return self._getFileId(file); - }, - getIndex: function (id) { - return self.fileManager.getIdList().indexOf(id); - }, - getThumb: function (id) { - var $thumb = null; - self._getThumbs().each(function () { - if ($(this).attr('data-fileid') === id) { - $thumb = $(this); - } - }); - return $thumb; - }, - getThumbIndex: function ($thumb) { - var id = $thumb.attr('data-fileid'); - return self.fileManager.getIndex(id); - }, - getIdList: function () { - return Object.keys(self.fileManager.stack); - }, - getFile: function (id) { - return self.fileManager.stack[id] || null; - }, - getFileName: function (id, fmt) { - var file = self.fileManager.getFile(id); - if (!file) { - return ''; - } - return fmt ? (file.nameFmt || '') : file.name || ''; - }, - getFirstFile: function () { - var ids = self.fileManager.getIdList(), id = ids && ids.length ? ids[0] : null; - return self.fileManager.getFile(id); - }, - setFile: function (id, file) { - if (self.fileManager.getFile(id)) { - self.fileManager.stack[id].file = file; - } else { - self.fileManager.add(file, id); - } - }, - setProcessed: function (id) { - self.fileManager.processed.push(id); - }, - getProgress: function () { - var total = self.fileManager.total(), processed = self.fileManager.processed.length; - if (!total) { - return 0; - } - return Math.ceil(processed / total * 100); - - }, - setProgress: function (id, pct) { - var f = self.fileManager.getFile(id); - if (!isNaN(pct) && f) { - f.progress = pct; - } - } - }; - }, - _setUploadData: function (fd, config) { - var self = this; - $.each(config, function (key, value) { - var param = self.uploadParamNames[key] || key; - if ($h.isArray(value)) { - fd.append(param, value[0], value[1]); - } else { - fd.append(param, value); - } - }); - }, - _initResumableUpload: function () { - var self = this, opts = self.resumableUploadOptions, logs = $h.logMessages; - if (!self.enableResumableUpload) { - return; - } - if (opts.fallback !== false && typeof opts.fallback !== 'function') { - opts.fallback = function (s) { - s._log(logs.noResumableSupport); - s.enableResumableUpload = false; - }; - } - if (!$h.hasResumableUploadSupport() && opts.fallback !== false) { - opts.fallback(self); - return; - } - if (!self.uploadUrl && self.enableResumableUpload) { - self._log(logs.noUploadUrl); - self.enableResumableUpload = false; - return; - - } - opts.chunkSize = parseFloat(opts.chunkSize); - if (opts.chunkSize <= 0 || isNaN(opts.chunkSize)) { - self._log(logs.invalidChunkSize, {chunkSize: opts.chunkSize}); - self.enableResumableUpload = false; - return; - } - self.resumableManager = { - init: function (id, f, index) { - var rm = self.resumableManager, fm = self.fileManager; - rm.currThreads = 0; - rm.logs = []; - rm.stack = []; - rm.error = ''; - rm.chunkIntervalId = null; - rm.id = id; - rm.file = f.file; - rm.fileName = f.name; - rm.fileIndex = index; - rm.completed = false; - rm.testing = false; - rm.lastProgress = 0; - if (self.showPreview) { - rm.$thumb = fm.getThumb(id) || null; - rm.$progress = rm.$btnDelete = null; - if (rm.$thumb && rm.$thumb.length) { - rm.$progress = rm.$thumb.find('.file-thumb-progress'); - rm.$btnDelete = rm.$thumb.find('.kv-file-remove'); - } - } - rm.chunkSize = self.resumableUploadOptions.chunkSize * 1024; - rm.chunkCount = rm.getTotalChunks(); - }, - logAjaxError: function (jqXHR, textStatus, errorThrown) { - if (self.resumableUploadOptions.showErrorLog) { - self._log(logs.ajaxError, { - status: jqXHR.status, - error: errorThrown, - text: jqXHR.responseText || '' - }); - } - }, - reset: function () { - var rm = self.resumableManager; - rm.processed = {}; - }, - setProcessed: function (status) { - var rm = self.resumableManager, fm = self.fileManager, id = rm.id, msg, - $thumb = rm.$thumb, $prog = rm.$progress, hasThumb = $thumb && $thumb.length, - params = {id: hasThumb ? $thumb.attr('id') : '', index: fm.getIndex(id), fileId: id}; - rm.completed = true; - rm.lastProgress = 0; - fm.uploadedSize += rm.file.size; - if (hasThumb) { - $thumb.removeClass('file-uploading'); - } - if (status === 'success') { - if (self.showPreview) { - self._setProgress(101, $prog); - self._setThumbStatus($thumb, 'Success'); - self._initUploadSuccess(rm.processed[id].data, $thumb); - } - self.fileManager.removeFile(id); - delete rm.processed[id]; - self._raise('fileuploaded', [params.id, params.index, params.fileId]); - if (fm.isProcessed()) { - self._setProgress(101); - } - } else { - if (self.showPreview) { - self._setThumbStatus($thumb, 'Error'); - self._setPreviewError($thumb, true); - self._setProgress(101, $prog, self.msgProgressError); - self._setProgress(101, self.$progress, self.msgProgressError); - self.cancelling = true; - } - if (!self.$errorContainer.find('li[data-file-id="' + params.fileId + '"]').length) { - msg = self.msgResumableUploadRetriesExceeded.setTokens({ - file: rm.fileName, - max: self.resumableUploadOptions.maxRetries, - error: rm.error - }); - self._showFileError(msg, params); - } - } - if (fm.isProcessed()) { - rm.reset(); - } - }, - check: function () { - var rm = self.resumableManager, status = true; - $.each(rm.logs, function (index, value) { - if (!value) { - status = false; - return false; - } - }); - if (status) { - clearInterval(rm.chunkIntervalId); - rm.setProcessed('success'); - } - }, - processedResumables: function () { - var logs = self.resumableManager.logs, i, count = 0; - if (!logs || !logs.length) { - return 0; - } - for (i = 0; i < logs.length; i++) { - if (logs[i] === true) { - count++; - } - } - return count; - }, - getUploadedSize: function () { - var rm = self.resumableManager, size = rm.processedResumables() * rm.chunkSize; - return size > rm.file.size ? rm.file.size : size; - }, - getTotalChunks: function () { - var rm = self.resumableManager, chunkSize = parseFloat(rm.chunkSize); - if (!isNaN(chunkSize) && chunkSize > 0) { - return Math.ceil(rm.file.size / chunkSize); - } - return 0; - }, - getProgress: function () { - var rm = self.resumableManager, processed = rm.processedResumables(), total = rm.chunkCount; - if (total === 0) { - return 0; - } - return Math.ceil(processed / total * 100); - }, - checkAborted: function (intervalId) { - if (self.paused || self.cancelling) { - clearInterval(intervalId); - self.unlock(); - } - }, - upload: function () { - var rm = self.resumableManager, fm = self.fileManager, ids = fm.getIdList(), flag = 'new', - intervalId; - intervalId = setInterval(function () { - var id; - rm.checkAborted(intervalId); - if (flag === 'new') { - self.lock(); - flag = 'processing'; - id = ids.shift(); - fm.initStats(id); - if (fm.stack[id]) { - rm.init(id, fm.stack[id], fm.getIndex(id)); - rm.testUpload(); - rm.uploadResumable(); - } - } - if (!fm.isPending(id) && rm.completed) { - flag = 'new'; - } - if (fm.isProcessed()) { - var $initThumbs = self.$preview.find('.file-preview-initial'); - if ($initThumbs.length) { - $h.addCss($initThumbs, $h.SORT_CSS); - self._initSortable(); - } - clearInterval(intervalId); - self._clearFileInput(); - self.unlock(); - setTimeout(function () { - var data = self.previewCache.data; - if (data) { - self.initialPreview = data.content; - self.initialPreviewConfig = data.config; - self.initialPreviewThumbTags = data.tags; - } - self._raise('filebatchuploadcomplete', [ - self.initialPreview, - self.initialPreviewConfig, - self.initialPreviewThumbTags, - self._getExtraData() - ]); - }, self.processDelay); - } - }, self.processDelay); - }, - uploadResumable: function () { - var i, rm = self.resumableManager, total = rm.chunkCount; - for (i = 0; i < total; i++) { - rm.logs[i] = !!(rm.processed[rm.id] && rm.processed[rm.id][i]); - } - for (i = 0; i < total; i++) { - rm.pushAjax(i, 0); - } - rm.chunkIntervalId = setInterval(rm.loopAjax, self.queueDelay); - }, - testUpload: function () { - var rm = self.resumableManager, opts = self.resumableUploadOptions, fd, f, - fm = self.fileManager, id = rm.id, fnBefore, fnSuccess, fnError, fnComplete, outData; - if (!opts.testUrl) { - rm.testing = false; - return; - } - rm.testing = true; - fd = new FormData(); - f = fm.stack[id]; - self._setUploadData(fd, { - fileId: id, - fileName: f.fileName, - fileSize: f.size, - fileRelativePath: f.relativePath, - chunkSize: rm.chunkSize, - chunkCount: rm.chunkCount - }); - fnBefore = function (jqXHR) { - outData = self._getOutData(fd, jqXHR); - self._raise('filetestbeforesend', [id, fm, rm, outData]); - }; - fnSuccess = function (data, textStatus, jqXHR) { - outData = self._getOutData(fd, jqXHR, data); - var pNames = self.uploadParamNames, chunksUploaded = pNames.chunksUploaded || 'chunksUploaded', - params = [id, fm, rm, outData]; - if (!data[chunksUploaded] || !$h.isArray(data[chunksUploaded])) { - self._raise('filetesterror', params); - } else { - if (!rm.processed[id]) { - rm.processed[id] = {}; - } - $.each(data[chunksUploaded], function (key, index) { - rm.logs[index] = true; - rm.processed[id][index] = true; - }); - rm.processed[id].data = data; - self._raise('filetestsuccess', params); - } - rm.testing = false; - }; - fnError = function (jqXHR, textStatus, errorThrown) { - outData = self._getOutData(fd, jqXHR); - self._raise('filetestajaxerror', [id, fm, rm, outData]); - rm.logAjaxError(jqXHR, textStatus, errorThrown); - rm.testing = false; - }; - fnComplete = function () { - self._raise('filetestcomplete', [id, fm, rm, self._getOutData(fd)]); - rm.testing = false; - }; - self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, fd, id, rm.fileIndex, opts.testUrl); - }, - pushAjax: function (index, retry) { - self.resumableManager.stack.push([index, retry]); - }, - sendAjax: function (index, retry) { - var fm = self.fileManager, rm = self.resumableManager, opts = self.resumableUploadOptions, f, - chunkSize = rm.chunkSize, id = rm.id, file = rm.file, $thumb = rm.$thumb, - $btnDelete = rm.$btnDelete; - if (rm.processed[id] && rm.processed[id][index]) { - return; - } - rm.currThreads++; - if (retry > opts.maxRetries) { - rm.setProcessed('error'); - return; - } - var fd, outData, fnBefore, fnSuccess, fnError, fnComplete, slice = file.slice ? 'slice' : - (file.mozSlice ? 'mozSlice' : (file.webkitSlice ? 'webkitSlice' : 'slice')), - blob = file[slice](chunkSize * index, chunkSize * (index + 1)); - fd = new FormData(); - f = fm.stack[id]; - self._setUploadData(fd, { - chunkCount: rm.chunkCount, - chunkIndex: index, - chunkSize: chunkSize, - chunkSizeStart: chunkSize * index, - fileBlob: [blob, rm.fileName], - fileId: id, - fileName: rm.fileName, - fileRelativePath: f.relativePath, - fileSize: file.size, - retryCount: retry - }); - if (rm.$progress && rm.$progress.length) { - rm.$progress.show(); - } - fnBefore = function (jqXHR) { - outData = self._getOutData(fd, jqXHR); - if (self.showPreview) { - if (!$thumb.hasClass('file-preview-success')) { - self._setThumbStatus($thumb, 'Loading'); - $h.addCss($thumb, 'file-uploading'); - } - $btnDelete.attr('disabled', true); - } - self._raise('filechunkbeforesend', [id, index, retry, fm, rm, outData]); - }; - fnSuccess = function (data, textStatus, jqXHR) { - outData = self._getOutData(fd, jqXHR, data); - var paramNames = self.uploadParamNames, chunkIndex = paramNames.chunkIndex || 'chunkIndex', - opts = self.resumableUploadOptions, params = [id, index, retry, fm, rm, outData]; - rm.currThreads--; - if (data.error) { - if (opts.showErrorLog) { - self._log(logs.retryStatus, { - retry: retry + 1, - filename: rm.fileName, - chunk: index - }); - } - rm.pushAjax(index, retry + 1); - rm.error = data.error; - self._raise('filechunkerror', params); - } else { - rm.logs[data[chunkIndex]] = true; - if (!rm.processed[id]) { - rm.processed[id] = {}; - } - rm.processed[id][data[chunkIndex]] = true; - rm.processed[id].data = data; - self._raise('filechunksuccess', params); - rm.check(); - } - }; - fnError = function (jqXHR, textStatus, errorThrown) { - outData = self._getOutData(fd, jqXHR); - rm.currThreads--; - rm.error = errorThrown; - rm.logAjaxError(jqXHR, textStatus, errorThrown); - self._raise('filechunkajaxerror', [id, index, retry, fm, rm, outData]); - rm.pushAjax(index, retry + 1); - }; - fnComplete = function () { - self._raise('filechunkcomplete', [id, index, retry, fm, rm, self._getOutData(fd)]); - }; - self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, fd, id, rm.fileIndex); - }, - loopAjax: function () { - var rm = self.resumableManager; - if (rm.currThreads < self.resumableUploadOptions.maxThreads && !rm.testing) { - var arr = rm.stack.shift(), index; - if (typeof arr !== 'undefined') { - index = arr[0]; - if (!rm.processed[rm.id] || !rm.processed[rm.id][index]) { - rm.sendAjax(index, arr[1]); - } else { - if (rm.processedResumables() >= rm.getTotalChunks()) { - rm.setProcessed('success'); - clearInterval(rm.chunkIntervalId); - } - } - } - } - } - }; - self.resumableManager.reset(); - }, - _initTemplateDefaults: function () { - var self = this, tMain1, tMain2, tPreview, tFileIcon, tClose, tCaption, tBtnDefault, tBtnLink, tBtnBrowse, - tModalMain, tModal, tProgress, tSize, tFooter, tActions, tActionDelete, tActionUpload, tActionDownload, - tActionZoom, tActionDrag, tIndicator, tTagBef, tTagBef1, tTagBef2, tTagAft, tGeneric, tHtml, tImage, - tText, tOffice, tGdocs, tVideo, tAudio, tFlash, tObject, tPdf, tOther, tStyle, tZoomCache, vDefaultDim, - tStats; - tMain1 = '{preview}\n' + - '
\n' + - '
\n' + - ' {caption}\n' + - '
\n' + - ' {remove}\n' + - ' {cancel}\n' + - ' {pause}\n' + - ' {upload}\n' + - ' {browse}\n' + - '
\n' + - '
'; - tMain2 = '{preview}\n
\n
\n' + - '{remove}\n{cancel}\n{upload}\n{browse}\n'; - tPreview = '
\n' + - ' {close}' + - '
\n' + - '
\n' + - '
\n' + - '
' + - '
\n' + - '
\n' + - '
\n' + - '
'; - tClose = $h.closeButton('fileinput-remove'); - tFileIcon = ''; - // noinspection HtmlUnknownAttribute - tCaption = '
\n' + - ' \n' + - ' \n' + - '
'; - //noinspection HtmlUnknownAttribute - tBtnDefault = ''; - //noinspection HtmlUnknownAttribute - tBtnLink = '{icon} {label}'; - //noinspection HtmlUnknownAttribute - tBtnBrowse = '
{icon} {label}
'; - tModalMain = ''; - tModal = '\n'; - tProgress = '
\n' + - '
\n' + - ' {status}\n' + - '
\n' + - '
{stats}'; - tStats = '
' + - '{pendingTime} ' + - '{uploadSpeed}' + - '
'; - tSize = ' ({sizeText})'; - tFooter = ''; - tActions = '
\n' + - ' \n' + - '
\n' + - '{drag}\n' + - '
'; - //noinspection HtmlUnknownAttribute - tActionDelete = '\n'; - tActionUpload = ''; - tActionDownload = '{downloadIcon}'; - tActionZoom = ''; - tActionDrag = '{dragIcon}'; - tIndicator = '
{indicator}
'; - tTagBef = '
\n'; - tTagBef2 = tTagBef + ' title="{caption}">
\n'; - tTagAft = '
{footer}\n
\n'; - tGeneric = '{content}\n'; - tStyle = ' {style}'; - tHtml = '
{data}
\n'; - tImage = '\n'; - tText = '\n'; - tOffice = ''; - tGdocs = ''; - tVideo = '\n'; - tAudio = '\n'; - tFlash = '\n'; - tPdf = '\n'; - tObject = '\n' + '\n' + - $h.OBJECT_PARAMS + ' ' + $h.DEFAULT_PREVIEW + '\n\n'; - tOther = '
\n' + $h.DEFAULT_PREVIEW + '\n
\n'; - tZoomCache = ''; - vDefaultDim = {width: '100%', height: '100%', 'min-height': '480px'}; - if (self._isPdfRendered()) { - tPdf = self.pdfRendererTemplate.replace('{renderer}', self._encodeURI(self.pdfRendererUrl)); - } - self.defaults = { - layoutTemplates: { - main1: tMain1, - main2: tMain2, - preview: tPreview, - close: tClose, - fileIcon: tFileIcon, - caption: tCaption, - modalMain: tModalMain, - modal: tModal, - progress: tProgress, - stats: tStats, - size: tSize, - footer: tFooter, - indicator: tIndicator, - actions: tActions, - actionDelete: tActionDelete, - actionUpload: tActionUpload, - actionDownload: tActionDownload, - actionZoom: tActionZoom, - actionDrag: tActionDrag, - btnDefault: tBtnDefault, - btnLink: tBtnLink, - btnBrowse: tBtnBrowse, - zoomCache: tZoomCache - }, - previewMarkupTags: { - tagBefore1: tTagBef1, - tagBefore2: tTagBef2, - tagAfter: tTagAft - }, - previewContentTemplates: { - generic: tGeneric, - html: tHtml, - image: tImage, - text: tText, - office: tOffice, - gdocs: tGdocs, - video: tVideo, - audio: tAudio, - flash: tFlash, - object: tObject, - pdf: tPdf, - other: tOther - }, - allowedPreviewTypes: ['image', 'html', 'text', 'video', 'audio', 'flash', 'pdf', 'object'], - previewTemplates: {}, - previewSettings: { - image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'}, - html: {width: '213px', height: '160px'}, - text: {width: '213px', height: '160px'}, - office: {width: '213px', height: '160px'}, - gdocs: {width: '213px', height: '160px'}, - video: {width: '213px', height: '160px'}, - audio: {width: '100%', height: '30px'}, - flash: {width: '213px', height: '160px'}, - object: {width: '213px', height: '160px'}, - pdf: {width: '100%', height: '160px'}, - other: {width: '213px', height: '160px'} - }, - previewSettingsSmall: { - image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'}, - html: {width: '100%', height: '160px'}, - text: {width: '100%', height: '160px'}, - office: {width: '100%', height: '160px'}, - gdocs: {width: '100%', height: '160px'}, - video: {width: '100%', height: 'auto'}, - audio: {width: '100%', height: '30px'}, - flash: {width: '100%', height: 'auto'}, - object: {width: '100%', height: 'auto'}, - pdf: {width: '100%', height: '160px'}, - other: {width: '100%', height: '160px'} - }, - previewZoomSettings: { - image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'}, - html: vDefaultDim, - text: vDefaultDim, - office: {width: '100%', height: '100%', 'max-width': '100%', 'min-height': '480px'}, - gdocs: {width: '100%', height: '100%', 'max-width': '100%', 'min-height': '480px'}, - video: {width: 'auto', height: '100%', 'max-width': '100%'}, - audio: {width: '100%', height: '30px'}, - flash: {width: 'auto', height: '480px'}, - object: {width: 'auto', height: '100%', 'max-width': '100%', 'min-height': '480px'}, - pdf: vDefaultDim, - other: {width: 'auto', height: '100%', 'min-height': '480px'} - }, - mimeTypeAliases: { - 'video/quicktime': 'video/mp4' - }, - fileTypeSettings: { - image: function (vType, vName) { - return ($h.compare(vType, 'image.*') && !$h.compare(vType, /(tiff?|wmf)$/i) || - $h.compare(vName, /\.(gif|png|jpe?g)$/i)); - }, - html: function (vType, vName) { - return $h.compare(vType, 'text/html') || $h.compare(vName, /\.(htm|html)$/i); - }, - office: function (vType, vName) { - return $h.compare(vType, /(word|excel|powerpoint|office)$/i) || - $h.compare(vName, /\.(docx?|xlsx?|pptx?|pps|potx?)$/i); - }, - gdocs: function (vType, vName) { - return $h.compare(vType, /(word|excel|powerpoint|office|iwork-pages|tiff?)$/i) || - $h.compare(vName, - /\.(docx?|xlsx?|pptx?|pps|potx?|rtf|ods|odt|pages|ai|dxf|ttf|tiff?|wmf|e?ps)$/i); - }, - text: function (vType, vName) { - return $h.compare(vType, 'text.*') || $h.compare(vName, /\.(xml|javascript)$/i) || - $h.compare(vName, /\.(txt|md|csv|nfo|ini|json|php|js|css)$/i); - }, - video: function (vType, vName) { - return $h.compare(vType, 'video.*') && ($h.compare(vType, /(ogg|mp4|mp?g|mov|webm|3gp)$/i) || - $h.compare(vName, /\.(og?|mp4|webm|mp?g|mov|3gp)$/i)); - }, - audio: function (vType, vName) { - return $h.compare(vType, 'audio.*') && ($h.compare(vName, /(ogg|mp3|mp?g|wav)$/i) || - $h.compare(vName, /\.(og?|mp3|mp?g|wav)$/i)); - }, - flash: function (vType, vName) { - return $h.compare(vType, 'application/x-shockwave-flash', true) || $h.compare(vName, - /\.(swf)$/i); - }, - pdf: function (vType, vName) { - return $h.compare(vType, 'application/pdf', true) || $h.compare(vName, /\.(pdf)$/i); - }, - object: function () { - return true; - }, - other: function () { - return true; - } - }, - fileActionSettings: { - showRemove: true, - showUpload: true, - showDownload: true, - showZoom: true, - showDrag: true, - removeIcon: '', - removeClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary', - removeErrorClass: 'btn btn-sm btn-kv btn-danger', - removeTitle: 'Remove file', - uploadIcon: '', - uploadClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary', - uploadTitle: 'Upload file', - uploadRetryIcon: '', - uploadRetryTitle: 'Retry upload', - downloadIcon: '', - downloadClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary', - downloadTitle: 'Download file', - zoomIcon: '', - zoomClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary', - zoomTitle: 'View Details', - dragIcon: '', - dragClass: 'text-info', - dragTitle: 'Move / Rearrange', - dragSettings: {}, - indicatorNew: '', - indicatorSuccess: '', - indicatorError: '', - indicatorLoading: '', - indicatorPaused: '', - indicatorNewTitle: 'Not uploaded yet', - indicatorSuccessTitle: 'Uploaded', - indicatorErrorTitle: 'Upload Error', - indicatorLoadingTitle: 'Uploading ...', - indicatorPausedTitle: 'Upload Paused' - } - }; - $.each(self.defaults, function (key, setting) { - if (key === 'allowedPreviewTypes') { - if (self.allowedPreviewTypes === undefined) { - self.allowedPreviewTypes = setting; - } - return; - } - self[key] = $.extend(true, {}, setting, self[key]); - }); - self._initPreviewTemplates(); - }, - _initPreviewTemplates: function () { - var self = this, tags = self.previewMarkupTags, tagBef, tagAft = tags.tagAfter; - $.each(self.previewContentTemplates, function (key, value) { - if ($h.isEmpty(self.previewTemplates[key])) { - tagBef = tags.tagBefore2; - if (key === 'generic' || key === 'image' || key === 'html' || key === 'text') { - tagBef = tags.tagBefore1; - } - if (self._isPdfRendered() && key === 'pdf') { - tagBef = tagBef.replace('kv-file-content', 'kv-file-content kv-pdf-rendered'); - } - self.previewTemplates[key] = tagBef + value + tagAft; - } - }); - }, - _initPreviewCache: function () { - var self = this; - self.previewCache = { - data: {}, - init: function () { - var content = self.initialPreview; - if (content.length > 0 && !$h.isArray(content)) { - content = content.split(self.initialPreviewDelimiter); - } - self.previewCache.data = { - content: content, - config: self.initialPreviewConfig, - tags: self.initialPreviewThumbTags - }; - }, - count: function (skipNull) { - if (!self.previewCache.data || !self.previewCache.data.content) { - return 0; - } - if (skipNull) { - var chk = self.previewCache.data.content.filter(function (n) { - return n !== null; - }); - return chk.length; - } - return self.previewCache.data.content.length; - }, - get: function (i, isDisabled) { - var ind = 'init_' + i, data = self.previewCache.data, config = data.config[i], fileId, - content = data.content[i], previewId = self.previewInitId + '-' + ind, out, $tmp, cat, ftr, - fname, ftype, frameClass, asData = $h.ifSet('previewAsData', config, self.initialPreviewAsData), - a = config ? {title: config.title || null, alt: config.alt || null} : {title: null, alt: null}, - parseTemplate = function (cat, dat, fn, ft, id, ftr, ind, fc, t) { - fc = ' file-preview-initial ' + $h.SORT_CSS + (fc ? ' ' + fc : ''); - /** @namespace config.zoomData */ - fileId = config && config.fileId || 'file_' + id; - return self._generatePreviewTemplate(cat, dat, fn, ft, id, fileId, false, null, fc, - ftr, ind, t, a, config && config.zoomData || dat); - }; - if (!content || !content.length) { - return ''; - } - isDisabled = isDisabled === undefined ? true : isDisabled; - cat = $h.ifSet('type', config, self.initialPreviewFileType || 'generic'); - fname = $h.ifSet('filename', config, $h.ifSet('caption', config)); - ftype = $h.ifSet('filetype', config, cat); - ftr = self.previewCache.footer(i, isDisabled, (config && config.size || null)); - frameClass = $h.ifSet('frameClass', config); - if (asData) { - out = parseTemplate(cat, content, fname, ftype, previewId, ftr, ind, frameClass); - } else { - out = parseTemplate('generic', content, fname, ftype, previewId, ftr, ind, frameClass, cat) - .setTokens({'content': data.content[i]}); - } - if (data.tags.length && data.tags[i]) { - out = $h.replaceTags(out, data.tags[i]); - } - /** @namespace config.frameAttr */ - if (!$h.isEmpty(config) && !$h.isEmpty(config.frameAttr)) { - $tmp = $(document.createElement('div')).html(out); - $tmp.find('.file-preview-initial').attr(config.frameAttr); - out = $tmp.html(); - $tmp.remove(); - } - return out; - }, - clean: function (data) { - data.content = $h.cleanArray(data.content); - data.config = $h.cleanArray(data.config); - data.tags = $h.cleanArray(data.tags); - self.previewCache.data = data; - }, - add: function (content, config, tags, append) { - var data = self.previewCache.data, index = content.length - 1; - if (!content || !content.length) { - return index; - } - if (!$h.isArray(content)) { - content = content.split(self.initialPreviewDelimiter); - } - if (append) { - index = data.content.push(content[0]) - 1; - data.config[index] = config; - data.tags[index] = tags; - } else { - data.content = content; - data.config = config; - data.tags = tags; - } - self.previewCache.clean(data); - return index; - }, - set: function (content, config, tags, append) { - var data = self.previewCache.data, i, chk; - if (!content || !content.length) { - return; - } - if (!$h.isArray(content)) { - content = content.split(self.initialPreviewDelimiter); - } - chk = content.filter(function (n) { - return n !== null; - }); - if (!chk.length) { - return; - } - if (data.content === undefined) { - data.content = []; - } - if (data.config === undefined) { - data.config = []; - } - if (data.tags === undefined) { - data.tags = []; - } - if (append) { - for (i = 0; i < content.length; i++) { - if (content[i]) { - data.content.push(content[i]); - } - } - for (i = 0; i < config.length; i++) { - if (config[i]) { - data.config.push(config[i]); - } - } - for (i = 0; i < tags.length; i++) { - if (tags[i]) { - data.tags.push(tags[i]); - } - } - } else { - data.content = content; - data.config = config; - data.tags = tags; - } - self.previewCache.clean(data); - }, - unset: function (index) { - var chk = self.previewCache.count(), rev = self.reversePreviewOrder; - if (!chk) { - return; - } - if (chk === 1) { - self.previewCache.data.content = []; - self.previewCache.data.config = []; - self.previewCache.data.tags = []; - self.initialPreview = []; - self.initialPreviewConfig = []; - self.initialPreviewThumbTags = []; - return; - } - self.previewCache.data.content = $h.spliceArray(self.previewCache.data.content, index, rev); - self.previewCache.data.config = $h.spliceArray(self.previewCache.data.config, index, rev); - self.previewCache.data.tags = $h.spliceArray(self.previewCache.data.tags, index, rev); - var data = $.extend(true, {}, self.previewCache.data); - self.previewCache.clean(data); - }, - out: function () { - var html = '', caption, len = self.previewCache.count(), i, content; - if (len === 0) { - return {content: '', caption: ''}; - } - for (i = 0; i < len; i++) { - content = self.previewCache.get(i); - html = self.reversePreviewOrder ? (content + html) : (html + content); - } - caption = self._getMsgSelected(len); - return {content: html, caption: caption}; - }, - footer: function (i, isDisabled, size) { - var data = self.previewCache.data || {}; - if ($h.isEmpty(data.content)) { - return ''; - } - if ($h.isEmpty(data.config) || $h.isEmpty(data.config[i])) { - data.config[i] = {}; - } - isDisabled = isDisabled === undefined ? true : isDisabled; - var config = data.config[i], caption = $h.ifSet('caption', config), a, - width = $h.ifSet('width', config, 'auto'), url = $h.ifSet('url', config, false), - key = $h.ifSet('key', config, null), fileId = $h.ifSet('fileId', config, null), - fs = self.fileActionSettings, initPreviewShowDel = self.initialPreviewShowDelete || false, - downloadInitialUrl = !self.initialPreviewDownloadUrl ? '' : - self.initialPreviewDownloadUrl + '?key=' + key + (fileId ? '&fileId=' + fileId : ''), - dUrl = config.downloadUrl || downloadInitialUrl, - dFil = config.filename || config.caption || '', - initPreviewShowDwl = !!(dUrl), - sDel = $h.ifSet('showRemove', config, $h.ifSet('showRemove', fs, initPreviewShowDel)), - sDwl = $h.ifSet('showDownload', config, $h.ifSet('showDownload', fs, initPreviewShowDwl)), - sZm = $h.ifSet('showZoom', config, $h.ifSet('showZoom', fs, true)), - sDrg = $h.ifSet('showDrag', config, $h.ifSet('showDrag', fs, true)), - dis = (url === false) && isDisabled; - sDwl = sDwl && config.downloadUrl !== false && !!dUrl; - a = self._renderFileActions(config, false, sDwl, sDel, sZm, sDrg, dis, url, key, true, dUrl, dFil); - return self._getLayoutTemplate('footer').setTokens({ - 'progress': self._renderThumbProgress(), - 'actions': a, - 'caption': caption, - 'size': self._getSize(size), - 'width': width, - 'indicator': '' - }); - } - }; - self.previewCache.init(); - }, - _isPdfRendered: function () { - var self = this, useLib = self.usePdfRenderer, - flag = typeof useLib === 'function' ? useLib() : !!useLib; - return flag && self.pdfRendererUrl; - }, - _handler: function ($el, event, callback) { - var self = this, ns = self.namespace, ev = event.split(' ').join(ns + ' ') + ns; - if (!$el || !$el.length) { - return; - } - $el.off(ev).on(ev, callback); - }, - _encodeURI: function (vUrl) { - var self = this; - return self.encodeUrl ? encodeURI(vUrl) : vUrl; - }, - _log: function (msg, tokens) { - var self = this, id = self.$element.attr('id'); - if (id) { - msg = '"' + id + '": ' + msg; - } - msg = 'bootstrap-fileinput: ' + msg; - if (typeof tokens === 'object') { - msg.setTokens(tokens); - } - if (typeof window.console.log !== 'undefined') { - window.console.log(msg); - } else { - window.alert(msg); - } - }, - _validate: function () { - var self = this, status = self.$element.attr('type') === 'file'; - if (!status) { - self._log($h.logMessages.badInputType); - } - return status; - }, - _errorsExist: function () { - var self = this, $err, $errList = self.$errorContainer.find('li'); - if ($errList.length) { - return true; - } - $err = $(document.createElement('div')).html(self.$errorContainer.html()); - $err.find('.kv-error-close').remove(); - $err.find('ul').remove(); - return !!$.trim($err.text()).length; - }, - _errorHandler: function (evt, caption) { - var self = this, err = evt.target.error, showError = function (msg) { - self._showError(msg.replace('{name}', caption)); - }; - /** @namespace err.NOT_FOUND_ERR */ - /** @namespace err.SECURITY_ERR */ - /** @namespace err.NOT_READABLE_ERR */ - if (err.code === err.NOT_FOUND_ERR) { - showError(self.msgFileNotFound); - } else { - if (err.code === err.SECURITY_ERR) { - showError(self.msgFileSecured); - } else { - if (err.code === err.NOT_READABLE_ERR) { - showError(self.msgFileNotReadable); - } else { - if (err.code === err.ABORT_ERR) { - showError(self.msgFilePreviewAborted); - } else { - showError(self.msgFilePreviewError); - } - } - } - } - }, - _addError: function (msg) { - var self = this, $error = self.$errorContainer; - if (msg && $error.length) { - $error.html(self.errorCloseButton + msg); - self._handler($error.find('.kv-error-close'), 'click', function () { - setTimeout(function () { - if (self.showPreview && !self.getFrames().length) { - self.clear(); - } - $error.fadeOut('slow'); - }, self.processDelay); - }); - } - }, - _setValidationError: function (css) { - var self = this; - css = (css ? css + ' ' : '') + 'has-error'; - self.$container.removeClass(css).addClass('has-error'); - $h.addCss(self.$captionContainer, 'is-invalid'); - }, - _resetErrors: function (fade) { - var self = this, $error = self.$errorContainer; - self.isError = false; - self.$container.removeClass('has-error'); - self.$captionContainer.removeClass('is-invalid'); - $error.html(''); - if (fade) { - $error.fadeOut('slow'); - } else { - $error.hide(); - } - }, - _showFolderError: function (folders) { - var self = this, $error = self.$errorContainer, msg; - if (!folders) { - return; - } - if (!self.isAjaxUpload) { - self._clearFileInput(); - } - msg = self.msgFoldersNotAllowed.replace('{n}', folders); - self._addError(msg); - self._setValidationError(); - $error.fadeIn(800); - self._raise('filefoldererror', [folders, msg]); - }, - _showFileError: function (msg, params, event) { - var self = this, $error = self.$errorContainer, ev = event || 'fileuploaderror', - fId = params && params.fileId || '', e = params && params.id ? - '
  • ' + msg + '
  • ' : '
  • ' + msg + '
  • '; - if ($error.find('ul').length === 0) { - self._addError('
      ' + e + '
    '); - } else { - $error.find('ul').append(e); - } - $error.fadeIn(800); - self._raise(ev, [params, msg]); - self._setValidationError('file-input-new'); - return true; - }, - _showError: function (msg, params, event) { - var self = this, $error = self.$errorContainer, ev = event || 'fileerror'; - params = params || {}; - params.reader = self.reader; - self._addError(msg); - $error.fadeIn(800); - self._raise(ev, [params, msg]); - if (!self.isAjaxUpload) { - self._clearFileInput(); - } - self._setValidationError('file-input-new'); - self.$btnUpload.attr('disabled', true); - return true; - }, - _noFilesError: function (params) { - var self = this, label = self.minFileCount > 1 ? self.filePlural : self.fileSingle, - msg = self.msgFilesTooLess.replace('{n}', self.minFileCount).replace('{files}', label), - $error = self.$errorContainer; - self._addError(msg); - self.isError = true; - self._updateFileDetails(0); - $error.fadeIn(800); - self._raise('fileerror', [params, msg]); - self._clearFileInput(); - self._setValidationError(); - }, - _parseError: function (operation, jqXHR, errorThrown, fileName) { - /** @namespace jqXHR.responseJSON */ - var self = this, errMsg = $.trim(errorThrown + ''), textPre, - text = jqXHR.responseJSON !== undefined && jqXHR.responseJSON.error !== undefined ? - jqXHR.responseJSON.error : jqXHR.responseText; - if (self.cancelling && self.msgUploadAborted) { - errMsg = self.msgUploadAborted; - } - if (self.showAjaxErrorDetails && text) { - text = $.trim(text.replace(/\n\s*\n/g, '\n')); - textPre = text.length ? '
    ' + text + '
    ' : ''; - errMsg += errMsg ? textPre : text; - } - if (!errMsg) { - errMsg = self.msgAjaxError.replace('{operation}', operation); - } - self.cancelling = false; - return fileName ? '' + fileName + ': ' + errMsg : errMsg; - }, - _parseFileType: function (type, name) { - var self = this, isValid, vType, cat, i, types = self.allowedPreviewTypes || []; - if (type === 'application/text-plain') { - return 'text'; - } - for (i = 0; i < types.length; i++) { - cat = types[i]; - isValid = self.fileTypeSettings[cat]; - vType = isValid(type, name) ? cat : ''; - if (!$h.isEmpty(vType)) { - return vType; - } - } - return 'other'; - }, - _getPreviewIcon: function (fname) { - var self = this, ext, out = null; - if (fname && fname.indexOf('.') > -1) { - ext = fname.split('.').pop(); - if (self.previewFileIconSettings) { - out = self.previewFileIconSettings[ext] || self.previewFileIconSettings[ext.toLowerCase()] || null; - } - if (self.previewFileExtSettings) { - $.each(self.previewFileExtSettings, function (key, func) { - if (self.previewFileIconSettings[key] && func(ext)) { - out = self.previewFileIconSettings[key]; - //noinspection UnnecessaryReturnStatementJS - return; - } - }); - } - } - return out; - }, - _parseFilePreviewIcon: function (content, fname) { - var self = this, icn = self._getPreviewIcon(fname) || self.previewFileIcon, out = content; - if (out.indexOf('{previewFileIcon}') > -1) { - out = out.setTokens({'previewFileIconClass': self.previewFileIconClass, 'previewFileIcon': icn}); - } - return out; - }, - _raise: function (event, params) { - var self = this, e = $.Event(event); - if (params !== undefined) { - self.$element.trigger(e, params); - } else { - self.$element.trigger(e); - } - if (e.isDefaultPrevented() || e.result === false) { - return false; - } - switch (event) { - // ignore these events - case 'filebatchuploadcomplete': - case 'filebatchuploadsuccess': - case 'fileuploaded': - case 'fileclear': - case 'filecleared': - case 'filereset': - case 'fileerror': - case 'filefoldererror': - case 'fileuploaderror': - case 'filebatchuploaderror': - case 'filedeleteerror': - case 'filecustomerror': - case 'filesuccessremove': - break; - // receive data response via `filecustomerror` event` - default: - if (!self.ajaxAborted) { - self.ajaxAborted = e.result; - } - break; - } - return true; - }, - _listenFullScreen: function (isFullScreen) { - var self = this, $modal = self.$modal, $btnFull, $btnBord; - if (!$modal || !$modal.length) { - return; - } - $btnFull = $modal && $modal.find('.btn-fullscreen'); - $btnBord = $modal && $modal.find('.btn-borderless'); - if (!$btnFull.length || !$btnBord.length) { - return; - } - $btnFull.removeClass('active').attr('aria-pressed', 'false'); - $btnBord.removeClass('active').attr('aria-pressed', 'false'); - if (isFullScreen) { - $btnFull.addClass('active').attr('aria-pressed', 'true'); - } else { - $btnBord.addClass('active').attr('aria-pressed', 'true'); - } - if ($modal.hasClass('file-zoom-fullscreen')) { - self._maximizeZoomDialog(); - } else { - if (isFullScreen) { - self._maximizeZoomDialog(); - } else { - $btnBord.removeClass('active').attr('aria-pressed', 'false'); - } - } - }, - _listen: function () { - var self = this, $el = self.$element, $form = self.$form, $cont = self.$container, fullScreenEvents; - self._handler($el, 'click', function (e) { - if ($el.hasClass('file-no-browse')) { - if ($el.data('zoneClicked')) { - $el.data('zoneClicked', false); - } else { - e.preventDefault(); - } - } - }); - self._handler($el, 'change', $.proxy(self._change, self)); - if (self.showBrowse) { - self._handler(self.$btnFile, 'click', $.proxy(self._browse, self)); - } - self._handler($cont.find('.fileinput-remove:not([disabled])'), 'click', $.proxy(self.clear, self)); - self._handler($cont.find('.fileinput-cancel'), 'click', $.proxy(self.cancel, self)); - self._handler($cont.find('.fileinput-pause'), 'click', $.proxy(self.pause, self)); - self._initDragDrop(); - self._handler($form, 'reset', $.proxy(self.clear, self)); - if (!self.isAjaxUpload) { - self._handler($form, 'submit', $.proxy(self._submitForm, self)); - } - self._handler(self.$container.find('.fileinput-upload'), 'click', $.proxy(self._uploadClick, self)); - self._handler($(window), 'resize', function () { - self._listenFullScreen(screen.width === window.innerWidth && screen.height === window.innerHeight); - }); - fullScreenEvents = 'webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange'; - self._handler($(document), fullScreenEvents, function () { - self._listenFullScreen($h.checkFullScreen()); - }); - self._autoFitContent(); - self._initClickable(); - self._refreshPreview(); - }, - _autoFitContent: function () { - var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, - self = this, config = width < 400 ? (self.previewSettingsSmall || self.defaults.previewSettingsSmall) : - (self.previewSettings || self.defaults.previewSettings), sel; - $.each(config, function (cat, settings) { - sel = '.file-preview-frame .file-preview-' + cat; - self.$preview.find(sel + '.kv-preview-data,' + sel + ' .kv-preview-data').css(settings); - }); - }, - _scanDroppedItems: function (item, files, path) { - path = path || ''; - var self = this, i, dirReader, readDir, errorHandler = function (e) { - self._log($h.logMessages.badDroppedFiles); - self._log(e); - }; - if (item.isFile) { - item.file(function (file) { - files.push(file); - }, errorHandler); - } else { - if (item.isDirectory) { - dirReader = item.createReader(); - readDir = function () { - dirReader.readEntries(function (entries) { - if (entries && entries.length > 0) { - for (i = 0; i < entries.length; i++) { - self._scanDroppedItems(entries[i], files, path + item.name + '/'); - } - // recursively call readDir() again, since browser can only handle first 100 entries. - readDir(); - } - return null; - }, errorHandler); - }; - readDir(); - } - } - - }, - _initDragDrop: function () { - var self = this, $zone = self.$dropZone; - if (self.dropZoneEnabled && self.showPreview) { - self._handler($zone, 'dragenter dragover', $.proxy(self._zoneDragEnter, self)); - self._handler($zone, 'dragleave', $.proxy(self._zoneDragLeave, self)); - self._handler($zone, 'drop', $.proxy(self._zoneDrop, self)); - self._handler($(document), 'dragenter dragover drop', self._zoneDragDropInit); - } - }, - _zoneDragDropInit: function (e) { - e.stopPropagation(); - e.preventDefault(); - }, - _zoneDragEnter: function (e) { - var self = this, dataTransfer = e.originalEvent.dataTransfer, - hasFiles = $.inArray('Files', dataTransfer.types) > -1; - self._zoneDragDropInit(e); - if (self.isDisabled || !hasFiles) { - e.originalEvent.dataTransfer.effectAllowed = 'none'; - e.originalEvent.dataTransfer.dropEffect = 'none'; - return; - } - if (self._raise('fileDragEnter', {'sourceEvent': e, 'files': dataTransfer.types.Files})) { - $h.addCss(self.$dropZone, 'file-highlighted'); - } - }, - _zoneDragLeave: function (e) { - var self = this; - self._zoneDragDropInit(e); - if (self.isDisabled) { - return; - } - if (self._raise('fileDragLeave', {'sourceEvent': e})) { - self.$dropZone.removeClass('file-highlighted'); - } - - }, - _zoneDrop: function (e) { - /** @namespace e.originalEvent.dataTransfer */ - var self = this, i, $el = self.$element, dataTransfer = e.originalEvent.dataTransfer, - files = dataTransfer.files, items = dataTransfer.items, folders = $h.getDragDropFolders(items), - processFiles = function () { - if (!self.isAjaxUpload) { - self.changeTriggered = true; - $el.get(0).files = files; - setTimeout(function () { - self.changeTriggered = false; - $el.trigger('change' + self.namespace); - }, self.processDelay); - } else { - self._change(e, files); - } - self.$dropZone.removeClass('file-highlighted'); - }; - e.preventDefault(); - if (self.isDisabled || $h.isEmpty(files)) { - return; - } - if (!self._raise('fileDragDrop', {'sourceEvent': e, 'files': files})) { - return; - } - if (folders > 0) { - if (!self.isAjaxUpload) { - self._showFolderError(folders); - return; - } - files = []; - for (i = 0; i < items.length; i++) { - var item = items[i].webkitGetAsEntry(); - if (item) { - self._scanDroppedItems(item, files); - } - } - setTimeout(function () { - processFiles(); - }, 500); - } else { - processFiles(); - } - }, - _uploadClick: function (e) { - var self = this, $btn = self.$container.find('.fileinput-upload'), $form, - isEnabled = !$btn.hasClass('disabled') && $h.isEmpty($btn.attr('disabled')); - if (e && e.isDefaultPrevented()) { - return; - } - if (!self.isAjaxUpload) { - if (isEnabled && $btn.attr('type') !== 'submit') { - $form = $btn.closest('form'); - // downgrade to normal form submit if possible - if ($form.length) { - $form.trigger('submit'); - } - e.preventDefault(); - } - return; - } - e.preventDefault(); - if (isEnabled) { - self.upload(); - } - }, - _submitForm: function () { - var self = this; - return self._isFileSelectionValid() && !self._abort({}); - }, - _clearPreview: function () { - var self = this, $p = self.$preview, - $thumbs = self.showUploadedThumbs ? self.getFrames(':not(.file-preview-success)') : self.getFrames(); - $thumbs.each(function () { - var $thumb = $(this); - $thumb.remove(); - $h.cleanZoomCache($p.find('#zoom-' + $thumb.attr('id'))); - }); - if (!self.getFrames().length || !self.showPreview) { - self._resetUpload(); - } - self._validateDefaultPreview(); - }, - _initSortable: function () { - var self = this, $el = self.$preview, settings, selector = '.' + $h.SORT_CSS, - rev = self.reversePreviewOrder; - if (!window.KvSortable || $el.find(selector).length === 0) { - return; - } - //noinspection JSUnusedGlobalSymbols - settings = { - handle: '.drag-handle-init', - dataIdAttr: 'data-preview-id', - scroll: false, - draggable: selector, - onSort: function (e) { - var oldIndex = e.oldIndex, newIndex = e.newIndex, i = 0; - self.initialPreview = $h.moveArray(self.initialPreview, oldIndex, newIndex, rev); - self.initialPreviewConfig = $h.moveArray(self.initialPreviewConfig, oldIndex, newIndex, rev); - self.previewCache.init(); - self.getFrames('.file-preview-initial').each(function () { - $(this).attr('data-fileindex', 'init_' + i); - i++; - }); - self._raise('filesorted', { - previewId: $(e.item).attr('id'), - 'oldIndex': oldIndex, - 'newIndex': newIndex, - stack: self.initialPreviewConfig - }); - } - }; - if ($el.data('kvsortable')) { - $el.kvsortable('destroy'); - } - $.extend(true, settings, self.fileActionSettings.dragSettings); - $el.kvsortable(settings); - }, - _setPreviewContent: function (content) { - var self = this; - self.$preview.html(content); - self._autoFitContent(); - }, - _initPreviewImageOrientations: function () { - var self = this, i = 0; - if (!self.autoOrientImageInitial) { - return; - } - self.getFrames('.file-preview-initial').each(function () { - var $thumb = $(this), $img, $zoomImg, id, config = self.initialPreviewConfig[i]; - /** @namespace config.exif */ - if (config && config.exif && config.exif.Orientation) { - id = $thumb.attr('id'); - $img = $thumb.find('>.kv-file-content img'); - $zoomImg = self.$preview.find('#zoom-' + id + ' >.kv-file-content img'); - self.setImageOrientation($img, $zoomImg, config.exif.Orientation, $thumb); - } - i++; - }); - }, - _initPreview: function (isInit) { - var self = this, cap = self.initialCaption || '', out; - if (!self.previewCache.count(true)) { - self._clearPreview(); - if (isInit) { - self._setCaption(cap); - } else { - self._initCaption(); - } - return; - } - out = self.previewCache.out(); - cap = isInit && self.initialCaption ? self.initialCaption : out.caption; - self._setPreviewContent(out.content); - self._setInitThumbAttr(); - self._setCaption(cap); - self._initSortable(); - if (!$h.isEmpty(out.content)) { - self.$container.removeClass('file-input-new'); - } - self._initPreviewImageOrientations(); - }, - _getZoomButton: function (type) { - var self = this, label = self.previewZoomButtonIcons[type], css = self.previewZoomButtonClasses[type], - title = ' title="' + (self.previewZoomButtonTitles[type] || '') + '" ', - params = title + (type === 'close' ? ' data-dismiss="modal" aria-hidden="true"' : ''); - if (type === 'fullscreen' || type === 'borderless' || type === 'toggleheader') { - params += ' data-toggle="button" aria-pressed="false" autocomplete="off"'; - } - return ''; - }, - _getModalContent: function () { - var self = this; - return self._getLayoutTemplate('modal').setTokens({ - 'rtl': self.rtl ? ' kv-rtl' : '', - 'zoomFrameClass': self.frameClass, - 'heading': self.msgZoomModalHeading, - 'prev': self._getZoomButton('prev'), - 'next': self._getZoomButton('next'), - 'toggleheader': self._getZoomButton('toggleheader'), - 'fullscreen': self._getZoomButton('fullscreen'), - 'borderless': self._getZoomButton('borderless'), - 'close': self._getZoomButton('close') - }); - }, - _listenModalEvent: function (event) { - var self = this, $modal = self.$modal, getParams = function (e) { - return { - sourceEvent: e, - previewId: $modal.data('previewId'), - modal: $modal - }; - }; - $modal.on(event + '.bs.modal', function (e) { - var $btnFull = $modal.find('.btn-fullscreen'), $btnBord = $modal.find('.btn-borderless'); - self._raise('filezoom' + event, getParams(e)); - if (event === 'shown') { - $btnBord.removeClass('active').attr('aria-pressed', 'false'); - $btnFull.removeClass('active').attr('aria-pressed', 'false'); - if ($modal.hasClass('file-zoom-fullscreen')) { - self._maximizeZoomDialog(); - if ($h.checkFullScreen()) { - $btnFull.addClass('active').attr('aria-pressed', 'true'); - } else { - $btnBord.addClass('active').attr('aria-pressed', 'true'); - } - } - } - }); - }, - _initZoom: function () { - var self = this, $dialog, modalMain = self._getLayoutTemplate('modalMain'), modalId = '#' + $h.MODAL_ID; - if (!self.showPreview) { - return; - } - self.$modal = $(modalId); - if (!self.$modal || !self.$modal.length) { - $dialog = $(document.createElement('div')).html(modalMain).insertAfter(self.$container); - self.$modal = $(modalId).insertBefore($dialog); - $dialog.remove(); - } - $h.initModal(self.$modal); - self.$modal.html(self._getModalContent()); - $.each($h.MODAL_EVENTS, function (key, event) { - self._listenModalEvent(event); - }); - }, - _initZoomButtons: function () { - var self = this, previewId = self.$modal.data('previewId') || '', $first, $last, - thumbs = self.getFrames().toArray(), len = thumbs.length, $prev = self.$modal.find('.btn-prev'), - $next = self.$modal.find('.btn-next'); - if (thumbs.length < 2) { - $prev.hide(); - $next.hide(); - return; - } else { - $prev.show(); - $next.show(); - } - if (!len) { - return; - } - $first = $(thumbs[0]); - $last = $(thumbs[len - 1]); - $prev.removeAttr('disabled'); - $next.removeAttr('disabled'); - if ($first.length && $first.attr('id') === previewId) { - $prev.attr('disabled', true); - } - if ($last.length && $last.attr('id') === previewId) { - $next.attr('disabled', true); - } - }, - _maximizeZoomDialog: function () { - var self = this, $modal = self.$modal, $head = $modal.find('.modal-header:visible'), - $foot = $modal.find('.modal-footer:visible'), $body = $modal.find('.modal-body'), - h = $(window).height(), diff = 0; - $modal.addClass('file-zoom-fullscreen'); - if ($head && $head.length) { - h -= $head.outerHeight(true); - } - if ($foot && $foot.length) { - h -= $foot.outerHeight(true); - } - if ($body && $body.length) { - diff = $body.outerHeight(true) - $body.height(); - h -= diff; - } - $modal.find('.kv-zoom-body').height(h); - }, - _resizeZoomDialog: function (fullScreen) { - var self = this, $modal = self.$modal, $btnFull = $modal.find('.btn-fullscreen'), - $btnBord = $modal.find('.btn-borderless'); - if ($modal.hasClass('file-zoom-fullscreen')) { - $h.toggleFullScreen(false); - if (!fullScreen) { - if (!$btnFull.hasClass('active')) { - $modal.removeClass('file-zoom-fullscreen'); - self.$modal.find('.kv-zoom-body').css('height', self.zoomModalHeight); - } else { - $btnFull.removeClass('active').attr('aria-pressed', 'false'); - } - } else { - if (!$btnFull.hasClass('active')) { - $modal.removeClass('file-zoom-fullscreen'); - self._resizeZoomDialog(true); - if ($btnBord.hasClass('active')) { - $btnBord.removeClass('active').attr('aria-pressed', 'false'); - } - } - } - } else { - if (!fullScreen) { - self._maximizeZoomDialog(); - return; - } - $h.toggleFullScreen(true); - } - $modal.focus(); - }, - _setZoomContent: function ($frame, animate) { - var self = this, $content, tmplt, body, title, $body, $dataEl, config, previewId = $frame.attr('id'), - $zoomPreview = self.$preview.find('#zoom-' + previewId), $modal = self.$modal, $tmp, - $btnFull = $modal.find('.btn-fullscreen'), $btnBord = $modal.find('.btn-borderless'), cap, size, - $btnTogh = $modal.find('.btn-toggleheader'); - tmplt = $zoomPreview.attr('data-template') || 'generic'; - $content = $zoomPreview.find('.kv-file-content'); - body = $content.length ? $content.html() : ''; - cap = $frame.data('caption') || ''; - size = $frame.data('size') || ''; - title = cap + ' ' + size; - $modal.find('.kv-zoom-title').attr('title', $('
    ').html(title).text()).html(title); - $body = $modal.find('.kv-zoom-body'); - $modal.removeClass('kv-single-content'); - if (animate) { - $tmp = $body.addClass('file-thumb-loading').clone().insertAfter($body); - $body.html(body).hide(); - $tmp.fadeOut('fast', function () { - $body.fadeIn('fast', function () { - $body.removeClass('file-thumb-loading'); - }); - $tmp.remove(); - }); - } else { - $body.html(body); - } - config = self.previewZoomSettings[tmplt]; - if (config) { - $dataEl = $body.find('.kv-preview-data'); - $h.addCss($dataEl, 'file-zoom-detail'); - $.each(config, function (key, value) { - $dataEl.css(key, value); - if (($dataEl.attr('width') && key === 'width') || ($dataEl.attr('height') && key === 'height')) { - $dataEl.removeAttr(key); - } - }); - } - $modal.data('previewId', previewId); - self._handler($modal.find('.btn-prev'), 'click', function () { - self._zoomSlideShow('prev', previewId); - }); - self._handler($modal.find('.btn-next'), 'click', function () { - self._zoomSlideShow('next', previewId); - }); - self._handler($btnFull, 'click', function () { - self._resizeZoomDialog(true); - }); - self._handler($btnBord, 'click', function () { - self._resizeZoomDialog(false); - }); - self._handler($btnTogh, 'click', function () { - var $header = $modal.find('.modal-header'), $floatBar = $modal.find('.modal-body .floating-buttons'), - ht, $actions = $header.find('.kv-zoom-actions'), resize = function (height) { - var $body = self.$modal.find('.kv-zoom-body'), h = self.zoomModalHeight; - if ($modal.hasClass('file-zoom-fullscreen')) { - h = $body.outerHeight(true); - if (!height) { - h = h - $header.outerHeight(true); - } - } - $body.css('height', height ? h + height : h); - }; - if ($header.is(':visible')) { - ht = $header.outerHeight(true); - $header.slideUp('slow', function () { - $actions.find('.btn').appendTo($floatBar); - resize(ht); - }); - } else { - $floatBar.find('.btn').appendTo($actions); - $header.slideDown('slow', function () { - resize(); - }); - } - $modal.focus(); - }); - self._handler($modal, 'keydown', function (e) { - var key = e.which || e.keyCode, $prev = $(this).find('.btn-prev'), $next = $(this).find('.btn-next'), - vId = $(this).data('previewId'), vPrevKey = self.rtl ? 39 : 37, vNextKey = self.rtl ? 37 : 39; - if (key === vPrevKey && $prev.length && !$prev.attr('disabled')) { - self._zoomSlideShow('prev', vId); - } - if (key === vNextKey && $next.length && !$next.attr('disabled')) { - self._zoomSlideShow('next', vId); - } - }); - }, - _zoomPreview: function ($btn) { - var self = this, $frame, $modal = self.$modal; - if (!$btn.length) { - throw 'Cannot zoom to detailed preview!'; - } - $h.initModal($modal); - $modal.html(self._getModalContent()); - $frame = $btn.closest($h.FRAMES); - self._setZoomContent($frame); - $modal.modal('show'); - self._initZoomButtons(); - }, - _zoomSlideShow: function (dir, previewId) { - var self = this, $btn = self.$modal.find('.kv-zoom-actions .btn-' + dir), $targFrame, i, - thumbs = self.getFrames().toArray(), len = thumbs.length, out; - if ($btn.attr('disabled')) { - return; - } - for (i = 0; i < len; i++) { - if ($(thumbs[i]).attr('id') === previewId) { - out = dir === 'prev' ? i - 1 : i + 1; - break; - } - } - if (out < 0 || out >= len || !thumbs[out]) { - return; - } - $targFrame = $(thumbs[out]); - if ($targFrame.length) { - self._setZoomContent($targFrame, true); - } - self._initZoomButtons(); - self._raise('filezoom' + dir, {'previewId': previewId, modal: self.$modal}); - }, - _initZoomButton: function () { - var self = this; - self.$preview.find('.kv-file-zoom').each(function () { - var $el = $(this); - self._handler($el, 'click', function () { - self._zoomPreview($el); - }); - }); - }, - _inputFileCount: function () { - return this.$element.get(0).files.length; - }, - _refreshPreview: function () { - var self = this, files; - if ((!self._inputFileCount() && !self.isAjaxUpload) || !self.showPreview || !self.isPreviewable) { - return; - } - if (self.isAjaxUpload) { - if (self.fileManager.count() > 0) { - files = $.extend(true, {}, self.fileManager.stack); - self.fileManager.clear(); - self._clearFileInput(); - } else { - files = self.$element.get(0).files; - } - } else { - files = self.$element.get(0).files; - } - if (files && files.length) { - self.readFiles(files); - self._setFileDropZoneTitle(); - } - }, - _clearObjects: function ($el) { - $el.find('video audio').each(function () { - this.pause(); - $(this).remove(); - }); - $el.find('img object div').each(function () { - $(this).remove(); - }); - }, - _clearFileInput: function () { - var self = this, $el = self.$element, $srcFrm, $tmpFrm, $tmpEl; - if (!self._inputFileCount()) { - return; - } - $srcFrm = $el.closest('form'); - $tmpFrm = $(document.createElement('form')); - $tmpEl = $(document.createElement('div')); - $el.before($tmpEl); - if ($srcFrm.length) { - $srcFrm.after($tmpFrm); - } else { - $tmpEl.after($tmpFrm); - } - $tmpFrm.append($el).trigger('reset'); - $tmpEl.before($el).remove(); - $tmpFrm.remove(); - }, - _resetUpload: function () { - var self = this; - self.uploadCache = {content: [], config: [], tags: [], append: true}; - self.$btnUpload.removeAttr('disabled'); - self._setProgress(0); - self.$progress.hide(); - self._resetErrors(false); - self._initAjax(); - self.fileManager.clearImages(); - self._resetCanvas(); - self.cacheInitialPreview = {}; - if (self.overwriteInitial) { - self.initialPreview = []; - self.initialPreviewConfig = []; - self.initialPreviewThumbTags = []; - self.previewCache.data = { - content: [], - config: [], - tags: [] - }; - } - }, - _resetCanvas: function () { - var self = this; - if (self.canvas && self.imageCanvasContext) { - self.imageCanvasContext.clearRect(0, 0, self.canvas.width, self.canvas.height); - } - }, - _hasInitialPreview: function () { - var self = this; - return !self.overwriteInitial && self.previewCache.count(true); - }, - _resetPreview: function () { - var self = this, out, cap; - if (self.previewCache.count(true)) { - out = self.previewCache.out(); - self._setPreviewContent(out.content); - self._setInitThumbAttr(); - cap = self.initialCaption ? self.initialCaption : out.caption; - self._setCaption(cap); - } else { - self._clearPreview(); - self._initCaption(); - } - if (self.showPreview) { - self._initZoom(); - self._initSortable(); - } - }, - _clearDefaultPreview: function () { - var self = this; - self.$preview.find('.file-default-preview').remove(); - }, - _validateDefaultPreview: function () { - var self = this; - if (!self.showPreview || $h.isEmpty(self.defaultPreviewContent)) { - return; - } - self._setPreviewContent('
    ' + self.defaultPreviewContent + '
    '); - self.$container.removeClass('file-input-new'); - self._initClickable(); - }, - _resetPreviewThumbs: function (isAjax) { - var self = this, out; - if (isAjax) { - self._clearPreview(); - self.clearFileStack(); - return; - } - if (self._hasInitialPreview()) { - out = self.previewCache.out(); - self._setPreviewContent(out.content); - self._setInitThumbAttr(); - self._setCaption(out.caption); - self._initPreviewActions(); - } else { - self._clearPreview(); - } - }, - _getLayoutTemplate: function (t) { - var self = this, template = self.layoutTemplates[t]; - if ($h.isEmpty(self.customLayoutTags)) { - return template; - } - return $h.replaceTags(template, self.customLayoutTags); - }, - _getPreviewTemplate: function (t) { - var self = this, template = self.previewTemplates[t]; - if ($h.isEmpty(self.customPreviewTags)) { - return template; - } - return $h.replaceTags(template, self.customPreviewTags); - }, - _getOutData: function (formdata, jqXHR, responseData, filesData) { - var self = this; - jqXHR = jqXHR || {}; - responseData = responseData || {}; - filesData = filesData || self.fileManager.list(); - return { - formdata: formdata, - files: filesData, - filenames: self.filenames, - filescount: self.getFilesCount(), - extra: self._getExtraData(), - response: responseData, - reader: self.reader, - jqXHR: jqXHR - }; - }, - _getMsgSelected: function (n) { - var self = this, strFiles = n === 1 ? self.fileSingle : self.filePlural; - return n > 0 ? self.msgSelected.replace('{n}', n).replace('{files}', strFiles) : self.msgNoFilesSelected; - }, - _getFrame: function (id) { - var self = this, $frame = $('#' + id); - if (!$frame.length) { - self._log($h.logMessages.invalidThumb, {id: id}); - return null; - } - return $frame; - }, - _getThumbs: function (css) { - css = css || ''; - return this.getFrames(':not(.file-preview-initial)' + css); - }, - _getExtraData: function (fileId, index) { - var self = this, data = self.uploadExtraData; - if (typeof self.uploadExtraData === 'function') { - data = self.uploadExtraData(fileId, index); - } - return data; - }, - _initXhr: function (xhrobj, fileId, fileCount) { - var self = this, fm = self.fileManager, func = function (event) { - var pct = 0, total = event.total, loaded = event.loaded || event.position, - stats = fm.getUploadStats(fileId, loaded, total); - /** @namespace event.lengthComputable */ - if (event.lengthComputable && !self.enableResumableUpload) { - pct = $h.round(loaded / total * 100); - } - if (fileId) { - self._setFileUploadStats(fileId, pct, fileCount, stats); - } else { - self._setProgress(pct, null, null, self._getStats(stats)); - } - self._raise('fileajaxprogress', [stats]); - }; - if (xhrobj.upload) { - if (self.progressDelay) { - func = $h.debounce(func, self.progressDelay); - } - xhrobj.upload.addEventListener('progress', func, false); - } - return xhrobj; - }, - _initAjaxSettings: function () { - var self = this; - self._ajaxSettings = $.extend(true, {}, self.ajaxSettings); - self._ajaxDeleteSettings = $.extend(true, {}, self.ajaxDeleteSettings); - }, - _mergeAjaxCallback: function (funcName, srcFunc, type) { - var self = this, settings = self._ajaxSettings, flag = self.mergeAjaxCallbacks, targFunc; - if (type === 'delete') { - settings = self._ajaxDeleteSettings; - flag = self.mergeAjaxDeleteCallbacks; - } - targFunc = settings[funcName]; - if (flag && typeof targFunc === 'function') { - if (flag === 'before') { - settings[funcName] = function () { - targFunc.apply(this, arguments); - srcFunc.apply(this, arguments); - }; - } else { - settings[funcName] = function () { - srcFunc.apply(this, arguments); - targFunc.apply(this, arguments); - }; - } - } else { - settings[funcName] = srcFunc; - } - }, - _ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError, formdata, fileId, index, vUrl) { - var self = this, settings, defaults, data, processQueue; - if (!self._raise('filepreajax', [formdata, fileId, index])) { - return; - } - formdata.append('initialPreview', JSON.stringify(self.initialPreview)); - formdata.append('initialPreviewConfig', JSON.stringify(self.initialPreviewConfig)); - formdata.append('initialPreviewThumbTags', JSON.stringify(self.initialPreviewThumbTags)); - self._initAjaxSettings(); - self._mergeAjaxCallback('beforeSend', fnBefore); - self._mergeAjaxCallback('success', fnSuccess); - self._mergeAjaxCallback('complete', fnComplete); - self._mergeAjaxCallback('error', fnError); - vUrl = vUrl || self.uploadUrlThumb || self.uploadUrl; - if (typeof vUrl === 'function') { - vUrl = vUrl(); - } - data = self._getExtraData(fileId, index) || {}; - if (typeof data === 'object') { - $.each(data, function (key, value) { - formdata.append(key, value); - }); - } - defaults = { - xhr: function () { - var xhrobj = $.ajaxSettings.xhr(); - return self._initXhr(xhrobj, fileId, self.fileManager.count()); - }, - url: self._encodeURI(vUrl), - type: 'POST', - dataType: 'json', - data: formdata, - cache: false, - processData: false, - contentType: false - }; - settings = $.extend(true, {}, defaults, self._ajaxSettings); - self.ajaxQueue.push(settings); - processQueue = function () { - var config, xhr; - if (self.ajaxCurrentThreads < self.maxAjaxThreads) { - config = self.ajaxQueue.shift(); - if (typeof config !== 'undefined') { - self.ajaxCurrentThreads++; - xhr = $.ajax(config).done(function () { - clearInterval(self.ajaxQueueIntervalId); - self.ajaxCurrentThreads--; - }); - self.ajaxRequests.push(xhr); - } - } - }; - self.ajaxQueueIntervalId = setInterval(processQueue, self.queueDelay); - - }, - _mergeArray: function (prop, content) { - var self = this, arr1 = $h.cleanArray(self[prop]), arr2 = $h.cleanArray(content); - self[prop] = arr1.concat(arr2); - }, - _initUploadSuccess: function (out, $thumb, allFiles) { - var self = this, append, data, index, $div, $newCache, content, config, tags, i; - if (!self.showPreview || typeof out !== 'object' || $.isEmptyObject(out)) { - return; - } - if (out.initialPreview !== undefined && out.initialPreview.length > 0) { - self.hasInitData = true; - content = out.initialPreview || []; - config = out.initialPreviewConfig || []; - tags = out.initialPreviewThumbTags || []; - append = out.append === undefined || out.append; - if (content.length > 0 && !$h.isArray(content)) { - content = content.split(self.initialPreviewDelimiter); - } - if (content.length) { - self._mergeArray('initialPreview', content); - self._mergeArray('initialPreviewConfig', config); - self._mergeArray('initialPreviewThumbTags', tags); - } - if ($thumb !== undefined) { - if (!allFiles) { - index = self.previewCache.add(content[0], config[0], tags[0], append); - data = self.previewCache.get(index, false); - $div = $(document.createElement('div')).html(data).hide().insertAfter($thumb); - $newCache = $div.find('.kv-zoom-cache'); - if ($newCache && $newCache.length) { - $newCache.insertAfter($thumb); - } - $thumb.fadeOut('slow', function () { - var $newThumb = $div.find('.file-preview-frame'); - if ($newThumb && $newThumb.length) { - $newThumb.insertBefore($thumb).fadeIn('slow').css('display:inline-block'); - } - self._initPreviewActions(); - self._clearFileInput(); - $h.cleanZoomCache(self.$preview.find('#zoom-' + $thumb.attr('id'))); - $thumb.remove(); - $div.remove(); - self._initSortable(); - }); - } else { - i = $thumb.attr('data-fileindex'); - self.uploadCache.content[i] = content[0]; - self.uploadCache.config[i] = config[0] || []; - self.uploadCache.tags[i] = tags[0] || []; - self.uploadCache.append = append; - } - } else { - self.previewCache.set(content, config, tags, append); - self._initPreview(); - self._initPreviewActions(); - } - } - }, - _initSuccessThumbs: function () { - var self = this; - if (!self.showPreview) { - return; - } - self._getThumbs($h.FRAMES + '.file-preview-success').each(function () { - var $thumb = $(this), $preview = self.$preview, $remove = $thumb.find('.kv-file-remove'); - $remove.removeAttr('disabled'); - self._handler($remove, 'click', function () { - var id = $thumb.attr('id'), - out = self._raise('filesuccessremove', [id, $thumb.attr('data-fileindex')]); - $h.cleanMemory($thumb); - if (out === false) { - return; - } - $thumb.fadeOut('slow', function () { - $h.cleanZoomCache($preview.find('#zoom-' + id)); - $thumb.remove(); - if (!self.getFrames().length) { - self.reset(); - } - }); - }); - }); - }, - _updateInitialPreview: function () { - var self = this, u = self.uploadCache, i, j, len = 0, data = self.cacheInitialPreview; - if (data && data.content) { - len = data.content.length; - } - if (self.showPreview) { - self.previewCache.set(u.content, u.config, u.tags, u.append); - if (len) { - for (i = 0; i < u.content.length; i++) { - j = i + len; - data.content[j] = u.content[i]; - //noinspection JSUnresolvedVariable - if (data.config.length) { - data.config[j] = u.config[i]; - } - if (data.tags.length) { - data.tags[j] = u.tags[i]; - } - } - self.initialPreview = $h.cleanArray(data.content); - self.initialPreviewConfig = $h.cleanArray(data.config); - self.initialPreviewThumbTags = $h.cleanArray(data.tags); - } else { - self.initialPreview = u.content; - self.initialPreviewConfig = u.config; - self.initialPreviewThumbTags = u.tags; - } - self.cacheInitialPreview = {}; - if (self.hasInitData) { - self._initPreview(); - self._initPreviewActions(); - } - } - }, - _uploadSingle: function (i, id, isBatch) { - var self = this, fm = self.fileManager, count = fm.count(), formdata = new FormData(), outData, - previewId = self.previewInitId + '-' + i, $thumb, chkComplete, $btnUpload, $btnDelete, - hasPostData = count > 0 || !$.isEmptyObject(self.uploadExtraData), uploadFailed, $prog, fnBefore, - errMsg, fnSuccess, fnComplete, fnError, updateUploadLog, op = self.ajaxOperations.uploadThumb, - fileObj = fm.getFile(id), params = {id: previewId, index: i, fileId: id}, - fileName = self.fileManager.getFileName(id, true); - if (self.enableResumableUpload) { // not enabled for resumable uploads - return; - } - if (self.showPreview) { - $thumb = self.fileManager.getThumb(id); - $prog = $thumb.find('.file-thumb-progress'); - $btnUpload = $thumb.find('.kv-file-upload'); - $btnDelete = $thumb.find('.kv-file-remove'); - $prog.show(); - } - if (count === 0 || !hasPostData || (self.showPreview && $btnUpload && $btnUpload.hasClass('disabled')) || - self._abort(params)) { - return; - } - updateUploadLog = function () { - if (!uploadFailed) { - fm.removeFile(id); - } else { - fm.errors.push(id); - } - fm.setProcessed(id); - if (fm.isProcessed()) { - self.fileBatchCompleted = true; - } - }; - chkComplete = function () { - var $initThumbs; - if (!self.fileBatchCompleted) { - return; - } - setTimeout(function () { - var triggerReset = fm.count() === 0, errCount = fm.errors.length; - self._updateInitialPreview(); - self.unlock(triggerReset); - if (triggerReset) { - self._clearFileInput(); - } - $initThumbs = self.$preview.find('.file-preview-initial'); - if (self.uploadAsync && $initThumbs.length) { - $h.addCss($initThumbs, $h.SORT_CSS); - self._initSortable(); - } - self._raise('filebatchuploadcomplete', [fm.stack, self._getExtraData()]); - if (!self.retryErrorUploads || errCount === 0) { - fm.clear(); - } - self._setProgress(101); - self.ajaxAborted = false; - }, self.processDelay); - }; - fnBefore = function (jqXHR) { - outData = self._getOutData(formdata, jqXHR); - fm.initStats(id); - self.fileBatchCompleted = false; - if (!isBatch) { - self.ajaxAborted = false; - } - if (self.showPreview) { - if (!$thumb.hasClass('file-preview-success')) { - self._setThumbStatus($thumb, 'Loading'); - $h.addCss($thumb, 'file-uploading'); - } - $btnUpload.attr('disabled', true); - $btnDelete.attr('disabled', true); - } - if (!isBatch) { - self.lock(); - } - if (fm.errors.indexOf(id) !== -1) { - delete fm.errors[id]; - } - self._raise('filepreupload', [outData, previewId, i]); - $.extend(true, params, outData); - if (self._abort(params)) { - jqXHR.abort(); - if (!isBatch) { - self._setThumbStatus($thumb, 'New'); - $thumb.removeClass('file-uploading'); - $btnUpload.removeAttr('disabled'); - $btnDelete.removeAttr('disabled'); - self.unlock(); - } - self._setProgressCancelled(); - } - }; - fnSuccess = function (data, textStatus, jqXHR) { - var pid = self.showPreview && $thumb.attr('id') ? $thumb.attr('id') : previewId; - outData = self._getOutData(formdata, jqXHR, data); - $.extend(true, params, outData); - setTimeout(function () { - if ($h.isEmpty(data) || $h.isEmpty(data.error)) { - if (self.showPreview) { - self._setThumbStatus($thumb, 'Success'); - $btnUpload.hide(); - self._initUploadSuccess(data, $thumb, isBatch); - self._setProgress(101, $prog); - } - self._raise('fileuploaded', [outData, pid, i]); - if (!isBatch) { - self.fileManager.remove($thumb); - } else { - updateUploadLog(); - } - } else { - uploadFailed = true; - errMsg = self._parseError(op, jqXHR, self.msgUploadError, self.fileManager.getFileName(id)); - self._showFileError(errMsg, params); - self._setPreviewError($thumb, true); - if (!self.retryErrorUploads) { - $btnUpload.hide(); - } - if (isBatch) { - updateUploadLog(); - } - self._setProgress(101, $('#' + pid).find('.file-thumb-progress'), self.msgUploadError); - } - }, self.processDelay); - }; - fnComplete = function () { - setTimeout(function () { - if (self.showPreview) { - $btnUpload.removeAttr('disabled'); - $btnDelete.removeAttr('disabled'); - $thumb.removeClass('file-uploading'); - } - if (!isBatch) { - self.unlock(false); - self._clearFileInput(); - } else { - chkComplete(); - } - self._initSuccessThumbs(); - }, self.processDelay); - }; - fnError = function (jqXHR, textStatus, errorThrown) { - errMsg = self._parseError(op, jqXHR, errorThrown, self.fileManager.getFileName(id)); - uploadFailed = true; - setTimeout(function () { - if (isBatch) { - updateUploadLog(); - } - self.fileManager.setProgress(id, 100); - self._setPreviewError($thumb, true); - if (!self.retryErrorUploads) { - $btnUpload.hide(); - } - $.extend(true, params, self._getOutData(formdata, jqXHR)); - self._setProgress(101, $prog, self.msgAjaxProgressError.replace('{operation}', op)); - self._setProgress(101, $thumb.find('.file-thumb-progress'), self.msgUploadError); - self._showFileError(errMsg, params); - }, self.processDelay); - }; - formdata.append(self.uploadFileAttr, fileObj.file, fileName); - self._setUploadData(formdata, {fileId: id}); - self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, formdata, id, i); - }, - _uploadBatch: function () { - var self = this, fm = self.fileManager, total = fm.total(), params = {}, fnBefore, fnSuccess, fnError, - fnComplete, hasPostData = total > 0 || !$.isEmptyObject(self.uploadExtraData), errMsg, - setAllUploaded, formdata = new FormData(), op = self.ajaxOperations.uploadBatch; - if (total === 0 || !hasPostData || self._abort(params)) { - return; - } - setAllUploaded = function () { - self.fileManager.clear(); - self._clearFileInput(); - }; - fnBefore = function (jqXHR) { - self.lock(); - fm.initStats(); - var outData = self._getOutData(formdata, jqXHR); - self.ajaxAborted = false; - if (self.showPreview) { - self._getThumbs().each(function () { - var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload'), - $btnDelete = $thumb.find('.kv-file-remove'); - if (!$thumb.hasClass('file-preview-success')) { - self._setThumbStatus($thumb, 'Loading'); - $h.addCss($thumb, 'file-uploading'); - } - $btnUpload.attr('disabled', true); - $btnDelete.attr('disabled', true); - }); - } - self._raise('filebatchpreupload', [outData]); - if (self._abort(outData)) { - jqXHR.abort(); - self._getThumbs().each(function () { - var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload'), - $btnDelete = $thumb.find('.kv-file-remove'); - if ($thumb.hasClass('file-preview-loading')) { - self._setThumbStatus($thumb, 'New'); - $thumb.removeClass('file-uploading'); - } - $btnUpload.removeAttr('disabled'); - $btnDelete.removeAttr('disabled'); - }); - self._setProgressCancelled(); - } - }; - fnSuccess = function (data, textStatus, jqXHR) { - /** @namespace data.errorkeys */ - var outData = self._getOutData(formdata, jqXHR, data), key = 0, - $thumbs = self._getThumbs(':not(.file-preview-success)'), - keys = $h.isEmpty(data) || $h.isEmpty(data.errorkeys) ? [] : data.errorkeys; - - if ($h.isEmpty(data) || $h.isEmpty(data.error)) { - self._raise('filebatchuploadsuccess', [outData]); - setAllUploaded(); - if (self.showPreview) { - $thumbs.each(function () { - var $thumb = $(this); - self._setThumbStatus($thumb, 'Success'); - $thumb.removeClass('file-uploading'); - $thumb.find('.kv-file-upload').hide().removeAttr('disabled'); - }); - self._initUploadSuccess(data); - } else { - self.reset(); - } - self._setProgress(101); - } else { - if (self.showPreview) { - $thumbs.each(function () { - var $thumb = $(this); - $thumb.removeClass('file-uploading'); - $thumb.find('.kv-file-upload').removeAttr('disabled'); - $thumb.find('.kv-file-remove').removeAttr('disabled'); - if (keys.length === 0 || $.inArray(key, keys) !== -1) { - self._setPreviewError($thumb, true); - if (!self.retryErrorUploads) { - $thumb.find('.kv-file-upload').hide(); - self.fileManager.remove($thumb); - } - } else { - $thumb.find('.kv-file-upload').hide(); - self._setThumbStatus($thumb, 'Success'); - self.fileManager.remove($thumb); - } - if (!$thumb.hasClass('file-preview-error') || self.retryErrorUploads) { - key++; - } - }); - self._initUploadSuccess(data); - } - errMsg = self._parseError(op, jqXHR, self.msgUploadError); - self._showFileError(errMsg, outData, 'filebatchuploaderror'); - self._setProgress(101, self.$progress, self.msgUploadError); - } - }; - fnComplete = function () { - self.unlock(); - self._initSuccessThumbs(); - self._clearFileInput(); - self._raise('filebatchuploadcomplete', [self.fileManager.stack, self._getExtraData()]); - }; - fnError = function (jqXHR, textStatus, errorThrown) { - var outData = self._getOutData(formdata, jqXHR); - errMsg = self._parseError(op, jqXHR, errorThrown); - self._showFileError(errMsg, outData, 'filebatchuploaderror'); - self.uploadFileCount = total - 1; - if (!self.showPreview) { - return; - } - self._getThumbs().each(function () { - var $thumb = $(this); - $thumb.removeClass('file-uploading'); - if (self.fileManager.getFile($thumb.attr('data-fileid'))) { - self._setPreviewError($thumb); - } - }); - self._getThumbs().removeClass('file-uploading'); - self._getThumbs(' .kv-file-upload').removeAttr('disabled'); - self._getThumbs(' .kv-file-delete').removeAttr('disabled'); - self._setProgress(101, self.$progress, self.msgAjaxProgressError.replace('{operation}', op)); - }; - var ctr = 0; - $.each(self.fileManager.stack, function (key, data) { - if (!$h.isEmpty(data.file)) { - formdata.append(self.uploadFileAttr, data.file, (data.nameFmt || ('untitled_' + ctr))); - } - ctr++; - }); - self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, formdata); - }, - _uploadExtraOnly: function () { - var self = this, params = {}, fnBefore, fnSuccess, fnComplete, fnError, formdata = new FormData(), errMsg, - op = self.ajaxOperations.uploadExtra; - if (self._abort(params)) { - return; - } - fnBefore = function (jqXHR) { - self.lock(); - var outData = self._getOutData(formdata, jqXHR); - self._raise('filebatchpreupload', [outData]); - self._setProgress(50); - params.data = outData; - params.xhr = jqXHR; - if (self._abort(params)) { - jqXHR.abort(); - self._setProgressCancelled(); - } - }; - fnSuccess = function (data, textStatus, jqXHR) { - var outData = self._getOutData(formdata, jqXHR, data); - if ($h.isEmpty(data) || $h.isEmpty(data.error)) { - self._raise('filebatchuploadsuccess', [outData]); - self._clearFileInput(); - self._initUploadSuccess(data); - self._setProgress(101); - } else { - errMsg = self._parseError(op, jqXHR, self.msgUploadError); - self._showFileError(errMsg, outData, 'filebatchuploaderror'); - } - }; - fnComplete = function () { - self.unlock(); - self._clearFileInput(); - self._raise('filebatchuploadcomplete', [self.fileManager.stack, self._getExtraData()]); - }; - fnError = function (jqXHR, textStatus, errorThrown) { - var outData = self._getOutData(formdata, jqXHR); - errMsg = self._parseError(op, jqXHR, errorThrown); - params.data = outData; - self._showFileError(errMsg, outData, 'filebatchuploaderror'); - self._setProgress(101, self.$progress, self.msgAjaxProgressError.replace('{operation}', op)); - }; - self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, formdata); - }, - _deleteFileIndex: function ($frame) { - var self = this, ind = $frame.attr('data-fileindex'), rev = self.reversePreviewOrder; - if (ind.substring(0, 5) === 'init_') { - ind = parseInt(ind.replace('init_', '')); - self.initialPreview = $h.spliceArray(self.initialPreview, ind, rev); - self.initialPreviewConfig = $h.spliceArray(self.initialPreviewConfig, ind, rev); - self.initialPreviewThumbTags = $h.spliceArray(self.initialPreviewThumbTags, ind, rev); - self.getFrames().each(function () { - var $nFrame = $(this), nInd = $nFrame.attr('data-fileindex'); - if (nInd.substring(0, 5) === 'init_') { - nInd = parseInt(nInd.replace('init_', '')); - if (nInd > ind) { - nInd--; - $nFrame.attr('data-fileindex', 'init_' + nInd); - } - } - }); - if (self.uploadAsync || self.enableResumableUpload) { - self.cacheInitialPreview = self.getPreview(); - } - } - }, - _initFileActions: function () { - var self = this, $preview = self.$preview; - if (!self.showPreview) { - return; - } - self._initZoomButton(); - self.getFrames(' .kv-file-remove').each(function () { - var $el = $(this), $frame = $el.closest($h.FRAMES), hasError, id = $frame.attr('id'), - ind = $frame.attr('data-fileindex'), n, cap, status; - self._handler($el, 'click', function () { - status = self._raise('filepreremove', [id, ind]); - if (status === false || !self._validateMinCount()) { - return false; - } - hasError = $frame.hasClass('file-preview-error'); - $h.cleanMemory($frame); - $frame.fadeOut('slow', function () { - $h.cleanZoomCache($preview.find('#zoom-' + id)); - self.fileManager.remove($frame); - self._clearObjects($frame); - $frame.remove(); - if (id && hasError) { - self.$errorContainer.find('li[data-thumb-id="' + id + '"]').fadeOut('fast', function () { - $(this).remove(); - if (!self._errorsExist()) { - self._resetErrors(); - } - }); - } - self._clearFileInput(); - var chk = self.previewCache.count(true), len = self.fileManager.count(), - file, hasThumb = self.showPreview && self.getFrames().length; - if (len === 0 && chk === 0 && !hasThumb) { - self.reset(); - } else { - n = chk + len; - if (n > 1) { - cap = self._getMsgSelected(n); - } else { - file = self.fileManager.getFirstFile(); - cap = file ? file.nameFmt : '_'; - } - self._setCaption(cap); - } - self._raise('fileremoved', [id, ind]); - }); - }); - }); - self.getFrames(' .kv-file-upload').each(function () { - var $el = $(this); - self._handler($el, 'click', function () { - var $frame = $el.closest($h.FRAMES), id = $frame.attr('data-fileid'); - self.$progress.hide(); - if ($frame.hasClass('file-preview-error') && !self.retryErrorUploads) { - return; - } - self._uploadSingle(self.fileManager.getIndex(id), id, false); - }); - }); - }, - _initPreviewActions: function () { - var self = this, $preview = self.$preview, deleteExtraData = self.deleteExtraData || {}, - btnRemove = $h.FRAMES + ' .kv-file-remove', settings = self.fileActionSettings, - origClass = settings.removeClass, errClass = settings.removeErrorClass, - resetProgress = function () { - var hasFiles = self.isAjaxUpload ? self.previewCache.count(true) : self._inputFileCount(); - if (!self.getFrames().length && !hasFiles) { - self._setCaption(''); - self.reset(); - self.initialCaption = ''; - } - }; - self._initZoomButton(); - $preview.find(btnRemove).each(function () { - var $el = $(this), vUrl = $el.data('url') || self.deleteUrl, vKey = $el.data('key'), errMsg, fnBefore, - fnSuccess, fnError, op = self.ajaxOperations.deleteThumb; - if ($h.isEmpty(vUrl) || vKey === undefined) { - return; - } - if (typeof vUrl === 'function') { - vUrl = vUrl(); - } - var $frame = $el.closest($h.FRAMES), cache = self.previewCache.data, settings, params, config, - fileName, extraData, index = $frame.attr('data-fileindex'); - index = parseInt(index.replace('init_', '')); - config = $h.isEmpty(cache.config) && $h.isEmpty(cache.config[index]) ? null : cache.config[index]; - extraData = $h.isEmpty(config) || $h.isEmpty(config.extra) ? deleteExtraData : config.extra; - fileName = config.filename || config.caption || ''; - if (typeof extraData === 'function') { - extraData = extraData(); - } - params = {id: $el.attr('id'), key: vKey, extra: extraData}; - fnBefore = function (jqXHR) { - self.ajaxAborted = false; - self._raise('filepredelete', [vKey, jqXHR, extraData]); - if (self._abort()) { - jqXHR.abort(); - } else { - $el.removeClass(errClass); - $h.addCss($frame, 'file-uploading'); - $h.addCss($el, 'disabled ' + origClass); - } - }; - fnSuccess = function (data, textStatus, jqXHR) { - var n, cap; - if (!$h.isEmpty(data) && !$h.isEmpty(data.error)) { - params.jqXHR = jqXHR; - params.response = data; - errMsg = self._parseError(op, jqXHR, self.msgDeleteError, fileName); - self._showFileError(errMsg, params, 'filedeleteerror'); - $frame.removeClass('file-uploading'); - $el.removeClass('disabled ' + origClass).addClass(errClass); - resetProgress(); - return; - } - $frame.removeClass('file-uploading').addClass('file-deleted'); - $frame.fadeOut('slow', function () { - index = parseInt(($frame.attr('data-fileindex')).replace('init_', '')); - self.previewCache.unset(index); - self._deleteFileIndex($frame); - n = self.previewCache.count(true); - cap = n > 0 ? self._getMsgSelected(n) : ''; - self._setCaption(cap); - self._raise('filedeleted', [vKey, jqXHR, extraData]); - $h.cleanZoomCache($preview.find('#zoom-' + $frame.attr('id'))); - self._clearObjects($frame); - $frame.remove(); - resetProgress(); - }); - }; - fnError = function (jqXHR, textStatus, errorThrown) { - var errMsg = self._parseError(op, jqXHR, errorThrown, fileName); - params.jqXHR = jqXHR; - params.response = {}; - self._showFileError(errMsg, params, 'filedeleteerror'); - $frame.removeClass('file-uploading'); - $el.removeClass('disabled ' + origClass).addClass(errClass); - resetProgress(); - }; - self._initAjaxSettings(); - self._mergeAjaxCallback('beforeSend', fnBefore, 'delete'); - self._mergeAjaxCallback('success', fnSuccess, 'delete'); - self._mergeAjaxCallback('error', fnError, 'delete'); - settings = $.extend(true, {}, { - url: self._encodeURI(vUrl), - type: 'POST', - dataType: 'json', - data: $.extend(true, {}, {key: vKey}, extraData) - }, self._ajaxDeleteSettings); - self._handler($el, 'click', function () { - if (!self._validateMinCount()) { - return false; - } - self.ajaxAborted = false; - self._raise('filebeforedelete', [vKey, extraData]); - //noinspection JSUnresolvedVariable,JSHint - if (self.ajaxAborted instanceof Promise) { - self.ajaxAborted.then(function (result) { - if (!result) { - $.ajax(settings); - } - }); - } else { - if (!self.ajaxAborted) { - $.ajax(settings); - } - } - }); - }); - }, - _hideFileIcon: function () { - var self = this; - if (self.overwriteInitial) { - self.$captionContainer.removeClass('icon-visible'); - } - }, - _showFileIcon: function () { - var self = this; - $h.addCss(self.$captionContainer, 'icon-visible'); - }, - _getSize: function (bytes, sizes) { - var self = this, size = parseFloat(bytes), i, func = self.fileSizeGetter, out; - if (!$.isNumeric(bytes) || !$.isNumeric(size)) { - return ''; - } - if (typeof func === 'function') { - out = func(size); - } else { - if (size === 0) { - out = '0.00 B'; - } else { - i = Math.floor(Math.log(size) / Math.log(1024)); - if (!sizes) { - sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - } - out = (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + sizes[i]; - } - } - return self._getLayoutTemplate('size').replace('{sizeText}', out); - }, - _getFileType: function (ftype) { - var self = this; - return self.mimeTypeAliases[ftype] || ftype; - }, - _generatePreviewTemplate: function ( - cat, - data, - fname, - ftype, - previewId, - fileId, - isError, - size, - frameClass, - foot, - ind, - templ, - attrs, - zoomData - ) { - var self = this, caption = self.slug(fname), prevContent, zoomContent = '', styleAttribs = '', - screenW = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, - config, newCat = self.preferIconicPreview ? 'other' : cat, title = caption, alt = caption, - footer = foot || self._renderFileFooter(cat, caption, size, 'auto', isError), - hasIconSetting = self._getPreviewIcon(fname), typeCss = 'type-default', - forcePrevIcon = hasIconSetting && self.preferIconicPreview, - forceZoomIcon = hasIconSetting && self.preferIconicZoomPreview, getContent; - config = screenW < 400 ? (self.previewSettingsSmall[newCat] || self.defaults.previewSettingsSmall[newCat]) : - (self.previewSettings[newCat] || self.defaults.previewSettings[newCat]); - if (config) { - $.each(config, function (key, val) { - styleAttribs += key + ':' + val + ';'; - }); - } - getContent = function (c, d, zoom, frameCss) { - var id = zoom ? 'zoom-' + previewId : previewId, tmplt = self._getPreviewTemplate(c), - css = (frameClass || '') + ' ' + frameCss; - if (self.frameClass) { - css = self.frameClass + ' ' + css; - } - if (zoom) { - css = css.replace(' ' + $h.SORT_CSS, ''); - } - tmplt = self._parseFilePreviewIcon(tmplt, fname); - if (c === 'text') { - d = $h.htmlEncode(d); - } - if (cat === 'object' && !ftype) { - $.each(self.defaults.fileTypeSettings, function (key, func) { - if (key === 'object' || key === 'other') { - return; - } - if (func(fname, ftype)) { - typeCss = 'type-' + key; - } - }); - } - if (!$h.isEmpty(attrs)) { - if (attrs.title !== undefined && attrs.title !== null) { - title = attrs.title; - } - if (attrs.alt !== undefined && attrs.alt !== null) { - title = attrs.alt; - } - } - return tmplt.setTokens({ - 'previewId': id, - 'caption': caption, - 'title': title, - 'alt': alt, - 'frameClass': css, - 'type': self._getFileType(ftype), - 'fileindex': ind, - 'fileid': fileId || '', - 'typeCss': typeCss, - 'footer': footer, - 'data': d, - 'template': templ || cat, - 'style': styleAttribs ? 'style="' + styleAttribs + '"' : '' - }); - }; - ind = ind || previewId.slice(previewId.lastIndexOf('-') + 1); - if (self.fileActionSettings.showZoom) { - zoomContent = getContent((forceZoomIcon ? 'other' : cat), zoomData ? zoomData : data, true, - 'kv-zoom-thumb'); - } - zoomContent = '\n' + self._getLayoutTemplate('zoomCache').replace('{zoomContent}', zoomContent); - if (typeof self.sanitizeZoomCache === 'function') { - zoomContent = self.sanitizeZoomCache(zoomContent); - } - prevContent = getContent((forcePrevIcon ? 'other' : cat), data, false, 'kv-preview-thumb'); - return prevContent + zoomContent; - }, - _addToPreview: function ($preview, content) { - var self = this; - return self.reversePreviewOrder ? $preview.prepend(content) : $preview.append(content); - }, - _previewDefault: function (file, previewId, isDisabled) { - var self = this, $preview = self.$preview; - if (!self.showPreview) { - return; - } - var fname = $h.getFileName(file), ftype = file ? file.type : '', content, size = file.size || 0, - caption = self._getFileName(file, ''), isError = isDisabled === true && !self.isAjaxUpload, - data = $h.createObjectURL(file), fileId = self.fileManager.getId(file); - self._clearDefaultPreview(); - content = self._generatePreviewTemplate('other', data, fname, ftype, previewId, fileId, isError, size); - self._addToPreview($preview, content); - self._setThumbAttr(previewId, caption, size); - if (isDisabled === true && self.isAjaxUpload) { - self._setThumbStatus($('#' + previewId), 'Error'); - } - }, - canPreview: function (file) { - var self = this; - if (!file || !self.showPreview || !self.$preview || !self.$preview.length) { - return false; - } - var name = file.name || '', type = file.type || '', size = (file.size || 0) / 1000, - cat = self._parseFileType(type, name), allowedTypes, allowedMimes, allowedExts, skipPreview, - types = self.allowedPreviewTypes, mimes = self.allowedPreviewMimeTypes, - exts = self.allowedPreviewExtensions || [], dTypes = self.disabledPreviewTypes, - dMimes = self.disabledPreviewMimeTypes, dExts = self.disabledPreviewExtensions || [], - maxSize = self.maxFilePreviewSize && parseFloat(self.maxFilePreviewSize) || 0, - expAllExt = new RegExp('\\.(' + exts.join('|') + ')$', 'i'), - expDisExt = new RegExp('\\.(' + dExts.join('|') + ')$', 'i'); - allowedTypes = !types || types.indexOf(cat) !== -1; - allowedMimes = !mimes || mimes.indexOf(type) !== -1; - allowedExts = !exts.length || $h.compare(name, expAllExt); - skipPreview = (dTypes && dTypes.indexOf(cat) !== -1) || (dMimes && dMimes.indexOf(type) !== -1) || - (dExts.length && $h.compare(name, expDisExt)) || (maxSize && !isNaN(maxSize) && size > maxSize); - return !skipPreview && (allowedTypes || allowedMimes || allowedExts); - }, - _previewFile: function (i, file, theFile, previewId, data, fileInfo) { - if (!this.showPreview) { - return; - } - var self = this, fname = $h.getFileName(file), ftype = fileInfo.type, caption = fileInfo.name, - cat = self._parseFileType(ftype, fname), content, $preview = self.$preview, fsize = file.size || 0, - iData = (cat === 'text' || cat === 'html' || cat === 'image') ? theFile.target.result : data, - fileId = self.fileManager.getId(file); - /** @namespace window.DOMPurify */ - if (cat === 'html' && self.purifyHtml && window.DOMPurify) { - iData = window.DOMPurify.sanitize(iData); - } - content = self._generatePreviewTemplate(cat, iData, fname, ftype, previewId, fileId, false, fsize); - self._clearDefaultPreview(); - self._addToPreview($preview, content); - var $thumb = $preview.find('#' + previewId), $img = $thumb.find('img'), id = $thumb.attr('data-fileid'); - self._validateImageOrientation($img, file, previewId, id, caption, ftype, fsize, iData); - self._setThumbAttr(previewId, caption, fsize); - self._initSortable(); - }, - _setThumbAttr: function (id, caption, size) { - var self = this, $frame = $('#' + id); - if ($frame.length) { - size = size && size > 0 ? self._getSize(size) : ''; - $frame.data({'caption': caption, 'size': size}); - } - }, - _setInitThumbAttr: function () { - var self = this, data = self.previewCache.data, len = self.previewCache.count(true), config, - caption, size, previewId; - if (len === 0) { - return; - } - for (var i = 0; i < len; i++) { - config = data.config[i]; - previewId = self.previewInitId + '-' + 'init_' + i; - caption = $h.ifSet('caption', config, $h.ifSet('filename', config)); - size = $h.ifSet('size', config); - self._setThumbAttr(previewId, caption, size); - } - }, - _slugDefault: function (text) { - // noinspection RegExpRedundantEscape - return $h.isEmpty(text) ? '' : String(text).replace(/[\[\]\/\{}:;#%=\(\)\*\+\?\\\^\$\|<>&"']/g, '_'); - }, - _updateFileDetails: function (numFiles) { - var self = this, $el = self.$element, label, n, log, nFiles, file, - name = ($h.isIE(9) && $h.findFileName($el.val())) || ($el[0].files[0] && $el[0].files[0].name); - if (!name && self.fileManager.count() > 0) { - file = self.fileManager.getFirstFile(); - label = file.nameFmt; - } else { - label = name ? self.slug(name) : '_'; - } - n = self.isAjaxUpload ? self.fileManager.count() : numFiles; - nFiles = self.previewCache.count(true) + n; - log = n === 1 ? label : self._getMsgSelected(nFiles); - if (self.isError) { - self.$previewContainer.removeClass('file-thumb-loading'); - self.$previewStatus.html(''); - self.$captionContainer.removeClass('icon-visible'); - } else { - self._showFileIcon(); - } - self._setCaption(log, self.isError); - self.$container.removeClass('file-input-new file-input-ajax-new'); - if (arguments.length === 1) { - self._raise('fileselect', [numFiles, label]); - } - if (self.previewCache.count(true)) { - self._initPreviewActions(); - } - }, - _setThumbStatus: function ($thumb, status) { - var self = this; - if (!self.showPreview) { - return; - } - var icon = 'indicator' + status, msg = icon + 'Title', - css = 'file-preview-' + status.toLowerCase(), - $indicator = $thumb.find('.file-upload-indicator'), - config = self.fileActionSettings; - $thumb.removeClass('file-preview-success file-preview-error file-preview-paused file-preview-loading'); - if (status === 'Success') { - $thumb.find('.file-drag-handle').remove(); - } - $indicator.html(config[icon]); - $indicator.attr('title', config[msg]); - $thumb.addClass(css); - if (status === 'Error' && !self.retryErrorUploads) { - $thumb.find('.kv-file-upload').attr('disabled', true); - } - }, - _setProgressCancelled: function () { - var self = this; - self._setProgress(101, self.$progress, self.msgCancelled); - }, - _setProgress: function (p, $el, error, stats) { - var self = this; - $el = $el || self.$progress; - if (!$el.length) { - return; - } - var pct = Math.min(p, 100), out, pctLimit = self.progressUploadThreshold, - t = p <= 100 ? self.progressTemplate : self.progressCompleteTemplate, - template = pct < 100 ? self.progressTemplate : - (error ? (self.paused ? self.progressPauseTemplate : self.progressErrorTemplate) : t); - if (p >= 100) { - stats = ''; - } - if (!$h.isEmpty(template)) { - if (pctLimit && pct > pctLimit && p <= 100) { - out = template.setTokens({'percent': pctLimit, 'status': self.msgUploadThreshold}); - } else { - out = template.setTokens({'percent': pct, 'status': (p > 100 ? self.msgUploadEnd : pct + '%')}); - } - stats = stats || ''; - out = out.setTokens({stats: stats}); - $el.html(out); - if (error) { - $el.find('[role="progressbar"]').html(error); - } - } - }, - _setFileDropZoneTitle: function () { - var self = this, $zone = self.$container.find('.file-drop-zone'), title = self.dropZoneTitle, strFiles; - if (self.isClickable) { - strFiles = $h.isEmpty(self.$element.attr('multiple')) ? self.fileSingle : self.filePlural; - title += self.dropZoneClickTitle.replace('{files}', strFiles); - } - $zone.find('.' + self.dropZoneTitleClass).remove(); - if (!self.showPreview || $zone.length === 0 || self.fileManager.count() > 0 || !self.dropZoneEnabled || - (!self.isAjaxUpload && self.$element.files)) { - return; - } - if ($zone.find($h.FRAMES).length === 0 && $h.isEmpty(self.defaultPreviewContent)) { - $zone.prepend('
    ' + title + '
    '); - } - self.$container.removeClass('file-input-new'); - $h.addCss(self.$container, 'file-input-ajax-new'); - }, - _getStats: function (stats) { - var self = this, pendingTime, t; - if (!self.showUploadStats || !stats || !stats.bitrate) { - return ''; - } - t = self._getLayoutTemplate('stats'); - pendingTime = (!stats.elapsed || !stats.bps) ? self.msgCalculatingTime : - self.msgPendingTime.setTokens({time: $h.getElapsed(Math.ceil(stats.pendingBytes / stats.bps))}); - - return t.setTokens({ - uploadSpeed: stats.bitrate, - pendingTime: pendingTime - }); - }, - _setResumableProgress: function (pct, stats, $thumb) { - var self = this, rm = self.resumableManager, obj = $thumb ? rm : self, - $prog = $thumb ? $thumb.find('.file-thumb-progress') : null; - if (obj.lastProgress === 0) { - obj.lastProgress = pct; - } - if (pct < obj.lastProgress) { - pct = obj.lastProgress; - } - self._setProgress(pct, $prog, null, self._getStats(stats)); - obj.lastProgress = pct; - }, - _setFileUploadStats: function (id, pct, total, stats) { - var self = this, $prog = self.$progress; - if (!self.showPreview && (!$prog || !$prog.length)) { - return; - } - var fm = self.fileManager, $thumb = fm.getThumb(id), pctTot, rm = self.resumableManager, - totUpSize = 0, totSize = fm.getTotalSize(), totStats = $.extend(true, {}, stats); - if (self.enableResumableUpload) { - var loaded = stats.loaded, currUplSize = rm.getUploadedSize(), currTotSize = rm.file.size, totLoaded; - loaded += currUplSize; - totLoaded = fm.uploadedSize + loaded; - pct = $h.round(100 * loaded / currTotSize); - stats.pendingBytes = currTotSize - currUplSize; - self._setResumableProgress(pct, stats, $thumb); - pctTot = Math.floor(100 * totLoaded / totSize); - totStats.pendingBytes = totSize - totLoaded; - self._setResumableProgress(pctTot, totStats); - } else { - fm.setProgress(id, pct); - $prog = $thumb && $thumb.length ? $thumb.find('.file-thumb-progress') : null; - self._setProgress(pct, $prog, null, self._getStats(stats)); - $.each(fm.stats, function (id, cfg) { - totUpSize += cfg.loaded; - }); - totStats.pendingBytes = totSize - totUpSize; - pctTot = $h.round(totUpSize / totSize * 100); - self._setProgress(pctTot, null, null, self._getStats(totStats)); - } - }, - _validateMinCount: function () { - var self = this, len = self.isAjaxUpload ? self.fileManager.count() : self._inputFileCount(); - if (self.validateInitialCount && self.minFileCount > 0 && self._getFileCount(len - 1) < self.minFileCount) { - self._noFilesError({}); - return false; - } - return true; - }, - _getFileCount: function (fileCount) { - var self = this, addCount = 0; - if (self.validateInitialCount && !self.overwriteInitial) { - addCount = self.previewCache.count(true); - fileCount += addCount; - } - return fileCount; - }, - _getFileId: function (file) { - return $h.getFileId(file, this.generateFileId); - }, - _getFileName: function (file, defaultValue) { - var self = this, fileName = $h.getFileName(file); - return fileName ? self.slug(fileName) : defaultValue; - }, - _getFileNames: function (skipNull) { - var self = this; - return self.filenames.filter(function (n) { - return (skipNull ? n !== undefined : n !== undefined && n !== null); - }); - }, - _setPreviewError: function ($thumb, keepFile) { - var self = this, removeFrame = self.removeFromPreviewOnError && !self.retryErrorUploads; - if (!keepFile || removeFrame) { - self.fileManager.remove($thumb); - } - if (!self.showPreview) { - return; - } - if (removeFrame) { - $thumb.remove(); - return; - } else { - self._setThumbStatus($thumb, 'Error'); - } - self._refreshUploadButton($thumb); - }, - _refreshUploadButton: function ($thumb) { - var self = this, $btn = $thumb.find('.kv-file-upload'), cfg = self.fileActionSettings, - icon = cfg.uploadIcon, title = cfg.uploadTitle; - if (!$btn.length) { - return; - } - if (self.retryErrorUploads) { - icon = cfg.uploadRetryIcon; - title = cfg.uploadRetryTitle; - } - $btn.attr('title', title).html(icon); - }, - _checkDimensions: function (i, chk, $img, $thumb, fname, type, params) { - var self = this, msg, dim, tag = chk === 'Small' ? 'min' : 'max', limit = self[tag + 'Image' + type], - $imgEl, isValid; - if ($h.isEmpty(limit) || !$img.length) { - return; - } - $imgEl = $img[0]; - dim = (type === 'Width') ? $imgEl.naturalWidth || $imgEl.width : $imgEl.naturalHeight || $imgEl.height; - isValid = chk === 'Small' ? dim >= limit : dim <= limit; - if (isValid) { - return; - } - msg = self['msgImage' + type + chk].setTokens({'name': fname, 'size': limit}); - self._showFileError(msg, params); - self._setPreviewError($thumb); - }, - _getExifObj: function (data) { - var self = this, exifObj = null, error = $h.logMessages.exifWarning; - if (data.slice(0, 23) !== 'data:image/jpeg;base64,' && data.slice(0, 22) !== 'data:image/jpg;base64,') { - exifObj = null; - return; - } - try { - exifObj = window.piexif ? window.piexif.load(data) : null; - } catch (err) { - exifObj = null; - error = err && err.message || ''; - } - if (!exifObj) { - self._log($h.logMessages.badExifParser, {details: error}); - } - return exifObj; - }, - setImageOrientation: function ($img, $zoomImg, value, $thumb) { - var self = this, invalidImg = !$img || !$img.length, invalidZoomImg = !$zoomImg || !$zoomImg.length, $mark, - isHidden = false, $div, zoomOnly = invalidImg && $thumb && $thumb.attr('data-template') === 'image', ev; - if (invalidImg && invalidZoomImg) { - return; - } - ev = 'load.fileinputimageorient'; - if (zoomOnly) { - $img = $zoomImg; - $zoomImg = null; - $img.css(self.previewSettings.image); - $div = $(document.createElement('div')).appendTo($thumb.find('.kv-file-content')); - $mark = $(document.createElement('span')).insertBefore($img); - $img.css('visibility', 'hidden').removeClass('file-zoom-detail').appendTo($div); - } else { - isHidden = !$img.is(':visible'); - } - $img.off(ev).on(ev, function () { - if (isHidden) { - self.$preview.removeClass('hide-content'); - $thumb.find('.kv-file-content').css('visibility', 'hidden'); - } - var img = $img.get(0), zoomImg = $zoomImg && $zoomImg.length ? $zoomImg.get(0) : null, - h = img.offsetHeight, w = img.offsetWidth, r = $h.getRotation(value); - if (isHidden) { - $thumb.find('.kv-file-content').css('visibility', 'visible'); - self.$preview.addClass('hide-content'); - } - $img.data('orientation', value); - if (zoomImg) { - $zoomImg.data('orientation', value); - } - if (value < 5) { - $h.setTransform(img, r); - $h.setTransform(zoomImg, r); - return; - } - var offsetAngle = Math.atan(w / h), origFactor = Math.sqrt(Math.pow(h, 2) + Math.pow(w, 2)), - scale = !origFactor ? 1 : (h / Math.cos(Math.PI / 2 + offsetAngle)) / origFactor, - s = ' scale(' + Math.abs(scale) + ')'; - $h.setTransform(img, r + s); - $h.setTransform(zoomImg, r + s); - if (zoomOnly) { - $img.css('visibility', 'visible').insertAfter($mark).addClass('file-zoom-detail'); - $mark.remove(); - $div.remove(); - } - }); - }, - _validateImageOrientation: function ($img, file, previewId, fileId, caption, ftype, fsize, iData) { - var self = this, exifObj, value, autoOrientImage = self.autoOrientImage; - exifObj = autoOrientImage ? self._getExifObj(iData) : null; - value = exifObj ? exifObj['0th'][piexif.ImageIFD.Orientation] : null; // jshint ignore:line - if (!value) { - self._validateImage(previewId, fileId, caption, ftype, fsize, iData, exifObj); - return; - } - self.setImageOrientation($img, $('#zoom-' + previewId + ' img'), value, $('#' + previewId)); - self._raise('fileimageoriented', {'$img': $img, 'file': file}); - self._validateImage(previewId, fileId, caption, ftype, fsize, iData, exifObj); - }, - _validateImage: function (previewId, fileId, fname, ftype, fsize, iData, exifObj) { - var self = this, $preview = self.$preview, params, w1, w2, $thumb = $preview.find('#' + previewId), - i = $thumb.attr('data-fileindex'), $img = $thumb.find('img'); - fname = fname || 'Untitled'; - $img.one('load', function () { - w1 = $thumb.width(); - w2 = $preview.width(); - if (w1 > w2) { - $img.css('width', '100%'); - } - params = {ind: i, id: previewId, fileId: fileId}; - self._checkDimensions(i, 'Small', $img, $thumb, fname, 'Width', params); - self._checkDimensions(i, 'Small', $img, $thumb, fname, 'Height', params); - if (!self.resizeImage) { - self._checkDimensions(i, 'Large', $img, $thumb, fname, 'Width', params); - self._checkDimensions(i, 'Large', $img, $thumb, fname, 'Height', params); - } - self._raise('fileimageloaded', [previewId]); - self.fileManager.addImage(fileId, { - ind: i, - img: $img, - thumb: $thumb, - pid: previewId, - typ: ftype, - siz: fsize, - validated: false, - imgData: iData, - exifObj: exifObj - }); - $thumb.data('exif', exifObj); - self._validateAllImages(); - }).one('error', function () { - self._raise('fileimageloaderror', [previewId]); - }).each(function () { - if (this.complete) { - $(this).trigger('load'); - } else { - if (this.error) { - $(this).trigger('error'); - } - } - }); - }, - _validateAllImages: function () { - var self = this, counter = {val: 0}, numImgs = self.fileManager.getImageCount(), fsize, - minSize = self.resizeIfSizeMoreThan; - if (numImgs !== self.fileManager.totalImages) { - return; - } - self._raise('fileimagesloaded'); - if (!self.resizeImage) { - return; - } - $.each(self.fileManager.loadedImages, function (id, config) { - if (!config.validated) { - fsize = config.siz; - if (fsize && fsize > minSize * 1000) { - self._getResizedImage(id, config, counter, numImgs); - } - config.validated = true; - } - }); - }, - _getResizedImage: function (id, config, counter, numImgs) { - var self = this, img = $(config.img)[0], width = img.naturalWidth, height = img.naturalHeight, blob, - ratio = 1, maxWidth = self.maxImageWidth || width, maxHeight = self.maxImageHeight || height, - isValidImage = !!(width && height), chkWidth, chkHeight, canvas = self.imageCanvas, dataURI, - context = self.imageCanvasContext, type = config.typ, pid = config.pid, ind = config.ind, - $thumb = config.thumb, throwError, msg, exifObj = config.exifObj, exifStr, file, params, evParams; - throwError = function (msg, params, ev) { - if (self.isAjaxUpload) { - self._showFileError(msg, params, ev); - } else { - self._showError(msg, params, ev); - } - self._setPreviewError($thumb); - }; - file = self.fileManager.getFile(id); - params = {id: pid, 'index': ind, fileId: id}; - evParams = [id, pid, ind]; - if (!file || !isValidImage || (width <= maxWidth && height <= maxHeight)) { - if (isValidImage && file) { - self._raise('fileimageresized', evParams); - } - counter.val++; - if (counter.val === numImgs) { - self._raise('fileimagesresized'); - } - if (!isValidImage) { - throwError(self.msgImageResizeError, params, 'fileimageresizeerror'); - return; - } - } - type = type || self.resizeDefaultImageType; - chkWidth = width > maxWidth; - chkHeight = height > maxHeight; - if (self.resizePreference === 'width') { - ratio = chkWidth ? maxWidth / width : (chkHeight ? maxHeight / height : 1); - } else { - ratio = chkHeight ? maxHeight / height : (chkWidth ? maxWidth / width : 1); - } - self._resetCanvas(); - width *= ratio; - height *= ratio; - canvas.width = width; - canvas.height = height; - try { - context.drawImage(img, 0, 0, width, height); - dataURI = canvas.toDataURL(type, self.resizeQuality); - if (exifObj) { - exifStr = window.piexif.dump(exifObj); - dataURI = window.piexif.insert(exifStr, dataURI); - } - blob = $h.dataURI2Blob(dataURI); - self.fileManager.setFile(id, blob); - self._raise('fileimageresized', evParams); - counter.val++; - if (counter.val === numImgs) { - self._raise('fileimagesresized', [undefined, undefined]); - } - if (!(blob instanceof Blob)) { - throwError(self.msgImageResizeError, params, 'fileimageresizeerror'); - } - } - catch (err) { - counter.val++; - if (counter.val === numImgs) { - self._raise('fileimagesresized', [undefined, undefined]); - } - msg = self.msgImageResizeException.replace('{errors}', err.message); - throwError(msg, params, 'fileimageresizeexception'); - } - }, - _initBrowse: function ($container) { - var self = this, $el = self.$element; - if (self.showBrowse) { - self.$btnFile = $container.find('.btn-file').append($el); - } else { - $el.appendTo($container).attr('tabindex', -1); - $h.addCss($el, 'file-no-browse'); - } - }, - _initClickable: function () { - var self = this, $zone, $tmpZone; - if (!self.isClickable) { - return; - } - $zone = self.$dropZone; - if (!self.isAjaxUpload) { - $tmpZone = self.$preview.find('.file-default-preview'); - if ($tmpZone.length) { - $zone = $tmpZone; - } - } - - $h.addCss($zone, 'clickable'); - $zone.attr('tabindex', -1); - self._handler($zone, 'click', function (e) { - var $tar = $(e.target); - if (!$(self.elErrorContainer + ':visible').length && - (!$tar.parents('.file-preview-thumbnails').length || $tar.parents( - '.file-default-preview').length)) { - self.$element.data('zoneClicked', true).trigger('click'); - $zone.blur(); - } - }); - }, - _initCaption: function () { - var self = this, cap = self.initialCaption || ''; - if (self.overwriteInitial || $h.isEmpty(cap)) { - self.$caption.val(''); - return false; - } - self._setCaption(cap); - return true; - }, - _setCaption: function (content, isError) { - var self = this, title, out, icon, n, cap, file; - if (!self.$caption.length) { - return; - } - self.$captionContainer.removeClass('icon-visible'); - if (isError) { - title = $('
    ' + self.msgValidationError + '
    ').text(); - n = self.fileManager.count(); - if (n) { - file = self.fileManager.getFirstFile(); - cap = n === 1 && file ? file.nameFmt : self._getMsgSelected(n); - } else { - cap = self._getMsgSelected(self.msgNo); - } - out = $h.isEmpty(content) ? cap : content; - icon = '' + self.msgValidationErrorIcon + ''; - } else { - if ($h.isEmpty(content)) { - return; - } - title = $('
    ' + content + '
    ').text(); - out = title; - icon = self._getLayoutTemplate('fileIcon'); - } - self.$captionContainer.addClass('icon-visible'); - self.$caption.attr('title', title).val(out); - self.$captionIcon.html(icon); - }, - _createContainer: function () { - var self = this, attribs = {'class': 'file-input file-input-new' + (self.rtl ? ' kv-rtl' : '')}, - $container = $(document.createElement('div')).attr(attribs).html(self._renderMain()); - $container.insertBefore(self.$element); - self._initBrowse($container); - if (self.theme) { - $container.addClass('theme-' + self.theme); - } - return $container; - }, - _refreshContainer: function () { - var self = this, $container = self.$container, $el = self.$element; - $el.insertAfter($container); - $container.html(self._renderMain()); - self._initBrowse($container); - self._validateDisabled(); - }, - _validateDisabled: function () { - var self = this; - self.$caption.attr({readonly: self.isDisabled}); - }, - _renderMain: function () { - var self = this, - dropCss = self.dropZoneEnabled ? ' file-drop-zone' : 'file-drop-disabled', - close = !self.showClose ? '' : self._getLayoutTemplate('close'), - preview = !self.showPreview ? '' : self._getLayoutTemplate('preview') - .setTokens({'class': self.previewClass, 'dropClass': dropCss}), - css = self.isDisabled ? self.captionClass + ' file-caption-disabled' : self.captionClass, - caption = self.captionTemplate.setTokens({'class': css + ' kv-fileinput-caption'}); - return self.mainTemplate.setTokens({ - 'class': self.mainClass + (!self.showBrowse && self.showCaption ? ' no-browse' : ''), - 'preview': preview, - 'close': close, - 'caption': caption, - 'upload': self._renderButton('upload'), - 'remove': self._renderButton('remove'), - 'cancel': self._renderButton('cancel'), - 'pause': self._renderButton('pause'), - 'browse': self._renderButton('browse') - }); - - }, - _renderButton: function (type) { - var self = this, tmplt = self._getLayoutTemplate('btnDefault'), css = self[type + 'Class'], - title = self[type + 'Title'], icon = self[type + 'Icon'], label = self[type + 'Label'], - status = self.isDisabled ? ' disabled' : '', btnType = 'button'; - switch (type) { - case 'remove': - if (!self.showRemove) { - return ''; - } - break; - case 'cancel': - if (!self.showCancel) { - return ''; - } - css += ' kv-hidden'; - break; - case 'pause': - if (!self.showPause) { - return ''; - } - css += ' kv-hidden'; - break; - case 'upload': - if (!self.showUpload) { - return ''; - } - if (self.isAjaxUpload && !self.isDisabled) { - tmplt = self._getLayoutTemplate('btnLink').replace('{href}', self.uploadUrl); - } else { - btnType = 'submit'; - } - break; - case 'browse': - if (!self.showBrowse) { - return ''; - } - tmplt = self._getLayoutTemplate('btnBrowse'); - break; - default: - return ''; - } - - css += type === 'browse' ? ' btn-file' : ' fileinput-' + type + ' fileinput-' + type + '-button'; - if (!$h.isEmpty(label)) { - label = ' ' + label + ''; - } - return tmplt.setTokens({ - 'type': btnType, 'css': css, 'title': title, 'status': status, 'icon': icon, 'label': label - }); - }, - _renderThumbProgress: function () { - var self = this; - return '
    ' + - self.progressInfoTemplate.setTokens({percent: 101, status: self.msgUploadBegin, stats: ''}) + - '
    '; - }, - _renderFileFooter: function (cat, caption, size, width, isError) { - var self = this, config = self.fileActionSettings, rem = config.showRemove, drg = config.showDrag, - upl = config.showUpload, zoom = config.showZoom, out, params, - template = self._getLayoutTemplate('footer'), tInd = self._getLayoutTemplate('indicator'), - ind = isError ? config.indicatorError : config.indicatorNew, - title = isError ? config.indicatorErrorTitle : config.indicatorNewTitle, - indicator = tInd.setTokens({'indicator': ind, 'indicatorTitle': title}); - size = self._getSize(size); - params = {type: cat, caption: caption, size: size, width: width, progress: '', indicator: indicator}; - if (self.isAjaxUpload) { - params.progress = self._renderThumbProgress(); - params.actions = self._renderFileActions(params, upl, false, rem, zoom, drg, false, false, false); - } else { - params.actions = self._renderFileActions(params, false, false, false, zoom, drg, false, false, false); - } - out = template.setTokens(params); - out = $h.replaceTags(out, self.previewThumbTags); - return out; - }, - _renderFileActions: function ( - cfg, - showUpl, - showDwn, - showDel, - showZoom, - showDrag, - disabled, - url, - key, - isInit, - dUrl, - dFile - ) { - var self = this; - if (!cfg.type && isInit) { - cfg.type = 'image'; - } - if (self.enableResumableUpload) { - showUpl = false; - } else { - if (typeof showUpl === 'function') { - showUpl = showUpl(cfg); - } - } - if (typeof showDwn === 'function') { - showDwn = showDwn(cfg); - } - if (typeof showDel === 'function') { - showDel = showDel(cfg); - } - if (typeof showZoom === 'function') { - showZoom = showZoom(cfg); - } - if (typeof showDrag === 'function') { - showDrag = showDrag(cfg); - } - if (!showUpl && !showDwn && !showDel && !showZoom && !showDrag) { - return ''; - } - var vUrl = url === false ? '' : ' data-url="' + url + '"', btnZoom = '', btnDrag = '', css, - vKey = key === false ? '' : ' data-key="' + key + '"', btnDelete = '', btnUpload = '', btnDownload = '', - template = self._getLayoutTemplate('actions'), config = self.fileActionSettings, - otherButtons = self.otherActionButtons.setTokens({'dataKey': vKey, 'key': key}), - removeClass = disabled ? config.removeClass + ' disabled' : config.removeClass; - if (showDel) { - btnDelete = self._getLayoutTemplate('actionDelete').setTokens({ - 'removeClass': removeClass, - 'removeIcon': config.removeIcon, - 'removeTitle': config.removeTitle, - 'dataUrl': vUrl, - 'dataKey': vKey, - 'key': key - }); - } - if (showUpl) { - btnUpload = self._getLayoutTemplate('actionUpload').setTokens({ - 'uploadClass': config.uploadClass, - 'uploadIcon': config.uploadIcon, - 'uploadTitle': config.uploadTitle - }); - } - if (showDwn) { - btnDownload = self._getLayoutTemplate('actionDownload').setTokens({ - 'downloadClass': config.downloadClass, - 'downloadIcon': config.downloadIcon, - 'downloadTitle': config.downloadTitle, - 'downloadUrl': dUrl || self.initialPreviewDownloadUrl - }); - btnDownload = btnDownload.setTokens({'filename': dFile, 'key': key}); - } - if (showZoom) { - btnZoom = self._getLayoutTemplate('actionZoom').setTokens({ - 'zoomClass': config.zoomClass, - 'zoomIcon': config.zoomIcon, - 'zoomTitle': config.zoomTitle - }); - } - if (showDrag && isInit) { - css = 'drag-handle-init ' + config.dragClass; - btnDrag = self._getLayoutTemplate('actionDrag').setTokens({ - 'dragClass': css, - 'dragTitle': config.dragTitle, - 'dragIcon': config.dragIcon - }); - } - return template.setTokens({ - 'delete': btnDelete, - 'upload': btnUpload, - 'download': btnDownload, - 'zoom': btnZoom, - 'drag': btnDrag, - 'other': otherButtons - }); - }, - _browse: function (e) { - var self = this; - if (e && e.isDefaultPrevented() || !self._raise('filebrowse')) { - return; - } - if (self.isError && !self.isAjaxUpload) { - self.clear(); - } - self.$captionContainer.focus(); - }, - _change: function (e) { - var self = this; - if (self.changeTriggered) { - return; - } - var $el = self.$element, isDragDrop = arguments.length > 1, isAjaxUpload = self.isAjaxUpload, - tfiles, files = isDragDrop ? arguments[1] : $el.get(0).files, total, - maxCount = !isAjaxUpload && $h.isEmpty($el.attr('multiple')) ? 1 : self.maxFileCount, - len, ctr = self.fileManager.count(), isSingleUpload = $h.isEmpty($el.attr('multiple')), - flagSingle = (isSingleUpload && ctr > 0), - throwError = function (mesg, file, previewId, index) { - var p1 = $.extend(true, {}, self._getOutData(null, {}, {}, files), {id: previewId, index: index}), - p2 = {id: previewId, index: index, file: file, files: files}; - return isAjaxUpload ? self._showFileError(mesg, p1) : self._showError(mesg, p2); - }, - maxCountCheck = function (n, m) { - var msg = self.msgFilesTooMany.replace('{m}', m).replace('{n}', n); - self.isError = throwError(msg, null, null, null); - self.$captionContainer.removeClass('icon-visible'); - self._setCaption('', true); - self.$container.removeClass('file-input-new file-input-ajax-new'); - }; - self.reader = null; - self._resetUpload(); - self._hideFileIcon(); - if (self.dropZoneEnabled) { - self.$container.find('.file-drop-zone .' + self.dropZoneTitleClass).remove(); - } - if (!isAjaxUpload) { - if (e.target && e.target.files === undefined) { - files = e.target.value ? [{name: e.target.value.replace(/^.+\\/, '')}] : []; - } else { - files = e.target.files || {}; - } - } - tfiles = files; - if ($h.isEmpty(tfiles) || tfiles.length === 0) { - if (!isAjaxUpload) { - self.clear(); - } - self._raise('fileselectnone'); - return; - } - self._resetErrors(); - len = tfiles.length; - total = self._getFileCount(isAjaxUpload ? (self.fileManager.count() + len) : len); - if (maxCount > 0 && total > maxCount) { - if (!self.autoReplace || len > maxCount) { - maxCountCheck((self.autoReplace && len > maxCount ? len : total), maxCount); - return; - } - if (total > maxCount) { - self._resetPreviewThumbs(isAjaxUpload); - } - } else { - if (!isAjaxUpload || flagSingle) { - self._resetPreviewThumbs(false); - if (flagSingle) { - self.clearFileStack(); - } - } else { - if (isAjaxUpload && ctr === 0 && (!self.previewCache.count(true) || self.overwriteInitial)) { - self._resetPreviewThumbs(true); - } - } - } - self.readFiles(tfiles); - }, - _abort: function (params) { - var self = this, data; - if (self.ajaxAborted && typeof self.ajaxAborted === 'object' && self.ajaxAborted.message !== undefined) { - data = $.extend(true, {}, self._getOutData(null), params); - data.abortData = self.ajaxAborted.data || {}; - data.abortMessage = self.ajaxAborted.message; - self._setProgress(101, self.$progress, self.msgCancelled); - self._showFileError(self.ajaxAborted.message, data, 'filecustomerror'); - self.cancel(); - return true; - } - return !!self.ajaxAborted; - }, - _resetFileStack: function () { - var self = this, i = 0; - self._getThumbs().each(function () { - var $thumb = $(this), ind = $thumb.attr('data-fileindex'), pid = $thumb.attr('id'); - if (ind === '-1' || ind === -1) { - return; - } - if (!self.fileManager.getFile($thumb.attr('data-fileid'))) { - $thumb.attr({'id': self.previewInitId + '-' + i, 'data-fileindex': i}); - i++; - } else { - $thumb.attr({'id': 'uploaded-' + $h.uniqId(), 'data-fileindex': '-1'}); - } - self.$preview.find('#zoom-' + pid).attr({ - 'id': 'zoom-' + $thumb.attr('id'), - 'data-fileindex': $thumb.attr('data-fileindex') - }); - }); - }, - _isFileSelectionValid: function (cnt) { - var self = this; - cnt = cnt || 0; - if (self.required && !self.getFilesCount()) { - self.$errorContainer.html(''); - self._showFileError(self.msgFileRequired); - return false; - } - if (self.minFileCount > 0 && self._getFileCount(cnt) < self.minFileCount) { - self._noFilesError({}); - return false; - } - return true; - }, - clearFileStack: function () { - var self = this; - self.fileManager.clear(); - self._initResumableUpload(); - if (self.enableResumableUpload) { - if (self.showPause === null) { - self.showPause = true; - } - if (self.showCancel === null) { - self.showCancel = false; - } - } else { - self.showPause = false; - if (self.showCancel === null) { - self.showCancel = true; - } - } - return self.$element; - }, - getFileStack: function () { - return this.fileManager.stack; - }, - getFileList: function () { - return this.fileManager.list(); - }, - getFilesCount: function () { - var self = this, len = self.isAjaxUpload ? self.fileManager.count() : self._inputFileCount(); - return self._getFileCount(len); - }, - readFiles: function (files) { - this.reader = new FileReader(); - var self = this, $el = self.$element, reader = self.reader, - $container = self.$previewContainer, $status = self.$previewStatus, msgLoading = self.msgLoading, - msgProgress = self.msgProgress, previewInitId = self.previewInitId, numFiles = files.length, - settings = self.fileTypeSettings, ctr = self.fileManager.count(), readFile, - fileTypes = self.allowedFileTypes, typLen = fileTypes ? fileTypes.length : 0, - fileExt = self.allowedFileExtensions, strExt = $h.isEmpty(fileExt) ? '' : fileExt.join(', '), - throwError = function (msg, file, previewId, index, fileId) { - var p1 = $.extend(true, {}, self._getOutData(null, {}, {}, files), - {id: previewId, index: index, fileId: fileId}), $thumb = $('#' + previewId), - p2 = {id: previewId, index: index, fileId: fileId, file: file, files: files}; - self._previewDefault(file, previewId, true); - if (self.isAjaxUpload) { - setTimeout(function () { - readFile(index + 1); - }, self.processDelay); - } else { - numFiles = 0; - } - self._initFileActions(); - $thumb.remove(); - self.isError = self.isAjaxUpload ? self._showFileError(msg, p1) : self._showError(msg, p2); - self._updateFileDetails(numFiles); - }; - self.fileManager.clearImages(); - $.each(files, function (key, file) { - var func = self.fileTypeSettings.image; - if (func && func(file.type)) { - self.fileManager.totalImages++; - } - }); - readFile = function (i) { - if ($h.isEmpty($el.attr('multiple'))) { - numFiles = 1; - } - if (i >= numFiles) { - if (self.isAjaxUpload && self.fileManager.count() > 0) { - self._raise('filebatchselected', [self.fileManager.stack]); - } else { - self._raise('filebatchselected', [files]); - } - $container.removeClass('file-thumb-loading'); - $status.html(''); - return; - } - var node = ctr + i, previewId = previewInitId + '-' + node, file = files[i], fSizeKB, j, msg, $thumb, - fnText = settings.text, fnImage = settings.image, fnHtml = settings.html, typ, chk, typ1, typ2, - caption = self._getFileName(file, ''), fileSize = (file && file.size || 0) / 1000, - fileExtExpr = '', previewData = $h.createObjectURL(file), fileCount = 0, - strTypes = '', fileId, - func, knownTypes = 0, isText, isHtml, isImage, txtFlag, processFileLoaded = function () { - var msg = msgProgress.setTokens({ - 'index': i + 1, - 'files': numFiles, - 'percent': 50, - 'name': caption - }); - setTimeout(function () { - $status.html(msg); - self._updateFileDetails(numFiles); - readFile(i + 1); - }, self.processDelay); - self._raise('fileloaded', [file, previewId, i, reader]); - }; - if (!file) { - return; - } - fileId = self.fileManager.getId(file); - if (typLen > 0) { - for (j = 0; j < typLen; j++) { - typ1 = fileTypes[j]; - typ2 = self.msgFileTypes[typ1] || typ1; - strTypes += j === 0 ? typ2 : ', ' + typ2; - } - } - if (caption === false) { - readFile(i + 1); - return; - } - if (caption.length === 0) { - msg = self.msgInvalidFileName.replace('{name}', $h.htmlEncode($h.getFileName(file), '[unknown]')); - throwError(msg, file, previewId, i, fileId); - return; - } - if (!$h.isEmpty(fileExt)) { - fileExtExpr = new RegExp('\\.(' + fileExt.join('|') + ')$', 'i'); - } - fSizeKB = fileSize.toFixed(2); - if (self.maxFileSize > 0 && fileSize > self.maxFileSize) { - msg = self.msgSizeTooLarge.setTokens({ - 'name': caption, - 'size': fSizeKB, - 'maxSize': self.maxFileSize - }); - throwError(msg, file, previewId, i, fileId); - return; - } - if (self.minFileSize !== null && fileSize <= $h.getNum(self.minFileSize)) { - msg = self.msgSizeTooSmall.setTokens({ - 'name': caption, - 'size': fSizeKB, - 'minSize': self.minFileSize - }); - throwError(msg, file, previewId, i, fileId); - return; - } - if (!$h.isEmpty(fileTypes) && $h.isArray(fileTypes)) { - for (j = 0; j < fileTypes.length; j += 1) { - typ = fileTypes[j]; - func = settings[typ]; - fileCount += !func || (typeof func !== 'function') ? 0 : (func(file.type, - $h.getFileName(file)) ? 1 : 0); - } - if (fileCount === 0) { - msg = self.msgInvalidFileType.setTokens({name: caption, types: strTypes}); - throwError(msg, file, previewId, i, fileId); - return; - } - } - if (fileCount === 0 && !$h.isEmpty(fileExt) && $h.isArray(fileExt) && !$h.isEmpty(fileExtExpr)) { - chk = $h.compare(caption, fileExtExpr); - fileCount += $h.isEmpty(chk) ? 0 : chk.length; - if (fileCount === 0) { - msg = self.msgInvalidFileExtension.setTokens({name: caption, extensions: strExt}); - throwError(msg, file, previewId, i, fileId); - return; - } - } - if (self.isAjaxUpload && self.fileManager.exists(fileId)) { - msg = self.msgDuplicateFile.setTokens({name: caption, size: fSizeKB}); - throwError(msg, file, previewId, i, fileId); - $thumb = $('#' + previewId); - if ($thumb && $thumb.length) { - $thumb.remove(); - } - return; - } - if (!self.canPreview(file)) { - if (self.isAjaxUpload) { - self.fileManager.add(file); - } - if (self.showPreview) { - $container.addClass('file-thumb-loading'); - self._previewDefault(file, previewId); - self._initFileActions(); - } - setTimeout(function () { - self._updateFileDetails(numFiles); - readFile(i + 1); - self._raise('fileloaded', [file, previewId, i]); - }, 10); - return; - } - isText = fnText(file.type, caption); - isHtml = fnHtml(file.type, caption); - isImage = fnImage(file.type, caption); - $status.html(msgLoading.replace('{index}', i + 1).replace('{files}', numFiles)); - $container.addClass('file-thumb-loading'); - reader.onerror = function (evt) { - self._errorHandler(evt, caption); - }; - reader.onload = function (theFile) { - var hex, fileInfo, uint, byte, bytes = [], contents, mime, readTextImage = function (textFlag) { - var newReader = new FileReader(); - newReader.onerror = function (theFileNew) { - self._errorHandler(theFileNew, caption); - }; - newReader.onload = function (theFileNew) { - self._previewFile(i, file, theFileNew, previewId, previewData, fileInfo); - self._initFileActions(); - processFileLoaded(); - }; - if (textFlag) { - newReader.readAsText(file, self.textEncoding); - } else { - newReader.readAsDataURL(file); - } - }; - fileInfo = {'name': caption, 'type': file.type}; - $.each(settings, function (k, f) { - if (k !== 'object' && k !== 'other' && typeof f === 'function' && f(file.type, caption)) { - knownTypes++; - } - }); - if (knownTypes === 0) {// auto detect mime types from content if no known file types detected - uint = new Uint8Array(theFile.target.result); - for (j = 0; j < uint.length; j++) { - byte = uint[j].toString(16); - bytes.push(byte); - } - hex = bytes.join('').toLowerCase().substring(0, 8); - mime = $h.getMimeType(hex, '', ''); - if ($h.isEmpty(mime)) { // look for ascii text content - contents = $h.arrayBuffer2String(reader.result); - mime = $h.isSvg(contents) ? 'image/svg+xml' : $h.getMimeType(hex, contents, file.type); - } - fileInfo = {'name': caption, 'type': mime}; - isText = fnText(mime, ''); - isHtml = fnHtml(mime, ''); - isImage = fnImage(mime, ''); - txtFlag = isText || isHtml; - if (txtFlag || isImage) { - readTextImage(txtFlag); - return; - } - } - self._previewFile(i, file, theFile, previewId, previewData, fileInfo); - self._initFileActions(); - processFileLoaded(); - }; - reader.onprogress = function (data) { - if (data.lengthComputable) { - var fact = (data.loaded / data.total) * 100, progress = Math.ceil(fact); - msg = msgProgress.setTokens({ - 'index': i + 1, - 'files': numFiles, - 'percent': progress, - 'name': caption - }); - setTimeout(function () { - $status.html(msg); - }, self.processDelay); - } - }; - - if (isText || isHtml) { - reader.readAsText(file, self.textEncoding); - } else { - if (isImage) { - reader.readAsDataURL(file); - } else { - reader.readAsArrayBuffer(file); - } - } - self.fileManager.add(file); - }; - - readFile(0); - self._updateFileDetails(numFiles, false); - }, - lock: function () { - var self = this, $container = self.$container; - self._resetErrors(); - self.disable(); - $container.addClass('is-locked'); - if (self.showCancel) { - $container.find('.fileinput-cancel').show(); - } - if (self.showPause) { - $container.find('.fileinput-pause').show(); - } - self._raise('filelock', [self.fileManager.stack, self._getExtraData()]); - return self.$element; - }, - unlock: function (reset) { - var self = this, $container = self.$container; - if (reset === undefined) { - reset = true; - } - self.enable(); - $container.removeClass('is-locked'); - if (self.showCancel) { - $container.find('.fileinput-cancel').hide(); - } - if (self.showPause) { - $container.find('.fileinput-pause').hide(); - } - if (reset) { - self._resetFileStack(); - } - self._raise('fileunlock', [self.fileManager.stack, self._getExtraData()]); - return self.$element; - }, - resume: function () { - var self = this, flag = false, $pr = self.$progress, rm = self.resumableManager; - if (!self.enableResumableUpload) { - return self.$element; - } - if (self.paused) { - $pr.html(self.progressPauseTemplate.setTokens({ - percent: 101, - status: self.msgUploadResume, - stats: '' - })); - } else { - flag = true; - } - self.paused = false; - if (flag) { - $pr.html(self.progressInfoTemplate.setTokens({ - percent: 101, - status: self.msgUploadBegin, - stats: '' - })); - } - setTimeout(function () { - rm.upload(); - }, self.processDelay); - return self.$element; - }, - pause: function () { - var self = this, rm = self.resumableManager, xhr = self.ajaxRequests, len = xhr.length, i, - pct = rm.getProgress(), actions = self.fileActionSettings; - if (!self.enableResumableUpload) { - return self.$element; - } - if (rm.chunkIntervalId) { - clearInterval(rm.chunkIntervalId); - } - if (self.ajaxQueueIntervalId) { - clearInterval(self.ajaxQueueIntervalId); - } - self._raise('fileuploadpaused', [self.fileManager, rm]); - if (len > 0) { - for (i = 0; i < len; i += 1) { - self.paused = true; - xhr[i].abort(); - } - } - if (self.showPreview) { - self._getThumbs().each(function () { - var $thumb = $(this), fileId = $thumb.attr('data-fileid'), t = self._getLayoutTemplate('stats'), - stats, $indicator = $thumb.find('.file-upload-indicator'); - $thumb.removeClass('file-uploading'); - if ($indicator.attr('title') === actions.indicatorLoadingTitle) { - self._setThumbStatus($thumb, 'Paused'); - stats = t.setTokens({pendingTime: self.msgPaused, uploadSpeed: ''}); - self.paused = true; - self._setProgress(pct, $thumb.find('.file-thumb-progress'), pct + '%', stats); - } - if (!self.fileManager.getFile(fileId)) { - $thumb.find('.kv-file-remove').removeClass('disabled').removeAttr('disabled'); - } - }); - } - self._setProgress(101, self.$progress, self.msgPaused); - return self.$element; - }, - cancel: function () { - var self = this, xhr = self.ajaxRequests, rm = self.resumableManager, len = xhr.length, i; - if (self.enableResumableUpload && rm.chunkIntervalId) { - clearInterval(rm.chunkIntervalId); - rm.reset(); - self._raise('fileuploadcancelled', [self.fileManager, rm]); - } else { - self._raise('fileuploadcancelled', [self.fileManager]); - } - if (self.ajaxQueueIntervalId) { - clearInterval(self.ajaxQueueIntervalId); - } - self._initAjax(); - if (len > 0) { - for (i = 0; i < len; i += 1) { - self.cancelling = true; - xhr[i].abort(); - } - } - self._getThumbs().each(function () { - var $thumb = $(this), fileId = $thumb.attr('data-fileid'), $prog = $thumb.find('.file-thumb-progress'); - $thumb.removeClass('file-uploading'); - self._setProgress(0, $prog); - $prog.hide(); - if (!self.fileManager.getFile(fileId)) { - $thumb.find('.kv-file-upload').removeClass('disabled').removeAttr('disabled'); - $thumb.find('.kv-file-remove').removeClass('disabled').removeAttr('disabled'); - } - self.unlock(); - }); - setTimeout(function () { - self._setProgressCancelled(); - }, self.processDelay); - return self.$element; - }, - clear: function () { - var self = this, cap; - if (!self._raise('fileclear')) { - return; - } - self.$btnUpload.removeAttr('disabled'); - self._getThumbs().find('video,audio,img').each(function () { - $h.cleanMemory($(this)); - }); - self._clearFileInput(); - self._resetUpload(); - self.clearFileStack(); - self._resetErrors(true); - if (self._hasInitialPreview()) { - self._showFileIcon(); - self._resetPreview(); - self._initPreviewActions(); - self.$container.removeClass('file-input-new'); - } else { - self._getThumbs().each(function () { - self._clearObjects($(this)); - }); - if (self.isAjaxUpload) { - self.previewCache.data = {}; - } - self.$preview.html(''); - cap = (!self.overwriteInitial && self.initialCaption.length > 0) ? self.initialCaption : ''; - self.$caption.attr('title', '').val(cap); - $h.addCss(self.$container, 'file-input-new'); - self._validateDefaultPreview(); - } - if (self.$container.find($h.FRAMES).length === 0) { - if (!self._initCaption()) { - self.$captionContainer.removeClass('icon-visible'); - } - } - self._hideFileIcon(); - self.$captionContainer.focus(); - self._setFileDropZoneTitle(); - self._raise('filecleared'); - return self.$element; - }, - reset: function () { - var self = this; - if (!self._raise('filereset')) { - return; - } - self.lastProgress = 0; - self._resetPreview(); - self.$container.find('.fileinput-filename').text(''); - $h.addCss(self.$container, 'file-input-new'); - if (self.getFrames().length || self.dropZoneEnabled) { - self.$container.removeClass('file-input-new'); - } - self.clearFileStack(); - self._setFileDropZoneTitle(); - return self.$element; - }, - disable: function () { - var self = this; - self.isDisabled = true; - self._raise('filedisabled'); - self.$element.attr('disabled', 'disabled'); - self.$container.find('.kv-fileinput-caption').addClass('file-caption-disabled'); - self.$container.find('.fileinput-remove, .fileinput-upload, .file-preview-frame button') - .attr('disabled', true); - $h.addCss(self.$container.find('.btn-file'), 'disabled'); - self._initDragDrop(); - return self.$element; - }, - enable: function () { - var self = this; - self.isDisabled = false; - self._raise('fileenabled'); - self.$element.removeAttr('disabled'); - self.$container.find('.kv-fileinput-caption').removeClass('file-caption-disabled'); - self.$container.find('.fileinput-remove, .fileinput-upload, .file-preview-frame button') - .removeAttr('disabled'); - self.$container.find('.btn-file').removeClass('disabled'); - self._initDragDrop(); - return self.$element; - }, - upload: function () { - var self = this, fm = self.fileManager, totLen = fm.count(), i, outData, len, - hasExtraData = !$.isEmptyObject(self._getExtraData()); - if (!self.isAjaxUpload || self.isDisabled || !self._isFileSelectionValid(totLen)) { - return; - } - self.lastProgress = 0; - self._resetUpload(); - if (totLen === 0 && !hasExtraData) { - self._showFileError(self.msgUploadEmpty); - return; - } - self.cancelling = false; - self.$progress.show(); - self.lock(); - len = fm.count(); - if (totLen === 0 && hasExtraData) { - self._setProgress(2); - self._uploadExtraOnly(); - return; - } - if (self.enableResumableUpload) { - return self.resume(); - } - if (self.uploadAsync || self.enableResumableUpload) { - outData = self._getOutData(null); - self._raise('filebatchpreupload', [outData]); - self.fileBatchCompleted = false; - self.uploadCache = {content: [], config: [], tags: [], append: true}; - for (i = 0; i < len; i++) { - self.uploadCache.content[i] = null; - self.uploadCache.config[i] = null; - self.uploadCache.tags[i] = null; - } - self.$preview.find('.file-preview-initial').removeClass($h.SORT_CSS); - self._initSortable(); - self.cacheInitialPreview = self.getPreview(); - } - self._setProgress(2); - self.hasInitData = false; - if (self.uploadAsync) { - i = 0; - $.each(fm.stack, function (id) { - self._uploadSingle(i, id, true); - i++; - }); - return; - } - self._uploadBatch(); - return self.$element; - }, - destroy: function () { - var self = this, $form = self.$form, $cont = self.$container, $el = self.$element, ns = self.namespace; - $(document).off(ns); - $(window).off(ns); - if ($form && $form.length) { - $form.off(ns); - } - if (self.isAjaxUpload) { - self._clearFileInput(); - } - self._cleanup(); - self._initPreviewCache(); - $el.insertBefore($cont).off(ns).removeData(); - $cont.off().remove(); - return $el; - }, - refresh: function (options) { - var self = this, $el = self.$element; - if (typeof options !== 'object' || $h.isEmpty(options)) { - options = self.options; - } else { - options = $.extend(true, {}, self.options, options); - } - self._init(options, true); - self._listen(); - return $el; - }, - zoom: function (frameId) { - var self = this, $frame = self._getFrame(frameId), $modal = self.$modal; - if (!$frame) { - return; - } - $h.initModal($modal); - $modal.html(self._getModalContent()); - self._setZoomContent($frame); - $modal.modal('show'); - self._initZoomButtons(); - }, - getExif: function (frameId) { - var self = this, $frame = self._getFrame(frameId); - return $frame && $frame.data('exif') || null; - }, - getFrames: function (cssFilter) { - var self = this, $frames; - cssFilter = cssFilter || ''; - $frames = self.$preview.find($h.FRAMES + cssFilter); - if (self.reversePreviewOrder) { - $frames = $($frames.get().reverse()); - } - return $frames; - }, - getPreview: function () { - var self = this; - return { - content: self.initialPreview, - config: self.initialPreviewConfig, - tags: self.initialPreviewThumbTags - }; - } - }; - - $.fn.fileinput = function (option) { - if (!$h.hasFileAPISupport() && !$h.isIE(9)) { - return; - } - var args = Array.apply(null, arguments), retvals = []; - args.shift(); - this.each(function () { - var self = $(this), data = self.data('fileinput'), options = typeof option === 'object' && option, - theme = options.theme || self.data('theme'), l = {}, t = {}, - lang = options.language || self.data('language') || $.fn.fileinput.defaults.language || 'en', opt; - if (!data) { - if (theme) { - t = $.fn.fileinputThemes[theme] || {}; - } - if (lang !== 'en' && !$h.isEmpty($.fn.fileinputLocales[lang])) { - l = $.fn.fileinputLocales[lang] || {}; - } - opt = $.extend(true, {}, $.fn.fileinput.defaults, t, $.fn.fileinputLocales.zh, l, options, self.data()); - data = new FileInput(this, opt); - self.data('fileinput', data); - } - - if (typeof option === 'string') { - retvals.push(data[option].apply(data, args)); - } - }); - switch (retvals.length) { - case 0: - return this; - case 1: - return retvals[0]; - default: - return retvals; - } - }; - - //noinspection HtmlUnknownAttribute - $.fn.fileinput.defaults = { - language: 'en', - showCaption: true, - showBrowse: true, - showPreview: true, - showRemove: true, - showUpload: true, - showUploadStats: true, - showCancel: null, - showPause: null, - showClose: true, - showUploadedThumbs: true, - browseOnZoneClick: false, - autoReplace: false, - autoOrientImage: function () { // applicable for JPEG images only and non ios safari - var ua = window.navigator.userAgent, webkit = !!ua.match(/WebKit/i), - iOS = !!ua.match(/iP(od|ad|hone)/i), iOSSafari = iOS && webkit && !ua.match(/CriOS/i); - return !iOSSafari; - }, - autoOrientImageInitial: true, - required: false, - rtl: false, - hideThumbnailContent: false, - encodeUrl: true, - generateFileId: null, - previewClass: '', - captionClass: '', - frameClass: 'krajee-default', - mainClass: 'file-caption-main', - mainTemplate: null, - purifyHtml: true, - fileSizeGetter: null, - initialCaption: '', - initialPreview: [], - initialPreviewDelimiter: '*$$*', - initialPreviewAsData: false, - initialPreviewFileType: 'image', - initialPreviewConfig: [], - initialPreviewThumbTags: [], - previewThumbTags: {}, - initialPreviewShowDelete: true, - initialPreviewDownloadUrl: '', - removeFromPreviewOnError: false, - deleteUrl: '', - deleteExtraData: {}, - overwriteInitial: true, - sanitizeZoomCache: function (content) { - var $container = $(document.createElement('div')).append(content); - $container.find('input,select,.file-thumbnail-footer').remove(); - return $container.html(); - }, - previewZoomButtonIcons: { - prev: '', - next: '', - toggleheader: '', - fullscreen: '', - borderless: '', - close: '' - }, - previewZoomButtonClasses: { - prev: 'btn btn-navigate', - next: 'btn btn-navigate', - toggleheader: 'btn btn-sm btn-kv btn-default btn-outline-secondary', - fullscreen: 'btn btn-sm btn-kv btn-default btn-outline-secondary', - borderless: 'btn btn-sm btn-kv btn-default btn-outline-secondary', - close: 'btn btn-sm btn-kv btn-default btn-outline-secondary' - }, - previewTemplates: {}, - previewContentTemplates: {}, - preferIconicPreview: false, - preferIconicZoomPreview: false, - allowedFileTypes: null, - allowedFileExtensions: null, - allowedPreviewTypes: undefined, - allowedPreviewMimeTypes: null, - allowedPreviewExtensions: null, - disabledPreviewTypes: undefined, - disabledPreviewExtensions: ['msi', 'exe', 'com', 'zip', 'rar', 'app', 'vb', 'scr'], - disabledPreviewMimeTypes: null, - defaultPreviewContent: null, - customLayoutTags: {}, - customPreviewTags: {}, - previewFileIcon: '', - previewFileIconClass: 'file-other-icon', - previewFileIconSettings: {}, - previewFileExtSettings: {}, - buttonLabelClass: 'hidden-xs', - browseIcon: ' ', - browseClass: 'btn btn-primary', - removeIcon: '', - removeClass: 'btn btn-default btn-secondary', - cancelIcon: '', - cancelClass: 'btn btn-default btn-secondary', - pauseIcon: '', - pauseClass: 'btn btn-default btn-secondary', - uploadIcon: '', - uploadClass: 'btn btn-default btn-secondary', - uploadUrl: null, - uploadUrlThumb: null, - uploadAsync: true, - uploadParamNames: { - chunkCount: 'chunkCount', - chunkIndex: 'chunkIndex', - chunkSize: 'chunkSize', - chunkSizeStart: 'chunkSizeStart', - chunksUploaded: 'chunksUploaded', - fileBlob: 'fileBlob', - fileId: 'fileId', - fileName: 'fileName', - fileRelativePath: 'fileRelativePath', - fileSize: 'fileSize', - retryCount: 'retryCount' - }, - maxAjaxThreads: 5, - processDelay: 100, - queueDelay: 10, // must be lesser than process delay - progressDelay: 0, // must be lesser than process delay - enableResumableUpload: false, - resumableUploadOptions: { - fallback: null, - testUrl: null, // used for checking status of chunks/ files previously / partially uploaded - chunkSize: 2 * 1024, // in KB - maxThreads: 4, - maxRetries: 3, - showErrorLog: true - }, - uploadExtraData: {}, - zoomModalHeight: 480, - minImageWidth: null, - minImageHeight: null, - maxImageWidth: null, - maxImageHeight: null, - resizeImage: false, - resizePreference: 'width', - resizeQuality: 0.92, - resizeDefaultImageType: 'image/jpeg', - resizeIfSizeMoreThan: 0, // in KB - minFileSize: 0, - maxFileSize: 0, - maxFilePreviewSize: 25600, // 25 MB - minFileCount: 0, - maxFileCount: 0, - validateInitialCount: false, - msgValidationErrorClass: 'text-danger', - msgValidationErrorIcon: ' ', - msgErrorClass: 'file-error-message', - progressThumbClass: 'progress-bar progress-bar-striped active', - progressClass: 'progress-bar bg-success progress-bar-success progress-bar-striped active', - progressInfoClass: 'progress-bar bg-info progress-bar-info progress-bar-striped active', - progressCompleteClass: 'progress-bar bg-success progress-bar-success', - progressPauseClass: 'progress-bar bg-primary progress-bar-primary progress-bar-striped active', - progressErrorClass: 'progress-bar bg-danger progress-bar-danger', - progressUploadThreshold: 99, - previewFileType: 'image', - elCaptionContainer: null, - elCaptionText: null, - elPreviewContainer: null, - elPreviewImage: null, - elPreviewStatus: null, - elErrorContainer: null, - errorCloseButton: $h.closeButton('kv-error-close'), - slugCallback: null, - dropZoneEnabled: true, - dropZoneTitleClass: 'file-drop-zone-title', - fileActionSettings: {}, - otherActionButtons: '', - textEncoding: 'UTF-8', - ajaxSettings: {}, - ajaxDeleteSettings: {}, - showAjaxErrorDetails: true, - mergeAjaxCallbacks: false, - mergeAjaxDeleteCallbacks: false, - retryErrorUploads: true, - reversePreviewOrder: false, - usePdfRenderer: function () { - //noinspection JSUnresolvedVariable - var isIE11 = !!window.MSInputMethodContext && !!document.documentMode; - return !!navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/i) || isIE11; - }, - pdfRendererUrl: '', - pdfRendererTemplate: '' - }; - - // noinspection HtmlUnknownAttribute - $.fn.fileinputLocales.en = { - fileSingle: 'file', - filePlural: 'files', - browseLabel: 'Browse …', - removeLabel: 'Remove', - removeTitle: 'Clear all unprocessed files', - cancelLabel: 'Cancel', - cancelTitle: 'Abort ongoing upload', - pauseLabel: 'Pause', - pauseTitle: 'Pause ongoing upload', - uploadLabel: 'Upload', - uploadTitle: 'Upload selected files', - msgNo: 'No', - msgNoFilesSelected: 'No files selected', - msgCancelled: 'Cancelled', - msgPaused: 'Paused', - msgPlaceholder: 'Select {files}...', - msgZoomModalHeading: 'Detailed Preview', - msgFileRequired: 'You must select a file to upload.', - msgSizeTooSmall: 'File "{name}" ({size} KB) is too small and must be larger than {minSize} KB.', - msgSizeTooLarge: 'File "{name}" ({size} KB) exceeds maximum allowed upload size of {maxSize} KB.', - msgFilesTooLess: 'You must select at least {n} {files} to upload.', - msgFilesTooMany: 'Number of files selected for upload ({n}) exceeds maximum allowed limit of {m}.', - msgFileNotFound: 'File "{name}" not found!', - msgFileSecured: 'Security restrictions prevent reading the file "{name}".', - msgFileNotReadable: 'File "{name}" is not readable.', - msgFilePreviewAborted: 'File preview aborted for "{name}".', - msgFilePreviewError: 'An error occurred while reading the file "{name}".', - msgInvalidFileName: 'Invalid or unsupported characters in file name "{name}".', - msgInvalidFileType: 'Invalid type for file "{name}". Only "{types}" files are supported.', - msgInvalidFileExtension: 'Invalid extension for file "{name}". Only "{extensions}" files are supported.', - msgFileTypes: { - 'image': 'image', - 'html': 'HTML', - 'text': 'text', - 'video': 'video', - 'audio': 'audio', - 'flash': 'flash', - 'pdf': 'PDF', - 'object': 'object' - }, - msgUploadAborted: 'The file upload was aborted', - msgUploadThreshold: 'Processing...', - msgUploadBegin: 'Initializing...', - msgUploadEnd: 'Done', - msgUploadResume: 'Resuming upload...', - msgUploadEmpty: 'No valid data available for upload.', - msgUploadError: 'Upload Error', - msgDeleteError: 'Delete Error', - msgProgressError: 'Error', - msgValidationError: 'Validation Error', - msgLoading: 'Loading file {index} of {files} …', - msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.', - msgSelected: '{n} {files} selected', - msgFoldersNotAllowed: 'Drag & drop files only! {n} folder(s) dropped were skipped.', - msgImageWidthSmall: 'Width of image file "{name}" must be at least {size} px.', - msgImageHeightSmall: 'Height of image file "{name}" must be at least {size} px.', - msgImageWidthLarge: 'Width of image file "{name}" cannot exceed {size} px.', - msgImageHeightLarge: 'Height of image file "{name}" cannot exceed {size} px.', - msgImageResizeError: 'Could not get the image dimensions to resize.', - msgImageResizeException: 'Error while resizing the image.
    {errors}
    ', - msgAjaxError: 'Something went wrong with the {operation} operation. Please try again later!', - msgAjaxProgressError: '{operation} failed', - msgDuplicateFile: 'File "{name}" of same size "{size} KB" has already been selected earlier. Skipping duplicate selection.', - msgResumableUploadRetriesExceeded: 'Upload aborted beyond {max} retries for file {file}! Error Details:
    {error}
    ', - msgPendingTime: '{time} remaining', - msgCalculatingTime: 'calculating time remaining', - ajaxOperations: { - deleteThumb: 'file delete', - uploadThumb: 'file upload', - uploadBatch: 'batch file upload', - uploadExtra: 'form data upload' - }, - dropZoneTitle: 'Drag & drop files here …', - dropZoneClickTitle: '
    (or click to select {files})', - previewZoomButtonTitles: { - prev: 'View previous file', - next: 'View next file', - toggleheader: 'Toggle header', - fullscreen: 'Toggle full screen', - borderless: 'Toggle borderless mode', - close: 'Close detailed preview' - } - }; - - $.fn.fileinputLocales.zh = { - fileSingle: '文件', - filePlural: '个文件', - browseLabel: '选择 …', - removeLabel: '移除', - removeTitle: '清除选中文件', - cancelLabel: '取消', - cancelTitle: '取消进行中的上传', - pauseLabel: 'Pause', - pauseTitle: 'Pause ongoing upload', - uploadLabel: '上传', - uploadTitle: '上传选中文件', - msgNo: '没有', - msgNoFilesSelected: '未选择文件', - msgPaused: 'Paused', - msgCancelled: '取消', - msgPlaceholder: '选择 {files}...', - msgZoomModalHeading: '详细预览', - msgFileRequired: '必须选择一个文件上传.', - msgSizeTooSmall: '文件 "{name}" ({size} KB) 必须大于限定大小 {minSize} KB.', - msgSizeTooLarge: '文件 "{name}" ({size} KB) 超过了允许大小 {maxSize} KB.', - msgFilesTooLess: '你必须选择最少 {n} {files} 来上传. ', - msgFilesTooMany: '选择的上传文件个数 ({n}) 超出最大文件的限制个数 {m}.', - msgFileNotFound: '文件 "{name}" 未找到!', - msgFileSecured: '安全限制,为了防止读取文件 "{name}".', - msgFileNotReadable: '文件 "{name}" 不可读.', - msgFilePreviewAborted: '取消 "{name}" 的预览.', - msgFilePreviewError: '读取 "{name}" 时出现了一个错误.', - msgInvalidFileName: '文件名 "{name}" 包含非法字符.', - msgInvalidFileType: '不正确的类型 "{name}". 只支持 "{types}" 类型的文件.', - msgInvalidFileExtension: '不正确的文件扩展名 "{name}". 只支持 "{extensions}" 的文件扩展名.', - msgFileTypes: { - 'image': 'image', - 'html': 'HTML', - 'text': 'text', - 'video': 'video', - 'audio': 'audio', - 'flash': 'flash', - 'pdf': 'PDF', - 'object': 'object' - }, - msgUploadAborted: '该文件上传被中止', - msgUploadThreshold: '处理中...', - msgUploadBegin: '正在初始化...', - msgUploadEnd: '完成', - msgUploadResume: 'Resuming upload...', - msgUploadEmpty: '无效的文件上传.', - msgUploadError: 'Upload Error', - msgDeleteError: 'Delete Error', - msgProgressError: '上传出错', - msgValidationError: '验证错误', - msgLoading: '加载第 {index} 文件 共 {files} …', - msgProgress: '加载第 {index} 文件 共 {files} - {name} - {percent}% 完成.', - msgSelected: '{n} {files} 选中', - msgFoldersNotAllowed: '只支持拖拽文件! 跳过 {n} 拖拽的文件夹.', - msgImageWidthSmall: '图像文件的"{name}"的宽度必须是至少{size}像素.', - msgImageHeightSmall: '图像文件的"{name}"的高度必须至少为{size}像素.', - msgImageWidthLarge: '图像文件"{name}"的宽度不能超过{size}像素.', - msgImageHeightLarge: '图像文件"{name}"的高度不能超过{size}像素.', - msgImageResizeError: '无法获取的图像尺寸调整。', - msgImageResizeException: '调整图像大小时发生错误。
    {errors}
    ', - msgAjaxError: '{operation} 发生错误. 请重试!', - msgAjaxProgressError: '{operation} 失败', - msgDuplicateFile: 'File "{name}" of same size "{size} KB" has already been selected earlier. Skipping duplicate selection.', - msgResumableUploadRetriesExceeded: 'Upload aborted beyond {max} retries for file {file}! Error Details:
    {error}
    ', - msgPendingTime: '{time} remaining', - msgCalculatingTime: 'calculating time remaining', - ajaxOperations: { - deleteThumb: '删除文件', - uploadThumb: '上传文件', - uploadBatch: '批量上传', - uploadExtra: '表单数据上传' - }, - dropZoneTitle: '拖拽文件到这里 …
    支持多文件同时上传', - dropZoneClickTitle: '
    (或点击{files}按钮选择文件)', - fileActionSettings: { - removeTitle: '删除文件', - uploadTitle: '上传文件', - downloadTitle: '下载文件', - uploadRetryTitle: '重试', - zoomTitle: '查看详情', - dragTitle: '移动 / 重置', - indicatorNewTitle: '没有上传', - indicatorSuccessTitle: '上传', - indicatorErrorTitle: '上传错误', - indicatorPausedTitle: 'Upload Paused', - indicatorLoadingTitle: '上传 ...' - }, - previewZoomButtonTitles: { - prev: '预览上一个文件', - next: '预览下一个文件', - toggleheader: '缩放', - fullscreen: '全屏', - borderless: '无边界模式', - close: '关闭当前预览' - } - }; - - $.fn.fileinput.Constructor = FileInput; - - /** - * Convert automatically file inputs with class 'file' into a bootstrap fileinput control. - */ - $(document).ready(function () { - var $input = $('input.file[type=file]'); - if ($input.length) { - $input.fileinput(); - } - }); +/*! + * bootstrap-fileinput v5.0.4 + * http://plugins.krajee.com/file-input + * + * Author: Kartik Visweswaran + * Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com + * + * Licensed under the BSD-3-Clause + * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md + */ +(function (factory) { + 'use strict'; + //noinspection JSUnresolvedVariable + if (typeof define === 'function' && define.amd) { // jshint ignore:line + // AMD. Register as an anonymous module. + define(['jquery'], factory); // jshint ignore:line + } else { // noinspection JSUnresolvedVariable + if (typeof module === 'object' && module.exports) { // jshint ignore:line + // Node/CommonJS + // noinspection JSUnresolvedVariable + module.exports = factory(require('jquery')); // jshint ignore:line + } else { + // Browser globals + factory(window.jQuery); + } + } +}(function ($) { + 'use strict'; + + $.fn.fileinputLocales = {}; + $.fn.fileinputThemes = {}; + + String.prototype.setTokens = function (replacePairs) { + var str = this.toString(), key, re; + for (key in replacePairs) { + if (replacePairs.hasOwnProperty(key)) { + re = new RegExp('\{' + key + '\}', 'g'); + str = str.replace(re, replacePairs[key]); + } + } + return str; + }; + + var $h, FileInput; + + // fileinput helper object for all global variables and internal helper methods + //noinspection JSUnresolvedVariable + $h = { + FRAMES: '.kv-preview-thumb', + SORT_CSS: 'file-sortable', + OBJECT_PARAMS: '\n' + + '\n' + + '\n' + + '\n' + + '\n' + + '\n', + DEFAULT_PREVIEW: '
    \n' + + '{previewFileIcon}\n' + + '
    ', + MODAL_ID: 'kvFileinputModal', + MODAL_EVENTS: ['show', 'shown', 'hide', 'hidden', 'loaded'], + logMessages: { + ajaxError: '{status}: {error}. Error Details: {text}.', + badDroppedFiles: 'Error scanning dropped files!', + badExifParser: 'Error loading the piexif.js library. {details}', + badInputType: 'The input "type" must be set to "file" for initializing the "bootstrap-fileinput" plugin.', + exifWarning: 'To avoid this warning, either set "autoOrientImage" to "false" OR ensure you have loaded ' + + 'the "piexif.js" library correctly on your page before the "fileinput.js" script.', + invalidChunkSize: 'Invalid upload chunk size: "{chunkSize}". Resumable uploads are disabled.', + invalidThumb: 'Invalid thumb frame with id: "{id}".', + noResumableSupport: 'The browser does not support resumable or chunk uploads.', + noUploadUrl: 'The "uploadUrl" is not set. Ajax uploads and resumable uploads have been disabled.', + retryStatus: 'Retrying upload for chunk # {chunk} for {filename}... retry # {retry}.' + }, + objUrl: window.URL || window.webkitURL, + now: function () { + return new Date(); + }, + round: function (num) { + num = parseFloat(num); + return isNaN(num) ? 0 : Math.floor(Math.round(num)); + }, + getFileRelativePath: function (file) { + /** @namespace file.relativePath */ + /** @namespace file.webkitRelativePath */ + return String(file.relativePath || file.webkitRelativePath || $h.getFileName(file) || null); + + }, + getFileId: function (file, generateFileId) { + var relativePath = $h.getFileRelativePath(file); + if (typeof generateFileId === 'function') { + return generateFileId(file); + } + if (!file) { + return null; + } + if (!relativePath) { + return null; + } + return (file.size + '_' + relativePath.replace(/\s/img, '_')); + }, + getElapsed: function (seconds) { + var delta = seconds, out = '', result = {}, structure = { + year: 31536000, + month: 2592000, + week: 604800, // uncomment row to ignore + day: 86400, // feel free to add your own row + hour: 3600, + minute: 60, + second: 1 + }; + Object.keys(structure).forEach(function (key) { + result[key] = Math.floor(delta / structure[key]); + delta -= result[key] * structure[key]; + }); + $.each(result, function (key, value) { + if (value > 0) { + out += (out ? ' ' : '') + value + key.substring(0, 1); + } + }); + return out; + }, + debounce: function (func, delay) { + var inDebounce; + return function () { + var args = arguments, context = this; + clearTimeout(inDebounce); + inDebounce = setTimeout(function () { + func.apply(context, args); + }, delay); + }; + }, + stopEvent: function (e) { + e.stopPropagation(); + e.preventDefault(); + }, + getFileName: function (file) { + /** @namespace file.fileName */ + return file ? (file.fileName || file.name || '') : ''; // some confusion in different versions of Firefox + }, + createObjectURL: function (data) { + if ($h.objUrl && $h.objUrl.createObjectURL && data) { + return $h.objUrl.createObjectURL(data); + } + return ''; + }, + revokeObjectURL: function (data) { + if ($h.objUrl && $h.objUrl.revokeObjectURL && data) { + $h.objUrl.revokeObjectURL(data); + } + }, + compare: function (input, str, exact) { + return input !== undefined && (exact ? input === str : input.match(str)); + }, + isIE: function (ver) { + var div, status; + // check for IE versions < 11 + if (navigator.appName !== 'Microsoft Internet Explorer') { + return false; + } + if (ver === 10) { + return new RegExp('msie\\s' + ver, 'i').test(navigator.userAgent); + } + div = document.createElement('div'); + div.innerHTML = ''; + status = div.getElementsByTagName('i').length; + document.body.appendChild(div); + div.parentNode.removeChild(div); + return status; + }, + canAssignFilesToInput: function () { + var input = document.createElement('input'); + try { + input.type = 'file'; + input.files = null; + return true; + } catch (err) { + return false; + } + }, + getDragDropFolders: function (items) { + var i, item, len = items ? items.length : 0, folders = 0; + if (len > 0 && items[0].webkitGetAsEntry()) { + for (i = 0; i < len; i++) { + item = items[i].webkitGetAsEntry(); + if (item && item.isDirectory) { + folders++; + } + } + } + return folders; + }, + initModal: function ($modal) { + var $body = $('body'); + if ($body.length) { + $modal.appendTo($body); + } + }, + isEmpty: function (value, trim) { + return value === undefined || value === null || value.length === 0 || (trim && $.trim(value) === ''); + }, + isArray: function (a) { + return Array.isArray(a) || Object.prototype.toString.call(a) === '[object Array]'; + }, + ifSet: function (needle, haystack, def) { + def = def || ''; + return (haystack && typeof haystack === 'object' && needle in haystack) ? haystack[needle] : def; + }, + cleanArray: function (arr) { + if (!(arr instanceof Array)) { + arr = []; + } + return arr.filter(function (e) { + return (e !== undefined && e !== null); + }); + }, + spliceArray: function (arr, index, reverseOrder) { + var i, j = 0, out = [], newArr; + if (!(arr instanceof Array)) { + return []; + } + newArr = $.extend(true, [], arr); + if (reverseOrder) { + newArr.reverse(); + } + for (i = 0; i < newArr.length; i++) { + if (i !== index) { + out[j] = newArr[i]; + j++; + } + } + if (reverseOrder) { + out.reverse(); + } + return out; + }, + getNum: function (num, def) { + def = def || 0; + if (typeof num === 'number') { + return num; + } + if (typeof num === 'string') { + num = parseFloat(num); + } + return isNaN(num) ? def : num; + }, + hasFileAPISupport: function () { + return !!(window.File && window.FileReader); + }, + hasDragDropSupport: function () { + var div = document.createElement('div'); + /** @namespace div.draggable */ + /** @namespace div.ondragstart */ + /** @namespace div.ondrop */ + return !$h.isIE(9) && + (div.draggable !== undefined || (div.ondragstart !== undefined && div.ondrop !== undefined)); + }, + hasFileUploadSupport: function () { + return $h.hasFileAPISupport() && window.FormData; + }, + hasBlobSupport: function () { + try { + return !!window.Blob && Boolean(new Blob()); + } catch (e) { + return false; + } + }, + hasArrayBufferViewSupport: function () { + try { + return new Blob([new Uint8Array(100)]).size === 100; + } catch (e) { + return false; + } + }, + hasResumableUploadSupport: function () { + /** @namespace Blob.prototype.webkitSlice */ + /** @namespace Blob.prototype.mozSlice */ + return $h.hasFileUploadSupport() && $h.hasBlobSupport() && $h.hasArrayBufferViewSupport() && + (!!Blob.prototype.webkitSlice || !!Blob.prototype.mozSlice || !!Blob.prototype.slice || false); + }, + dataURI2Blob: function (dataURI) { + //noinspection JSUnresolvedVariable + var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || + window.MSBlobBuilder, canBlob = $h.hasBlobSupport(), byteStr, arrayBuffer, intArray, i, mimeStr, bb, + canProceed = (canBlob || BlobBuilder) && window.atob && window.ArrayBuffer && window.Uint8Array; + if (!canProceed) { + return null; + } + if (dataURI.split(',')[0].indexOf('base64') >= 0) { + byteStr = atob(dataURI.split(',')[1]); + } else { + byteStr = decodeURIComponent(dataURI.split(',')[1]); + } + arrayBuffer = new ArrayBuffer(byteStr.length); + intArray = new Uint8Array(arrayBuffer); + for (i = 0; i < byteStr.length; i += 1) { + intArray[i] = byteStr.charCodeAt(i); + } + mimeStr = dataURI.split(',')[0].split(':')[1].split(';')[0]; + if (canBlob) { + return new Blob([$h.hasArrayBufferViewSupport() ? intArray : arrayBuffer], {type: mimeStr}); + } + bb = new BlobBuilder(); + bb.append(arrayBuffer); + return bb.getBlob(mimeStr); + }, + arrayBuffer2String: function (buffer) { + //noinspection JSUnresolvedVariable + if (window.TextDecoder) { + // noinspection JSUnresolvedFunction + return new TextDecoder('utf-8').decode(buffer); + } + var array = Array.prototype.slice.apply(new Uint8Array(buffer)), out = '', i = 0, len, c, char2, char3; + len = array.length; + while (i < len) { + c = array[i++]; + switch (c >> 4) { // jshint ignore:line + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + // 0xxxxxxx + out += String.fromCharCode(c); + break; + case 12: + case 13: + // 110x xxxx 10xx xxxx + char2 = array[i++]; + out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); // jshint ignore:line + break; + case 14: + // 1110 xxxx 10xx xxxx 10xx xxxx + char2 = array[i++]; + char3 = array[i++]; + out += String.fromCharCode(((c & 0x0F) << 12) | // jshint ignore:line + ((char2 & 0x3F) << 6) | // jshint ignore:line + ((char3 & 0x3F) << 0)); // jshint ignore:line + break; + } + } + return out; + }, + isHtml: function (str) { + var a = document.createElement('div'); + a.innerHTML = str; + for (var c = a.childNodes, i = c.length; i--;) { + if (c[i].nodeType === 1) { + return true; + } + } + return false; + }, + isSvg: function (str) { + return str.match(/^\s*<\?xml/i) && (str.match(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + }, + replaceTags: function (str, tags) { + var out = str; + if (!tags) { + return out; + } + $.each(tags, function (key, value) { + if (typeof value === 'function') { + value = value(); + } + out = out.split(key).join(value); + }); + return out; + }, + cleanMemory: function ($thumb) { + var data = $thumb.is('img') ? $thumb.attr('src') : $thumb.find('source').attr('src'); + $h.revokeObjectURL(data); + }, + findFileName: function (filePath) { + var sepIndex = filePath.lastIndexOf('/'); + if (sepIndex === -1) { + sepIndex = filePath.lastIndexOf('\\'); + } + return filePath.split(filePath.substring(sepIndex, sepIndex + 1)).pop(); + }, + checkFullScreen: function () { + //noinspection JSUnresolvedVariable + return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || + document.msFullscreenElement; + }, + toggleFullScreen: function (maximize) { + var doc = document, de = doc.documentElement; + if (de && maximize && !$h.checkFullScreen()) { + /** @namespace document.requestFullscreen */ + /** @namespace document.msRequestFullscreen */ + /** @namespace document.mozRequestFullScreen */ + /** @namespace document.webkitRequestFullscreen */ + /** @namespace Element.ALLOW_KEYBOARD_INPUT */ + if (de.requestFullscreen) { + de.requestFullscreen(); + } else { + if (de.msRequestFullscreen) { + de.msRequestFullscreen(); + } else { + if (de.mozRequestFullScreen) { + de.mozRequestFullScreen(); + } else { + if (de.webkitRequestFullscreen) { + de.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); + } + } + } + } + } else { + /** @namespace document.exitFullscreen */ + /** @namespace document.msExitFullscreen */ + /** @namespace document.mozCancelFullScreen */ + /** @namespace document.webkitExitFullscreen */ + if (doc.exitFullscreen) { + doc.exitFullscreen(); + } else { + if (doc.msExitFullscreen) { + doc.msExitFullscreen(); + } else { + if (doc.mozCancelFullScreen) { + doc.mozCancelFullScreen(); + } else { + if (doc.webkitExitFullscreen) { + doc.webkitExitFullscreen(); + } + } + } + } + } + }, + moveArray: function (arr, oldIndex, newIndex, reverseOrder) { + var newArr = $.extend(true, [], arr); + if (reverseOrder) { + newArr.reverse(); + } + if (newIndex >= newArr.length) { + var k = newIndex - newArr.length; + while ((k--) + 1) { + newArr.push(undefined); + } + } + newArr.splice(newIndex, 0, newArr.splice(oldIndex, 1)[0]); + if (reverseOrder) { + newArr.reverse(); + } + return newArr; + }, + cleanZoomCache: function ($el) { + var $cache = $el.closest('.kv-zoom-cache-theme'); + if (!$cache.length) { + $cache = $el.closest('.kv-zoom-cache'); + } + $cache.remove(); + }, + closeButton: function (css) { + css = css ? 'close ' + css : 'close'; + return ''; + }, + getRotation: function (value) { + switch (value) { + case 2: + return 'rotateY(180deg)'; + case 3: + return 'rotate(180deg)'; + case 4: + return 'rotate(180deg) rotateY(180deg)'; + case 5: + return 'rotate(270deg) rotateY(180deg)'; + case 6: + return 'rotate(90deg)'; + case 7: + return 'rotate(90deg) rotateY(180deg)'; + case 8: + return 'rotate(270deg)'; + default: + return ''; + } + }, + setTransform: function (el, val) { + if (!el) { + return; + } + el.style.transform = val; + el.style.webkitTransform = val; + el.style['-moz-transform'] = val; + el.style['-ms-transform'] = val; + el.style['-o-transform'] = val; + } + }; + FileInput = function (element, options) { + var self = this; + self.$element = $(element); + self.$parent = self.$element.parent(); + if (!self._validate()) { + return; + } + self.isPreviewable = $h.hasFileAPISupport(); + self.isIE9 = $h.isIE(9); + self.isIE10 = $h.isIE(10); + if (self.isPreviewable || self.isIE9) { + self._init(options); + self._listen(); + } + self.$element.removeClass('file-loading'); + }; + //noinspection JSUnusedGlobalSymbols + FileInput.prototype = { + constructor: FileInput, + _cleanup: function () { + var self = this; + self.reader = null; + self.clearFileStack(); + self.fileBatchCompleted = true; + self.isError = false; + self.cancelling = false; + self.paused = false; + self.lastProgress = 0; + self._initAjax(); + }, + _initAjax: function () { + var self = this; + self.ajaxQueue = []; + self.ajaxRequests = []; + self.ajaxQueueIntervalId = null; + self.ajaxCurrentThreads = 0; + self.ajaxAborted = false; + }, + _init: function (options, refreshMode) { + var self = this, f, $el = self.$element, $cont, t, tmp; + self.options = options; + $.each(options, function (key, value) { + switch (key) { + case 'minFileCount': + case 'maxFileCount': + case 'minFileSize': + case 'maxFileSize': + case 'maxFilePreviewSize': + case 'resizeImageQuality': + case 'resizeIfSizeMoreThan': + case 'progressUploadThreshold': + case 'initialPreviewCount': + case 'zoomModalHeight': + case 'minImageHeight': + case 'maxImageHeight': + case 'minImageWidth': + case 'maxImageWidth': + self[key] = $h.getNum(value); + break; + default: + self[key] = value; + break; + } + }); + if (self.rtl) { // swap buttons for rtl + tmp = self.previewZoomButtonIcons.prev; + self.previewZoomButtonIcons.prev = self.previewZoomButtonIcons.next; + self.previewZoomButtonIcons.next = tmp; + } + // validate chunk threads to not exceed maxAjaxThreads + if (!isNaN(self.maxAjaxThreads) && self.maxAjaxThreads < self.resumableUploadOptions.maxThreads) { + self.resumableUploadOptions.maxThreads = self.maxAjaxThreads; + } + self._initFileManager(); + if (typeof self.autoOrientImage === 'function') { + self.autoOrientImage = self.autoOrientImage(); + } + if (typeof self.autoOrientImageInitial === 'function') { + self.autoOrientImageInitial = self.autoOrientImageInitial(); + } + if (!refreshMode) { + self._cleanup(); + } + self.$form = $el.closest('form'); + self._initTemplateDefaults(); + self.uploadFileAttr = !$h.isEmpty($el.attr('name')) ? $el.attr('name') : 'file_data'; + t = self._getLayoutTemplate('progress'); + self.progressTemplate = t.replace('{class}', self.progressClass); + self.progressInfoTemplate = t.replace('{class}', self.progressInfoClass); + self.progressPauseTemplate = t.replace('{class}', self.progressPauseClass); + self.progressCompleteTemplate = t.replace('{class}', self.progressCompleteClass); + self.progressErrorTemplate = t.replace('{class}', self.progressErrorClass); + self.isDisabled = $el.attr('disabled') || $el.attr('readonly'); + if (self.isDisabled) { + $el.attr('disabled', true); + } + self.isClickable = self.browseOnZoneClick && self.showPreview && + (self.dropZoneEnabled || !$h.isEmpty(self.defaultPreviewContent)); + self.isAjaxUpload = $h.hasFileUploadSupport() && !$h.isEmpty(self.uploadUrl); + self.dropZoneEnabled = $h.hasDragDropSupport() && self.dropZoneEnabled; + if (!self.isAjaxUpload) { + self.dropZoneEnabled = self.dropZoneEnabled && $h.canAssignFilesToInput(); + } + self.slug = typeof options.slugCallback === 'function' ? options.slugCallback : self._slugDefault; + self.mainTemplate = self.showCaption ? self._getLayoutTemplate('main1') : self._getLayoutTemplate('main2'); + self.captionTemplate = self._getLayoutTemplate('caption'); + self.previewGenericTemplate = self._getPreviewTemplate('generic'); + if (!self.imageCanvas && self.resizeImage && (self.maxImageWidth || self.maxImageHeight)) { + self.imageCanvas = document.createElement('canvas'); + self.imageCanvasContext = self.imageCanvas.getContext('2d'); + } + if ($h.isEmpty($el.attr('id'))) { + $el.attr('id', $h.uniqId()); + } + self.namespace = '.fileinput_' + $el.attr('id').replace(/-/g, '_'); + if (self.$container === undefined) { + self.$container = self._createContainer(); + } else { + self._refreshContainer(); + } + $cont = self.$container; + self.$dropZone = $cont.find('.file-drop-zone'); + self.$progress = $cont.find('.kv-upload-progress'); + self.$btnUpload = $cont.find('.fileinput-upload'); + self.$captionContainer = $h.getElement(options, 'elCaptionContainer', $cont.find('.file-caption')); + self.$caption = $h.getElement(options, 'elCaptionText', $cont.find('.file-caption-name')); + if (!$h.isEmpty(self.msgPlaceholder)) { + f = $el.attr('multiple') ? self.filePlural : self.fileSingle; + self.$caption.attr('placeholder', self.msgPlaceholder.replace('{files}', f)); + } + self.$captionIcon = self.$captionContainer.find('.file-caption-icon'); + self.$previewContainer = $h.getElement(options, 'elPreviewContainer', $cont.find('.file-preview')); + self.$preview = $h.getElement(options, 'elPreviewImage', $cont.find('.file-preview-thumbnails')); + self.$previewStatus = $h.getElement(options, 'elPreviewStatus', $cont.find('.file-preview-status')); + self.$errorContainer = $h.getElement(options, 'elErrorContainer', + self.$previewContainer.find('.kv-fileinput-error')); + self._validateDisabled(); + if (!$h.isEmpty(self.msgErrorClass)) { + $h.addCss(self.$errorContainer, self.msgErrorClass); + } + if (!refreshMode) { + self.$errorContainer.hide(); + self.previewInitId = 'preview-' + $h.uniqId(); + self._initPreviewCache(); + self._initPreview(true); + self._initPreviewActions(); + if (self.$parent.hasClass('file-loading')) { + self.$container.insertBefore(self.$parent); + self.$parent.remove(); + } + } else { + if (!self._errorsExist()) { + self.$errorContainer.hide(); + } + } + self._setFileDropZoneTitle(); + if ($el.attr('disabled')) { + self.disable(); + } + self._initZoom(); + if (self.hideThumbnailContent) { + $h.addCss(self.$preview, 'hide-content'); + } + }, + _initFileManager: function () { + var self = this; + self.fileManager = { + stack: {}, + processed: [], + errors: [], + loadedImages: {}, + totalImages: 0, + totalFiles: null, + totalSize: null, + uploadedSize: 0, + stats: {}, + initStats: function (id) { + var data = {started: $h.now().getTime()}; + if (id) { + self.fileManager.stats[id] = data; + } else { + self.fileManager.stats = data; + } + }, + getUploadStats: function (id, loaded, total) { + var fm = self.fileManager, started = id ? fm.stats[id] && fm.stats[id].started || null : null; + if (!started) { + started = $h.now().getTime(); + } + var elapsed = ($h.now().getTime() - started) / 1000, + speeds = ['B/s', 'KB/s', 'MB/s', 'GB/s', 'TB/s', 'PB/s', 'EB/s', 'ZB/s', 'YB/s'], + bps = elapsed ? loaded / elapsed : 0, bitrate = self._getSize(bps, speeds), + pendingBytes = total - loaded, + out = { + fileId: id, + started: started, + elapsed: elapsed, + loaded: loaded, + total: total, + bps: bps, + bitrate: bitrate, + pendingBytes: pendingBytes + }; + if (id) { + fm.stats[id] = out; + } else { + fm.stats = out; + } + return out; + }, + exists: function (id) { + return $.inArray(id, self.fileManager.getIdList()) !== -1; + }, + count: function () { + return self.fileManager.getIdList().length; + }, + total: function () { + var fm = self.fileManager; + if (!fm.totalFiles) { + fm.totalFiles = fm.count(); + } + return fm.totalFiles; + }, + getTotalSize: function () { + var fm = self.fileManager; + if (fm.totalSize) { + return fm.totalSize; + } + fm.totalSize = 0; + $.each(self.fileManager.stack, function (id, f) { + var size = parseFloat(f.size); + fm.totalSize += isNaN(size) ? 0 : size; + }); + return fm.totalSize; + }, + add: function (file, id) { + if (!id) { + id = self.fileManager.getId(file); + } + if (!id) { + return; + } + self.fileManager.stack[id] = { + file: file, + name: $h.getFileName(file), + relativePath: $h.getFileRelativePath(file), + size: file.size, + nameFmt: self._getFileName(file, ''), + sizeFmt: self._getSize(file.size) + }; + }, + remove: function ($thumb) { + var id = $thumb.attr('data-fileid'); + if (id) { + self.fileManager.removeFile(id); + } + }, + removeFile: function (id) { + delete self.fileManager.stack[id]; + delete self.fileManager.loadedImages[id]; + }, + move: function (idFrom, idTo) { + var result = {}, stack = self.fileManager.stack; + if (!idFrom && !idTo || idFrom === idTo) { + return; + } + $.each(stack, function (k, v) { + if (k !== idFrom) { + result[k] = v; + } + if (k === idTo) { + result[idFrom] = stack[idFrom]; + } + }); + self.fileManager.stack = result; + }, + list: function () { + var files = []; + $.each(self.fileManager.stack, function (k, v) { + if (v && v.file) { + files.push(v.file); + } + }); + return files; + }, + isPending: function (id) { + return $.inArray(id, self.fileManager.processed) === -1 && self.fileManager.exists(id); + }, + isProcessed: function () { + var processed = true, fm = self.fileManager; + $.each(fm.stack, function (id) { + if (fm.isPending(id)) { + processed = false; + } + }); + return processed; + }, + clear: function () { + var fm = self.fileManager; + fm.totalFiles = null; + fm.totalSize = null; + fm.uploadedSize = 0; + fm.stack = {}; + fm.errors = []; + fm.processed = []; + fm.stats = {}; + fm.clearImages(); + }, + clearImages: function () { + self.fileManager.loadedImages = {}; + self.fileManager.totalImages = 0; + }, + addImage: function (id, config) { + self.fileManager.loadedImages[id] = config; + }, + removeImage: function (id) { + delete self.fileManager.loadedImages[id]; + }, + getImageIdList: function () { + return Object.keys(self.fileManager.loadedImages); + }, + getImageCount: function () { + return self.fileManager.getImageIdList().length; + }, + getId: function (file) { + return self._getFileId(file); + }, + getIndex: function (id) { + return self.fileManager.getIdList().indexOf(id); + }, + getThumb: function (id) { + var $thumb = null; + self._getThumbs().each(function () { + if ($(this).attr('data-fileid') === id) { + $thumb = $(this); + } + }); + return $thumb; + }, + getThumbIndex: function ($thumb) { + var id = $thumb.attr('data-fileid'); + return self.fileManager.getIndex(id); + }, + getIdList: function () { + return Object.keys(self.fileManager.stack); + }, + getFile: function (id) { + return self.fileManager.stack[id] || null; + }, + getFileName: function (id, fmt) { + var file = self.fileManager.getFile(id); + if (!file) { + return ''; + } + return fmt ? (file.nameFmt || '') : file.name || ''; + }, + getFirstFile: function () { + var ids = self.fileManager.getIdList(), id = ids && ids.length ? ids[0] : null; + return self.fileManager.getFile(id); + }, + setFile: function (id, file) { + if (self.fileManager.getFile(id)) { + self.fileManager.stack[id].file = file; + } else { + self.fileManager.add(file, id); + } + }, + setProcessed: function (id) { + self.fileManager.processed.push(id); + }, + getProgress: function () { + var total = self.fileManager.total(), processed = self.fileManager.processed.length; + if (!total) { + return 0; + } + return Math.ceil(processed / total * 100); + + }, + setProgress: function (id, pct) { + var f = self.fileManager.getFile(id); + if (!isNaN(pct) && f) { + f.progress = pct; + } + } + }; + }, + _setUploadData: function (fd, config) { + var self = this; + $.each(config, function (key, value) { + var param = self.uploadParamNames[key] || key; + if ($h.isArray(value)) { + fd.append(param, value[0], value[1]); + } else { + fd.append(param, value); + } + }); + }, + _initResumableUpload: function () { + var self = this, opts = self.resumableUploadOptions, logs = $h.logMessages; + if (!self.enableResumableUpload) { + return; + } + if (opts.fallback !== false && typeof opts.fallback !== 'function') { + opts.fallback = function (s) { + s._log(logs.noResumableSupport); + s.enableResumableUpload = false; + }; + } + if (!$h.hasResumableUploadSupport() && opts.fallback !== false) { + opts.fallback(self); + return; + } + if (!self.uploadUrl && self.enableResumableUpload) { + self._log(logs.noUploadUrl); + self.enableResumableUpload = false; + return; + + } + opts.chunkSize = parseFloat(opts.chunkSize); + if (opts.chunkSize <= 0 || isNaN(opts.chunkSize)) { + self._log(logs.invalidChunkSize, {chunkSize: opts.chunkSize}); + self.enableResumableUpload = false; + return; + } + self.resumableManager = { + init: function (id, f, index) { + var rm = self.resumableManager, fm = self.fileManager; + rm.currThreads = 0; + rm.logs = []; + rm.stack = []; + rm.error = ''; + rm.chunkIntervalId = null; + rm.id = id; + rm.file = f.file; + rm.fileName = f.name; + rm.fileIndex = index; + rm.completed = false; + rm.testing = false; + rm.lastProgress = 0; + if (self.showPreview) { + rm.$thumb = fm.getThumb(id) || null; + rm.$progress = rm.$btnDelete = null; + if (rm.$thumb && rm.$thumb.length) { + rm.$progress = rm.$thumb.find('.file-thumb-progress'); + rm.$btnDelete = rm.$thumb.find('.kv-file-remove'); + } + } + rm.chunkSize = self.resumableUploadOptions.chunkSize * 1024; + rm.chunkCount = rm.getTotalChunks(); + }, + logAjaxError: function (jqXHR, textStatus, errorThrown) { + if (self.resumableUploadOptions.showErrorLog) { + self._log(logs.ajaxError, { + status: jqXHR.status, + error: errorThrown, + text: jqXHR.responseText || '' + }); + } + }, + reset: function () { + var rm = self.resumableManager; + rm.processed = {}; + }, + setProcessed: function (status) { + var rm = self.resumableManager, fm = self.fileManager, id = rm.id, msg, + $thumb = rm.$thumb, $prog = rm.$progress, hasThumb = $thumb && $thumb.length, + params = {id: hasThumb ? $thumb.attr('id') : '', index: fm.getIndex(id), fileId: id}; + rm.completed = true; + rm.lastProgress = 0; + fm.uploadedSize += rm.file.size; + if (hasThumb) { + $thumb.removeClass('file-uploading'); + } + if (status === 'success') { + if (self.showPreview) { + self._setProgress(101, $prog); + self._setThumbStatus($thumb, 'Success'); + self._initUploadSuccess(rm.processed[id].data, $thumb); + } + self.fileManager.removeFile(id); + delete rm.processed[id]; + self._raise('fileuploaded', [params.id, params.index, params.fileId]); + if (fm.isProcessed()) { + self._setProgress(101); + } + } else { + if (self.showPreview) { + self._setThumbStatus($thumb, 'Error'); + self._setPreviewError($thumb, true); + self._setProgress(101, $prog, self.msgProgressError); + self._setProgress(101, self.$progress, self.msgProgressError); + self.cancelling = true; + } + if (!self.$errorContainer.find('li[data-file-id="' + params.fileId + '"]').length) { + msg = self.msgResumableUploadRetriesExceeded.setTokens({ + file: rm.fileName, + max: self.resumableUploadOptions.maxRetries, + error: rm.error + }); + self._showFileError(msg, params); + } + } + if (fm.isProcessed()) { + rm.reset(); + } + }, + check: function () { + var rm = self.resumableManager, status = true; + $.each(rm.logs, function (index, value) { + if (!value) { + status = false; + return false; + } + }); + if (status) { + clearInterval(rm.chunkIntervalId); + rm.setProcessed('success'); + } + }, + processedResumables: function () { + var logs = self.resumableManager.logs, i, count = 0; + if (!logs || !logs.length) { + return 0; + } + for (i = 0; i < logs.length; i++) { + if (logs[i] === true) { + count++; + } + } + return count; + }, + getUploadedSize: function () { + var rm = self.resumableManager, size = rm.processedResumables() * rm.chunkSize; + return size > rm.file.size ? rm.file.size : size; + }, + getTotalChunks: function () { + var rm = self.resumableManager, chunkSize = parseFloat(rm.chunkSize); + if (!isNaN(chunkSize) && chunkSize > 0) { + return Math.ceil(rm.file.size / chunkSize); + } + return 0; + }, + getProgress: function () { + var rm = self.resumableManager, processed = rm.processedResumables(), total = rm.chunkCount; + if (total === 0) { + return 0; + } + return Math.ceil(processed / total * 100); + }, + checkAborted: function (intervalId) { + if (self.paused || self.cancelling) { + clearInterval(intervalId); + self.unlock(); + } + }, + upload: function () { + var rm = self.resumableManager, fm = self.fileManager, ids = fm.getIdList(), flag = 'new', + intervalId; + intervalId = setInterval(function () { + var id; + rm.checkAborted(intervalId); + if (flag === 'new') { + self.lock(); + flag = 'processing'; + id = ids.shift(); + fm.initStats(id); + if (fm.stack[id]) { + rm.init(id, fm.stack[id], fm.getIndex(id)); + rm.testUpload(); + rm.uploadResumable(); + } + } + if (!fm.isPending(id) && rm.completed) { + flag = 'new'; + } + if (fm.isProcessed()) { + var $initThumbs = self.$preview.find('.file-preview-initial'); + if ($initThumbs.length) { + $h.addCss($initThumbs, $h.SORT_CSS); + self._initSortable(); + } + clearInterval(intervalId); + self._clearFileInput(); + self.unlock(); + setTimeout(function () { + var data = self.previewCache.data; + if (data) { + self.initialPreview = data.content; + self.initialPreviewConfig = data.config; + self.initialPreviewThumbTags = data.tags; + } + self._raise('filebatchuploadcomplete', [ + self.initialPreview, + self.initialPreviewConfig, + self.initialPreviewThumbTags, + self._getExtraData() + ]); + }, self.processDelay); + } + }, self.processDelay); + }, + uploadResumable: function () { + var i, rm = self.resumableManager, total = rm.chunkCount; + for (i = 0; i < total; i++) { + rm.logs[i] = !!(rm.processed[rm.id] && rm.processed[rm.id][i]); + } + for (i = 0; i < total; i++) { + rm.pushAjax(i, 0); + } + rm.chunkIntervalId = setInterval(rm.loopAjax, self.queueDelay); + }, + testUpload: function () { + var rm = self.resumableManager, opts = self.resumableUploadOptions, fd, f, + fm = self.fileManager, id = rm.id, fnBefore, fnSuccess, fnError, fnComplete, outData; + if (!opts.testUrl) { + rm.testing = false; + return; + } + rm.testing = true; + fd = new FormData(); + f = fm.stack[id]; + self._setUploadData(fd, { + fileId: id, + fileName: f.fileName, + fileSize: f.size, + fileRelativePath: f.relativePath, + chunkSize: rm.chunkSize, + chunkCount: rm.chunkCount + }); + fnBefore = function (jqXHR) { + outData = self._getOutData(fd, jqXHR); + self._raise('filetestbeforesend', [id, fm, rm, outData]); + }; + fnSuccess = function (data, textStatus, jqXHR) { + outData = self._getOutData(fd, jqXHR, data); + var pNames = self.uploadParamNames, chunksUploaded = pNames.chunksUploaded || 'chunksUploaded', + params = [id, fm, rm, outData]; + if (!data[chunksUploaded] || !$h.isArray(data[chunksUploaded])) { + self._raise('filetesterror', params); + } else { + if (!rm.processed[id]) { + rm.processed[id] = {}; + } + $.each(data[chunksUploaded], function (key, index) { + rm.logs[index] = true; + rm.processed[id][index] = true; + }); + rm.processed[id].data = data; + self._raise('filetestsuccess', params); + } + rm.testing = false; + }; + fnError = function (jqXHR, textStatus, errorThrown) { + outData = self._getOutData(fd, jqXHR); + self._raise('filetestajaxerror', [id, fm, rm, outData]); + rm.logAjaxError(jqXHR, textStatus, errorThrown); + rm.testing = false; + }; + fnComplete = function () { + self._raise('filetestcomplete', [id, fm, rm, self._getOutData(fd)]); + rm.testing = false; + }; + self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, fd, id, rm.fileIndex, opts.testUrl); + }, + pushAjax: function (index, retry) { + self.resumableManager.stack.push([index, retry]); + }, + sendAjax: function (index, retry) { + var fm = self.fileManager, rm = self.resumableManager, opts = self.resumableUploadOptions, f, + chunkSize = rm.chunkSize, id = rm.id, file = rm.file, $thumb = rm.$thumb, + $btnDelete = rm.$btnDelete; + if (rm.processed[id] && rm.processed[id][index]) { + return; + } + rm.currThreads++; + if (retry > opts.maxRetries) { + rm.setProcessed('error'); + return; + } + var fd, outData, fnBefore, fnSuccess, fnError, fnComplete, slice = file.slice ? 'slice' : + (file.mozSlice ? 'mozSlice' : (file.webkitSlice ? 'webkitSlice' : 'slice')), + blob = file[slice](chunkSize * index, chunkSize * (index + 1)); + fd = new FormData(); + f = fm.stack[id]; + self._setUploadData(fd, { + chunkCount: rm.chunkCount, + chunkIndex: index, + chunkSize: chunkSize, + chunkSizeStart: chunkSize * index, + fileBlob: [blob, rm.fileName], + fileId: id, + fileName: rm.fileName, + fileRelativePath: f.relativePath, + fileSize: file.size, + retryCount: retry + }); + if (rm.$progress && rm.$progress.length) { + rm.$progress.show(); + } + fnBefore = function (jqXHR) { + outData = self._getOutData(fd, jqXHR); + if (self.showPreview) { + if (!$thumb.hasClass('file-preview-success')) { + self._setThumbStatus($thumb, 'Loading'); + $h.addCss($thumb, 'file-uploading'); + } + $btnDelete.attr('disabled', true); + } + self._raise('filechunkbeforesend', [id, index, retry, fm, rm, outData]); + }; + fnSuccess = function (data, textStatus, jqXHR) { + outData = self._getOutData(fd, jqXHR, data); + var paramNames = self.uploadParamNames, chunkIndex = paramNames.chunkIndex || 'chunkIndex', + opts = self.resumableUploadOptions, params = [id, index, retry, fm, rm, outData]; + rm.currThreads--; + if (data.error) { + if (opts.showErrorLog) { + self._log(logs.retryStatus, { + retry: retry + 1, + filename: rm.fileName, + chunk: index + }); + } + rm.pushAjax(index, retry + 1); + rm.error = data.error; + self._raise('filechunkerror', params); + } else { + rm.logs[data[chunkIndex]] = true; + if (!rm.processed[id]) { + rm.processed[id] = {}; + } + rm.processed[id][data[chunkIndex]] = true; + rm.processed[id].data = data; + self._raise('filechunksuccess', params); + rm.check(); + } + }; + fnError = function (jqXHR, textStatus, errorThrown) { + outData = self._getOutData(fd, jqXHR); + rm.currThreads--; + rm.error = errorThrown; + rm.logAjaxError(jqXHR, textStatus, errorThrown); + self._raise('filechunkajaxerror', [id, index, retry, fm, rm, outData]); + rm.pushAjax(index, retry + 1); + }; + fnComplete = function () { + self._raise('filechunkcomplete', [id, index, retry, fm, rm, self._getOutData(fd)]); + }; + self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, fd, id, rm.fileIndex); + }, + loopAjax: function () { + var rm = self.resumableManager; + if (rm.currThreads < self.resumableUploadOptions.maxThreads && !rm.testing) { + var arr = rm.stack.shift(), index; + if (typeof arr !== 'undefined') { + index = arr[0]; + if (!rm.processed[rm.id] || !rm.processed[rm.id][index]) { + rm.sendAjax(index, arr[1]); + } else { + if (rm.processedResumables() >= rm.getTotalChunks()) { + rm.setProcessed('success'); + clearInterval(rm.chunkIntervalId); + } + } + } + } + } + }; + self.resumableManager.reset(); + }, + _initTemplateDefaults: function () { + var self = this, tMain1, tMain2, tPreview, tFileIcon, tClose, tCaption, tBtnDefault, tBtnLink, tBtnBrowse, + tModalMain, tModal, tProgress, tSize, tFooter, tActions, tActionDelete, tActionUpload, tActionDownload, + tActionZoom, tActionDrag, tIndicator, tTagBef, tTagBef1, tTagBef2, tTagAft, tGeneric, tHtml, tImage, + tText, tOffice, tGdocs, tVideo, tAudio, tFlash, tObject, tPdf, tOther, tStyle, tZoomCache, vDefaultDim, + tStats; + tMain1 = '{preview}\n' + + '
    \n' + + '
    \n' + + ' {caption}\n' + + '
    \n' + + ' {remove}\n' + + ' {cancel}\n' + + ' {pause}\n' + + ' {upload}\n' + + ' {browse}\n' + + '
    \n' + + '
    '; + tMain2 = '{preview}\n
    \n
    \n' + + '{remove}\n{cancel}\n{upload}\n{browse}\n'; + tPreview = '
    \n' + + ' {close}' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    ' + + '
    \n' + + '
    \n' + + '
    \n' + + '
    '; + tClose = $h.closeButton('fileinput-remove'); + tFileIcon = ''; + // noinspection HtmlUnknownAttribute + tCaption = '
    \n' + + ' \n' + + ' \n' + + '
    '; + //noinspection HtmlUnknownAttribute + tBtnDefault = ''; + //noinspection HtmlUnknownAttribute + tBtnLink = '{icon} {label}'; + //noinspection HtmlUnknownAttribute + tBtnBrowse = '
    {icon} {label}
    '; + tModalMain = ''; + tModal = '\n'; + tProgress = '
    \n' + + '
    \n' + + ' {status}\n' + + '
    \n' + + '
    {stats}'; + tStats = '
    ' + + '{pendingTime} ' + + '{uploadSpeed}' + + '
    '; + tSize = ' ({sizeText})'; + tFooter = ''; + tActions = '
    \n' + + ' \n' + + '
    \n' + + '{drag}\n' + + '
    '; + //noinspection HtmlUnknownAttribute + tActionDelete = '\n'; + tActionUpload = ''; + tActionDownload = '{downloadIcon}'; + tActionZoom = ''; + tActionDrag = '{dragIcon}'; + tIndicator = '
    {indicator}
    '; + tTagBef = '
    \n'; + tTagBef2 = tTagBef + ' title="{caption}">
    \n'; + tTagAft = '
    {footer}\n
    \n'; + tGeneric = '{content}\n'; + tStyle = ' {style}'; + tHtml = '
    {data}
    \n'; + tImage = '\n'; + tText = '\n'; + tOffice = ''; + tGdocs = ''; + tVideo = '\n'; + tAudio = '\n'; + tFlash = '\n'; + tPdf = '\n'; + tObject = '\n' + '\n' + + $h.OBJECT_PARAMS + ' ' + $h.DEFAULT_PREVIEW + '\n\n'; + tOther = '
    \n' + $h.DEFAULT_PREVIEW + '\n
    \n'; + tZoomCache = ''; + vDefaultDim = {width: '100%', height: '100%', 'min-height': '480px'}; + if (self._isPdfRendered()) { + tPdf = self.pdfRendererTemplate.replace('{renderer}', self._encodeURI(self.pdfRendererUrl)); + } + self.defaults = { + layoutTemplates: { + main1: tMain1, + main2: tMain2, + preview: tPreview, + close: tClose, + fileIcon: tFileIcon, + caption: tCaption, + modalMain: tModalMain, + modal: tModal, + progress: tProgress, + stats: tStats, + size: tSize, + footer: tFooter, + indicator: tIndicator, + actions: tActions, + actionDelete: tActionDelete, + actionUpload: tActionUpload, + actionDownload: tActionDownload, + actionZoom: tActionZoom, + actionDrag: tActionDrag, + btnDefault: tBtnDefault, + btnLink: tBtnLink, + btnBrowse: tBtnBrowse, + zoomCache: tZoomCache + }, + previewMarkupTags: { + tagBefore1: tTagBef1, + tagBefore2: tTagBef2, + tagAfter: tTagAft + }, + previewContentTemplates: { + generic: tGeneric, + html: tHtml, + image: tImage, + text: tText, + office: tOffice, + gdocs: tGdocs, + video: tVideo, + audio: tAudio, + flash: tFlash, + object: tObject, + pdf: tPdf, + other: tOther + }, + allowedPreviewTypes: ['image', 'html', 'text', 'video', 'audio', 'flash', 'pdf', 'object'], + previewTemplates: {}, + previewSettings: { + image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'}, + html: {width: '213px', height: '160px'}, + text: {width: '213px', height: '160px'}, + office: {width: '213px', height: '160px'}, + gdocs: {width: '213px', height: '160px'}, + video: {width: '213px', height: '160px'}, + audio: {width: '100%', height: '30px'}, + flash: {width: '213px', height: '160px'}, + object: {width: '213px', height: '160px'}, + pdf: {width: '100%', height: '160px'}, + other: {width: '213px', height: '160px'} + }, + previewSettingsSmall: { + image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'}, + html: {width: '100%', height: '160px'}, + text: {width: '100%', height: '160px'}, + office: {width: '100%', height: '160px'}, + gdocs: {width: '100%', height: '160px'}, + video: {width: '100%', height: 'auto'}, + audio: {width: '100%', height: '30px'}, + flash: {width: '100%', height: 'auto'}, + object: {width: '100%', height: 'auto'}, + pdf: {width: '100%', height: '160px'}, + other: {width: '100%', height: '160px'} + }, + previewZoomSettings: { + image: {width: 'auto', height: 'auto', 'max-width': '100%', 'max-height': '100%'}, + html: vDefaultDim, + text: vDefaultDim, + office: {width: '100%', height: '100%', 'max-width': '100%', 'min-height': '480px'}, + gdocs: {width: '100%', height: '100%', 'max-width': '100%', 'min-height': '480px'}, + video: {width: 'auto', height: '100%', 'max-width': '100%'}, + audio: {width: '100%', height: '30px'}, + flash: {width: 'auto', height: '480px'}, + object: {width: 'auto', height: '100%', 'max-width': '100%', 'min-height': '480px'}, + pdf: vDefaultDim, + other: {width: 'auto', height: '100%', 'min-height': '480px'} + }, + mimeTypeAliases: { + 'video/quicktime': 'video/mp4' + }, + fileTypeSettings: { + image: function (vType, vName) { + return ($h.compare(vType, 'image.*') && !$h.compare(vType, /(tiff?|wmf)$/i) || + $h.compare(vName, /\.(gif|png|jpe?g)$/i)); + }, + html: function (vType, vName) { + return $h.compare(vType, 'text/html') || $h.compare(vName, /\.(htm|html)$/i); + }, + office: function (vType, vName) { + return $h.compare(vType, /(word|excel|powerpoint|office)$/i) || + $h.compare(vName, /\.(docx?|xlsx?|pptx?|pps|potx?)$/i); + }, + gdocs: function (vType, vName) { + return $h.compare(vType, /(word|excel|powerpoint|office|iwork-pages|tiff?)$/i) || + $h.compare(vName, + /\.(docx?|xlsx?|pptx?|pps|potx?|rtf|ods|odt|pages|ai|dxf|ttf|tiff?|wmf|e?ps)$/i); + }, + text: function (vType, vName) { + return $h.compare(vType, 'text.*') || $h.compare(vName, /\.(xml|javascript)$/i) || + $h.compare(vName, /\.(txt|md|csv|nfo|ini|json|php|js|css)$/i); + }, + video: function (vType, vName) { + return $h.compare(vType, 'video.*') && ($h.compare(vType, /(ogg|mp4|mp?g|mov|webm|3gp)$/i) || + $h.compare(vName, /\.(og?|mp4|webm|mp?g|mov|3gp)$/i)); + }, + audio: function (vType, vName) { + return $h.compare(vType, 'audio.*') && ($h.compare(vName, /(ogg|mp3|mp?g|wav)$/i) || + $h.compare(vName, /\.(og?|mp3|mp?g|wav)$/i)); + }, + flash: function (vType, vName) { + return $h.compare(vType, 'application/x-shockwave-flash', true) || $h.compare(vName, + /\.(swf)$/i); + }, + pdf: function (vType, vName) { + return $h.compare(vType, 'application/pdf', true) || $h.compare(vName, /\.(pdf)$/i); + }, + object: function () { + return true; + }, + other: function () { + return true; + } + }, + fileActionSettings: { + showRemove: true, + showUpload: true, + showDownload: true, + showZoom: true, + showDrag: true, + removeIcon: '', + removeClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary', + removeErrorClass: 'btn btn-sm btn-kv btn-danger', + removeTitle: 'Remove file', + uploadIcon: '', + uploadClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary', + uploadTitle: 'Upload file', + uploadRetryIcon: '', + uploadRetryTitle: 'Retry upload', + downloadIcon: '', + downloadClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary', + downloadTitle: 'Download file', + zoomIcon: '', + zoomClass: 'btn btn-sm btn-kv btn-default btn-outline-secondary', + zoomTitle: 'View Details', + dragIcon: '', + dragClass: 'text-info', + dragTitle: 'Move / Rearrange', + dragSettings: {}, + indicatorNew: '', + indicatorSuccess: '', + indicatorError: '', + indicatorLoading: '', + indicatorPaused: '', + indicatorNewTitle: 'Not uploaded yet', + indicatorSuccessTitle: 'Uploaded', + indicatorErrorTitle: 'Upload Error', + indicatorLoadingTitle: 'Uploading ...', + indicatorPausedTitle: 'Upload Paused' + } + }; + $.each(self.defaults, function (key, setting) { + if (key === 'allowedPreviewTypes') { + if (self.allowedPreviewTypes === undefined) { + self.allowedPreviewTypes = setting; + } + return; + } + self[key] = $.extend(true, {}, setting, self[key]); + }); + self._initPreviewTemplates(); + }, + _initPreviewTemplates: function () { + var self = this, tags = self.previewMarkupTags, tagBef, tagAft = tags.tagAfter; + $.each(self.previewContentTemplates, function (key, value) { + if ($h.isEmpty(self.previewTemplates[key])) { + tagBef = tags.tagBefore2; + if (key === 'generic' || key === 'image' || key === 'html' || key === 'text') { + tagBef = tags.tagBefore1; + } + if (self._isPdfRendered() && key === 'pdf') { + tagBef = tagBef.replace('kv-file-content', 'kv-file-content kv-pdf-rendered'); + } + self.previewTemplates[key] = tagBef + value + tagAft; + } + }); + }, + _initPreviewCache: function () { + var self = this; + self.previewCache = { + data: {}, + init: function () { + var content = self.initialPreview; + if (content.length > 0 && !$h.isArray(content)) { + content = content.split(self.initialPreviewDelimiter); + } + self.previewCache.data = { + content: content, + config: self.initialPreviewConfig, + tags: self.initialPreviewThumbTags + }; + }, + count: function (skipNull) { + if (!self.previewCache.data || !self.previewCache.data.content) { + return 0; + } + if (skipNull) { + var chk = self.previewCache.data.content.filter(function (n) { + return n !== null; + }); + return chk.length; + } + return self.previewCache.data.content.length; + }, + get: function (i, isDisabled) { + var ind = 'init_' + i, data = self.previewCache.data, config = data.config[i], fileId, + content = data.content[i], previewId = self.previewInitId + '-' + ind, out, $tmp, cat, ftr, + fname, ftype, frameClass, asData = $h.ifSet('previewAsData', config, self.initialPreviewAsData), + a = config ? {title: config.title || null, alt: config.alt || null} : {title: null, alt: null}, + parseTemplate = function (cat, dat, fn, ft, id, ftr, ind, fc, t) { + fc = ' file-preview-initial ' + $h.SORT_CSS + (fc ? ' ' + fc : ''); + /** @namespace config.zoomData */ + fileId = config && config.fileId || 'file_' + id; + return self._generatePreviewTemplate(cat, dat, fn, ft, id, fileId, false, null, fc, + ftr, ind, t, a, config && config.zoomData || dat); + }; + if (!content || !content.length) { + return ''; + } + isDisabled = isDisabled === undefined ? true : isDisabled; + cat = $h.ifSet('type', config, self.initialPreviewFileType || 'generic'); + fname = $h.ifSet('filename', config, $h.ifSet('caption', config)); + ftype = $h.ifSet('filetype', config, cat); + ftr = self.previewCache.footer(i, isDisabled, (config && config.size || null)); + frameClass = $h.ifSet('frameClass', config); + if (asData) { + out = parseTemplate(cat, content, fname, ftype, previewId, ftr, ind, frameClass); + } else { + out = parseTemplate('generic', content, fname, ftype, previewId, ftr, ind, frameClass, cat) + .setTokens({'content': data.content[i]}); + } + if (data.tags.length && data.tags[i]) { + out = $h.replaceTags(out, data.tags[i]); + } + /** @namespace config.frameAttr */ + if (!$h.isEmpty(config) && !$h.isEmpty(config.frameAttr)) { + $tmp = $(document.createElement('div')).html(out); + $tmp.find('.file-preview-initial').attr(config.frameAttr); + out = $tmp.html(); + $tmp.remove(); + } + return out; + }, + clean: function (data) { + data.content = $h.cleanArray(data.content); + data.config = $h.cleanArray(data.config); + data.tags = $h.cleanArray(data.tags); + self.previewCache.data = data; + }, + add: function (content, config, tags, append) { + var data = self.previewCache.data, index = content.length - 1; + if (!content || !content.length) { + return index; + } + if (!$h.isArray(content)) { + content = content.split(self.initialPreviewDelimiter); + } + if (append) { + index = data.content.push(content[0]) - 1; + data.config[index] = config; + data.tags[index] = tags; + } else { + data.content = content; + data.config = config; + data.tags = tags; + } + self.previewCache.clean(data); + return index; + }, + set: function (content, config, tags, append) { + var data = self.previewCache.data, i, chk; + if (!content || !content.length) { + return; + } + if (!$h.isArray(content)) { + content = content.split(self.initialPreviewDelimiter); + } + chk = content.filter(function (n) { + return n !== null; + }); + if (!chk.length) { + return; + } + if (data.content === undefined) { + data.content = []; + } + if (data.config === undefined) { + data.config = []; + } + if (data.tags === undefined) { + data.tags = []; + } + if (append) { + for (i = 0; i < content.length; i++) { + if (content[i]) { + data.content.push(content[i]); + } + } + for (i = 0; i < config.length; i++) { + if (config[i]) { + data.config.push(config[i]); + } + } + for (i = 0; i < tags.length; i++) { + if (tags[i]) { + data.tags.push(tags[i]); + } + } + } else { + data.content = content; + data.config = config; + data.tags = tags; + } + self.previewCache.clean(data); + }, + unset: function (index) { + var chk = self.previewCache.count(), rev = self.reversePreviewOrder; + if (!chk) { + return; + } + if (chk === 1) { + self.previewCache.data.content = []; + self.previewCache.data.config = []; + self.previewCache.data.tags = []; + self.initialPreview = []; + self.initialPreviewConfig = []; + self.initialPreviewThumbTags = []; + return; + } + self.previewCache.data.content = $h.spliceArray(self.previewCache.data.content, index, rev); + self.previewCache.data.config = $h.spliceArray(self.previewCache.data.config, index, rev); + self.previewCache.data.tags = $h.spliceArray(self.previewCache.data.tags, index, rev); + var data = $.extend(true, {}, self.previewCache.data); + self.previewCache.clean(data); + }, + out: function () { + var html = '', caption, len = self.previewCache.count(), i, content; + if (len === 0) { + return {content: '', caption: ''}; + } + for (i = 0; i < len; i++) { + content = self.previewCache.get(i); + html = self.reversePreviewOrder ? (content + html) : (html + content); + } + caption = self._getMsgSelected(len); + return {content: html, caption: caption}; + }, + footer: function (i, isDisabled, size) { + var data = self.previewCache.data || {}; + if ($h.isEmpty(data.content)) { + return ''; + } + if ($h.isEmpty(data.config) || $h.isEmpty(data.config[i])) { + data.config[i] = {}; + } + isDisabled = isDisabled === undefined ? true : isDisabled; + var config = data.config[i], caption = $h.ifSet('caption', config), a, + width = $h.ifSet('width', config, 'auto'), url = $h.ifSet('url', config, false), + key = $h.ifSet('key', config, null), fileId = $h.ifSet('fileId', config, null), + fs = self.fileActionSettings, initPreviewShowDel = self.initialPreviewShowDelete || false, + downloadInitialUrl = !self.initialPreviewDownloadUrl ? '' : + self.initialPreviewDownloadUrl + '?key=' + key + (fileId ? '&fileId=' + fileId : ''), + dUrl = config.downloadUrl || downloadInitialUrl, + dFil = config.filename || config.caption || '', + initPreviewShowDwl = !!(dUrl), + sDel = $h.ifSet('showRemove', config, $h.ifSet('showRemove', fs, initPreviewShowDel)), + sDwl = $h.ifSet('showDownload', config, $h.ifSet('showDownload', fs, initPreviewShowDwl)), + sZm = $h.ifSet('showZoom', config, $h.ifSet('showZoom', fs, true)), + sDrg = $h.ifSet('showDrag', config, $h.ifSet('showDrag', fs, true)), + dis = (url === false) && isDisabled; + sDwl = sDwl && config.downloadUrl !== false && !!dUrl; + a = self._renderFileActions(config, false, sDwl, sDel, sZm, sDrg, dis, url, key, true, dUrl, dFil); + return self._getLayoutTemplate('footer').setTokens({ + 'progress': self._renderThumbProgress(), + 'actions': a, + 'caption': caption, + 'size': self._getSize(size), + 'width': width, + 'indicator': '' + }); + } + }; + self.previewCache.init(); + }, + _isPdfRendered: function () { + var self = this, useLib = self.usePdfRenderer, + flag = typeof useLib === 'function' ? useLib() : !!useLib; + return flag && self.pdfRendererUrl; + }, + _handler: function ($el, event, callback) { + var self = this, ns = self.namespace, ev = event.split(' ').join(ns + ' ') + ns; + if (!$el || !$el.length) { + return; + } + $el.off(ev).on(ev, callback); + }, + _encodeURI: function (vUrl) { + var self = this; + return self.encodeUrl ? encodeURI(vUrl) : vUrl; + }, + _log: function (msg, tokens) { + var self = this, id = self.$element.attr('id'); + if (id) { + msg = '"' + id + '": ' + msg; + } + msg = 'bootstrap-fileinput: ' + msg; + if (typeof tokens === 'object') { + msg.setTokens(tokens); + } + if (typeof window.console.log !== 'undefined') { + window.console.log(msg); + } else { + window.alert(msg); + } + }, + _validate: function () { + var self = this, status = self.$element.attr('type') === 'file'; + if (!status) { + self._log($h.logMessages.badInputType); + } + return status; + }, + _errorsExist: function () { + var self = this, $err, $errList = self.$errorContainer.find('li'); + if ($errList.length) { + return true; + } + $err = $(document.createElement('div')).html(self.$errorContainer.html()); + $err.find('.kv-error-close').remove(); + $err.find('ul').remove(); + return !!$.trim($err.text()).length; + }, + _errorHandler: function (evt, caption) { + var self = this, err = evt.target.error, showError = function (msg) { + self._showError(msg.replace('{name}', caption)); + }; + /** @namespace err.NOT_FOUND_ERR */ + /** @namespace err.SECURITY_ERR */ + /** @namespace err.NOT_READABLE_ERR */ + if (err.code === err.NOT_FOUND_ERR) { + showError(self.msgFileNotFound); + } else { + if (err.code === err.SECURITY_ERR) { + showError(self.msgFileSecured); + } else { + if (err.code === err.NOT_READABLE_ERR) { + showError(self.msgFileNotReadable); + } else { + if (err.code === err.ABORT_ERR) { + showError(self.msgFilePreviewAborted); + } else { + showError(self.msgFilePreviewError); + } + } + } + } + }, + _addError: function (msg) { + var self = this, $error = self.$errorContainer; + if (msg && $error.length) { + $error.html(self.errorCloseButton + msg); + self._handler($error.find('.kv-error-close'), 'click', function () { + setTimeout(function () { + if (self.showPreview && !self.getFrames().length) { + self.clear(); + } + $error.fadeOut('slow'); + }, self.processDelay); + }); + } + }, + _setValidationError: function (css) { + var self = this; + css = (css ? css + ' ' : '') + 'has-error'; + self.$container.removeClass(css).addClass('has-error'); + $h.addCss(self.$captionContainer, 'is-invalid'); + }, + _resetErrors: function (fade) { + var self = this, $error = self.$errorContainer; + self.isError = false; + self.$container.removeClass('has-error'); + self.$captionContainer.removeClass('is-invalid'); + $error.html(''); + if (fade) { + $error.fadeOut('slow'); + } else { + $error.hide(); + } + }, + _showFolderError: function (folders) { + var self = this, $error = self.$errorContainer, msg; + if (!folders) { + return; + } + if (!self.isAjaxUpload) { + self._clearFileInput(); + } + msg = self.msgFoldersNotAllowed.replace('{n}', folders); + self._addError(msg); + self._setValidationError(); + $error.fadeIn(800); + self._raise('filefoldererror', [folders, msg]); + }, + _showFileError: function (msg, params, event) { + var self = this, $error = self.$errorContainer, ev = event || 'fileuploaderror', + fId = params && params.fileId || '', e = params && params.id ? + '
  • ' + msg + '
  • ' : '
  • ' + msg + '
  • '; + if ($error.find('ul').length === 0) { + self._addError('
      ' + e + '
    '); + } else { + $error.find('ul').append(e); + } + $error.fadeIn(800); + self._raise(ev, [params, msg]); + self._setValidationError('file-input-new'); + return true; + }, + _showError: function (msg, params, event) { + var self = this, $error = self.$errorContainer, ev = event || 'fileerror'; + params = params || {}; + params.reader = self.reader; + self._addError(msg); + $error.fadeIn(800); + self._raise(ev, [params, msg]); + if (!self.isAjaxUpload) { + self._clearFileInput(); + } + self._setValidationError('file-input-new'); + self.$btnUpload.attr('disabled', true); + return true; + }, + _noFilesError: function (params) { + var self = this, label = self.minFileCount > 1 ? self.filePlural : self.fileSingle, + msg = self.msgFilesTooLess.replace('{n}', self.minFileCount).replace('{files}', label), + $error = self.$errorContainer; + self._addError(msg); + self.isError = true; + self._updateFileDetails(0); + $error.fadeIn(800); + self._raise('fileerror', [params, msg]); + self._clearFileInput(); + self._setValidationError(); + }, + _parseError: function (operation, jqXHR, errorThrown, fileName) { + /** @namespace jqXHR.responseJSON */ + var self = this, errMsg = $.trim(errorThrown + ''), textPre, + text = jqXHR.responseJSON !== undefined && jqXHR.responseJSON.error !== undefined ? + jqXHR.responseJSON.error : jqXHR.responseText; + if (self.cancelling && self.msgUploadAborted) { + errMsg = self.msgUploadAborted; + } + if (self.showAjaxErrorDetails && text) { + text = $.trim(text.replace(/\n\s*\n/g, '\n')); + textPre = text.length ? '
    ' + text + '
    ' : ''; + errMsg += errMsg ? textPre : text; + } + if (!errMsg) { + errMsg = self.msgAjaxError.replace('{operation}', operation); + } + self.cancelling = false; + return fileName ? '' + fileName + ': ' + errMsg : errMsg; + }, + _parseFileType: function (type, name) { + var self = this, isValid, vType, cat, i, types = self.allowedPreviewTypes || []; + if (type === 'application/text-plain') { + return 'text'; + } + for (i = 0; i < types.length; i++) { + cat = types[i]; + isValid = self.fileTypeSettings[cat]; + vType = isValid(type, name) ? cat : ''; + if (!$h.isEmpty(vType)) { + return vType; + } + } + return 'other'; + }, + _getPreviewIcon: function (fname) { + var self = this, ext, out = null; + if (fname && fname.indexOf('.') > -1) { + ext = fname.split('.').pop(); + if (self.previewFileIconSettings) { + out = self.previewFileIconSettings[ext] || self.previewFileIconSettings[ext.toLowerCase()] || null; + } + if (self.previewFileExtSettings) { + $.each(self.previewFileExtSettings, function (key, func) { + if (self.previewFileIconSettings[key] && func(ext)) { + out = self.previewFileIconSettings[key]; + //noinspection UnnecessaryReturnStatementJS + return; + } + }); + } + } + return out; + }, + _parseFilePreviewIcon: function (content, fname) { + var self = this, icn = self._getPreviewIcon(fname) || self.previewFileIcon, out = content; + if (out.indexOf('{previewFileIcon}') > -1) { + out = out.setTokens({'previewFileIconClass': self.previewFileIconClass, 'previewFileIcon': icn}); + } + return out; + }, + _raise: function (event, params) { + var self = this, e = $.Event(event); + if (params !== undefined) { + self.$element.trigger(e, params); + } else { + self.$element.trigger(e); + } + if (e.isDefaultPrevented() || e.result === false) { + return false; + } + switch (event) { + // ignore these events + case 'filebatchuploadcomplete': + case 'filebatchuploadsuccess': + case 'fileuploaded': + case 'fileclear': + case 'filecleared': + case 'filereset': + case 'fileerror': + case 'filefoldererror': + case 'fileuploaderror': + case 'filebatchuploaderror': + case 'filedeleteerror': + case 'filecustomerror': + case 'filesuccessremove': + break; + // receive data response via `filecustomerror` event` + default: + if (!self.ajaxAborted) { + self.ajaxAborted = e.result; + } + break; + } + return true; + }, + _listenFullScreen: function (isFullScreen) { + var self = this, $modal = self.$modal, $btnFull, $btnBord; + if (!$modal || !$modal.length) { + return; + } + $btnFull = $modal && $modal.find('.btn-fullscreen'); + $btnBord = $modal && $modal.find('.btn-borderless'); + if (!$btnFull.length || !$btnBord.length) { + return; + } + $btnFull.removeClass('active').attr('aria-pressed', 'false'); + $btnBord.removeClass('active').attr('aria-pressed', 'false'); + if (isFullScreen) { + $btnFull.addClass('active').attr('aria-pressed', 'true'); + } else { + $btnBord.addClass('active').attr('aria-pressed', 'true'); + } + if ($modal.hasClass('file-zoom-fullscreen')) { + self._maximizeZoomDialog(); + } else { + if (isFullScreen) { + self._maximizeZoomDialog(); + } else { + $btnBord.removeClass('active').attr('aria-pressed', 'false'); + } + } + }, + _listen: function () { + var self = this, $el = self.$element, $form = self.$form, $cont = self.$container, fullScreenEvents; + self._handler($el, 'click', function (e) { + if ($el.hasClass('file-no-browse')) { + if ($el.data('zoneClicked')) { + $el.data('zoneClicked', false); + } else { + e.preventDefault(); + } + } + }); + self._handler($el, 'change', $.proxy(self._change, self)); + if (self.showBrowse) { + self._handler(self.$btnFile, 'click', $.proxy(self._browse, self)); + } + self._handler($cont.find('.fileinput-remove:not([disabled])'), 'click', $.proxy(self.clear, self)); + self._handler($cont.find('.fileinput-cancel'), 'click', $.proxy(self.cancel, self)); + self._handler($cont.find('.fileinput-pause'), 'click', $.proxy(self.pause, self)); + self._initDragDrop(); + self._handler($form, 'reset', $.proxy(self.clear, self)); + if (!self.isAjaxUpload) { + self._handler($form, 'submit', $.proxy(self._submitForm, self)); + } + self._handler(self.$container.find('.fileinput-upload'), 'click', $.proxy(self._uploadClick, self)); + self._handler($(window), 'resize', function () { + self._listenFullScreen(screen.width === window.innerWidth && screen.height === window.innerHeight); + }); + fullScreenEvents = 'webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange'; + self._handler($(document), fullScreenEvents, function () { + self._listenFullScreen($h.checkFullScreen()); + }); + self._autoFitContent(); + self._initClickable(); + self._refreshPreview(); + }, + _autoFitContent: function () { + var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, + self = this, config = width < 400 ? (self.previewSettingsSmall || self.defaults.previewSettingsSmall) : + (self.previewSettings || self.defaults.previewSettings), sel; + $.each(config, function (cat, settings) { + sel = '.file-preview-frame .file-preview-' + cat; + self.$preview.find(sel + '.kv-preview-data,' + sel + ' .kv-preview-data').css(settings); + }); + }, + _scanDroppedItems: function (item, files, path) { + path = path || ''; + var self = this, i, dirReader, readDir, errorHandler = function (e) { + self._log($h.logMessages.badDroppedFiles); + self._log(e); + }; + if (item.isFile) { + item.file(function (file) { + files.push(file); + }, errorHandler); + } else { + if (item.isDirectory) { + dirReader = item.createReader(); + readDir = function () { + dirReader.readEntries(function (entries) { + if (entries && entries.length > 0) { + for (i = 0; i < entries.length; i++) { + self._scanDroppedItems(entries[i], files, path + item.name + '/'); + } + // recursively call readDir() again, since browser can only handle first 100 entries. + readDir(); + } + return null; + }, errorHandler); + }; + readDir(); + } + } + + }, + _initDragDrop: function () { + var self = this, $zone = self.$dropZone; + if (self.dropZoneEnabled && self.showPreview) { + self._handler($zone, 'dragenter dragover', $.proxy(self._zoneDragEnter, self)); + self._handler($zone, 'dragleave', $.proxy(self._zoneDragLeave, self)); + self._handler($zone, 'drop', $.proxy(self._zoneDrop, self)); + self._handler($(document), 'dragenter dragover drop', self._zoneDragDropInit); + } + }, + _zoneDragDropInit: function (e) { + e.stopPropagation(); + e.preventDefault(); + }, + _zoneDragEnter: function (e) { + var self = this, dataTransfer = e.originalEvent.dataTransfer, + hasFiles = $.inArray('Files', dataTransfer.types) > -1; + self._zoneDragDropInit(e); + if (self.isDisabled || !hasFiles) { + e.originalEvent.dataTransfer.effectAllowed = 'none'; + e.originalEvent.dataTransfer.dropEffect = 'none'; + return; + } + if (self._raise('fileDragEnter', {'sourceEvent': e, 'files': dataTransfer.types.Files})) { + $h.addCss(self.$dropZone, 'file-highlighted'); + } + }, + _zoneDragLeave: function (e) { + var self = this; + self._zoneDragDropInit(e); + if (self.isDisabled) { + return; + } + if (self._raise('fileDragLeave', {'sourceEvent': e})) { + self.$dropZone.removeClass('file-highlighted'); + } + + }, + _zoneDrop: function (e) { + /** @namespace e.originalEvent.dataTransfer */ + var self = this, i, $el = self.$element, dataTransfer = e.originalEvent.dataTransfer, + files = dataTransfer.files, items = dataTransfer.items, folders = $h.getDragDropFolders(items), + processFiles = function () { + if (!self.isAjaxUpload) { + self.changeTriggered = true; + $el.get(0).files = files; + setTimeout(function () { + self.changeTriggered = false; + $el.trigger('change' + self.namespace); + }, self.processDelay); + } else { + self._change(e, files); + } + self.$dropZone.removeClass('file-highlighted'); + }; + e.preventDefault(); + if (self.isDisabled || $h.isEmpty(files)) { + return; + } + if (!self._raise('fileDragDrop', {'sourceEvent': e, 'files': files})) { + return; + } + if (folders > 0) { + if (!self.isAjaxUpload) { + self._showFolderError(folders); + return; + } + files = []; + for (i = 0; i < items.length; i++) { + var item = items[i].webkitGetAsEntry(); + if (item) { + self._scanDroppedItems(item, files); + } + } + setTimeout(function () { + processFiles(); + }, 500); + } else { + processFiles(); + } + }, + _uploadClick: function (e) { + var self = this, $btn = self.$container.find('.fileinput-upload'), $form, + isEnabled = !$btn.hasClass('disabled') && $h.isEmpty($btn.attr('disabled')); + if (e && e.isDefaultPrevented()) { + return; + } + if (!self.isAjaxUpload) { + if (isEnabled && $btn.attr('type') !== 'submit') { + $form = $btn.closest('form'); + // downgrade to normal form submit if possible + if ($form.length) { + $form.trigger('submit'); + } + e.preventDefault(); + } + return; + } + e.preventDefault(); + if (isEnabled) { + self.upload(); + } + }, + _submitForm: function () { + var self = this; + return self._isFileSelectionValid() && !self._abort({}); + }, + _clearPreview: function () { + var self = this, $p = self.$preview, + $thumbs = self.showUploadedThumbs ? self.getFrames(':not(.file-preview-success)') : self.getFrames(); + $thumbs.each(function () { + var $thumb = $(this); + $thumb.remove(); + $h.cleanZoomCache($p.find('#zoom-' + $thumb.attr('id'))); + }); + if (!self.getFrames().length || !self.showPreview) { + self._resetUpload(); + } + self._validateDefaultPreview(); + }, + _initSortable: function () { + var self = this, $el = self.$preview, settings, selector = '.' + $h.SORT_CSS, + rev = self.reversePreviewOrder; + if (!window.KvSortable || $el.find(selector).length === 0) { + return; + } + //noinspection JSUnusedGlobalSymbols + settings = { + handle: '.drag-handle-init', + dataIdAttr: 'data-preview-id', + scroll: false, + draggable: selector, + onSort: function (e) { + var oldIndex = e.oldIndex, newIndex = e.newIndex, i = 0; + self.initialPreview = $h.moveArray(self.initialPreview, oldIndex, newIndex, rev); + self.initialPreviewConfig = $h.moveArray(self.initialPreviewConfig, oldIndex, newIndex, rev); + self.previewCache.init(); + self.getFrames('.file-preview-initial').each(function () { + $(this).attr('data-fileindex', 'init_' + i); + i++; + }); + self._raise('filesorted', { + previewId: $(e.item).attr('id'), + 'oldIndex': oldIndex, + 'newIndex': newIndex, + stack: self.initialPreviewConfig + }); + } + }; + if ($el.data('kvsortable')) { + $el.kvsortable('destroy'); + } + $.extend(true, settings, self.fileActionSettings.dragSettings); + $el.kvsortable(settings); + }, + _setPreviewContent: function (content) { + var self = this; + self.$preview.html(content); + self._autoFitContent(); + }, + _initPreviewImageOrientations: function () { + var self = this, i = 0; + if (!self.autoOrientImageInitial) { + return; + } + self.getFrames('.file-preview-initial').each(function () { + var $thumb = $(this), $img, $zoomImg, id, config = self.initialPreviewConfig[i]; + /** @namespace config.exif */ + if (config && config.exif && config.exif.Orientation) { + id = $thumb.attr('id'); + $img = $thumb.find('>.kv-file-content img'); + $zoomImg = self.$preview.find('#zoom-' + id + ' >.kv-file-content img'); + self.setImageOrientation($img, $zoomImg, config.exif.Orientation, $thumb); + } + i++; + }); + }, + _initPreview: function (isInit) { + var self = this, cap = self.initialCaption || '', out; + if (!self.previewCache.count(true)) { + self._clearPreview(); + if (isInit) { + self._setCaption(cap); + } else { + self._initCaption(); + } + return; + } + out = self.previewCache.out(); + cap = isInit && self.initialCaption ? self.initialCaption : out.caption; + self._setPreviewContent(out.content); + self._setInitThumbAttr(); + self._setCaption(cap); + self._initSortable(); + if (!$h.isEmpty(out.content)) { + self.$container.removeClass('file-input-new'); + } + self._initPreviewImageOrientations(); + }, + _getZoomButton: function (type) { + var self = this, label = self.previewZoomButtonIcons[type], css = self.previewZoomButtonClasses[type], + title = ' title="' + (self.previewZoomButtonTitles[type] || '') + '" ', + params = title + (type === 'close' ? ' data-dismiss="modal" aria-hidden="true"' : ''); + if (type === 'fullscreen' || type === 'borderless' || type === 'toggleheader') { + params += ' data-toggle="button" aria-pressed="false" autocomplete="off"'; + } + return ''; + }, + _getModalContent: function () { + var self = this; + return self._getLayoutTemplate('modal').setTokens({ + 'rtl': self.rtl ? ' kv-rtl' : '', + 'zoomFrameClass': self.frameClass, + 'heading': self.msgZoomModalHeading, + 'prev': self._getZoomButton('prev'), + 'next': self._getZoomButton('next'), + 'toggleheader': self._getZoomButton('toggleheader'), + 'fullscreen': self._getZoomButton('fullscreen'), + 'borderless': self._getZoomButton('borderless'), + 'close': self._getZoomButton('close') + }); + }, + _listenModalEvent: function (event) { + var self = this, $modal = self.$modal, getParams = function (e) { + return { + sourceEvent: e, + previewId: $modal.data('previewId'), + modal: $modal + }; + }; + $modal.on(event + '.bs.modal', function (e) { + var $btnFull = $modal.find('.btn-fullscreen'), $btnBord = $modal.find('.btn-borderless'); + self._raise('filezoom' + event, getParams(e)); + if (event === 'shown') { + $btnBord.removeClass('active').attr('aria-pressed', 'false'); + $btnFull.removeClass('active').attr('aria-pressed', 'false'); + if ($modal.hasClass('file-zoom-fullscreen')) { + self._maximizeZoomDialog(); + if ($h.checkFullScreen()) { + $btnFull.addClass('active').attr('aria-pressed', 'true'); + } else { + $btnBord.addClass('active').attr('aria-pressed', 'true'); + } + } + } + }); + }, + _initZoom: function () { + var self = this, $dialog, modalMain = self._getLayoutTemplate('modalMain'), modalId = '#' + $h.MODAL_ID; + if (!self.showPreview) { + return; + } + self.$modal = $(modalId); + if (!self.$modal || !self.$modal.length) { + $dialog = $(document.createElement('div')).html(modalMain).insertAfter(self.$container); + self.$modal = $(modalId).insertBefore($dialog); + $dialog.remove(); + } + $h.initModal(self.$modal); + self.$modal.html(self._getModalContent()); + $.each($h.MODAL_EVENTS, function (key, event) { + self._listenModalEvent(event); + }); + }, + _initZoomButtons: function () { + var self = this, previewId = self.$modal.data('previewId') || '', $first, $last, + thumbs = self.getFrames().toArray(), len = thumbs.length, $prev = self.$modal.find('.btn-prev'), + $next = self.$modal.find('.btn-next'); + if (thumbs.length < 2) { + $prev.hide(); + $next.hide(); + return; + } else { + $prev.show(); + $next.show(); + } + if (!len) { + return; + } + $first = $(thumbs[0]); + $last = $(thumbs[len - 1]); + $prev.removeAttr('disabled'); + $next.removeAttr('disabled'); + if ($first.length && $first.attr('id') === previewId) { + $prev.attr('disabled', true); + } + if ($last.length && $last.attr('id') === previewId) { + $next.attr('disabled', true); + } + }, + _maximizeZoomDialog: function () { + var self = this, $modal = self.$modal, $head = $modal.find('.modal-header:visible'), + $foot = $modal.find('.modal-footer:visible'), $body = $modal.find('.modal-body'), + h = $(window).height(), diff = 0; + $modal.addClass('file-zoom-fullscreen'); + if ($head && $head.length) { + h -= $head.outerHeight(true); + } + if ($foot && $foot.length) { + h -= $foot.outerHeight(true); + } + if ($body && $body.length) { + diff = $body.outerHeight(true) - $body.height(); + h -= diff; + } + $modal.find('.kv-zoom-body').height(h); + }, + _resizeZoomDialog: function (fullScreen) { + var self = this, $modal = self.$modal, $btnFull = $modal.find('.btn-fullscreen'), + $btnBord = $modal.find('.btn-borderless'); + if ($modal.hasClass('file-zoom-fullscreen')) { + $h.toggleFullScreen(false); + if (!fullScreen) { + if (!$btnFull.hasClass('active')) { + $modal.removeClass('file-zoom-fullscreen'); + self.$modal.find('.kv-zoom-body').css('height', self.zoomModalHeight); + } else { + $btnFull.removeClass('active').attr('aria-pressed', 'false'); + } + } else { + if (!$btnFull.hasClass('active')) { + $modal.removeClass('file-zoom-fullscreen'); + self._resizeZoomDialog(true); + if ($btnBord.hasClass('active')) { + $btnBord.removeClass('active').attr('aria-pressed', 'false'); + } + } + } + } else { + if (!fullScreen) { + self._maximizeZoomDialog(); + return; + } + $h.toggleFullScreen(true); + } + $modal.focus(); + }, + _setZoomContent: function ($frame, animate) { + var self = this, $content, tmplt, body, title, $body, $dataEl, config, previewId = $frame.attr('id'), + $zoomPreview = self.$preview.find('#zoom-' + previewId), $modal = self.$modal, $tmp, + $btnFull = $modal.find('.btn-fullscreen'), $btnBord = $modal.find('.btn-borderless'), cap, size, + $btnTogh = $modal.find('.btn-toggleheader'); + tmplt = $zoomPreview.attr('data-template') || 'generic'; + $content = $zoomPreview.find('.kv-file-content'); + body = $content.length ? $content.html() : ''; + cap = $frame.data('caption') || ''; + size = $frame.data('size') || ''; + title = cap + ' ' + size; + $modal.find('.kv-zoom-title').attr('title', $('
    ').html(title).text()).html(title); + $body = $modal.find('.kv-zoom-body'); + $modal.removeClass('kv-single-content'); + if (animate) { + $tmp = $body.addClass('file-thumb-loading').clone().insertAfter($body); + $body.html(body).hide(); + $tmp.fadeOut('fast', function () { + $body.fadeIn('fast', function () { + $body.removeClass('file-thumb-loading'); + }); + $tmp.remove(); + }); + } else { + $body.html(body); + } + config = self.previewZoomSettings[tmplt]; + if (config) { + $dataEl = $body.find('.kv-preview-data'); + $h.addCss($dataEl, 'file-zoom-detail'); + $.each(config, function (key, value) { + $dataEl.css(key, value); + if (($dataEl.attr('width') && key === 'width') || ($dataEl.attr('height') && key === 'height')) { + $dataEl.removeAttr(key); + } + }); + } + $modal.data('previewId', previewId); + self._handler($modal.find('.btn-prev'), 'click', function () { + self._zoomSlideShow('prev', previewId); + }); + self._handler($modal.find('.btn-next'), 'click', function () { + self._zoomSlideShow('next', previewId); + }); + self._handler($btnFull, 'click', function () { + self._resizeZoomDialog(true); + }); + self._handler($btnBord, 'click', function () { + self._resizeZoomDialog(false); + }); + self._handler($btnTogh, 'click', function () { + var $header = $modal.find('.modal-header'), $floatBar = $modal.find('.modal-body .floating-buttons'), + ht, $actions = $header.find('.kv-zoom-actions'), resize = function (height) { + var $body = self.$modal.find('.kv-zoom-body'), h = self.zoomModalHeight; + if ($modal.hasClass('file-zoom-fullscreen')) { + h = $body.outerHeight(true); + if (!height) { + h = h - $header.outerHeight(true); + } + } + $body.css('height', height ? h + height : h); + }; + if ($header.is(':visible')) { + ht = $header.outerHeight(true); + $header.slideUp('slow', function () { + $actions.find('.btn').appendTo($floatBar); + resize(ht); + }); + } else { + $floatBar.find('.btn').appendTo($actions); + $header.slideDown('slow', function () { + resize(); + }); + } + $modal.focus(); + }); + self._handler($modal, 'keydown', function (e) { + var key = e.which || e.keyCode, $prev = $(this).find('.btn-prev'), $next = $(this).find('.btn-next'), + vId = $(this).data('previewId'), vPrevKey = self.rtl ? 39 : 37, vNextKey = self.rtl ? 37 : 39; + if (key === vPrevKey && $prev.length && !$prev.attr('disabled')) { + self._zoomSlideShow('prev', vId); + } + if (key === vNextKey && $next.length && !$next.attr('disabled')) { + self._zoomSlideShow('next', vId); + } + }); + }, + _zoomPreview: function ($btn) { + var self = this, $frame, $modal = self.$modal; + if (!$btn.length) { + throw 'Cannot zoom to detailed preview!'; + } + $h.initModal($modal); + $modal.html(self._getModalContent()); + $frame = $btn.closest($h.FRAMES); + self._setZoomContent($frame); + $modal.modal('show'); + self._initZoomButtons(); + }, + _zoomSlideShow: function (dir, previewId) { + var self = this, $btn = self.$modal.find('.kv-zoom-actions .btn-' + dir), $targFrame, i, + thumbs = self.getFrames().toArray(), len = thumbs.length, out; + if ($btn.attr('disabled')) { + return; + } + for (i = 0; i < len; i++) { + if ($(thumbs[i]).attr('id') === previewId) { + out = dir === 'prev' ? i - 1 : i + 1; + break; + } + } + if (out < 0 || out >= len || !thumbs[out]) { + return; + } + $targFrame = $(thumbs[out]); + if ($targFrame.length) { + self._setZoomContent($targFrame, true); + } + self._initZoomButtons(); + self._raise('filezoom' + dir, {'previewId': previewId, modal: self.$modal}); + }, + _initZoomButton: function () { + var self = this; + self.$preview.find('.kv-file-zoom').each(function () { + var $el = $(this); + self._handler($el, 'click', function () { + self._zoomPreview($el); + }); + }); + }, + _inputFileCount: function () { + return this.$element.get(0).files.length; + }, + _refreshPreview: function () { + var self = this, files; + if ((!self._inputFileCount() && !self.isAjaxUpload) || !self.showPreview || !self.isPreviewable) { + return; + } + if (self.isAjaxUpload) { + if (self.fileManager.count() > 0) { + files = $.extend(true, {}, self.fileManager.stack); + self.fileManager.clear(); + self._clearFileInput(); + } else { + files = self.$element.get(0).files; + } + } else { + files = self.$element.get(0).files; + } + if (files && files.length) { + self.readFiles(files); + self._setFileDropZoneTitle(); + } + }, + _clearObjects: function ($el) { + $el.find('video audio').each(function () { + this.pause(); + $(this).remove(); + }); + $el.find('img object div').each(function () { + $(this).remove(); + }); + }, + _clearFileInput: function () { + var self = this, $el = self.$element, $srcFrm, $tmpFrm, $tmpEl; + if (!self._inputFileCount()) { + return; + } + $srcFrm = $el.closest('form'); + $tmpFrm = $(document.createElement('form')); + $tmpEl = $(document.createElement('div')); + $el.before($tmpEl); + if ($srcFrm.length) { + $srcFrm.after($tmpFrm); + } else { + $tmpEl.after($tmpFrm); + } + $tmpFrm.append($el).trigger('reset'); + $tmpEl.before($el).remove(); + $tmpFrm.remove(); + }, + _resetUpload: function () { + var self = this; + self.uploadCache = {content: [], config: [], tags: [], append: true}; + self.$btnUpload.removeAttr('disabled'); + self._setProgress(0); + self.$progress.hide(); + self._resetErrors(false); + self._initAjax(); + self.fileManager.clearImages(); + self._resetCanvas(); + self.cacheInitialPreview = {}; + if (self.overwriteInitial) { + self.initialPreview = []; + self.initialPreviewConfig = []; + self.initialPreviewThumbTags = []; + self.previewCache.data = { + content: [], + config: [], + tags: [] + }; + } + }, + _resetCanvas: function () { + var self = this; + if (self.canvas && self.imageCanvasContext) { + self.imageCanvasContext.clearRect(0, 0, self.canvas.width, self.canvas.height); + } + }, + _hasInitialPreview: function () { + var self = this; + return !self.overwriteInitial && self.previewCache.count(true); + }, + _resetPreview: function () { + var self = this, out, cap; + if (self.previewCache.count(true)) { + out = self.previewCache.out(); + self._setPreviewContent(out.content); + self._setInitThumbAttr(); + cap = self.initialCaption ? self.initialCaption : out.caption; + self._setCaption(cap); + } else { + self._clearPreview(); + self._initCaption(); + } + if (self.showPreview) { + self._initZoom(); + self._initSortable(); + } + }, + _clearDefaultPreview: function () { + var self = this; + self.$preview.find('.file-default-preview').remove(); + }, + _validateDefaultPreview: function () { + var self = this; + if (!self.showPreview || $h.isEmpty(self.defaultPreviewContent)) { + return; + } + self._setPreviewContent('
    ' + self.defaultPreviewContent + '
    '); + self.$container.removeClass('file-input-new'); + self._initClickable(); + }, + _resetPreviewThumbs: function (isAjax) { + var self = this, out; + if (isAjax) { + self._clearPreview(); + self.clearFileStack(); + return; + } + if (self._hasInitialPreview()) { + out = self.previewCache.out(); + self._setPreviewContent(out.content); + self._setInitThumbAttr(); + self._setCaption(out.caption); + self._initPreviewActions(); + } else { + self._clearPreview(); + } + }, + _getLayoutTemplate: function (t) { + var self = this, template = self.layoutTemplates[t]; + if ($h.isEmpty(self.customLayoutTags)) { + return template; + } + return $h.replaceTags(template, self.customLayoutTags); + }, + _getPreviewTemplate: function (t) { + var self = this, template = self.previewTemplates[t]; + if ($h.isEmpty(self.customPreviewTags)) { + return template; + } + return $h.replaceTags(template, self.customPreviewTags); + }, + _getOutData: function (formdata, jqXHR, responseData, filesData) { + var self = this; + jqXHR = jqXHR || {}; + responseData = responseData || {}; + filesData = filesData || self.fileManager.list(); + return { + formdata: formdata, + files: filesData, + filenames: self.filenames, + filescount: self.getFilesCount(), + extra: self._getExtraData(), + response: responseData, + reader: self.reader, + jqXHR: jqXHR + }; + }, + _getMsgSelected: function (n) { + var self = this, strFiles = n === 1 ? self.fileSingle : self.filePlural; + return n > 0 ? self.msgSelected.replace('{n}', n).replace('{files}', strFiles) : self.msgNoFilesSelected; + }, + _getFrame: function (id) { + var self = this, $frame = $('#' + id); + if (!$frame.length) { + self._log($h.logMessages.invalidThumb, {id: id}); + return null; + } + return $frame; + }, + _getThumbs: function (css) { + css = css || ''; + return this.getFrames(':not(.file-preview-initial)' + css); + }, + _getExtraData: function (fileId, index) { + var self = this, data = self.uploadExtraData; + if (typeof self.uploadExtraData === 'function') { + data = self.uploadExtraData(fileId, index); + } + return data; + }, + _initXhr: function (xhrobj, fileId, fileCount) { + var self = this, fm = self.fileManager, func = function (event) { + var pct = 0, total = event.total, loaded = event.loaded || event.position, + stats = fm.getUploadStats(fileId, loaded, total); + /** @namespace event.lengthComputable */ + if (event.lengthComputable && !self.enableResumableUpload) { + pct = $h.round(loaded / total * 100); + } + if (fileId) { + self._setFileUploadStats(fileId, pct, fileCount, stats); + } else { + self._setProgress(pct, null, null, self._getStats(stats)); + } + self._raise('fileajaxprogress', [stats]); + }; + if (xhrobj.upload) { + if (self.progressDelay) { + func = $h.debounce(func, self.progressDelay); + } + xhrobj.upload.addEventListener('progress', func, false); + } + return xhrobj; + }, + _initAjaxSettings: function () { + var self = this; + self._ajaxSettings = $.extend(true, {}, self.ajaxSettings); + self._ajaxDeleteSettings = $.extend(true, {}, self.ajaxDeleteSettings); + }, + _mergeAjaxCallback: function (funcName, srcFunc, type) { + var self = this, settings = self._ajaxSettings, flag = self.mergeAjaxCallbacks, targFunc; + if (type === 'delete') { + settings = self._ajaxDeleteSettings; + flag = self.mergeAjaxDeleteCallbacks; + } + targFunc = settings[funcName]; + if (flag && typeof targFunc === 'function') { + if (flag === 'before') { + settings[funcName] = function () { + targFunc.apply(this, arguments); + srcFunc.apply(this, arguments); + }; + } else { + settings[funcName] = function () { + srcFunc.apply(this, arguments); + targFunc.apply(this, arguments); + }; + } + } else { + settings[funcName] = srcFunc; + } + }, + _ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError, formdata, fileId, index, vUrl) { + var self = this, settings, defaults, data, processQueue; + if (!self._raise('filepreajax', [formdata, fileId, index])) { + return; + } + formdata.append('initialPreview', JSON.stringify(self.initialPreview)); + formdata.append('initialPreviewConfig', JSON.stringify(self.initialPreviewConfig)); + formdata.append('initialPreviewThumbTags', JSON.stringify(self.initialPreviewThumbTags)); + self._initAjaxSettings(); + self._mergeAjaxCallback('beforeSend', fnBefore); + self._mergeAjaxCallback('success', fnSuccess); + self._mergeAjaxCallback('complete', fnComplete); + self._mergeAjaxCallback('error', fnError); + vUrl = vUrl || self.uploadUrlThumb || self.uploadUrl; + if (typeof vUrl === 'function') { + vUrl = vUrl(); + } + data = self._getExtraData(fileId, index) || {}; + if (typeof data === 'object') { + $.each(data, function (key, value) { + formdata.append(key, value); + }); + } + defaults = { + xhr: function () { + var xhrobj = $.ajaxSettings.xhr(); + return self._initXhr(xhrobj, fileId, self.fileManager.count()); + }, + url: self._encodeURI(vUrl), + type: 'POST', + dataType: 'json', + data: formdata, + cache: false, + processData: false, + contentType: false + }; + settings = $.extend(true, {}, defaults, self._ajaxSettings); + self.ajaxQueue.push(settings); + processQueue = function () { + var config, xhr; + if (self.ajaxCurrentThreads < self.maxAjaxThreads) { + config = self.ajaxQueue.shift(); + if (typeof config !== 'undefined') { + self.ajaxCurrentThreads++; + xhr = $.ajax(config).done(function () { + clearInterval(self.ajaxQueueIntervalId); + self.ajaxCurrentThreads--; + }); + self.ajaxRequests.push(xhr); + } + } + }; + self.ajaxQueueIntervalId = setInterval(processQueue, self.queueDelay); + + }, + _mergeArray: function (prop, content) { + var self = this, arr1 = $h.cleanArray(self[prop]), arr2 = $h.cleanArray(content); + self[prop] = arr1.concat(arr2); + }, + _initUploadSuccess: function (out, $thumb, allFiles) { + var self = this, append, data, index, $div, $newCache, content, config, tags, i; + if (!self.showPreview || typeof out !== 'object' || $.isEmptyObject(out)) { + return; + } + if (out.initialPreview !== undefined && out.initialPreview.length > 0) { + self.hasInitData = true; + content = out.initialPreview || []; + config = out.initialPreviewConfig || []; + tags = out.initialPreviewThumbTags || []; + append = out.append === undefined || out.append; + if (content.length > 0 && !$h.isArray(content)) { + content = content.split(self.initialPreviewDelimiter); + } + if (content.length) { + self._mergeArray('initialPreview', content); + self._mergeArray('initialPreviewConfig', config); + self._mergeArray('initialPreviewThumbTags', tags); + } + if ($thumb !== undefined) { + if (!allFiles) { + index = self.previewCache.add(content[0], config[0], tags[0], append); + data = self.previewCache.get(index, false); + $div = $(document.createElement('div')).html(data).hide().insertAfter($thumb); + $newCache = $div.find('.kv-zoom-cache'); + if ($newCache && $newCache.length) { + $newCache.insertAfter($thumb); + } + $thumb.fadeOut('slow', function () { + var $newThumb = $div.find('.file-preview-frame'); + if ($newThumb && $newThumb.length) { + $newThumb.insertBefore($thumb).fadeIn('slow').css('display:inline-block'); + } + self._initPreviewActions(); + self._clearFileInput(); + $h.cleanZoomCache(self.$preview.find('#zoom-' + $thumb.attr('id'))); + $thumb.remove(); + $div.remove(); + self._initSortable(); + }); + } else { + i = $thumb.attr('data-fileindex'); + self.uploadCache.content[i] = content[0]; + self.uploadCache.config[i] = config[0] || []; + self.uploadCache.tags[i] = tags[0] || []; + self.uploadCache.append = append; + } + } else { + self.previewCache.set(content, config, tags, append); + self._initPreview(); + self._initPreviewActions(); + } + } + }, + _initSuccessThumbs: function () { + var self = this; + if (!self.showPreview) { + return; + } + self._getThumbs($h.FRAMES + '.file-preview-success').each(function () { + var $thumb = $(this), $preview = self.$preview, $remove = $thumb.find('.kv-file-remove'); + $remove.removeAttr('disabled'); + self._handler($remove, 'click', function () { + var id = $thumb.attr('id'), + out = self._raise('filesuccessremove', [id, $thumb.attr('data-fileindex')]); + $h.cleanMemory($thumb); + if (out === false) { + return; + } + $thumb.fadeOut('slow', function () { + $h.cleanZoomCache($preview.find('#zoom-' + id)); + $thumb.remove(); + if (!self.getFrames().length) { + self.reset(); + } + }); + }); + }); + }, + _updateInitialPreview: function () { + var self = this, u = self.uploadCache, i, j, len = 0, data = self.cacheInitialPreview; + if (data && data.content) { + len = data.content.length; + } + if (self.showPreview) { + self.previewCache.set(u.content, u.config, u.tags, u.append); + if (len) { + for (i = 0; i < u.content.length; i++) { + j = i + len; + data.content[j] = u.content[i]; + //noinspection JSUnresolvedVariable + if (data.config.length) { + data.config[j] = u.config[i]; + } + if (data.tags.length) { + data.tags[j] = u.tags[i]; + } + } + self.initialPreview = $h.cleanArray(data.content); + self.initialPreviewConfig = $h.cleanArray(data.config); + self.initialPreviewThumbTags = $h.cleanArray(data.tags); + } else { + self.initialPreview = u.content; + self.initialPreviewConfig = u.config; + self.initialPreviewThumbTags = u.tags; + } + self.cacheInitialPreview = {}; + if (self.hasInitData) { + self._initPreview(); + self._initPreviewActions(); + } + } + }, + _uploadSingle: function (i, id, isBatch) { + var self = this, fm = self.fileManager, count = fm.count(), formdata = new FormData(), outData, + previewId = self.previewInitId + '-' + i, $thumb, chkComplete, $btnUpload, $btnDelete, + hasPostData = count > 0 || !$.isEmptyObject(self.uploadExtraData), uploadFailed, $prog, fnBefore, + errMsg, fnSuccess, fnComplete, fnError, updateUploadLog, op = self.ajaxOperations.uploadThumb, + fileObj = fm.getFile(id), params = {id: previewId, index: i, fileId: id}, + fileName = self.fileManager.getFileName(id, true); + if (self.enableResumableUpload) { // not enabled for resumable uploads + return; + } + if (self.showPreview) { + $thumb = self.fileManager.getThumb(id); + $prog = $thumb.find('.file-thumb-progress'); + $btnUpload = $thumb.find('.kv-file-upload'); + $btnDelete = $thumb.find('.kv-file-remove'); + $prog.show(); + } + if (count === 0 || !hasPostData || (self.showPreview && $btnUpload && $btnUpload.hasClass('disabled')) || + self._abort(params)) { + return; + } + updateUploadLog = function () { + if (!uploadFailed) { + fm.removeFile(id); + } else { + fm.errors.push(id); + } + fm.setProcessed(id); + if (fm.isProcessed()) { + self.fileBatchCompleted = true; + } + }; + chkComplete = function () { + var $initThumbs; + if (!self.fileBatchCompleted) { + return; + } + setTimeout(function () { + var triggerReset = fm.count() === 0, errCount = fm.errors.length; + self._updateInitialPreview(); + self.unlock(triggerReset); + if (triggerReset) { + self._clearFileInput(); + } + $initThumbs = self.$preview.find('.file-preview-initial'); + if (self.uploadAsync && $initThumbs.length) { + $h.addCss($initThumbs, $h.SORT_CSS); + self._initSortable(); + } + self._raise('filebatchuploadcomplete', [fm.stack, self._getExtraData()]); + if (!self.retryErrorUploads || errCount === 0) { + fm.clear(); + } + self._setProgress(101); + self.ajaxAborted = false; + }, self.processDelay); + }; + fnBefore = function (jqXHR) { + outData = self._getOutData(formdata, jqXHR); + fm.initStats(id); + self.fileBatchCompleted = false; + if (!isBatch) { + self.ajaxAborted = false; + } + if (self.showPreview) { + if (!$thumb.hasClass('file-preview-success')) { + self._setThumbStatus($thumb, 'Loading'); + $h.addCss($thumb, 'file-uploading'); + } + $btnUpload.attr('disabled', true); + $btnDelete.attr('disabled', true); + } + if (!isBatch) { + self.lock(); + } + if (fm.errors.indexOf(id) !== -1) { + delete fm.errors[id]; + } + self._raise('filepreupload', [outData, previewId, i]); + $.extend(true, params, outData); + if (self._abort(params)) { + jqXHR.abort(); + if (!isBatch) { + self._setThumbStatus($thumb, 'New'); + $thumb.removeClass('file-uploading'); + $btnUpload.removeAttr('disabled'); + $btnDelete.removeAttr('disabled'); + self.unlock(); + } + self._setProgressCancelled(); + } + }; + fnSuccess = function (data, textStatus, jqXHR) { + var pid = self.showPreview && $thumb.attr('id') ? $thumb.attr('id') : previewId; + outData = self._getOutData(formdata, jqXHR, data); + $.extend(true, params, outData); + setTimeout(function () { + if ($h.isEmpty(data) || $h.isEmpty(data.error)) { + if (self.showPreview) { + self._setThumbStatus($thumb, 'Success'); + $btnUpload.hide(); + self._initUploadSuccess(data, $thumb, isBatch); + self._setProgress(101, $prog); + } + self._raise('fileuploaded', [outData, pid, i]); + if (!isBatch) { + self.fileManager.remove($thumb); + } else { + updateUploadLog(); + } + } else { + uploadFailed = true; + errMsg = self._parseError(op, jqXHR, self.msgUploadError, self.fileManager.getFileName(id)); + self._showFileError(errMsg, params); + self._setPreviewError($thumb, true); + if (!self.retryErrorUploads) { + $btnUpload.hide(); + } + if (isBatch) { + updateUploadLog(); + } + self._setProgress(101, $('#' + pid).find('.file-thumb-progress'), self.msgUploadError); + } + }, self.processDelay); + }; + fnComplete = function () { + setTimeout(function () { + if (self.showPreview) { + $btnUpload.removeAttr('disabled'); + $btnDelete.removeAttr('disabled'); + $thumb.removeClass('file-uploading'); + } + if (!isBatch) { + self.unlock(false); + self._clearFileInput(); + } else { + chkComplete(); + } + self._initSuccessThumbs(); + }, self.processDelay); + }; + fnError = function (jqXHR, textStatus, errorThrown) { + errMsg = self._parseError(op, jqXHR, errorThrown, self.fileManager.getFileName(id)); + uploadFailed = true; + setTimeout(function () { + if (isBatch) { + updateUploadLog(); + } + self.fileManager.setProgress(id, 100); + self._setPreviewError($thumb, true); + if (!self.retryErrorUploads) { + $btnUpload.hide(); + } + $.extend(true, params, self._getOutData(formdata, jqXHR)); + self._setProgress(101, $prog, self.msgAjaxProgressError.replace('{operation}', op)); + self._setProgress(101, $thumb.find('.file-thumb-progress'), self.msgUploadError); + self._showFileError(errMsg, params); + }, self.processDelay); + }; + formdata.append(self.uploadFileAttr, fileObj.file, fileName); + self._setUploadData(formdata, {fileId: id}); + self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, formdata, id, i); + }, + _uploadBatch: function () { + var self = this, fm = self.fileManager, total = fm.total(), params = {}, fnBefore, fnSuccess, fnError, + fnComplete, hasPostData = total > 0 || !$.isEmptyObject(self.uploadExtraData), errMsg, + setAllUploaded, formdata = new FormData(), op = self.ajaxOperations.uploadBatch; + if (total === 0 || !hasPostData || self._abort(params)) { + return; + } + setAllUploaded = function () { + self.fileManager.clear(); + self._clearFileInput(); + }; + fnBefore = function (jqXHR) { + self.lock(); + fm.initStats(); + var outData = self._getOutData(formdata, jqXHR); + self.ajaxAborted = false; + if (self.showPreview) { + self._getThumbs().each(function () { + var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload'), + $btnDelete = $thumb.find('.kv-file-remove'); + if (!$thumb.hasClass('file-preview-success')) { + self._setThumbStatus($thumb, 'Loading'); + $h.addCss($thumb, 'file-uploading'); + } + $btnUpload.attr('disabled', true); + $btnDelete.attr('disabled', true); + }); + } + self._raise('filebatchpreupload', [outData]); + if (self._abort(outData)) { + jqXHR.abort(); + self._getThumbs().each(function () { + var $thumb = $(this), $btnUpload = $thumb.find('.kv-file-upload'), + $btnDelete = $thumb.find('.kv-file-remove'); + if ($thumb.hasClass('file-preview-loading')) { + self._setThumbStatus($thumb, 'New'); + $thumb.removeClass('file-uploading'); + } + $btnUpload.removeAttr('disabled'); + $btnDelete.removeAttr('disabled'); + }); + self._setProgressCancelled(); + } + }; + fnSuccess = function (data, textStatus, jqXHR) { + /** @namespace data.errorkeys */ + var outData = self._getOutData(formdata, jqXHR, data), key = 0, + $thumbs = self._getThumbs(':not(.file-preview-success)'), + keys = $h.isEmpty(data) || $h.isEmpty(data.errorkeys) ? [] : data.errorkeys; + + if ($h.isEmpty(data) || $h.isEmpty(data.error)) { + self._raise('filebatchuploadsuccess', [outData]); + setAllUploaded(); + if (self.showPreview) { + $thumbs.each(function () { + var $thumb = $(this); + self._setThumbStatus($thumb, 'Success'); + $thumb.removeClass('file-uploading'); + $thumb.find('.kv-file-upload').hide().removeAttr('disabled'); + }); + self._initUploadSuccess(data); + } else { + self.reset(); + } + self._setProgress(101); + } else { + if (self.showPreview) { + $thumbs.each(function () { + var $thumb = $(this); + $thumb.removeClass('file-uploading'); + $thumb.find('.kv-file-upload').removeAttr('disabled'); + $thumb.find('.kv-file-remove').removeAttr('disabled'); + if (keys.length === 0 || $.inArray(key, keys) !== -1) { + self._setPreviewError($thumb, true); + if (!self.retryErrorUploads) { + $thumb.find('.kv-file-upload').hide(); + self.fileManager.remove($thumb); + } + } else { + $thumb.find('.kv-file-upload').hide(); + self._setThumbStatus($thumb, 'Success'); + self.fileManager.remove($thumb); + } + if (!$thumb.hasClass('file-preview-error') || self.retryErrorUploads) { + key++; + } + }); + self._initUploadSuccess(data); + } + errMsg = self._parseError(op, jqXHR, self.msgUploadError); + self._showFileError(errMsg, outData, 'filebatchuploaderror'); + self._setProgress(101, self.$progress, self.msgUploadError); + } + }; + fnComplete = function () { + self.unlock(); + self._initSuccessThumbs(); + self._clearFileInput(); + self._raise('filebatchuploadcomplete', [self.fileManager.stack, self._getExtraData()]); + }; + fnError = function (jqXHR, textStatus, errorThrown) { + var outData = self._getOutData(formdata, jqXHR); + errMsg = self._parseError(op, jqXHR, errorThrown); + self._showFileError(errMsg, outData, 'filebatchuploaderror'); + self.uploadFileCount = total - 1; + if (!self.showPreview) { + return; + } + self._getThumbs().each(function () { + var $thumb = $(this); + $thumb.removeClass('file-uploading'); + if (self.fileManager.getFile($thumb.attr('data-fileid'))) { + self._setPreviewError($thumb); + } + }); + self._getThumbs().removeClass('file-uploading'); + self._getThumbs(' .kv-file-upload').removeAttr('disabled'); + self._getThumbs(' .kv-file-delete').removeAttr('disabled'); + self._setProgress(101, self.$progress, self.msgAjaxProgressError.replace('{operation}', op)); + }; + var ctr = 0; + $.each(self.fileManager.stack, function (key, data) { + if (!$h.isEmpty(data.file)) { + formdata.append(self.uploadFileAttr, data.file, (data.nameFmt || ('untitled_' + ctr))); + } + ctr++; + }); + self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, formdata); + }, + _uploadExtraOnly: function () { + var self = this, params = {}, fnBefore, fnSuccess, fnComplete, fnError, formdata = new FormData(), errMsg, + op = self.ajaxOperations.uploadExtra; + if (self._abort(params)) { + return; + } + fnBefore = function (jqXHR) { + self.lock(); + var outData = self._getOutData(formdata, jqXHR); + self._raise('filebatchpreupload', [outData]); + self._setProgress(50); + params.data = outData; + params.xhr = jqXHR; + if (self._abort(params)) { + jqXHR.abort(); + self._setProgressCancelled(); + } + }; + fnSuccess = function (data, textStatus, jqXHR) { + var outData = self._getOutData(formdata, jqXHR, data); + if ($h.isEmpty(data) || $h.isEmpty(data.error)) { + self._raise('filebatchuploadsuccess', [outData]); + self._clearFileInput(); + self._initUploadSuccess(data); + self._setProgress(101); + } else { + errMsg = self._parseError(op, jqXHR, self.msgUploadError); + self._showFileError(errMsg, outData, 'filebatchuploaderror'); + } + }; + fnComplete = function () { + self.unlock(); + self._clearFileInput(); + self._raise('filebatchuploadcomplete', [self.fileManager.stack, self._getExtraData()]); + }; + fnError = function (jqXHR, textStatus, errorThrown) { + var outData = self._getOutData(formdata, jqXHR); + errMsg = self._parseError(op, jqXHR, errorThrown); + params.data = outData; + self._showFileError(errMsg, outData, 'filebatchuploaderror'); + self._setProgress(101, self.$progress, self.msgAjaxProgressError.replace('{operation}', op)); + }; + self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, formdata); + }, + _deleteFileIndex: function ($frame) { + var self = this, ind = $frame.attr('data-fileindex'), rev = self.reversePreviewOrder; + if (ind.substring(0, 5) === 'init_') { + ind = parseInt(ind.replace('init_', '')); + self.initialPreview = $h.spliceArray(self.initialPreview, ind, rev); + self.initialPreviewConfig = $h.spliceArray(self.initialPreviewConfig, ind, rev); + self.initialPreviewThumbTags = $h.spliceArray(self.initialPreviewThumbTags, ind, rev); + self.getFrames().each(function () { + var $nFrame = $(this), nInd = $nFrame.attr('data-fileindex'); + if (nInd.substring(0, 5) === 'init_') { + nInd = parseInt(nInd.replace('init_', '')); + if (nInd > ind) { + nInd--; + $nFrame.attr('data-fileindex', 'init_' + nInd); + } + } + }); + if (self.uploadAsync || self.enableResumableUpload) { + self.cacheInitialPreview = self.getPreview(); + } + } + }, + _initFileActions: function () { + var self = this, $preview = self.$preview; + if (!self.showPreview) { + return; + } + self._initZoomButton(); + self.getFrames(' .kv-file-remove').each(function () { + var $el = $(this), $frame = $el.closest($h.FRAMES), hasError, id = $frame.attr('id'), + ind = $frame.attr('data-fileindex'), n, cap, status; + self._handler($el, 'click', function () { + status = self._raise('filepreremove', [id, ind]); + if (status === false || !self._validateMinCount()) { + return false; + } + hasError = $frame.hasClass('file-preview-error'); + $h.cleanMemory($frame); + $frame.fadeOut('slow', function () { + $h.cleanZoomCache($preview.find('#zoom-' + id)); + self.fileManager.remove($frame); + self._clearObjects($frame); + $frame.remove(); + if (id && hasError) { + self.$errorContainer.find('li[data-thumb-id="' + id + '"]').fadeOut('fast', function () { + $(this).remove(); + if (!self._errorsExist()) { + self._resetErrors(); + } + }); + } + self._clearFileInput(); + var chk = self.previewCache.count(true), len = self.fileManager.count(), + file, hasThumb = self.showPreview && self.getFrames().length; + if (len === 0 && chk === 0 && !hasThumb) { + self.reset(); + } else { + n = chk + len; + if (n > 1) { + cap = self._getMsgSelected(n); + } else { + file = self.fileManager.getFirstFile(); + cap = file ? file.nameFmt : '_'; + } + self._setCaption(cap); + } + self._raise('fileremoved', [id, ind]); + }); + }); + }); + self.getFrames(' .kv-file-upload').each(function () { + var $el = $(this); + self._handler($el, 'click', function () { + var $frame = $el.closest($h.FRAMES), id = $frame.attr('data-fileid'); + self.$progress.hide(); + if ($frame.hasClass('file-preview-error') && !self.retryErrorUploads) { + return; + } + self._uploadSingle(self.fileManager.getIndex(id), id, false); + }); + }); + }, + _initPreviewActions: function () { + var self = this, $preview = self.$preview, deleteExtraData = self.deleteExtraData || {}, + btnRemove = $h.FRAMES + ' .kv-file-remove', settings = self.fileActionSettings, + origClass = settings.removeClass, errClass = settings.removeErrorClass, + resetProgress = function () { + var hasFiles = self.isAjaxUpload ? self.previewCache.count(true) : self._inputFileCount(); + if (!self.getFrames().length && !hasFiles) { + self._setCaption(''); + self.reset(); + self.initialCaption = ''; + } + }; + self._initZoomButton(); + $preview.find(btnRemove).each(function () { + var $el = $(this), vUrl = $el.data('url') || self.deleteUrl, vKey = $el.data('key'), errMsg, fnBefore, + fnSuccess, fnError, op = self.ajaxOperations.deleteThumb; + if ($h.isEmpty(vUrl) || vKey === undefined) { + return; + } + if (typeof vUrl === 'function') { + vUrl = vUrl(); + } + var $frame = $el.closest($h.FRAMES), cache = self.previewCache.data, settings, params, config, + fileName, extraData, index = $frame.attr('data-fileindex'); + index = parseInt(index.replace('init_', '')); + config = $h.isEmpty(cache.config) && $h.isEmpty(cache.config[index]) ? null : cache.config[index]; + extraData = $h.isEmpty(config) || $h.isEmpty(config.extra) ? deleteExtraData : config.extra; + fileName = config.filename || config.caption || ''; + if (typeof extraData === 'function') { + extraData = extraData(); + } + params = {id: $el.attr('id'), key: vKey, extra: extraData}; + fnBefore = function (jqXHR) { + self.ajaxAborted = false; + self._raise('filepredelete', [vKey, jqXHR, extraData]); + if (self._abort()) { + jqXHR.abort(); + } else { + $el.removeClass(errClass); + $h.addCss($frame, 'file-uploading'); + $h.addCss($el, 'disabled ' + origClass); + } + }; + fnSuccess = function (data, textStatus, jqXHR) { + var n, cap; + if (!$h.isEmpty(data) && !$h.isEmpty(data.error)) { + params.jqXHR = jqXHR; + params.response = data; + errMsg = self._parseError(op, jqXHR, self.msgDeleteError, fileName); + self._showFileError(errMsg, params, 'filedeleteerror'); + $frame.removeClass('file-uploading'); + $el.removeClass('disabled ' + origClass).addClass(errClass); + resetProgress(); + return; + } + $frame.removeClass('file-uploading').addClass('file-deleted'); + $frame.fadeOut('slow', function () { + index = parseInt(($frame.attr('data-fileindex')).replace('init_', '')); + self.previewCache.unset(index); + self._deleteFileIndex($frame); + n = self.previewCache.count(true); + cap = n > 0 ? self._getMsgSelected(n) : ''; + self._setCaption(cap); + self._raise('filedeleted', [vKey, jqXHR, extraData]); + $h.cleanZoomCache($preview.find('#zoom-' + $frame.attr('id'))); + self._clearObjects($frame); + $frame.remove(); + resetProgress(); + }); + }; + fnError = function (jqXHR, textStatus, errorThrown) { + var errMsg = self._parseError(op, jqXHR, errorThrown, fileName); + params.jqXHR = jqXHR; + params.response = {}; + self._showFileError(errMsg, params, 'filedeleteerror'); + $frame.removeClass('file-uploading'); + $el.removeClass('disabled ' + origClass).addClass(errClass); + resetProgress(); + }; + self._initAjaxSettings(); + self._mergeAjaxCallback('beforeSend', fnBefore, 'delete'); + self._mergeAjaxCallback('success', fnSuccess, 'delete'); + self._mergeAjaxCallback('error', fnError, 'delete'); + settings = $.extend(true, {}, { + url: self._encodeURI(vUrl), + type: 'POST', + dataType: 'json', + data: $.extend(true, {}, {key: vKey}, extraData) + }, self._ajaxDeleteSettings); + self._handler($el, 'click', function () { + if (!self._validateMinCount()) { + return false; + } + self.ajaxAborted = false; + self._raise('filebeforedelete', [vKey, extraData]); + //noinspection JSUnresolvedVariable,JSHint + if (self.ajaxAborted instanceof Promise) { + self.ajaxAborted.then(function (result) { + if (!result) { + $.ajax(settings); + } + }); + } else { + if (!self.ajaxAborted) { + $.ajax(settings); + } + } + }); + }); + }, + _hideFileIcon: function () { + var self = this; + if (self.overwriteInitial) { + self.$captionContainer.removeClass('icon-visible'); + } + }, + _showFileIcon: function () { + var self = this; + $h.addCss(self.$captionContainer, 'icon-visible'); + }, + _getSize: function (bytes, sizes) { + var self = this, size = parseFloat(bytes), i, func = self.fileSizeGetter, out; + if (!$.isNumeric(bytes) || !$.isNumeric(size)) { + return ''; + } + if (typeof func === 'function') { + out = func(size); + } else { + if (size === 0) { + out = '0.00 B'; + } else { + i = Math.floor(Math.log(size) / Math.log(1024)); + if (!sizes) { + sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + } + out = (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + sizes[i]; + } + } + return self._getLayoutTemplate('size').replace('{sizeText}', out); + }, + _getFileType: function (ftype) { + var self = this; + return self.mimeTypeAliases[ftype] || ftype; + }, + _generatePreviewTemplate: function ( + cat, + data, + fname, + ftype, + previewId, + fileId, + isError, + size, + frameClass, + foot, + ind, + templ, + attrs, + zoomData + ) { + var self = this, caption = self.slug(fname), prevContent, zoomContent = '', styleAttribs = '', + screenW = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, + config, newCat = self.preferIconicPreview ? 'other' : cat, title = caption, alt = caption, + footer = foot || self._renderFileFooter(cat, caption, size, 'auto', isError), + hasIconSetting = self._getPreviewIcon(fname), typeCss = 'type-default', + forcePrevIcon = hasIconSetting && self.preferIconicPreview, + forceZoomIcon = hasIconSetting && self.preferIconicZoomPreview, getContent; + config = screenW < 400 ? (self.previewSettingsSmall[newCat] || self.defaults.previewSettingsSmall[newCat]) : + (self.previewSettings[newCat] || self.defaults.previewSettings[newCat]); + if (config) { + $.each(config, function (key, val) { + styleAttribs += key + ':' + val + ';'; + }); + } + getContent = function (c, d, zoom, frameCss) { + var id = zoom ? 'zoom-' + previewId : previewId, tmplt = self._getPreviewTemplate(c), + css = (frameClass || '') + ' ' + frameCss; + if (self.frameClass) { + css = self.frameClass + ' ' + css; + } + if (zoom) { + css = css.replace(' ' + $h.SORT_CSS, ''); + } + tmplt = self._parseFilePreviewIcon(tmplt, fname); + if (c === 'text') { + d = $h.htmlEncode(d); + } + if (cat === 'object' && !ftype) { + $.each(self.defaults.fileTypeSettings, function (key, func) { + if (key === 'object' || key === 'other') { + return; + } + if (func(fname, ftype)) { + typeCss = 'type-' + key; + } + }); + } + if (!$h.isEmpty(attrs)) { + if (attrs.title !== undefined && attrs.title !== null) { + title = attrs.title; + } + if (attrs.alt !== undefined && attrs.alt !== null) { + title = attrs.alt; + } + } + return tmplt.setTokens({ + 'previewId': id, + 'caption': caption, + 'title': title, + 'alt': alt, + 'frameClass': css, + 'type': self._getFileType(ftype), + 'fileindex': ind, + 'fileid': fileId || '', + 'typeCss': typeCss, + 'footer': footer, + 'data': d, + 'template': templ || cat, + 'style': styleAttribs ? 'style="' + styleAttribs + '"' : '' + }); + }; + ind = ind || previewId.slice(previewId.lastIndexOf('-') + 1); + if (self.fileActionSettings.showZoom) { + zoomContent = getContent((forceZoomIcon ? 'other' : cat), zoomData ? zoomData : data, true, + 'kv-zoom-thumb'); + } + zoomContent = '\n' + self._getLayoutTemplate('zoomCache').replace('{zoomContent}', zoomContent); + if (typeof self.sanitizeZoomCache === 'function') { + zoomContent = self.sanitizeZoomCache(zoomContent); + } + prevContent = getContent((forcePrevIcon ? 'other' : cat), data, false, 'kv-preview-thumb'); + return prevContent + zoomContent; + }, + _addToPreview: function ($preview, content) { + var self = this; + return self.reversePreviewOrder ? $preview.prepend(content) : $preview.append(content); + }, + _previewDefault: function (file, previewId, isDisabled) { + var self = this, $preview = self.$preview; + if (!self.showPreview) { + return; + } + var fname = $h.getFileName(file), ftype = file ? file.type : '', content, size = file.size || 0, + caption = self._getFileName(file, ''), isError = isDisabled === true && !self.isAjaxUpload, + data = $h.createObjectURL(file), fileId = self.fileManager.getId(file); + self._clearDefaultPreview(); + content = self._generatePreviewTemplate('other', data, fname, ftype, previewId, fileId, isError, size); + self._addToPreview($preview, content); + self._setThumbAttr(previewId, caption, size); + if (isDisabled === true && self.isAjaxUpload) { + self._setThumbStatus($('#' + previewId), 'Error'); + } + }, + canPreview: function (file) { + var self = this; + if (!file || !self.showPreview || !self.$preview || !self.$preview.length) { + return false; + } + var name = file.name || '', type = file.type || '', size = (file.size || 0) / 1000, + cat = self._parseFileType(type, name), allowedTypes, allowedMimes, allowedExts, skipPreview, + types = self.allowedPreviewTypes, mimes = self.allowedPreviewMimeTypes, + exts = self.allowedPreviewExtensions || [], dTypes = self.disabledPreviewTypes, + dMimes = self.disabledPreviewMimeTypes, dExts = self.disabledPreviewExtensions || [], + maxSize = self.maxFilePreviewSize && parseFloat(self.maxFilePreviewSize) || 0, + expAllExt = new RegExp('\\.(' + exts.join('|') + ')$', 'i'), + expDisExt = new RegExp('\\.(' + dExts.join('|') + ')$', 'i'); + allowedTypes = !types || types.indexOf(cat) !== -1; + allowedMimes = !mimes || mimes.indexOf(type) !== -1; + allowedExts = !exts.length || $h.compare(name, expAllExt); + skipPreview = (dTypes && dTypes.indexOf(cat) !== -1) || (dMimes && dMimes.indexOf(type) !== -1) || + (dExts.length && $h.compare(name, expDisExt)) || (maxSize && !isNaN(maxSize) && size > maxSize); + return !skipPreview && (allowedTypes || allowedMimes || allowedExts); + }, + _previewFile: function (i, file, theFile, previewId, data, fileInfo) { + if (!this.showPreview) { + return; + } + var self = this, fname = $h.getFileName(file), ftype = fileInfo.type, caption = fileInfo.name, + cat = self._parseFileType(ftype, fname), content, $preview = self.$preview, fsize = file.size || 0, + iData = (cat === 'text' || cat === 'html' || cat === 'image') ? theFile.target.result : data, + fileId = self.fileManager.getId(file); + /** @namespace window.DOMPurify */ + if (cat === 'html' && self.purifyHtml && window.DOMPurify) { + iData = window.DOMPurify.sanitize(iData); + } + content = self._generatePreviewTemplate(cat, iData, fname, ftype, previewId, fileId, false, fsize); + self._clearDefaultPreview(); + self._addToPreview($preview, content); + var $thumb = $preview.find('#' + previewId), $img = $thumb.find('img'), id = $thumb.attr('data-fileid'); + self._validateImageOrientation($img, file, previewId, id, caption, ftype, fsize, iData); + self._setThumbAttr(previewId, caption, fsize); + self._initSortable(); + }, + _setThumbAttr: function (id, caption, size) { + var self = this, $frame = $('#' + id); + if ($frame.length) { + size = size && size > 0 ? self._getSize(size) : ''; + $frame.data({'caption': caption, 'size': size}); + } + }, + _setInitThumbAttr: function () { + var self = this, data = self.previewCache.data, len = self.previewCache.count(true), config, + caption, size, previewId; + if (len === 0) { + return; + } + for (var i = 0; i < len; i++) { + config = data.config[i]; + previewId = self.previewInitId + '-' + 'init_' + i; + caption = $h.ifSet('caption', config, $h.ifSet('filename', config)); + size = $h.ifSet('size', config); + self._setThumbAttr(previewId, caption, size); + } + }, + _slugDefault: function (text) { + // noinspection RegExpRedundantEscape + return $h.isEmpty(text) ? '' : String(text).replace(/[\[\]\/\{}:;#%=\(\)\*\+\?\\\^\$\|<>&"']/g, '_'); + }, + _updateFileDetails: function (numFiles) { + var self = this, $el = self.$element, label, n, log, nFiles, file, + name = ($h.isIE(9) && $h.findFileName($el.val())) || ($el[0].files[0] && $el[0].files[0].name); + if (!name && self.fileManager.count() > 0) { + file = self.fileManager.getFirstFile(); + label = file.nameFmt; + } else { + label = name ? self.slug(name) : '_'; + } + n = self.isAjaxUpload ? self.fileManager.count() : numFiles; + nFiles = self.previewCache.count(true) + n; + log = n === 1 ? label : self._getMsgSelected(nFiles); + if (self.isError) { + self.$previewContainer.removeClass('file-thumb-loading'); + self.$previewStatus.html(''); + self.$captionContainer.removeClass('icon-visible'); + } else { + self._showFileIcon(); + } + self._setCaption(log, self.isError); + self.$container.removeClass('file-input-new file-input-ajax-new'); + if (arguments.length === 1) { + self._raise('fileselect', [numFiles, label]); + } + if (self.previewCache.count(true)) { + self._initPreviewActions(); + } + }, + _setThumbStatus: function ($thumb, status) { + var self = this; + if (!self.showPreview) { + return; + } + var icon = 'indicator' + status, msg = icon + 'Title', + css = 'file-preview-' + status.toLowerCase(), + $indicator = $thumb.find('.file-upload-indicator'), + config = self.fileActionSettings; + $thumb.removeClass('file-preview-success file-preview-error file-preview-paused file-preview-loading'); + if (status === 'Success') { + $thumb.find('.file-drag-handle').remove(); + } + $indicator.html(config[icon]); + $indicator.attr('title', config[msg]); + $thumb.addClass(css); + if (status === 'Error' && !self.retryErrorUploads) { + $thumb.find('.kv-file-upload').attr('disabled', true); + } + }, + _setProgressCancelled: function () { + var self = this; + self._setProgress(101, self.$progress, self.msgCancelled); + }, + _setProgress: function (p, $el, error, stats) { + var self = this; + $el = $el || self.$progress; + if (!$el.length) { + return; + } + var pct = Math.min(p, 100), out, pctLimit = self.progressUploadThreshold, + t = p <= 100 ? self.progressTemplate : self.progressCompleteTemplate, + template = pct < 100 ? self.progressTemplate : + (error ? (self.paused ? self.progressPauseTemplate : self.progressErrorTemplate) : t); + if (p >= 100) { + stats = ''; + } + if (!$h.isEmpty(template)) { + if (pctLimit && pct > pctLimit && p <= 100) { + out = template.setTokens({'percent': pctLimit, 'status': self.msgUploadThreshold}); + } else { + out = template.setTokens({'percent': pct, 'status': (p > 100 ? self.msgUploadEnd : pct + '%')}); + } + stats = stats || ''; + out = out.setTokens({stats: stats}); + $el.html(out); + if (error) { + $el.find('[role="progressbar"]').html(error); + } + } + }, + _setFileDropZoneTitle: function () { + var self = this, $zone = self.$container.find('.file-drop-zone'), title = self.dropZoneTitle, strFiles; + if (self.isClickable) { + strFiles = $h.isEmpty(self.$element.attr('multiple')) ? self.fileSingle : self.filePlural; + title += self.dropZoneClickTitle.replace('{files}', strFiles); + } + $zone.find('.' + self.dropZoneTitleClass).remove(); + if (!self.showPreview || $zone.length === 0 || self.fileManager.count() > 0 || !self.dropZoneEnabled || + (!self.isAjaxUpload && self.$element.files)) { + return; + } + if ($zone.find($h.FRAMES).length === 0 && $h.isEmpty(self.defaultPreviewContent)) { + $zone.prepend('
    ' + title + '
    '); + } + self.$container.removeClass('file-input-new'); + $h.addCss(self.$container, 'file-input-ajax-new'); + }, + _getStats: function (stats) { + var self = this, pendingTime, t; + if (!self.showUploadStats || !stats || !stats.bitrate) { + return ''; + } + t = self._getLayoutTemplate('stats'); + pendingTime = (!stats.elapsed || !stats.bps) ? self.msgCalculatingTime : + self.msgPendingTime.setTokens({time: $h.getElapsed(Math.ceil(stats.pendingBytes / stats.bps))}); + + return t.setTokens({ + uploadSpeed: stats.bitrate, + pendingTime: pendingTime + }); + }, + _setResumableProgress: function (pct, stats, $thumb) { + var self = this, rm = self.resumableManager, obj = $thumb ? rm : self, + $prog = $thumb ? $thumb.find('.file-thumb-progress') : null; + if (obj.lastProgress === 0) { + obj.lastProgress = pct; + } + if (pct < obj.lastProgress) { + pct = obj.lastProgress; + } + self._setProgress(pct, $prog, null, self._getStats(stats)); + obj.lastProgress = pct; + }, + _setFileUploadStats: function (id, pct, total, stats) { + var self = this, $prog = self.$progress; + if (!self.showPreview && (!$prog || !$prog.length)) { + return; + } + var fm = self.fileManager, $thumb = fm.getThumb(id), pctTot, rm = self.resumableManager, + totUpSize = 0, totSize = fm.getTotalSize(), totStats = $.extend(true, {}, stats); + if (self.enableResumableUpload) { + var loaded = stats.loaded, currUplSize = rm.getUploadedSize(), currTotSize = rm.file.size, totLoaded; + loaded += currUplSize; + totLoaded = fm.uploadedSize + loaded; + pct = $h.round(100 * loaded / currTotSize); + stats.pendingBytes = currTotSize - currUplSize; + self._setResumableProgress(pct, stats, $thumb); + pctTot = Math.floor(100 * totLoaded / totSize); + totStats.pendingBytes = totSize - totLoaded; + self._setResumableProgress(pctTot, totStats); + } else { + fm.setProgress(id, pct); + $prog = $thumb && $thumb.length ? $thumb.find('.file-thumb-progress') : null; + self._setProgress(pct, $prog, null, self._getStats(stats)); + $.each(fm.stats, function (id, cfg) { + totUpSize += cfg.loaded; + }); + totStats.pendingBytes = totSize - totUpSize; + pctTot = $h.round(totUpSize / totSize * 100); + self._setProgress(pctTot, null, null, self._getStats(totStats)); + } + }, + _validateMinCount: function () { + var self = this, len = self.isAjaxUpload ? self.fileManager.count() : self._inputFileCount(); + if (self.validateInitialCount && self.minFileCount > 0 && self._getFileCount(len - 1) < self.minFileCount) { + self._noFilesError({}); + return false; + } + return true; + }, + _getFileCount: function (fileCount) { + var self = this, addCount = 0; + if (self.validateInitialCount && !self.overwriteInitial) { + addCount = self.previewCache.count(true); + fileCount += addCount; + } + return fileCount; + }, + _getFileId: function (file) { + return $h.getFileId(file, this.generateFileId); + }, + _getFileName: function (file, defaultValue) { + var self = this, fileName = $h.getFileName(file); + return fileName ? self.slug(fileName) : defaultValue; + }, + _getFileNames: function (skipNull) { + var self = this; + return self.filenames.filter(function (n) { + return (skipNull ? n !== undefined : n !== undefined && n !== null); + }); + }, + _setPreviewError: function ($thumb, keepFile) { + var self = this, removeFrame = self.removeFromPreviewOnError && !self.retryErrorUploads; + if (!keepFile || removeFrame) { + self.fileManager.remove($thumb); + } + if (!self.showPreview) { + return; + } + if (removeFrame) { + $thumb.remove(); + return; + } else { + self._setThumbStatus($thumb, 'Error'); + } + self._refreshUploadButton($thumb); + }, + _refreshUploadButton: function ($thumb) { + var self = this, $btn = $thumb.find('.kv-file-upload'), cfg = self.fileActionSettings, + icon = cfg.uploadIcon, title = cfg.uploadTitle; + if (!$btn.length) { + return; + } + if (self.retryErrorUploads) { + icon = cfg.uploadRetryIcon; + title = cfg.uploadRetryTitle; + } + $btn.attr('title', title).html(icon); + }, + _checkDimensions: function (i, chk, $img, $thumb, fname, type, params) { + var self = this, msg, dim, tag = chk === 'Small' ? 'min' : 'max', limit = self[tag + 'Image' + type], + $imgEl, isValid; + if ($h.isEmpty(limit) || !$img.length) { + return; + } + $imgEl = $img[0]; + dim = (type === 'Width') ? $imgEl.naturalWidth || $imgEl.width : $imgEl.naturalHeight || $imgEl.height; + isValid = chk === 'Small' ? dim >= limit : dim <= limit; + if (isValid) { + return; + } + msg = self['msgImage' + type + chk].setTokens({'name': fname, 'size': limit}); + self._showFileError(msg, params); + self._setPreviewError($thumb); + }, + _getExifObj: function (data) { + var self = this, exifObj = null, error = $h.logMessages.exifWarning; + if (data.slice(0, 23) !== 'data:image/jpeg;base64,' && data.slice(0, 22) !== 'data:image/jpg;base64,') { + exifObj = null; + return; + } + try { + exifObj = window.piexif ? window.piexif.load(data) : null; + } catch (err) { + exifObj = null; + error = err && err.message || ''; + } + if (!exifObj) { + self._log($h.logMessages.badExifParser, {details: error}); + } + return exifObj; + }, + setImageOrientation: function ($img, $zoomImg, value, $thumb) { + var self = this, invalidImg = !$img || !$img.length, invalidZoomImg = !$zoomImg || !$zoomImg.length, $mark, + isHidden = false, $div, zoomOnly = invalidImg && $thumb && $thumb.attr('data-template') === 'image', ev; + if (invalidImg && invalidZoomImg) { + return; + } + ev = 'load.fileinputimageorient'; + if (zoomOnly) { + $img = $zoomImg; + $zoomImg = null; + $img.css(self.previewSettings.image); + $div = $(document.createElement('div')).appendTo($thumb.find('.kv-file-content')); + $mark = $(document.createElement('span')).insertBefore($img); + $img.css('visibility', 'hidden').removeClass('file-zoom-detail').appendTo($div); + } else { + isHidden = !$img.is(':visible'); + } + $img.off(ev).on(ev, function () { + if (isHidden) { + self.$preview.removeClass('hide-content'); + $thumb.find('.kv-file-content').css('visibility', 'hidden'); + } + var img = $img.get(0), zoomImg = $zoomImg && $zoomImg.length ? $zoomImg.get(0) : null, + h = img.offsetHeight, w = img.offsetWidth, r = $h.getRotation(value); + if (isHidden) { + $thumb.find('.kv-file-content').css('visibility', 'visible'); + self.$preview.addClass('hide-content'); + } + $img.data('orientation', value); + if (zoomImg) { + $zoomImg.data('orientation', value); + } + if (value < 5) { + $h.setTransform(img, r); + $h.setTransform(zoomImg, r); + return; + } + var offsetAngle = Math.atan(w / h), origFactor = Math.sqrt(Math.pow(h, 2) + Math.pow(w, 2)), + scale = !origFactor ? 1 : (h / Math.cos(Math.PI / 2 + offsetAngle)) / origFactor, + s = ' scale(' + Math.abs(scale) + ')'; + $h.setTransform(img, r + s); + $h.setTransform(zoomImg, r + s); + if (zoomOnly) { + $img.css('visibility', 'visible').insertAfter($mark).addClass('file-zoom-detail'); + $mark.remove(); + $div.remove(); + } + }); + }, + _validateImageOrientation: function ($img, file, previewId, fileId, caption, ftype, fsize, iData) { + var self = this, exifObj, value, autoOrientImage = self.autoOrientImage; + exifObj = autoOrientImage ? self._getExifObj(iData) : null; + value = exifObj ? exifObj['0th'][piexif.ImageIFD.Orientation] : null; // jshint ignore:line + if (!value) { + self._validateImage(previewId, fileId, caption, ftype, fsize, iData, exifObj); + return; + } + self.setImageOrientation($img, $('#zoom-' + previewId + ' img'), value, $('#' + previewId)); + self._raise('fileimageoriented', {'$img': $img, 'file': file}); + self._validateImage(previewId, fileId, caption, ftype, fsize, iData, exifObj); + }, + _validateImage: function (previewId, fileId, fname, ftype, fsize, iData, exifObj) { + var self = this, $preview = self.$preview, params, w1, w2, $thumb = $preview.find('#' + previewId), + i = $thumb.attr('data-fileindex'), $img = $thumb.find('img'); + fname = fname || 'Untitled'; + $img.one('load', function () { + w1 = $thumb.width(); + w2 = $preview.width(); + if (w1 > w2) { + $img.css('width', '100%'); + } + params = {ind: i, id: previewId, fileId: fileId}; + self._checkDimensions(i, 'Small', $img, $thumb, fname, 'Width', params); + self._checkDimensions(i, 'Small', $img, $thumb, fname, 'Height', params); + if (!self.resizeImage) { + self._checkDimensions(i, 'Large', $img, $thumb, fname, 'Width', params); + self._checkDimensions(i, 'Large', $img, $thumb, fname, 'Height', params); + } + self._raise('fileimageloaded', [previewId]); + self.fileManager.addImage(fileId, { + ind: i, + img: $img, + thumb: $thumb, + pid: previewId, + typ: ftype, + siz: fsize, + validated: false, + imgData: iData, + exifObj: exifObj + }); + $thumb.data('exif', exifObj); + self._validateAllImages(); + }).one('error', function () { + self._raise('fileimageloaderror', [previewId]); + }).each(function () { + if (this.complete) { + $(this).trigger('load'); + } else { + if (this.error) { + $(this).trigger('error'); + } + } + }); + }, + _validateAllImages: function () { + var self = this, counter = {val: 0}, numImgs = self.fileManager.getImageCount(), fsize, + minSize = self.resizeIfSizeMoreThan; + if (numImgs !== self.fileManager.totalImages) { + return; + } + self._raise('fileimagesloaded'); + if (!self.resizeImage) { + return; + } + $.each(self.fileManager.loadedImages, function (id, config) { + if (!config.validated) { + fsize = config.siz; + if (fsize && fsize > minSize * 1000) { + self._getResizedImage(id, config, counter, numImgs); + } + config.validated = true; + } + }); + }, + _getResizedImage: function (id, config, counter, numImgs) { + var self = this, img = $(config.img)[0], width = img.naturalWidth, height = img.naturalHeight, blob, + ratio = 1, maxWidth = self.maxImageWidth || width, maxHeight = self.maxImageHeight || height, + isValidImage = !!(width && height), chkWidth, chkHeight, canvas = self.imageCanvas, dataURI, + context = self.imageCanvasContext, type = config.typ, pid = config.pid, ind = config.ind, + $thumb = config.thumb, throwError, msg, exifObj = config.exifObj, exifStr, file, params, evParams; + throwError = function (msg, params, ev) { + if (self.isAjaxUpload) { + self._showFileError(msg, params, ev); + } else { + self._showError(msg, params, ev); + } + self._setPreviewError($thumb); + }; + file = self.fileManager.getFile(id); + params = {id: pid, 'index': ind, fileId: id}; + evParams = [id, pid, ind]; + if (!file || !isValidImage || (width <= maxWidth && height <= maxHeight)) { + if (isValidImage && file) { + self._raise('fileimageresized', evParams); + } + counter.val++; + if (counter.val === numImgs) { + self._raise('fileimagesresized'); + } + if (!isValidImage) { + throwError(self.msgImageResizeError, params, 'fileimageresizeerror'); + return; + } + } + type = type || self.resizeDefaultImageType; + chkWidth = width > maxWidth; + chkHeight = height > maxHeight; + if (self.resizePreference === 'width') { + ratio = chkWidth ? maxWidth / width : (chkHeight ? maxHeight / height : 1); + } else { + ratio = chkHeight ? maxHeight / height : (chkWidth ? maxWidth / width : 1); + } + self._resetCanvas(); + width *= ratio; + height *= ratio; + canvas.width = width; + canvas.height = height; + try { + context.drawImage(img, 0, 0, width, height); + dataURI = canvas.toDataURL(type, self.resizeQuality); + if (exifObj) { + exifStr = window.piexif.dump(exifObj); + dataURI = window.piexif.insert(exifStr, dataURI); + } + blob = $h.dataURI2Blob(dataURI); + self.fileManager.setFile(id, blob); + self._raise('fileimageresized', evParams); + counter.val++; + if (counter.val === numImgs) { + self._raise('fileimagesresized', [undefined, undefined]); + } + if (!(blob instanceof Blob)) { + throwError(self.msgImageResizeError, params, 'fileimageresizeerror'); + } + } + catch (err) { + counter.val++; + if (counter.val === numImgs) { + self._raise('fileimagesresized', [undefined, undefined]); + } + msg = self.msgImageResizeException.replace('{errors}', err.message); + throwError(msg, params, 'fileimageresizeexception'); + } + }, + _initBrowse: function ($container) { + var self = this, $el = self.$element; + if (self.showBrowse) { + self.$btnFile = $container.find('.btn-file').append($el); + } else { + $el.appendTo($container).attr('tabindex', -1); + $h.addCss($el, 'file-no-browse'); + } + }, + _initClickable: function () { + var self = this, $zone, $tmpZone; + if (!self.isClickable) { + return; + } + $zone = self.$dropZone; + if (!self.isAjaxUpload) { + $tmpZone = self.$preview.find('.file-default-preview'); + if ($tmpZone.length) { + $zone = $tmpZone; + } + } + + $h.addCss($zone, 'clickable'); + $zone.attr('tabindex', -1); + self._handler($zone, 'click', function (e) { + var $tar = $(e.target); + if (!$(self.elErrorContainer + ':visible').length && + (!$tar.parents('.file-preview-thumbnails').length || $tar.parents( + '.file-default-preview').length)) { + self.$element.data('zoneClicked', true).trigger('click'); + $zone.blur(); + } + }); + }, + _initCaption: function () { + var self = this, cap = self.initialCaption || ''; + if (self.overwriteInitial || $h.isEmpty(cap)) { + self.$caption.val(''); + return false; + } + self._setCaption(cap); + return true; + }, + _setCaption: function (content, isError) { + var self = this, title, out, icon, n, cap, file; + if (!self.$caption.length) { + return; + } + self.$captionContainer.removeClass('icon-visible'); + if (isError) { + title = $('
    ' + self.msgValidationError + '
    ').text(); + n = self.fileManager.count(); + if (n) { + file = self.fileManager.getFirstFile(); + cap = n === 1 && file ? file.nameFmt : self._getMsgSelected(n); + } else { + cap = self._getMsgSelected(self.msgNo); + } + out = $h.isEmpty(content) ? cap : content; + icon = '' + self.msgValidationErrorIcon + ''; + } else { + if ($h.isEmpty(content)) { + return; + } + title = $('
    ' + content + '
    ').text(); + out = title; + icon = self._getLayoutTemplate('fileIcon'); + } + self.$captionContainer.addClass('icon-visible'); + self.$caption.attr('title', title).val(out); + self.$captionIcon.html(icon); + }, + _createContainer: function () { + var self = this, attribs = {'class': 'file-input file-input-new' + (self.rtl ? ' kv-rtl' : '')}, + $container = $(document.createElement('div')).attr(attribs).html(self._renderMain()); + $container.insertBefore(self.$element); + self._initBrowse($container); + if (self.theme) { + $container.addClass('theme-' + self.theme); + } + return $container; + }, + _refreshContainer: function () { + var self = this, $container = self.$container, $el = self.$element; + $el.insertAfter($container); + $container.html(self._renderMain()); + self._initBrowse($container); + self._validateDisabled(); + }, + _validateDisabled: function () { + var self = this; + self.$caption.attr({readonly: self.isDisabled}); + }, + _renderMain: function () { + var self = this, + dropCss = self.dropZoneEnabled ? ' file-drop-zone' : 'file-drop-disabled', + close = !self.showClose ? '' : self._getLayoutTemplate('close'), + preview = !self.showPreview ? '' : self._getLayoutTemplate('preview') + .setTokens({'class': self.previewClass, 'dropClass': dropCss}), + css = self.isDisabled ? self.captionClass + ' file-caption-disabled' : self.captionClass, + caption = self.captionTemplate.setTokens({'class': css + ' kv-fileinput-caption'}); + return self.mainTemplate.setTokens({ + 'class': self.mainClass + (!self.showBrowse && self.showCaption ? ' no-browse' : ''), + 'preview': preview, + 'close': close, + 'caption': caption, + 'upload': self._renderButton('upload'), + 'remove': self._renderButton('remove'), + 'cancel': self._renderButton('cancel'), + 'pause': self._renderButton('pause'), + 'browse': self._renderButton('browse') + }); + + }, + _renderButton: function (type) { + var self = this, tmplt = self._getLayoutTemplate('btnDefault'), css = self[type + 'Class'], + title = self[type + 'Title'], icon = self[type + 'Icon'], label = self[type + 'Label'], + status = self.isDisabled ? ' disabled' : '', btnType = 'button'; + switch (type) { + case 'remove': + if (!self.showRemove) { + return ''; + } + break; + case 'cancel': + if (!self.showCancel) { + return ''; + } + css += ' kv-hidden'; + break; + case 'pause': + if (!self.showPause) { + return ''; + } + css += ' kv-hidden'; + break; + case 'upload': + if (!self.showUpload) { + return ''; + } + if (self.isAjaxUpload && !self.isDisabled) { + tmplt = self._getLayoutTemplate('btnLink').replace('{href}', self.uploadUrl); + } else { + btnType = 'submit'; + } + break; + case 'browse': + if (!self.showBrowse) { + return ''; + } + tmplt = self._getLayoutTemplate('btnBrowse'); + break; + default: + return ''; + } + + css += type === 'browse' ? ' btn-file' : ' fileinput-' + type + ' fileinput-' + type + '-button'; + if (!$h.isEmpty(label)) { + label = ' ' + label + ''; + } + return tmplt.setTokens({ + 'type': btnType, 'css': css, 'title': title, 'status': status, 'icon': icon, 'label': label + }); + }, + _renderThumbProgress: function () { + var self = this; + return '
    ' + + self.progressInfoTemplate.setTokens({percent: 101, status: self.msgUploadBegin, stats: ''}) + + '
    '; + }, + _renderFileFooter: function (cat, caption, size, width, isError) { + var self = this, config = self.fileActionSettings, rem = config.showRemove, drg = config.showDrag, + upl = config.showUpload, zoom = config.showZoom, out, params, + template = self._getLayoutTemplate('footer'), tInd = self._getLayoutTemplate('indicator'), + ind = isError ? config.indicatorError : config.indicatorNew, + title = isError ? config.indicatorErrorTitle : config.indicatorNewTitle, + indicator = tInd.setTokens({'indicator': ind, 'indicatorTitle': title}); + size = self._getSize(size); + params = {type: cat, caption: caption, size: size, width: width, progress: '', indicator: indicator}; + if (self.isAjaxUpload) { + params.progress = self._renderThumbProgress(); + params.actions = self._renderFileActions(params, upl, false, rem, zoom, drg, false, false, false); + } else { + params.actions = self._renderFileActions(params, false, false, false, zoom, drg, false, false, false); + } + out = template.setTokens(params); + out = $h.replaceTags(out, self.previewThumbTags); + return out; + }, + _renderFileActions: function ( + cfg, + showUpl, + showDwn, + showDel, + showZoom, + showDrag, + disabled, + url, + key, + isInit, + dUrl, + dFile + ) { + var self = this; + if (!cfg.type && isInit) { + cfg.type = 'image'; + } + if (self.enableResumableUpload) { + showUpl = false; + } else { + if (typeof showUpl === 'function') { + showUpl = showUpl(cfg); + } + } + if (typeof showDwn === 'function') { + showDwn = showDwn(cfg); + } + if (typeof showDel === 'function') { + showDel = showDel(cfg); + } + if (typeof showZoom === 'function') { + showZoom = showZoom(cfg); + } + if (typeof showDrag === 'function') { + showDrag = showDrag(cfg); + } + if (!showUpl && !showDwn && !showDel && !showZoom && !showDrag) { + return ''; + } + var vUrl = url === false ? '' : ' data-url="' + url + '"', btnZoom = '', btnDrag = '', css, + vKey = key === false ? '' : ' data-key="' + key + '"', btnDelete = '', btnUpload = '', btnDownload = '', + template = self._getLayoutTemplate('actions'), config = self.fileActionSettings, + otherButtons = self.otherActionButtons.setTokens({'dataKey': vKey, 'key': key}), + removeClass = disabled ? config.removeClass + ' disabled' : config.removeClass; + if (showDel) { + btnDelete = self._getLayoutTemplate('actionDelete').setTokens({ + 'removeClass': removeClass, + 'removeIcon': config.removeIcon, + 'removeTitle': config.removeTitle, + 'dataUrl': vUrl, + 'dataKey': vKey, + 'key': key + }); + } + if (showUpl) { + btnUpload = self._getLayoutTemplate('actionUpload').setTokens({ + 'uploadClass': config.uploadClass, + 'uploadIcon': config.uploadIcon, + 'uploadTitle': config.uploadTitle + }); + } + if (showDwn) { + btnDownload = self._getLayoutTemplate('actionDownload').setTokens({ + 'downloadClass': config.downloadClass, + 'downloadIcon': config.downloadIcon, + 'downloadTitle': config.downloadTitle, + 'downloadUrl': dUrl || self.initialPreviewDownloadUrl + }); + btnDownload = btnDownload.setTokens({'filename': dFile, 'key': key}); + } + if (showZoom) { + btnZoom = self._getLayoutTemplate('actionZoom').setTokens({ + 'zoomClass': config.zoomClass, + 'zoomIcon': config.zoomIcon, + 'zoomTitle': config.zoomTitle + }); + } + if (showDrag && isInit) { + css = 'drag-handle-init ' + config.dragClass; + btnDrag = self._getLayoutTemplate('actionDrag').setTokens({ + 'dragClass': css, + 'dragTitle': config.dragTitle, + 'dragIcon': config.dragIcon + }); + } + return template.setTokens({ + 'delete': btnDelete, + 'upload': btnUpload, + 'download': btnDownload, + 'zoom': btnZoom, + 'drag': btnDrag, + 'other': otherButtons + }); + }, + _browse: function (e) { + var self = this; + if (e && e.isDefaultPrevented() || !self._raise('filebrowse')) { + return; + } + if (self.isError && !self.isAjaxUpload) { + self.clear(); + } + self.$captionContainer.focus(); + }, + _change: function (e) { + var self = this; + if (self.changeTriggered) { + return; + } + var $el = self.$element, isDragDrop = arguments.length > 1, isAjaxUpload = self.isAjaxUpload, + tfiles, files = isDragDrop ? arguments[1] : $el.get(0).files, total, + maxCount = !isAjaxUpload && $h.isEmpty($el.attr('multiple')) ? 1 : self.maxFileCount, + len, ctr = self.fileManager.count(), isSingleUpload = $h.isEmpty($el.attr('multiple')), + flagSingle = (isSingleUpload && ctr > 0), + throwError = function (mesg, file, previewId, index) { + var p1 = $.extend(true, {}, self._getOutData(null, {}, {}, files), {id: previewId, index: index}), + p2 = {id: previewId, index: index, file: file, files: files}; + return isAjaxUpload ? self._showFileError(mesg, p1) : self._showError(mesg, p2); + }, + maxCountCheck = function (n, m) { + var msg = self.msgFilesTooMany.replace('{m}', m).replace('{n}', n); + self.isError = throwError(msg, null, null, null); + self.$captionContainer.removeClass('icon-visible'); + self._setCaption('', true); + self.$container.removeClass('file-input-new file-input-ajax-new'); + }; + self.reader = null; + self._resetUpload(); + self._hideFileIcon(); + if (self.dropZoneEnabled) { + self.$container.find('.file-drop-zone .' + self.dropZoneTitleClass).remove(); + } + if (!isAjaxUpload) { + if (e.target && e.target.files === undefined) { + files = e.target.value ? [{name: e.target.value.replace(/^.+\\/, '')}] : []; + } else { + files = e.target.files || {}; + } + } + tfiles = files; + if ($h.isEmpty(tfiles) || tfiles.length === 0) { + if (!isAjaxUpload) { + self.clear(); + } + self._raise('fileselectnone'); + return; + } + self._resetErrors(); + len = tfiles.length; + total = self._getFileCount(isAjaxUpload ? (self.fileManager.count() + len) : len); + if (maxCount > 0 && total > maxCount) { + if (!self.autoReplace || len > maxCount) { + maxCountCheck((self.autoReplace && len > maxCount ? len : total), maxCount); + return; + } + if (total > maxCount) { + self._resetPreviewThumbs(isAjaxUpload); + } + } else { + if (!isAjaxUpload || flagSingle) { + self._resetPreviewThumbs(false); + if (flagSingle) { + self.clearFileStack(); + } + } else { + if (isAjaxUpload && ctr === 0 && (!self.previewCache.count(true) || self.overwriteInitial)) { + self._resetPreviewThumbs(true); + } + } + } + self.readFiles(tfiles); + }, + _abort: function (params) { + var self = this, data; + if (self.ajaxAborted && typeof self.ajaxAborted === 'object' && self.ajaxAborted.message !== undefined) { + data = $.extend(true, {}, self._getOutData(null), params); + data.abortData = self.ajaxAborted.data || {}; + data.abortMessage = self.ajaxAborted.message; + self._setProgress(101, self.$progress, self.msgCancelled); + self._showFileError(self.ajaxAborted.message, data, 'filecustomerror'); + self.cancel(); + return true; + } + return !!self.ajaxAborted; + }, + _resetFileStack: function () { + var self = this, i = 0; + self._getThumbs().each(function () { + var $thumb = $(this), ind = $thumb.attr('data-fileindex'), pid = $thumb.attr('id'); + if (ind === '-1' || ind === -1) { + return; + } + if (!self.fileManager.getFile($thumb.attr('data-fileid'))) { + $thumb.attr({'id': self.previewInitId + '-' + i, 'data-fileindex': i}); + i++; + } else { + $thumb.attr({'id': 'uploaded-' + $h.uniqId(), 'data-fileindex': '-1'}); + } + self.$preview.find('#zoom-' + pid).attr({ + 'id': 'zoom-' + $thumb.attr('id'), + 'data-fileindex': $thumb.attr('data-fileindex') + }); + }); + }, + _isFileSelectionValid: function (cnt) { + var self = this; + cnt = cnt || 0; + if (self.required && !self.getFilesCount()) { + self.$errorContainer.html(''); + self._showFileError(self.msgFileRequired); + return false; + } + if (self.minFileCount > 0 && self._getFileCount(cnt) < self.minFileCount) { + self._noFilesError({}); + return false; + } + return true; + }, + clearFileStack: function () { + var self = this; + self.fileManager.clear(); + self._initResumableUpload(); + if (self.enableResumableUpload) { + if (self.showPause === null) { + self.showPause = true; + } + if (self.showCancel === null) { + self.showCancel = false; + } + } else { + self.showPause = false; + if (self.showCancel === null) { + self.showCancel = true; + } + } + return self.$element; + }, + getFileStack: function () { + return this.fileManager.stack; + }, + getFileList: function () { + return this.fileManager.list(); + }, + getFilesCount: function () { + var self = this, len = self.isAjaxUpload ? self.fileManager.count() : self._inputFileCount(); + return self._getFileCount(len); + }, + readFiles: function (files) { + this.reader = new FileReader(); + var self = this, $el = self.$element, reader = self.reader, + $container = self.$previewContainer, $status = self.$previewStatus, msgLoading = self.msgLoading, + msgProgress = self.msgProgress, previewInitId = self.previewInitId, numFiles = files.length, + settings = self.fileTypeSettings, ctr = self.fileManager.count(), readFile, + fileTypes = self.allowedFileTypes, typLen = fileTypes ? fileTypes.length : 0, + fileExt = self.allowedFileExtensions, strExt = $h.isEmpty(fileExt) ? '' : fileExt.join(', '), + throwError = function (msg, file, previewId, index, fileId) { + var p1 = $.extend(true, {}, self._getOutData(null, {}, {}, files), + {id: previewId, index: index, fileId: fileId}), $thumb = $('#' + previewId), + p2 = {id: previewId, index: index, fileId: fileId, file: file, files: files}; + self._previewDefault(file, previewId, true); + if (self.isAjaxUpload) { + setTimeout(function () { + readFile(index + 1); + }, self.processDelay); + } else { + numFiles = 0; + } + self._initFileActions(); + $thumb.remove(); + self.isError = self.isAjaxUpload ? self._showFileError(msg, p1) : self._showError(msg, p2); + self._updateFileDetails(numFiles); + }; + self.fileManager.clearImages(); + $.each(files, function (key, file) { + var func = self.fileTypeSettings.image; + if (func && func(file.type)) { + self.fileManager.totalImages++; + } + }); + readFile = function (i) { + if ($h.isEmpty($el.attr('multiple'))) { + numFiles = 1; + } + if (i >= numFiles) { + if (self.isAjaxUpload && self.fileManager.count() > 0) { + self._raise('filebatchselected', [self.fileManager.stack]); + } else { + self._raise('filebatchselected', [files]); + } + $container.removeClass('file-thumb-loading'); + $status.html(''); + return; + } + var node = ctr + i, previewId = previewInitId + '-' + node, file = files[i], fSizeKB, j, msg, $thumb, + fnText = settings.text, fnImage = settings.image, fnHtml = settings.html, typ, chk, typ1, typ2, + caption = self._getFileName(file, ''), fileSize = (file && file.size || 0) / 1000, + fileExtExpr = '', previewData = $h.createObjectURL(file), fileCount = 0, + strTypes = '', fileId, + func, knownTypes = 0, isText, isHtml, isImage, txtFlag, processFileLoaded = function () { + var msg = msgProgress.setTokens({ + 'index': i + 1, + 'files': numFiles, + 'percent': 50, + 'name': caption + }); + setTimeout(function () { + $status.html(msg); + self._updateFileDetails(numFiles); + readFile(i + 1); + }, self.processDelay); + self._raise('fileloaded', [file, previewId, i, reader]); + }; + if (!file) { + return; + } + fileId = self.fileManager.getId(file); + if (typLen > 0) { + for (j = 0; j < typLen; j++) { + typ1 = fileTypes[j]; + typ2 = self.msgFileTypes[typ1] || typ1; + strTypes += j === 0 ? typ2 : ', ' + typ2; + } + } + if (caption === false) { + readFile(i + 1); + return; + } + if (caption.length === 0) { + msg = self.msgInvalidFileName.replace('{name}', $h.htmlEncode($h.getFileName(file), '[unknown]')); + throwError(msg, file, previewId, i, fileId); + return; + } + if (!$h.isEmpty(fileExt)) { + fileExtExpr = new RegExp('\\.(' + fileExt.join('|') + ')$', 'i'); + } + fSizeKB = fileSize.toFixed(2); + if (self.maxFileSize > 0 && fileSize > self.maxFileSize) { + msg = self.msgSizeTooLarge.setTokens({ + 'name': caption, + 'size': fSizeKB, + 'maxSize': self.maxFileSize + }); + throwError(msg, file, previewId, i, fileId); + return; + } + if (self.minFileSize !== null && fileSize <= $h.getNum(self.minFileSize)) { + msg = self.msgSizeTooSmall.setTokens({ + 'name': caption, + 'size': fSizeKB, + 'minSize': self.minFileSize + }); + throwError(msg, file, previewId, i, fileId); + return; + } + if (!$h.isEmpty(fileTypes) && $h.isArray(fileTypes)) { + for (j = 0; j < fileTypes.length; j += 1) { + typ = fileTypes[j]; + func = settings[typ]; + fileCount += !func || (typeof func !== 'function') ? 0 : (func(file.type, + $h.getFileName(file)) ? 1 : 0); + } + if (fileCount === 0) { + msg = self.msgInvalidFileType.setTokens({name: caption, types: strTypes}); + throwError(msg, file, previewId, i, fileId); + return; + } + } + if (fileCount === 0 && !$h.isEmpty(fileExt) && $h.isArray(fileExt) && !$h.isEmpty(fileExtExpr)) { + chk = $h.compare(caption, fileExtExpr); + fileCount += $h.isEmpty(chk) ? 0 : chk.length; + if (fileCount === 0) { + msg = self.msgInvalidFileExtension.setTokens({name: caption, extensions: strExt}); + throwError(msg, file, previewId, i, fileId); + return; + } + } + if (self.isAjaxUpload && self.fileManager.exists(fileId)) { + msg = self.msgDuplicateFile.setTokens({name: caption, size: fSizeKB}); + throwError(msg, file, previewId, i, fileId); + $thumb = $('#' + previewId); + if ($thumb && $thumb.length) { + $thumb.remove(); + } + return; + } + if (!self.canPreview(file)) { + if (self.isAjaxUpload) { + self.fileManager.add(file); + } + if (self.showPreview) { + $container.addClass('file-thumb-loading'); + self._previewDefault(file, previewId); + self._initFileActions(); + } + setTimeout(function () { + self._updateFileDetails(numFiles); + readFile(i + 1); + self._raise('fileloaded', [file, previewId, i]); + }, 10); + return; + } + isText = fnText(file.type, caption); + isHtml = fnHtml(file.type, caption); + isImage = fnImage(file.type, caption); + $status.html(msgLoading.replace('{index}', i + 1).replace('{files}', numFiles)); + $container.addClass('file-thumb-loading'); + reader.onerror = function (evt) { + self._errorHandler(evt, caption); + }; + reader.onload = function (theFile) { + var hex, fileInfo, uint, byte, bytes = [], contents, mime, readTextImage = function (textFlag) { + var newReader = new FileReader(); + newReader.onerror = function (theFileNew) { + self._errorHandler(theFileNew, caption); + }; + newReader.onload = function (theFileNew) { + self._previewFile(i, file, theFileNew, previewId, previewData, fileInfo); + self._initFileActions(); + processFileLoaded(); + }; + if (textFlag) { + newReader.readAsText(file, self.textEncoding); + } else { + newReader.readAsDataURL(file); + } + }; + fileInfo = {'name': caption, 'type': file.type}; + $.each(settings, function (k, f) { + if (k !== 'object' && k !== 'other' && typeof f === 'function' && f(file.type, caption)) { + knownTypes++; + } + }); + if (knownTypes === 0) {// auto detect mime types from content if no known file types detected + uint = new Uint8Array(theFile.target.result); + for (j = 0; j < uint.length; j++) { + byte = uint[j].toString(16); + bytes.push(byte); + } + hex = bytes.join('').toLowerCase().substring(0, 8); + mime = $h.getMimeType(hex, '', ''); + if ($h.isEmpty(mime)) { // look for ascii text content + contents = $h.arrayBuffer2String(reader.result); + mime = $h.isSvg(contents) ? 'image/svg+xml' : $h.getMimeType(hex, contents, file.type); + } + fileInfo = {'name': caption, 'type': mime}; + isText = fnText(mime, ''); + isHtml = fnHtml(mime, ''); + isImage = fnImage(mime, ''); + txtFlag = isText || isHtml; + if (txtFlag || isImage) { + readTextImage(txtFlag); + return; + } + } + self._previewFile(i, file, theFile, previewId, previewData, fileInfo); + self._initFileActions(); + processFileLoaded(); + }; + reader.onprogress = function (data) { + if (data.lengthComputable) { + var fact = (data.loaded / data.total) * 100, progress = Math.ceil(fact); + msg = msgProgress.setTokens({ + 'index': i + 1, + 'files': numFiles, + 'percent': progress, + 'name': caption + }); + setTimeout(function () { + $status.html(msg); + }, self.processDelay); + } + }; + + if (isText || isHtml) { + reader.readAsText(file, self.textEncoding); + } else { + if (isImage) { + reader.readAsDataURL(file); + } else { + reader.readAsArrayBuffer(file); + } + } + self.fileManager.add(file); + }; + + readFile(0); + self._updateFileDetails(numFiles, false); + }, + lock: function () { + var self = this, $container = self.$container; + self._resetErrors(); + self.disable(); + $container.addClass('is-locked'); + if (self.showCancel) { + $container.find('.fileinput-cancel').show(); + } + if (self.showPause) { + $container.find('.fileinput-pause').show(); + } + self._raise('filelock', [self.fileManager.stack, self._getExtraData()]); + return self.$element; + }, + unlock: function (reset) { + var self = this, $container = self.$container; + if (reset === undefined) { + reset = true; + } + self.enable(); + $container.removeClass('is-locked'); + if (self.showCancel) { + $container.find('.fileinput-cancel').hide(); + } + if (self.showPause) { + $container.find('.fileinput-pause').hide(); + } + if (reset) { + self._resetFileStack(); + } + self._raise('fileunlock', [self.fileManager.stack, self._getExtraData()]); + return self.$element; + }, + resume: function () { + var self = this, flag = false, $pr = self.$progress, rm = self.resumableManager; + if (!self.enableResumableUpload) { + return self.$element; + } + if (self.paused) { + $pr.html(self.progressPauseTemplate.setTokens({ + percent: 101, + status: self.msgUploadResume, + stats: '' + })); + } else { + flag = true; + } + self.paused = false; + if (flag) { + $pr.html(self.progressInfoTemplate.setTokens({ + percent: 101, + status: self.msgUploadBegin, + stats: '' + })); + } + setTimeout(function () { + rm.upload(); + }, self.processDelay); + return self.$element; + }, + pause: function () { + var self = this, rm = self.resumableManager, xhr = self.ajaxRequests, len = xhr.length, i, + pct = rm.getProgress(), actions = self.fileActionSettings; + if (!self.enableResumableUpload) { + return self.$element; + } + if (rm.chunkIntervalId) { + clearInterval(rm.chunkIntervalId); + } + if (self.ajaxQueueIntervalId) { + clearInterval(self.ajaxQueueIntervalId); + } + self._raise('fileuploadpaused', [self.fileManager, rm]); + if (len > 0) { + for (i = 0; i < len; i += 1) { + self.paused = true; + xhr[i].abort(); + } + } + if (self.showPreview) { + self._getThumbs().each(function () { + var $thumb = $(this), fileId = $thumb.attr('data-fileid'), t = self._getLayoutTemplate('stats'), + stats, $indicator = $thumb.find('.file-upload-indicator'); + $thumb.removeClass('file-uploading'); + if ($indicator.attr('title') === actions.indicatorLoadingTitle) { + self._setThumbStatus($thumb, 'Paused'); + stats = t.setTokens({pendingTime: self.msgPaused, uploadSpeed: ''}); + self.paused = true; + self._setProgress(pct, $thumb.find('.file-thumb-progress'), pct + '%', stats); + } + if (!self.fileManager.getFile(fileId)) { + $thumb.find('.kv-file-remove').removeClass('disabled').removeAttr('disabled'); + } + }); + } + self._setProgress(101, self.$progress, self.msgPaused); + return self.$element; + }, + cancel: function () { + var self = this, xhr = self.ajaxRequests, rm = self.resumableManager, len = xhr.length, i; + if (self.enableResumableUpload && rm.chunkIntervalId) { + clearInterval(rm.chunkIntervalId); + rm.reset(); + self._raise('fileuploadcancelled', [self.fileManager, rm]); + } else { + self._raise('fileuploadcancelled', [self.fileManager]); + } + if (self.ajaxQueueIntervalId) { + clearInterval(self.ajaxQueueIntervalId); + } + self._initAjax(); + if (len > 0) { + for (i = 0; i < len; i += 1) { + self.cancelling = true; + xhr[i].abort(); + } + } + self._getThumbs().each(function () { + var $thumb = $(this), fileId = $thumb.attr('data-fileid'), $prog = $thumb.find('.file-thumb-progress'); + $thumb.removeClass('file-uploading'); + self._setProgress(0, $prog); + $prog.hide(); + if (!self.fileManager.getFile(fileId)) { + $thumb.find('.kv-file-upload').removeClass('disabled').removeAttr('disabled'); + $thumb.find('.kv-file-remove').removeClass('disabled').removeAttr('disabled'); + } + self.unlock(); + }); + setTimeout(function () { + self._setProgressCancelled(); + }, self.processDelay); + return self.$element; + }, + clear: function () { + var self = this, cap; + if (!self._raise('fileclear')) { + return; + } + self.$btnUpload.removeAttr('disabled'); + self._getThumbs().find('video,audio,img').each(function () { + $h.cleanMemory($(this)); + }); + self._clearFileInput(); + self._resetUpload(); + self.clearFileStack(); + self._resetErrors(true); + if (self._hasInitialPreview()) { + self._showFileIcon(); + self._resetPreview(); + self._initPreviewActions(); + self.$container.removeClass('file-input-new'); + } else { + self._getThumbs().each(function () { + self._clearObjects($(this)); + }); + if (self.isAjaxUpload) { + self.previewCache.data = {}; + } + self.$preview.html(''); + cap = (!self.overwriteInitial && self.initialCaption.length > 0) ? self.initialCaption : ''; + self.$caption.attr('title', '').val(cap); + $h.addCss(self.$container, 'file-input-new'); + self._validateDefaultPreview(); + } + if (self.$container.find($h.FRAMES).length === 0) { + if (!self._initCaption()) { + self.$captionContainer.removeClass('icon-visible'); + } + } + self._hideFileIcon(); + self.$captionContainer.focus(); + self._setFileDropZoneTitle(); + self._raise('filecleared'); + return self.$element; + }, + reset: function () { + var self = this; + if (!self._raise('filereset')) { + return; + } + self.lastProgress = 0; + self._resetPreview(); + self.$container.find('.fileinput-filename').text(''); + $h.addCss(self.$container, 'file-input-new'); + if (self.getFrames().length || self.dropZoneEnabled) { + self.$container.removeClass('file-input-new'); + } + self.clearFileStack(); + self._setFileDropZoneTitle(); + return self.$element; + }, + disable: function () { + var self = this; + self.isDisabled = true; + self._raise('filedisabled'); + self.$element.attr('disabled', 'disabled'); + self.$container.find('.kv-fileinput-caption').addClass('file-caption-disabled'); + self.$container.find('.fileinput-remove, .fileinput-upload, .file-preview-frame button') + .attr('disabled', true); + $h.addCss(self.$container.find('.btn-file'), 'disabled'); + self._initDragDrop(); + return self.$element; + }, + enable: function () { + var self = this; + self.isDisabled = false; + self._raise('fileenabled'); + self.$element.removeAttr('disabled'); + self.$container.find('.kv-fileinput-caption').removeClass('file-caption-disabled'); + self.$container.find('.fileinput-remove, .fileinput-upload, .file-preview-frame button') + .removeAttr('disabled'); + self.$container.find('.btn-file').removeClass('disabled'); + self._initDragDrop(); + return self.$element; + }, + upload: function () { + var self = this, fm = self.fileManager, totLen = fm.count(), i, outData, len, + hasExtraData = !$.isEmptyObject(self._getExtraData()); + if (!self.isAjaxUpload || self.isDisabled || !self._isFileSelectionValid(totLen)) { + return; + } + self.lastProgress = 0; + self._resetUpload(); + if (totLen === 0 && !hasExtraData) { + self._showFileError(self.msgUploadEmpty); + return; + } + self.cancelling = false; + self.$progress.show(); + self.lock(); + len = fm.count(); + if (totLen === 0 && hasExtraData) { + self._setProgress(2); + self._uploadExtraOnly(); + return; + } + if (self.enableResumableUpload) { + return self.resume(); + } + if (self.uploadAsync || self.enableResumableUpload) { + outData = self._getOutData(null); + self._raise('filebatchpreupload', [outData]); + self.fileBatchCompleted = false; + self.uploadCache = {content: [], config: [], tags: [], append: true}; + for (i = 0; i < len; i++) { + self.uploadCache.content[i] = null; + self.uploadCache.config[i] = null; + self.uploadCache.tags[i] = null; + } + self.$preview.find('.file-preview-initial').removeClass($h.SORT_CSS); + self._initSortable(); + self.cacheInitialPreview = self.getPreview(); + } + self._setProgress(2); + self.hasInitData = false; + if (self.uploadAsync) { + i = 0; + $.each(fm.stack, function (id) { + self._uploadSingle(i, id, true); + i++; + }); + return; + } + self._uploadBatch(); + return self.$element; + }, + destroy: function () { + var self = this, $form = self.$form, $cont = self.$container, $el = self.$element, ns = self.namespace; + $(document).off(ns); + $(window).off(ns); + if ($form && $form.length) { + $form.off(ns); + } + if (self.isAjaxUpload) { + self._clearFileInput(); + } + self._cleanup(); + self._initPreviewCache(); + $el.insertBefore($cont).off(ns).removeData(); + $cont.off().remove(); + return $el; + }, + refresh: function (options) { + var self = this, $el = self.$element; + if (typeof options !== 'object' || $h.isEmpty(options)) { + options = self.options; + } else { + options = $.extend(true, {}, self.options, options); + } + self._init(options, true); + self._listen(); + return $el; + }, + zoom: function (frameId) { + var self = this, $frame = self._getFrame(frameId), $modal = self.$modal; + if (!$frame) { + return; + } + $h.initModal($modal); + $modal.html(self._getModalContent()); + self._setZoomContent($frame); + $modal.modal('show'); + self._initZoomButtons(); + }, + getExif: function (frameId) { + var self = this, $frame = self._getFrame(frameId); + return $frame && $frame.data('exif') || null; + }, + getFrames: function (cssFilter) { + var self = this, $frames; + cssFilter = cssFilter || ''; + $frames = self.$preview.find($h.FRAMES + cssFilter); + if (self.reversePreviewOrder) { + $frames = $($frames.get().reverse()); + } + return $frames; + }, + getPreview: function () { + var self = this; + return { + content: self.initialPreview, + config: self.initialPreviewConfig, + tags: self.initialPreviewThumbTags + }; + } + }; + + $.fn.fileinput = function (option) { + if (!$h.hasFileAPISupport() && !$h.isIE(9)) { + return; + } + var args = Array.apply(null, arguments), retvals = []; + args.shift(); + this.each(function () { + var self = $(this), data = self.data('fileinput'), options = typeof option === 'object' && option, + theme = options.theme || self.data('theme'), l = {}, t = {}, + lang = options.language || self.data('language') || $.fn.fileinput.defaults.language || 'en', opt; + if (!data) { + if (theme) { + t = $.fn.fileinputThemes[theme] || {}; + } + if (lang !== 'en' && !$h.isEmpty($.fn.fileinputLocales[lang])) { + l = $.fn.fileinputLocales[lang] || {}; + } + opt = $.extend(true, {}, $.fn.fileinput.defaults, t, $.fn.fileinputLocales.zh, l, options, self.data()); + data = new FileInput(this, opt); + self.data('fileinput', data); + } + + if (typeof option === 'string') { + retvals.push(data[option].apply(data, args)); + } + }); + switch (retvals.length) { + case 0: + return this; + case 1: + return retvals[0]; + default: + return retvals; + } + }; + + //noinspection HtmlUnknownAttribute + $.fn.fileinput.defaults = { + language: 'en', + showCaption: true, + showBrowse: true, + showPreview: true, + showRemove: true, + showUpload: true, + showUploadStats: true, + showCancel: null, + showPause: null, + showClose: true, + showUploadedThumbs: true, + browseOnZoneClick: false, + autoReplace: false, + autoOrientImage: function () { // applicable for JPEG images only and non ios safari + var ua = window.navigator.userAgent, webkit = !!ua.match(/WebKit/i), + iOS = !!ua.match(/iP(od|ad|hone)/i), iOSSafari = iOS && webkit && !ua.match(/CriOS/i); + return !iOSSafari; + }, + autoOrientImageInitial: true, + required: false, + rtl: false, + hideThumbnailContent: false, + encodeUrl: true, + generateFileId: null, + previewClass: '', + captionClass: '', + frameClass: 'krajee-default', + mainClass: 'file-caption-main', + mainTemplate: null, + purifyHtml: true, + fileSizeGetter: null, + initialCaption: '', + initialPreview: [], + initialPreviewDelimiter: '*$$*', + initialPreviewAsData: false, + initialPreviewFileType: 'image', + initialPreviewConfig: [], + initialPreviewThumbTags: [], + previewThumbTags: {}, + initialPreviewShowDelete: true, + initialPreviewDownloadUrl: '', + removeFromPreviewOnError: false, + deleteUrl: '', + deleteExtraData: {}, + overwriteInitial: true, + sanitizeZoomCache: function (content) { + var $container = $(document.createElement('div')).append(content); + $container.find('input,select,.file-thumbnail-footer').remove(); + return $container.html(); + }, + previewZoomButtonIcons: { + prev: '', + next: '', + toggleheader: '', + fullscreen: '', + borderless: '', + close: '' + }, + previewZoomButtonClasses: { + prev: 'btn btn-navigate', + next: 'btn btn-navigate', + toggleheader: 'btn btn-sm btn-kv btn-default btn-outline-secondary', + fullscreen: 'btn btn-sm btn-kv btn-default btn-outline-secondary', + borderless: 'btn btn-sm btn-kv btn-default btn-outline-secondary', + close: 'btn btn-sm btn-kv btn-default btn-outline-secondary' + }, + previewTemplates: {}, + previewContentTemplates: {}, + preferIconicPreview: false, + preferIconicZoomPreview: false, + allowedFileTypes: null, + allowedFileExtensions: null, + allowedPreviewTypes: undefined, + allowedPreviewMimeTypes: null, + allowedPreviewExtensions: null, + disabledPreviewTypes: undefined, + disabledPreviewExtensions: ['msi', 'exe', 'com', 'zip', 'rar', 'app', 'vb', 'scr'], + disabledPreviewMimeTypes: null, + defaultPreviewContent: null, + customLayoutTags: {}, + customPreviewTags: {}, + previewFileIcon: '', + previewFileIconClass: 'file-other-icon', + previewFileIconSettings: {}, + previewFileExtSettings: {}, + buttonLabelClass: 'hidden-xs', + browseIcon: ' ', + browseClass: 'btn btn-primary', + removeIcon: '', + removeClass: 'btn btn-default btn-secondary', + cancelIcon: '', + cancelClass: 'btn btn-default btn-secondary', + pauseIcon: '', + pauseClass: 'btn btn-default btn-secondary', + uploadIcon: '', + uploadClass: 'btn btn-default btn-secondary', + uploadUrl: null, + uploadUrlThumb: null, + uploadAsync: true, + uploadParamNames: { + chunkCount: 'chunkCount', + chunkIndex: 'chunkIndex', + chunkSize: 'chunkSize', + chunkSizeStart: 'chunkSizeStart', + chunksUploaded: 'chunksUploaded', + fileBlob: 'fileBlob', + fileId: 'fileId', + fileName: 'fileName', + fileRelativePath: 'fileRelativePath', + fileSize: 'fileSize', + retryCount: 'retryCount' + }, + maxAjaxThreads: 5, + processDelay: 100, + queueDelay: 10, // must be lesser than process delay + progressDelay: 0, // must be lesser than process delay + enableResumableUpload: false, + resumableUploadOptions: { + fallback: null, + testUrl: null, // used for checking status of chunks/ files previously / partially uploaded + chunkSize: 2 * 1024, // in KB + maxThreads: 4, + maxRetries: 3, + showErrorLog: true + }, + uploadExtraData: {}, + zoomModalHeight: 480, + minImageWidth: null, + minImageHeight: null, + maxImageWidth: null, + maxImageHeight: null, + resizeImage: false, + resizePreference: 'width', + resizeQuality: 0.92, + resizeDefaultImageType: 'image/jpeg', + resizeIfSizeMoreThan: 0, // in KB + minFileSize: 0, + maxFileSize: 0, + maxFilePreviewSize: 25600, // 25 MB + minFileCount: 0, + maxFileCount: 0, + validateInitialCount: false, + msgValidationErrorClass: 'text-danger', + msgValidationErrorIcon: ' ', + msgErrorClass: 'file-error-message', + progressThumbClass: 'progress-bar progress-bar-striped active', + progressClass: 'progress-bar bg-success progress-bar-success progress-bar-striped active', + progressInfoClass: 'progress-bar bg-info progress-bar-info progress-bar-striped active', + progressCompleteClass: 'progress-bar bg-success progress-bar-success', + progressPauseClass: 'progress-bar bg-primary progress-bar-primary progress-bar-striped active', + progressErrorClass: 'progress-bar bg-danger progress-bar-danger', + progressUploadThreshold: 99, + previewFileType: 'image', + elCaptionContainer: null, + elCaptionText: null, + elPreviewContainer: null, + elPreviewImage: null, + elPreviewStatus: null, + elErrorContainer: null, + errorCloseButton: $h.closeButton('kv-error-close'), + slugCallback: null, + dropZoneEnabled: true, + dropZoneTitleClass: 'file-drop-zone-title', + fileActionSettings: {}, + otherActionButtons: '', + textEncoding: 'UTF-8', + ajaxSettings: {}, + ajaxDeleteSettings: {}, + showAjaxErrorDetails: true, + mergeAjaxCallbacks: false, + mergeAjaxDeleteCallbacks: false, + retryErrorUploads: true, + reversePreviewOrder: false, + usePdfRenderer: function () { + //noinspection JSUnresolvedVariable + var isIE11 = !!window.MSInputMethodContext && !!document.documentMode; + return !!navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/i) || isIE11; + }, + pdfRendererUrl: '', + pdfRendererTemplate: '' + }; + + // noinspection HtmlUnknownAttribute + $.fn.fileinputLocales.en = { + fileSingle: 'file', + filePlural: 'files', + browseLabel: 'Browse …', + removeLabel: 'Remove', + removeTitle: 'Clear all unprocessed files', + cancelLabel: 'Cancel', + cancelTitle: 'Abort ongoing upload', + pauseLabel: 'Pause', + pauseTitle: 'Pause ongoing upload', + uploadLabel: 'Upload', + uploadTitle: 'Upload selected files', + msgNo: 'No', + msgNoFilesSelected: 'No files selected', + msgCancelled: 'Cancelled', + msgPaused: 'Paused', + msgPlaceholder: 'Select {files}...', + msgZoomModalHeading: 'Detailed Preview', + msgFileRequired: 'You must select a file to upload.', + msgSizeTooSmall: 'File "{name}" ({size} KB) is too small and must be larger than {minSize} KB.', + msgSizeTooLarge: 'File "{name}" ({size} KB) exceeds maximum allowed upload size of {maxSize} KB.', + msgFilesTooLess: 'You must select at least {n} {files} to upload.', + msgFilesTooMany: 'Number of files selected for upload ({n}) exceeds maximum allowed limit of {m}.', + msgFileNotFound: 'File "{name}" not found!', + msgFileSecured: 'Security restrictions prevent reading the file "{name}".', + msgFileNotReadable: 'File "{name}" is not readable.', + msgFilePreviewAborted: 'File preview aborted for "{name}".', + msgFilePreviewError: 'An error occurred while reading the file "{name}".', + msgInvalidFileName: 'Invalid or unsupported characters in file name "{name}".', + msgInvalidFileType: 'Invalid type for file "{name}". Only "{types}" files are supported.', + msgInvalidFileExtension: 'Invalid extension for file "{name}". Only "{extensions}" files are supported.', + msgFileTypes: { + 'image': 'image', + 'html': 'HTML', + 'text': 'text', + 'video': 'video', + 'audio': 'audio', + 'flash': 'flash', + 'pdf': 'PDF', + 'object': 'object' + }, + msgUploadAborted: 'The file upload was aborted', + msgUploadThreshold: 'Processing...', + msgUploadBegin: 'Initializing...', + msgUploadEnd: 'Done', + msgUploadResume: 'Resuming upload...', + msgUploadEmpty: 'No valid data available for upload.', + msgUploadError: 'Upload Error', + msgDeleteError: 'Delete Error', + msgProgressError: 'Error', + msgValidationError: 'Validation Error', + msgLoading: 'Loading file {index} of {files} …', + msgProgress: 'Loading file {index} of {files} - {name} - {percent}% completed.', + msgSelected: '{n} {files} selected', + msgFoldersNotAllowed: 'Drag & drop files only! {n} folder(s) dropped were skipped.', + msgImageWidthSmall: 'Width of image file "{name}" must be at least {size} px.', + msgImageHeightSmall: 'Height of image file "{name}" must be at least {size} px.', + msgImageWidthLarge: 'Width of image file "{name}" cannot exceed {size} px.', + msgImageHeightLarge: 'Height of image file "{name}" cannot exceed {size} px.', + msgImageResizeError: 'Could not get the image dimensions to resize.', + msgImageResizeException: 'Error while resizing the image.
    {errors}
    ', + msgAjaxError: 'Something went wrong with the {operation} operation. Please try again later!', + msgAjaxProgressError: '{operation} failed', + msgDuplicateFile: 'File "{name}" of same size "{size} KB" has already been selected earlier. Skipping duplicate selection.', + msgResumableUploadRetriesExceeded: 'Upload aborted beyond {max} retries for file {file}! Error Details:
    {error}
    ', + msgPendingTime: '{time} remaining', + msgCalculatingTime: 'calculating time remaining', + ajaxOperations: { + deleteThumb: 'file delete', + uploadThumb: 'file upload', + uploadBatch: 'batch file upload', + uploadExtra: 'form data upload' + }, + dropZoneTitle: 'Drag & drop files here …', + dropZoneClickTitle: '
    (or click to select {files})', + previewZoomButtonTitles: { + prev: 'View previous file', + next: 'View next file', + toggleheader: 'Toggle header', + fullscreen: 'Toggle full screen', + borderless: 'Toggle borderless mode', + close: 'Close detailed preview' + } + }; + + $.fn.fileinputLocales.zh = { + fileSingle: '文件', + filePlural: '个文件', + browseLabel: '选择 …', + removeLabel: '移除', + removeTitle: '清除选中文件', + cancelLabel: '取消', + cancelTitle: '取消进行中的上传', + pauseLabel: 'Pause', + pauseTitle: 'Pause ongoing upload', + uploadLabel: '上传', + uploadTitle: '上传选中文件', + msgNo: '没有', + msgNoFilesSelected: '未选择文件', + msgPaused: 'Paused', + msgCancelled: '取消', + msgPlaceholder: '选择 {files}...', + msgZoomModalHeading: '详细预览', + msgFileRequired: '必须选择一个文件上传.', + msgSizeTooSmall: '文件 "{name}" ({size} KB) 必须大于限定大小 {minSize} KB.', + msgSizeTooLarge: '文件 "{name}" ({size} KB) 超过了允许大小 {maxSize} KB.', + msgFilesTooLess: '你必须选择最少 {n} {files} 来上传. ', + msgFilesTooMany: '选择的上传文件个数 ({n}) 超出最大文件的限制个数 {m}.', + msgFileNotFound: '文件 "{name}" 未找到!', + msgFileSecured: '安全限制,为了防止读取文件 "{name}".', + msgFileNotReadable: '文件 "{name}" 不可读.', + msgFilePreviewAborted: '取消 "{name}" 的预览.', + msgFilePreviewError: '读取 "{name}" 时出现了一个错误.', + msgInvalidFileName: '文件名 "{name}" 包含非法字符.', + msgInvalidFileType: '不正确的类型 "{name}". 只支持 "{types}" 类型的文件.', + msgInvalidFileExtension: '不正确的文件扩展名 "{name}". 只支持 "{extensions}" 的文件扩展名.', + msgFileTypes: { + 'image': 'image', + 'html': 'HTML', + 'text': 'text', + 'video': 'video', + 'audio': 'audio', + 'flash': 'flash', + 'pdf': 'PDF', + 'object': 'object' + }, + msgUploadAborted: '该文件上传被中止', + msgUploadThreshold: '处理中...', + msgUploadBegin: '正在初始化...', + msgUploadEnd: '完成', + msgUploadResume: 'Resuming upload...', + msgUploadEmpty: '无效的文件上传.', + msgUploadError: 'Upload Error', + msgDeleteError: 'Delete Error', + msgProgressError: '上传出错', + msgValidationError: '验证错误', + msgLoading: '加载第 {index} 文件 共 {files} …', + msgProgress: '加载第 {index} 文件 共 {files} - {name} - {percent}% 完成.', + msgSelected: '{n} {files} 选中', + msgFoldersNotAllowed: '只支持拖拽文件! 跳过 {n} 拖拽的文件夹.', + msgImageWidthSmall: '图像文件的"{name}"的宽度必须是至少{size}像素.', + msgImageHeightSmall: '图像文件的"{name}"的高度必须至少为{size}像素.', + msgImageWidthLarge: '图像文件"{name}"的宽度不能超过{size}像素.', + msgImageHeightLarge: '图像文件"{name}"的高度不能超过{size}像素.', + msgImageResizeError: '无法获取的图像尺寸调整。', + msgImageResizeException: '调整图像大小时发生错误。
    {errors}
    ', + msgAjaxError: '{operation} 发生错误. 请重试!', + msgAjaxProgressError: '{operation} 失败', + msgDuplicateFile: 'File "{name}" of same size "{size} KB" has already been selected earlier. Skipping duplicate selection.', + msgResumableUploadRetriesExceeded: 'Upload aborted beyond {max} retries for file {file}! Error Details:
    {error}
    ', + msgPendingTime: '{time} remaining', + msgCalculatingTime: 'calculating time remaining', + ajaxOperations: { + deleteThumb: '删除文件', + uploadThumb: '上传文件', + uploadBatch: '批量上传', + uploadExtra: '表单数据上传' + }, + dropZoneTitle: '拖拽文件到这里 …
    支持多文件同时上传', + dropZoneClickTitle: '
    (或点击{files}按钮选择文件)', + fileActionSettings: { + removeTitle: '删除文件', + uploadTitle: '上传文件', + downloadTitle: '下载文件', + uploadRetryTitle: '重试', + zoomTitle: '查看详情', + dragTitle: '移动 / 重置', + indicatorNewTitle: '没有上传', + indicatorSuccessTitle: '上传', + indicatorErrorTitle: '上传错误', + indicatorPausedTitle: 'Upload Paused', + indicatorLoadingTitle: '上传 ...' + }, + previewZoomButtonTitles: { + prev: '预览上一个文件', + next: '预览下一个文件', + toggleheader: '缩放', + fullscreen: '全屏', + borderless: '无边界模式', + close: '关闭当前预览' + } + }; + + $.fn.fileinput.Constructor = FileInput; + + /** + * Convert automatically file inputs with class 'file' into a bootstrap fileinput control. + */ + $(document).ready(function () { + var $input = $('input.file[type=file]'); + if ($input.length) { + $input.fileinput(); + } + }); })); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.css b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.css similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.css rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.css index c7a5ae3c4..ef123ff1c 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.css @@ -1,12 +1,12 @@ -/*! - * bootstrap-fileinput v5.0.4 - * http://plugins.krajee.com/file-input - * - * Krajee default styling for bootstrap-fileinput. - * - * Author: Kartik Visweswaran - * Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com - * - * Licensed under the BSD-3-Clause - * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md +/*! + * bootstrap-fileinput v5.0.4 + * http://plugins.krajee.com/file-input + * + * Krajee default styling for bootstrap-fileinput. + * + * Author: Kartik Visweswaran + * Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com + * + * Licensed under the BSD-3-Clause + * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md */.btn-file input[type=file],.file-caption-icon,.file-no-browse,.file-preview .fileinput-remove,.file-zoom-dialog .btn-navigate,.file-zoom-dialog .floating-buttons,.krajee-default .file-thumb-progress{position:absolute}.file-loading input[type=file],input[type=file].file-loading{width:0;height:0}.file-no-browse{left:50%;bottom:20%;width:1px;height:1px;font-size:0;opacity:0;border:none;background:0 0;outline:0;box-shadow:none}.file-caption-icon,.file-input-ajax-new .fileinput-remove-button,.file-input-ajax-new .fileinput-upload-button,.file-input-ajax-new .no-browse .input-group-btn,.file-input-new .close,.file-input-new .file-preview,.file-input-new .fileinput-remove-button,.file-input-new .fileinput-upload-button,.file-input-new .glyphicon-file,.file-input-new .no-browse .input-group-btn,.file-zoom-dialog .modal-header:after,.file-zoom-dialog .modal-header:before,.hide-content .kv-file-content,.is-locked .fileinput-remove-button,.is-locked .fileinput-upload-button,.kv-hidden{display:none}.file-caption-icon .kv-caption-icon{line-height:inherit}.btn-file,.file-caption,.file-input,.file-loading:before,.file-preview,.file-zoom-dialog .modal-dialog,.krajee-default .file-thumbnail-footer,.krajee-default.file-preview-frame{position:relative}.file-error-message pre,.file-error-message ul,.krajee-default .file-actions,.krajee-default .file-other-error{text-align:left}.file-error-message pre,.file-error-message ul{margin:0}.krajee-default .file-drag-handle,.krajee-default .file-upload-indicator{float:left;margin-top:10px;width:16px;height:16px}.krajee-default .file-thumb-progress .progress,.krajee-default .file-thumb-progress .progress-bar{height:11px;font-family:Verdana,Helvetica,sans-serif;font-size:9px}.krajee-default .file-thumb-progress .progress,.kv-upload-progress .progress{background-color:#ccc}.krajee-default .file-caption-info,.krajee-default .file-size-info{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:160px;height:15px;margin:auto}.file-zoom-content>.file-object.type-flash,.file-zoom-content>.file-object.type-image,.file-zoom-content>.file-object.type-video{max-width:100%;max-height:100%;width:auto}.file-zoom-content>.file-object.type-flash,.file-zoom-content>.file-object.type-video{height:100%}.file-zoom-content>.file-object.type-default,.file-zoom-content>.file-object.type-html,.file-zoom-content>.file-object.type-pdf,.file-zoom-content>.file-object.type-text{width:100%}.file-loading:before{content:" Loading...";display:inline-block;padding-left:20px;line-height:16px;font-size:13px;font-variant:small-caps;color:#999;background:url(loading.gif) top left no-repeat}.file-object{margin:0 0 -5px;padding:0}.btn-file{overflow:hidden}.btn-file input[type=file]{top:0;left:0;min-width:100%;min-height:100%;text-align:right;opacity:0;background:none;cursor:inherit;display:block}.btn-file ::-ms-browse{font-size:10000px;width:100%;height:100%}.file-caption .file-caption-name{width:100%;margin:0;padding:0;box-shadow:none;border:none;background:0 0;outline:0}.file-caption.icon-visible .file-caption-icon{display:inline-block}.file-caption.icon-visible .file-caption-name{padding-left:15px}.file-caption-icon{left:8px}.file-error-message{color:#a94442;background-color:#f2dede;margin:5px;border:1px solid #ebccd1;border-radius:4px;padding:15px}.file-error-message pre{margin:5px 0}.file-caption-disabled{background-color:#eee;cursor:not-allowed;opacity:1}.file-preview{border-radius:5px;border:1px solid #ddd;padding:8px;width:100%;margin-bottom:5px}.file-preview .btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.file-preview .fileinput-remove{top:1px;right:1px;line-height:10px}.file-preview .clickable{cursor:pointer}.file-preview-image{font:40px Impact,Charcoal,sans-serif;color:green}.krajee-default.file-preview-frame{margin:8px;border:1px solid rgba(0,0,0,.2);box-shadow:0 0 10px 0 rgba(0,0,0,.2);padding:6px;float:left;text-align:center}.krajee-default.file-preview-frame .kv-file-content{width:213px;height:160px}.krajee-default .file-preview-other-frame{display:flex;align-items:center;justify-content:center}.krajee-default.file-preview-frame .kv-file-content.kv-pdf-rendered{width:400px}.krajee-default.file-preview-frame[data-template=audio] .kv-file-content{width:240px;height:55px}.krajee-default.file-preview-frame .file-thumbnail-footer{height:70px}.krajee-default.file-preview-frame:not(.file-preview-error):hover{border:1px solid rgba(0,0,0,.3);box-shadow:0 0 10px 0 rgba(0,0,0,.4)}.krajee-default .file-preview-text{display:block;color:#428bca;border:1px solid #ddd;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;outline:0;padding:8px;resize:none}.krajee-default .file-preview-html{border:1px solid #ddd;padding:8px;overflow:auto}.krajee-default .file-other-icon{font-size:6em;line-height:1}.krajee-default .file-footer-buttons{float:right}.krajee-default .file-footer-caption{display:block;text-align:center;padding-top:4px;font-size:11px;color:#777;margin-bottom:30px}.file-upload-stats{font-size:10px;text-align:center;width:100%}.kv-upload-progress .file-upload-stats{font-size:12px;margin:-10px 0 5px}.krajee-default .file-preview-error{opacity:.65;box-shadow:none}.krajee-default .file-thumb-progress{height:11px;top:37px;left:0;right:0}.krajee-default.kvsortable-ghost{background:#e1edf7;border:2px solid #a1abff}.krajee-default .file-preview-other:hover{opacity:.8}.krajee-default .file-preview-frame:not(.file-preview-error) .file-footer-caption:hover{color:#000}.kv-upload-progress .progress{height:20px;margin:10px 0;overflow:hidden}.kv-upload-progress .progress-bar{height:20px;font-family:Verdana,Helvetica,sans-serif}.file-zoom-dialog .file-other-icon{font-size:22em;font-size:50vmin}.file-zoom-dialog .modal-dialog{width:auto}.file-zoom-dialog .modal-header{display:flex;align-items:center;justify-content:space-between}.file-zoom-dialog .btn-navigate{padding:0;margin:0;background:0 0;text-decoration:none;outline:0;opacity:.7;top:45%;font-size:4em;color:#1c94c4}.file-zoom-dialog .btn-navigate:not([disabled]):hover{outline:0;box-shadow:none;opacity:.6}.file-zoom-dialog .floating-buttons{top:5px;right:10px}.file-zoom-dialog .btn-navigate[disabled]{opacity:.3}.file-zoom-dialog .btn-prev{left:1px}.file-zoom-dialog .btn-next{right:1px}.file-zoom-dialog .kv-zoom-title{font-weight:300;color:#999;max-width:50%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.file-input-ajax-new .no-browse .form-control,.file-input-new .no-browse .form-control{border-top-right-radius:4px;border-bottom-right-radius:4px}.file-caption-main{width:100%}.file-thumb-loading{background:url(loading.gif) center center no-repeat content-box!important}.file-drop-zone{border:1px dashed #aaa;border-radius:4px;text-align:center;vertical-align:middle;margin:12px 15px 12px 12px;padding:5px}.file-drop-zone.clickable:hover{border:2px dashed #999}.file-drop-zone.clickable:focus{border:2px solid #5acde2}.file-drop-zone .file-preview-thumbnails{cursor:default}.file-drop-zone-title{color:#aaa;font-size:1.6em;padding:85px 10px;cursor:default}.file-highlighted{border:2px dashed #999!important;background-color:#eee}.file-uploading{background:url(../img/loading-sm.gif) center bottom 10px no-repeat;opacity:.65}.file-zoom-fullscreen .modal-dialog{min-width:100%;margin:0}.file-zoom-fullscreen .modal-content{border-radius:0;box-shadow:none;min-height:100vh}.file-zoom-fullscreen .modal-body{overflow-y:auto}.floating-buttons{z-index:3000}.floating-buttons .btn-kv{margin-left:3px;z-index:3000}.kv-zoom-actions .btn-kv{margin-left:3px}.file-zoom-content{height:480px;text-align:center}.file-zoom-content .file-preview-image,.file-zoom-content .file-preview-video{max-height:100%}.file-zoom-content>.file-object.type-image{height:auto;min-height:inherit}.file-zoom-content>.file-object.type-audio{width:auto;height:30px}@media (min-width:576px){.file-zoom-dialog .modal-dialog{max-width:500px}}@media (min-width:992px){.file-zoom-dialog .modal-lg{max-width:800px}}@media (max-width:767px){.file-preview-thumbnails{display:flex;justify-content:center;align-items:center;flex-direction:column}.file-zoom-dialog .modal-header{flex-direction:column}}@media (max-width:350px){.krajee-default.file-preview-frame:not([data-template=audio]) .kv-file-content{width:160px}}@media (max-width:420px){.krajee-default.file-preview-frame .kv-file-content.kv-pdf-rendered{width:100%}}.file-loading[dir=rtl]:before{background:url(loading.gif) top right no-repeat;padding-left:0;padding-right:20px}.file-sortable .file-drag-handle{cursor:move;opacity:1}.file-sortable .file-drag-handle:hover{opacity:.7}.clickable .file-drop-zone-title{cursor:pointer}.file-preview-initial.sortable-chosen{background-color:#d9edf7} \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.js index 2a2206afa..c627c6cc2 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/fileinput.min.js @@ -1,10 +1,10 @@ -/*! - bootstrap-fileinput v5.0.4 - http://plugins.krajee.com/file-input - - Author: Kartik Visweswaran - Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com - - Licensed under the BSD-3-Clause - https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md +/*! + bootstrap-fileinput v5.0.4 + http://plugins.krajee.com/file-input + + Author: Kartik Visweswaran + Copyright: 2014 - 2019, Kartik Visweswaran, Krajee.com + + Licensed under the BSD-3-Clause + https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md */(function(factory){'use strict';if(typeof define==='function'&&define.amd){define(['jquery'],factory);}else{if(typeof module==='object'&&module.exports){module.exports=factory(require('jquery'));}else{factory(window.jQuery);}}}(function($){'use strict';$.fn.fileinputLocales={};$.fn.fileinputThemes={};String.prototype.setTokens=function(replacePairs){var str=this.toString(),key,re;for(key in replacePairs){if(replacePairs.hasOwnProperty(key)){re=new RegExp('\{'+key+'\}','g');str=str.replace(re,replacePairs[key]);}}return str;};var $h,FileInput;$h={FRAMES:'.kv-preview-thumb',SORT_CSS:'file-sortable',OBJECT_PARAMS:'\n'+'\n'+'\n'+'\n'+'\n'+'\n',DEFAULT_PREVIEW:'
    \n'+'{previewFileIcon}\n'+'
    ',MODAL_ID:'kvFileinputModal',MODAL_EVENTS:['show','shown','hide','hidden','loaded'],logMessages:{ajaxError:'{status}: {error}. Error Details: {text}.',badDroppedFiles:'Error scanning dropped files!',badExifParser:'Error loading the piexif.js library. {details}',badInputType:'The input "type" must be set to "file" for initializing the "bootstrap-fileinput" plugin.',exifWarning:'To avoid this warning, either set "autoOrientImage" to "false" OR ensure you have loaded '+'the "piexif.js" library correctly on your page before the "fileinput.js" script.',invalidChunkSize:'Invalid upload chunk size: "{chunkSize}". Resumable uploads are disabled.',invalidThumb:'Invalid thumb frame with id: "{id}".',noResumableSupport:'The browser does not support resumable or chunk uploads.',noUploadUrl:'The "uploadUrl" is not set. Ajax uploads and resumable uploads have been disabled.',retryStatus:'Retrying upload for chunk # {chunk} for {filename}... retry # {retry}.'},objUrl:window.URL||window.webkitURL,now:function(){return new Date();},round:function(num){num=parseFloat(num);return isNaN(num)?0:Math.floor(Math.round(num));},getFileRelativePath:function(file){return String(file.relativePath||file.webkitRelativePath||$h.getFileName(file)||null);},getFileId:function(file,generateFileId){var relativePath=$h.getFileRelativePath(file);if(typeof generateFileId==='function'){return generateFileId(file);}if(!file){return null;}if(!relativePath){return null;}return(file.size+'_'+relativePath.replace(/\s/img,'_'));},getElapsed:function(seconds){var delta=seconds,out='',result={},structure={year:31536000,month:2592000,week:604800,day:86400,hour:3600,minute:60,second:1};Object.keys(structure).forEach(function(key){result[key]=Math.floor(delta/structure[key]);delta-=result[key]*structure[key];});$.each(result,function(key,value){if(value>0){out+=(out?' ':'')+value+key.substring(0,1);}});return out;},debounce:function(func,delay){var inDebounce;return function(){var args=arguments,context=this;clearTimeout(inDebounce);inDebounce=setTimeout(function(){func.apply(context,args);},delay);};},stopEvent:function(e){e.stopPropagation();e.preventDefault();},getFileName:function(file){return file?(file.fileName||file.name||''):'';},createObjectURL:function(data){if($h.objUrl&&$h.objUrl.createObjectURL&&data){return $h.objUrl.createObjectURL(data);}return'';},revokeObjectURL:function(data){if($h.objUrl&&$h.objUrl.revokeObjectURL&&data){$h.objUrl.revokeObjectURL(data);}},compare:function(input,str,exact){return input!==undefined&&(exact?input===str:input.match(str));},isIE:function(ver){var div,status;if(navigator.appName!=='Microsoft Internet Explorer'){return false;}if(ver===10){return new RegExp('msie\\s'+ver,'i').test(navigator.userAgent);}div=document.createElement('div');div.innerHTML='';status=div.getElementsByTagName('i').length;document.body.appendChild(div);div.parentNode.removeChild(div);return status;},canAssignFilesToInput:function(){var input=document.createElement('input');try{input.type='file';input.files=null;return true;}catch(err){return false;}},getDragDropFolders:function(items){var i,item,len=items?items.length:0,folders=0;if(len>0&&items[0].webkitGetAsEntry()){for(i=0;i=0){byteStr=atob(dataURI.split(',')[1]);}else{byteStr=decodeURIComponent(dataURI.split(',')[1]);}arrayBuffer=new ArrayBuffer(byteStr.length);intArray=new Uint8Array(arrayBuffer);for(i=0;i>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:out+=String.fromCharCode(c);break;case 12:case 13:char2=array[i++];out+=String.fromCharCode(((c&0x1F)<<6)|(char2&0x3F));break;case 14:char2=array[i++];char3=array[i++];out+=String.fromCharCode(((c&0x0F)<<12)|((char2&0x3F)<<6)|((char3&0x3F)<<0));break;}}return out;},isHtml:function(str){var a=document.createElement('div');a.innerHTML=str;for(var c=a.childNodes,i=c.length;i--;){if(c[i].nodeType===1){return true;}}return false;},isSvg:function(str){return str.match(/^\s*<\?xml/i)&&(str.match(//g,'>').replace(/"/g,'"').replace(/'/g,''');},replaceTags:function(str,tags){var out=str;if(!tags){return out;}$.each(tags,function(key,value){if(typeof value==='function'){value=value();}out=out.split(key).join(value);});return out;},cleanMemory:function($thumb){var data=$thumb.is('img')?$thumb.attr('src'):$thumb.find('source').attr('src');$h.revokeObjectURL(data);},findFileName:function(filePath){var sepIndex=filePath.lastIndexOf('/');if(sepIndex===-1){sepIndex=filePath.lastIndexOf('\\');}return filePath.split(filePath.substring(sepIndex,sepIndex+1)).pop();},checkFullScreen:function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement;},toggleFullScreen:function(maximize){var doc=document,de=doc.documentElement;if(de&&maximize&&!$h.checkFullScreen()){if(de.requestFullscreen){de.requestFullscreen();}else{if(de.msRequestFullscreen){de.msRequestFullscreen();}else{if(de.mozRequestFullScreen){de.mozRequestFullScreen();}else{if(de.webkitRequestFullscreen){de.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);}}}}}else{if(doc.exitFullscreen){doc.exitFullscreen();}else{if(doc.msExitFullscreen){doc.msExitFullscreen();}else{if(doc.mozCancelFullScreen){doc.mozCancelFullScreen();}else{if(doc.webkitExitFullscreen){doc.webkitExitFullscreen();}}}}}},moveArray:function(arr,oldIndex,newIndex,reverseOrder){var newArr=$.extend(true,[],arr);if(reverseOrder){newArr.reverse();}if(newIndex>=newArr.length){var k=newIndex-newArr.length;while((k--)+1){newArr.push(undefined);}}newArr.splice(newIndex,0,newArr.splice(oldIndex,1)[0]);if(reverseOrder){newArr.reverse();}return newArr;},cleanZoomCache:function($el){var $cache=$el.closest('.kv-zoom-cache-theme');if(!$cache.length){$cache=$el.closest('.kv-zoom-cache');}$cache.remove();},closeButton:function(css){css=css?'close '+css:'close';return'';},getRotation:function(value){switch(value){case 2:return'rotateY(180deg)';case 3:return'rotate(180deg)';case 4:return'rotate(180deg) rotateY(180deg)';case 5:return'rotate(270deg) rotateY(180deg)';case 6:return'rotate(90deg)';case 7:return'rotate(90deg) rotateY(180deg)';case 8:return'rotate(270deg)';default:return'';}},setTransform:function(el,val){if(!el){return;}el.style.transform=val;el.style.webkitTransform=val;el.style['-moz-transform']=val;el.style['-ms-transform']=val;el.style['-o-transform']=val;}};FileInput=function(element,options){var self=this;self.$element=$(element);self.$parent=self.$element.parent();if(!self._validate()){return;}self.isPreviewable=$h.hasFileAPISupport();self.isIE9=$h.isIE(9);self.isIE10=$h.isIE(10);if(self.isPreviewable||self.isIE9){self._init(options);self._listen();}self.$element.removeClass('file-loading');};FileInput.prototype={constructor:FileInput,_cleanup:function(){var self=this;self.reader=null;self.clearFileStack();self.fileBatchCompleted=true;self.isError=false;self.cancelling=false;self.paused=false;self.lastProgress=0;self._initAjax();},_initAjax:function(){var self=this;self.ajaxQueue=[];self.ajaxRequests=[];self.ajaxQueueIntervalId=null;self.ajaxCurrentThreads=0;self.ajaxAborted=false;},_init:function(options,refreshMode){var self=this,f,$el=self.$element,$cont,t,tmp;self.options=options;$.each(options,function(key,value){switch(key){case'minFileCount':case'maxFileCount':case'minFileSize':case'maxFileSize':case'maxFilePreviewSize':case'resizeImageQuality':case'resizeIfSizeMoreThan':case'progressUploadThreshold':case'initialPreviewCount':case'zoomModalHeight':case'minImageHeight':case'maxImageHeight':case'minImageWidth':case'maxImageWidth':self[key]=$h.getNum(value);break;default:self[key]=value;break;}});if(self.rtl){tmp=self.previewZoomButtonIcons.prev;self.previewZoomButtonIcons.prev=self.previewZoomButtonIcons.next;self.previewZoomButtonIcons.next=tmp;}if(!isNaN(self.maxAjaxThreads)&&self.maxAjaxThreadsrm.file.size?rm.file.size:size;},getTotalChunks:function(){var rm=self.resumableManager,chunkSize=parseFloat(rm.chunkSize);if(!isNaN(chunkSize)&&chunkSize>0){return Math.ceil(rm.file.size/chunkSize);}return 0;},getProgress:function(){var rm=self.resumableManager,processed=rm.processedResumables(),total=rm.chunkCount;if(total===0){return 0;}return Math.ceil(processed/total*100);},checkAborted:function(intervalId){if(self.paused||self.cancelling){clearInterval(intervalId);self.unlock();}},upload:function(){var rm=self.resumableManager,fm=self.fileManager,ids=fm.getIdList(),flag='new',intervalId;intervalId=setInterval(function(){var id;rm.checkAborted(intervalId);if(flag==='new'){self.lock();flag='processing';id=ids.shift();fm.initStats(id);if(fm.stack[id]){rm.init(id,fm.stack[id],fm.getIndex(id));rm.testUpload();rm.uploadResumable();}}if(!fm.isPending(id)&&rm.completed){flag='new';}if(fm.isProcessed()){var $initThumbs=self.$preview.find('.file-preview-initial');if($initThumbs.length){$h.addCss($initThumbs,$h.SORT_CSS);self._initSortable();}clearInterval(intervalId);self._clearFileInput();self.unlock();setTimeout(function(){var data=self.previewCache.data;if(data){self.initialPreview=data.content;self.initialPreviewConfig=data.config;self.initialPreviewThumbTags=data.tags;}self._raise('filebatchuploadcomplete',[self.initialPreview,self.initialPreviewConfig,self.initialPreviewThumbTags,self._getExtraData()]);},self.processDelay);}},self.processDelay);},uploadResumable:function(){var i,rm=self.resumableManager,total=rm.chunkCount;for(i=0;iopts.maxRetries){rm.setProcessed('error');return;}var fd,outData,fnBefore,fnSuccess,fnError,fnComplete,slice=file.slice?'slice':(file.mozSlice?'mozSlice':(file.webkitSlice?'webkitSlice':'slice')),blob=file[slice](chunkSize*index,chunkSize*(index+1));fd=new FormData();f=fm.stack[id];self._setUploadData(fd,{chunkCount:rm.chunkCount,chunkIndex:index,chunkSize:chunkSize,chunkSizeStart:chunkSize*index,fileBlob:[blob,rm.fileName],fileId:id,fileName:rm.fileName,fileRelativePath:f.relativePath,fileSize:file.size,retryCount:retry});if(rm.$progress&&rm.$progress.length){rm.$progress.show();}fnBefore=function(jqXHR){outData=self._getOutData(fd,jqXHR);if(self.showPreview){if(!$thumb.hasClass('file-preview-success')){self._setThumbStatus($thumb,'Loading');$h.addCss($thumb,'file-uploading');}$btnDelete.attr('disabled',true);}self._raise('filechunkbeforesend',[id,index,retry,fm,rm,outData]);};fnSuccess=function(data,textStatus,jqXHR){outData=self._getOutData(fd,jqXHR,data);var paramNames=self.uploadParamNames,chunkIndex=paramNames.chunkIndex||'chunkIndex',opts=self.resumableUploadOptions,params=[id,index,retry,fm,rm,outData];rm.currThreads--;if(data.error){if(opts.showErrorLog){self._log(logs.retryStatus,{retry:retry+1,filename:rm.fileName,chunk:index});}rm.pushAjax(index,retry+1);rm.error=data.error;self._raise('filechunkerror',params);}else{rm.logs[data[chunkIndex]]=true;if(!rm.processed[id]){rm.processed[id]={};}rm.processed[id][data[chunkIndex]]=true;rm.processed[id].data=data;self._raise('filechunksuccess',params);rm.check();}};fnError=function(jqXHR,textStatus,errorThrown){outData=self._getOutData(fd,jqXHR);rm.currThreads--;rm.error=errorThrown;rm.logAjaxError(jqXHR,textStatus,errorThrown);self._raise('filechunkajaxerror',[id,index,retry,fm,rm,outData]);rm.pushAjax(index,retry+1);};fnComplete=function(){self._raise('filechunkcomplete',[id,index,retry,fm,rm,self._getOutData(fd)]);};self._ajaxSubmit(fnBefore,fnSuccess,fnComplete,fnError,fd,id,rm.fileIndex);},loopAjax:function(){var rm=self.resumableManager;if(rm.currThreads=rm.getTotalChunks()){rm.setProcessed('success');clearInterval(rm.chunkIntervalId);}}}}}};self.resumableManager.reset();},_initTemplateDefaults:function(){var self=this,tMain1,tMain2,tPreview,tFileIcon,tClose,tCaption,tBtnDefault,tBtnLink,tBtnBrowse,tModalMain,tModal,tProgress,tSize,tFooter,tActions,tActionDelete,tActionUpload,tActionDownload,tActionZoom,tActionDrag,tIndicator,tTagBef,tTagBef1,tTagBef2,tTagAft,tGeneric,tHtml,tImage,tText,tOffice,tGdocs,tVideo,tAudio,tFlash,tObject,tPdf,tOther,tStyle,tZoomCache,vDefaultDim,tStats;tMain1='{preview}\n'+'
    \n'+'
    \n'+' {caption}\n'+'
    \n'+' {remove}\n'+' {cancel}\n'+' {pause}\n'+' {upload}\n'+' {browse}\n'+'
    \n'+'
    ';tMain2='{preview}\n
    \n
    \n'+'{remove}\n{cancel}\n{upload}\n{browse}\n';tPreview='
    \n'+' {close}'+'
    \n'+'
    \n'+'
    \n'+'
    '+'
    \n'+'
    \n'+'
    \n'+'
    ';tClose=$h.closeButton('fileinput-remove');tFileIcon='';tCaption='
    \n'+' \n'+' \n'+'
    ';tBtnDefault='';tBtnLink='{icon} {label}';tBtnBrowse='
    {icon} {label}
    ';tModalMain='';tModal='\n';tProgress='
    \n'+'
    \n'+' {status}\n'+'
    \n'+'
    {stats}';tStats='
    '+'{pendingTime} '+'{uploadSpeed}'+'
    ';tSize=' ({sizeText})';tFooter='';tActions='
    \n'+' \n'+'
    \n'+'{drag}\n'+'
    ';tActionDelete='\n';tActionUpload='';tActionDownload='{downloadIcon}';tActionZoom='';tActionDrag='{dragIcon}';tIndicator='
    {indicator}
    ';tTagBef='
    \n';tTagBef2=tTagBef+' title="{caption}">
    \n';tTagAft='
    {footer}\n
    \n';tGeneric='{content}\n';tStyle=' {style}';tHtml='
    {data}
    \n';tImage='\n';tText='\n';tOffice='';tGdocs='';tVideo='\n';tAudio='\n';tFlash='\n';tPdf='\n';tObject='\n'+'\n'+$h.OBJECT_PARAMS+' '+$h.DEFAULT_PREVIEW+'\n\n';tOther='
    \n'+$h.DEFAULT_PREVIEW+'\n
    \n';tZoomCache='';vDefaultDim={width:'100%',height:'100%','min-height':'480px'};if(self._isPdfRendered()){tPdf=self.pdfRendererTemplate.replace('{renderer}',self._encodeURI(self.pdfRendererUrl));}self.defaults={layoutTemplates:{main1:tMain1,main2:tMain2,preview:tPreview,close:tClose,fileIcon:tFileIcon,caption:tCaption,modalMain:tModalMain,modal:tModal,progress:tProgress,stats:tStats,size:tSize,footer:tFooter,indicator:tIndicator,actions:tActions,actionDelete:tActionDelete,actionUpload:tActionUpload,actionDownload:tActionDownload,actionZoom:tActionZoom,actionDrag:tActionDrag,btnDefault:tBtnDefault,btnLink:tBtnLink,btnBrowse:tBtnBrowse,zoomCache:tZoomCache},previewMarkupTags:{tagBefore1:tTagBef1,tagBefore2:tTagBef2,tagAfter:tTagAft},previewContentTemplates:{generic:tGeneric,html:tHtml,image:tImage,text:tText,office:tOffice,gdocs:tGdocs,video:tVideo,audio:tAudio,flash:tFlash,object:tObject,pdf:tPdf,other:tOther},allowedPreviewTypes:['image','html','text','video','audio','flash','pdf','object'],previewTemplates:{},previewSettings:{image:{width:'auto',height:'auto','max-width':'100%','max-height':'100%'},html:{width:'213px',height:'160px'},text:{width:'213px',height:'160px'},office:{width:'213px',height:'160px'},gdocs:{width:'213px',height:'160px'},video:{width:'213px',height:'160px'},audio:{width:'100%',height:'30px'},flash:{width:'213px',height:'160px'},object:{width:'213px',height:'160px'},pdf:{width:'100%',height:'160px'},other:{width:'213px',height:'160px'}},previewSettingsSmall:{image:{width:'auto',height:'auto','max-width':'100%','max-height':'100%'},html:{width:'100%',height:'160px'},text:{width:'100%',height:'160px'},office:{width:'100%',height:'160px'},gdocs:{width:'100%',height:'160px'},video:{width:'100%',height:'auto'},audio:{width:'100%',height:'30px'},flash:{width:'100%',height:'auto'},object:{width:'100%',height:'auto'},pdf:{width:'100%',height:'160px'},other:{width:'100%',height:'160px'}},previewZoomSettings:{image:{width:'auto',height:'auto','max-width':'100%','max-height':'100%'},html:vDefaultDim,text:vDefaultDim,office:{width:'100%',height:'100%','max-width':'100%','min-height':'480px'},gdocs:{width:'100%',height:'100%','max-width':'100%','min-height':'480px'},video:{width:'auto',height:'100%','max-width':'100%'},audio:{width:'100%',height:'30px'},flash:{width:'auto',height:'480px'},object:{width:'auto',height:'100%','max-width':'100%','min-height':'480px'},pdf:vDefaultDim,other:{width:'auto',height:'100%','min-height':'480px'}},mimeTypeAliases:{'video/quicktime':'video/mp4'},fileTypeSettings:{image:function(vType,vName){return($h.compare(vType,'image.*')&&!$h.compare(vType,/(tiff?|wmf)$/i)||$h.compare(vName,/\.(gif|png|jpe?g)$/i));},html:function(vType,vName){return $h.compare(vType,'text/html')||$h.compare(vName,/\.(htm|html)$/i);},office:function(vType,vName){return $h.compare(vType,/(word|excel|powerpoint|office)$/i)||$h.compare(vName,/\.(docx?|xlsx?|pptx?|pps|potx?)$/i);},gdocs:function(vType,vName){return $h.compare(vType,/(word|excel|powerpoint|office|iwork-pages|tiff?)$/i)||$h.compare(vName,/\.(docx?|xlsx?|pptx?|pps|potx?|rtf|ods|odt|pages|ai|dxf|ttf|tiff?|wmf|e?ps)$/i);},text:function(vType,vName){return $h.compare(vType,'text.*')||$h.compare(vName,/\.(xml|javascript)$/i)||$h.compare(vName,/\.(txt|md|csv|nfo|ini|json|php|js|css)$/i);},video:function(vType,vName){return $h.compare(vType,'video.*')&&($h.compare(vType,/(ogg|mp4|mp?g|mov|webm|3gp)$/i)||$h.compare(vName,/\.(og?|mp4|webm|mp?g|mov|3gp)$/i));},audio:function(vType,vName){return $h.compare(vType,'audio.*')&&($h.compare(vName,/(ogg|mp3|mp?g|wav)$/i)||$h.compare(vName,/\.(og?|mp3|mp?g|wav)$/i));},flash:function(vType,vName){return $h.compare(vType,'application/x-shockwave-flash',true)||$h.compare(vName,/\.(swf)$/i);},pdf:function(vType,vName){return $h.compare(vType,'application/pdf',true)||$h.compare(vName,/\.(pdf)$/i);},object:function(){return true;},other:function(){return true;}},fileActionSettings:{showRemove:true,showUpload:true,showDownload:true,showZoom:true,showDrag:true,removeIcon:'',removeClass:'btn btn-sm btn-kv btn-default btn-outline-secondary',removeErrorClass:'btn btn-sm btn-kv btn-danger',removeTitle:'Remove file',uploadIcon:'',uploadClass:'btn btn-sm btn-kv btn-default btn-outline-secondary',uploadTitle:'Upload file',uploadRetryIcon:'',uploadRetryTitle:'Retry upload',downloadIcon:'',downloadClass:'btn btn-sm btn-kv btn-default btn-outline-secondary',downloadTitle:'Download file',zoomIcon:'',zoomClass:'btn btn-sm btn-kv btn-default btn-outline-secondary',zoomTitle:'View Details',dragIcon:'',dragClass:'text-info',dragTitle:'Move / Rearrange',dragSettings:{},indicatorNew:'',indicatorSuccess:'',indicatorError:'',indicatorLoading:'',indicatorPaused:'',indicatorNewTitle:'Not uploaded yet',indicatorSuccessTitle:'Uploaded',indicatorErrorTitle:'Upload Error',indicatorLoadingTitle:'Uploading ...',indicatorPausedTitle:'Upload Paused'}};$.each(self.defaults,function(key,setting){if(key==='allowedPreviewTypes'){if(self.allowedPreviewTypes===undefined){self.allowedPreviewTypes=setting;}return;}self[key]=$.extend(true,{},setting,self[key]);});self._initPreviewTemplates();},_initPreviewTemplates:function(){var self=this,tags=self.previewMarkupTags,tagBef,tagAft=tags.tagAfter;$.each(self.previewContentTemplates,function(key,value){if($h.isEmpty(self.previewTemplates[key])){tagBef=tags.tagBefore2;if(key==='generic'||key==='image'||key==='html'||key==='text'){tagBef=tags.tagBefore1;}if(self._isPdfRendered()&&key==='pdf'){tagBef=tagBef.replace('kv-file-content','kv-file-content kv-pdf-rendered');}self.previewTemplates[key]=tagBef+value+tagAft;}});},_initPreviewCache:function(){var self=this;self.previewCache={data:{},init:function(){var content=self.initialPreview;if(content.length>0&&!$h.isArray(content)){content=content.split(self.initialPreviewDelimiter);}self.previewCache.data={content:content,config:self.initialPreviewConfig,tags:self.initialPreviewThumbTags};},count:function(skipNull){if(!self.previewCache.data||!self.previewCache.data.content){return 0;}if(skipNull){var chk=self.previewCache.data.content.filter(function(n){return n!==null;});return chk.length;}return self.previewCache.data.content.length;},get:function(i,isDisabled){var ind='init_'+i,data=self.previewCache.data,config=data.config[i],fileId,content=data.content[i],previewId=self.previewInitId+'-'+ind,out,$tmp,cat,ftr,fname,ftype,frameClass,asData=$h.ifSet('previewAsData',config,self.initialPreviewAsData),a=config?{title:config.title||null,alt:config.alt||null}:{title:null,alt:null},parseTemplate=function(cat,dat,fn,ft,id,ftr,ind,fc,t){fc=' file-preview-initial '+$h.SORT_CSS+(fc?' '+fc:'');fileId=config&&config.fileId||'file_'+id;return self._generatePreviewTemplate(cat,dat,fn,ft,id,fileId,false,null,fc,ftr,ind,t,a,config&&config.zoomData||dat);};if(!content||!content.length){return'';}isDisabled=isDisabled===undefined?true:isDisabled;cat=$h.ifSet('type',config,self.initialPreviewFileType||'generic');fname=$h.ifSet('filename',config,$h.ifSet('caption',config));ftype=$h.ifSet('filetype',config,cat);ftr=self.previewCache.footer(i,isDisabled,(config&&config.size||null));frameClass=$h.ifSet('frameClass',config);if(asData){out=parseTemplate(cat,content,fname,ftype,previewId,ftr,ind,frameClass);}else{out=parseTemplate('generic',content,fname,ftype,previewId,ftr,ind,frameClass,cat).setTokens({'content':data.content[i]});}if(data.tags.length&&data.tags[i]){out=$h.replaceTags(out,data.tags[i]);}if(!$h.isEmpty(config)&&!$h.isEmpty(config.frameAttr)){$tmp=$(document.createElement('div')).html(out);$tmp.find('.file-preview-initial').attr(config.frameAttr);out=$tmp.html();$tmp.remove();}return out;},clean:function(data){data.content=$h.cleanArray(data.content);data.config=$h.cleanArray(data.config);data.tags=$h.cleanArray(data.tags);self.previewCache.data=data;},add:function(content,config,tags,append){var data=self.previewCache.data,index=content.length-1;if(!content||!content.length){return index;}if(!$h.isArray(content)){content=content.split(self.initialPreviewDelimiter);}if(append){index=data.content.push(content[0])-1;data.config[index]=config;data.tags[index]=tags;}else{data.content=content;data.config=config;data.tags=tags;}self.previewCache.clean(data);return index;},set:function(content,config,tags,append){var data=self.previewCache.data,i,chk;if(!content||!content.length){return;}if(!$h.isArray(content)){content=content.split(self.initialPreviewDelimiter);}chk=content.filter(function(n){return n!==null;});if(!chk.length){return;}if(data.content===undefined){data.content=[];}if(data.config===undefined){data.config=[];}if(data.tags===undefined){data.tags=[];}if(append){for(i=0;i'+msg+'':'
  • '+msg+'
  • ';if($error.find('ul').length===0){self._addError('
      '+e+'
    ');}else{$error.find('ul').append(e);}$error.fadeIn(800);self._raise(ev,[params,msg]);self._setValidationError('file-input-new');return true;},_showError:function(msg,params,event){var self=this,$error=self.$errorContainer,ev=event||'fileerror';params=params||{};params.reader=self.reader;self._addError(msg);$error.fadeIn(800);self._raise(ev,[params,msg]);if(!self.isAjaxUpload){self._clearFileInput();}self._setValidationError('file-input-new');self.$btnUpload.attr('disabled',true);return true;},_noFilesError:function(params){var self=this,label=self.minFileCount>1?self.filePlural:self.fileSingle,msg=self.msgFilesTooLess.replace('{n}',self.minFileCount).replace('{files}',label),$error=self.$errorContainer;self._addError(msg);self.isError=true;self._updateFileDetails(0);$error.fadeIn(800);self._raise('fileerror',[params,msg]);self._clearFileInput();self._setValidationError();},_parseError:function(operation,jqXHR,errorThrown,fileName){var self=this,errMsg=$.trim(errorThrown+''),textPre,text=jqXHR.responseJSON!==undefined&&jqXHR.responseJSON.error!==undefined?jqXHR.responseJSON.error:jqXHR.responseText;if(self.cancelling&&self.msgUploadAborted){errMsg=self.msgUploadAborted;}if(self.showAjaxErrorDetails&&text){text=$.trim(text.replace(/\n\s*\n/g,'\n'));textPre=text.length?'
    '+text+'
    ':'';errMsg+=errMsg?textPre:text;}if(!errMsg){errMsg=self.msgAjaxError.replace('{operation}',operation);}self.cancelling=false;return fileName?''+fileName+': '+errMsg:errMsg;},_parseFileType:function(type,name){var self=this,isValid,vType,cat,i,types=self.allowedPreviewTypes||[];if(type==='application/text-plain'){return'text';}for(i=0;i-1){ext=fname.split('.').pop();if(self.previewFileIconSettings){out=self.previewFileIconSettings[ext]||self.previewFileIconSettings[ext.toLowerCase()]||null;}if(self.previewFileExtSettings){$.each(self.previewFileExtSettings,function(key,func){if(self.previewFileIconSettings[key]&&func(ext)){out=self.previewFileIconSettings[key];return;}});}}return out;},_parseFilePreviewIcon:function(content,fname){var self=this,icn=self._getPreviewIcon(fname)||self.previewFileIcon,out=content;if(out.indexOf('{previewFileIcon}')>-1){out=out.setTokens({'previewFileIconClass':self.previewFileIconClass,'previewFileIcon':icn});}return out;},_raise:function(event,params){var self=this,e=$.Event(event);if(params!==undefined){self.$element.trigger(e,params);}else{self.$element.trigger(e);}if(e.isDefaultPrevented()||e.result===false){return false;}switch(event){case'filebatchuploadcomplete':case'filebatchuploadsuccess':case'fileuploaded':case'fileclear':case'filecleared':case'filereset':case'fileerror':case'filefoldererror':case'fileuploaderror':case'filebatchuploaderror':case'filedeleteerror':case'filecustomerror':case'filesuccessremove':break;default:if(!self.ajaxAborted){self.ajaxAborted=e.result;}break;}return true;},_listenFullScreen:function(isFullScreen){var self=this,$modal=self.$modal,$btnFull,$btnBord;if(!$modal||!$modal.length){return;}$btnFull=$modal&&$modal.find('.btn-fullscreen');$btnBord=$modal&&$modal.find('.btn-borderless');if(!$btnFull.length||!$btnBord.length){return;}$btnFull.removeClass('active').attr('aria-pressed','false');$btnBord.removeClass('active').attr('aria-pressed','false');if(isFullScreen){$btnFull.addClass('active').attr('aria-pressed','true');}else{$btnBord.addClass('active').attr('aria-pressed','true');}if($modal.hasClass('file-zoom-fullscreen')){self._maximizeZoomDialog();}else{if(isFullScreen){self._maximizeZoomDialog();}else{$btnBord.removeClass('active').attr('aria-pressed','false');}}},_listen:function(){var self=this,$el=self.$element,$form=self.$form,$cont=self.$container,fullScreenEvents;self._handler($el,'click',function(e){if($el.hasClass('file-no-browse')){if($el.data('zoneClicked')){$el.data('zoneClicked',false);}else{e.preventDefault();}}});self._handler($el,'change',$.proxy(self._change,self));if(self.showBrowse){self._handler(self.$btnFile,'click',$.proxy(self._browse,self));}self._handler($cont.find('.fileinput-remove:not([disabled])'),'click',$.proxy(self.clear,self));self._handler($cont.find('.fileinput-cancel'),'click',$.proxy(self.cancel,self));self._handler($cont.find('.fileinput-pause'),'click',$.proxy(self.pause,self));self._initDragDrop();self._handler($form,'reset',$.proxy(self.clear,self));if(!self.isAjaxUpload){self._handler($form,'submit',$.proxy(self._submitForm,self));}self._handler(self.$container.find('.fileinput-upload'),'click',$.proxy(self._uploadClick,self));self._handler($(window),'resize',function(){self._listenFullScreen(screen.width===window.innerWidth&&screen.height===window.innerHeight);});fullScreenEvents='webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange';self._handler($(document),fullScreenEvents,function(){self._listenFullScreen($h.checkFullScreen());});self._autoFitContent();self._initClickable();self._refreshPreview();},_autoFitContent:function(){var width=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,self=this,config=width<400?(self.previewSettingsSmall||self.defaults.previewSettingsSmall):(self.previewSettings||self.defaults.previewSettings),sel;$.each(config,function(cat,settings){sel='.file-preview-frame .file-preview-'+cat;self.$preview.find(sel+'.kv-preview-data,'+sel+' .kv-preview-data').css(settings);});},_scanDroppedItems:function(item,files,path){path=path||'';var self=this,i,dirReader,readDir,errorHandler=function(e){self._log($h.logMessages.badDroppedFiles);self._log(e);};if(item.isFile){item.file(function(file){files.push(file);},errorHandler);}else{if(item.isDirectory){dirReader=item.createReader();readDir=function(){dirReader.readEntries(function(entries){if(entries&&entries.length>0){for(i=0;i-1;self._zoneDragDropInit(e);if(self.isDisabled||!hasFiles){e.originalEvent.dataTransfer.effectAllowed='none';e.originalEvent.dataTransfer.dropEffect='none';return;}if(self._raise('fileDragEnter',{'sourceEvent':e,'files':dataTransfer.types.Files})){$h.addCss(self.$dropZone,'file-highlighted');}},_zoneDragLeave:function(e){var self=this;self._zoneDragDropInit(e);if(self.isDisabled){return;}if(self._raise('fileDragLeave',{'sourceEvent':e})){self.$dropZone.removeClass('file-highlighted');}},_zoneDrop:function(e){var self=this,i,$el=self.$element,dataTransfer=e.originalEvent.dataTransfer,files=dataTransfer.files,items=dataTransfer.items,folders=$h.getDragDropFolders(items),processFiles=function(){if(!self.isAjaxUpload){self.changeTriggered=true;$el.get(0).files=files;setTimeout(function(){self.changeTriggered=false;$el.trigger('change'+self.namespace);},self.processDelay);}else{self._change(e,files);}self.$dropZone.removeClass('file-highlighted');};e.preventDefault();if(self.isDisabled||$h.isEmpty(files)){return;}if(!self._raise('fileDragDrop',{'sourceEvent':e,'files':files})){return;}if(folders>0){if(!self.isAjaxUpload){self._showFolderError(folders);return;}files=[];for(i=0;i.kv-file-content img');$zoomImg=self.$preview.find('#zoom-'+id+' >.kv-file-content img');self.setImageOrientation($img,$zoomImg,config.exif.Orientation,$thumb);}i++;});},_initPreview:function(isInit){var self=this,cap=self.initialCaption||'',out;if(!self.previewCache.count(true)){self._clearPreview();if(isInit){self._setCaption(cap);}else{self._initCaption();}return;}out=self.previewCache.out();cap=isInit&&self.initialCaption?self.initialCaption:out.caption;self._setPreviewContent(out.content);self._setInitThumbAttr();self._setCaption(cap);self._initSortable();if(!$h.isEmpty(out.content)){self.$container.removeClass('file-input-new');}self._initPreviewImageOrientations();},_getZoomButton:function(type){var self=this,label=self.previewZoomButtonIcons[type],css=self.previewZoomButtonClasses[type],title=' title="'+(self.previewZoomButtonTitles[type]||'')+'" ',params=title+(type==='close'?' data-dismiss="modal" aria-hidden="true"':'');if(type==='fullscreen'||type==='borderless'||type==='toggleheader'){params+=' data-toggle="button" aria-pressed="false" autocomplete="off"';}return'';},_getModalContent:function(){var self=this;return self._getLayoutTemplate('modal').setTokens({'rtl':self.rtl?' kv-rtl':'','zoomFrameClass':self.frameClass,'heading':self.msgZoomModalHeading,'prev':self._getZoomButton('prev'),'next':self._getZoomButton('next'),'toggleheader':self._getZoomButton('toggleheader'),'fullscreen':self._getZoomButton('fullscreen'),'borderless':self._getZoomButton('borderless'),'close':self._getZoomButton('close')});},_listenModalEvent:function(event){var self=this,$modal=self.$modal,getParams=function(e){return{sourceEvent:e,previewId:$modal.data('previewId'),modal:$modal};};$modal.on(event+'.bs.modal',function(e){var $btnFull=$modal.find('.btn-fullscreen'),$btnBord=$modal.find('.btn-borderless');self._raise('filezoom'+event,getParams(e));if(event==='shown'){$btnBord.removeClass('active').attr('aria-pressed','false');$btnFull.removeClass('active').attr('aria-pressed','false');if($modal.hasClass('file-zoom-fullscreen')){self._maximizeZoomDialog();if($h.checkFullScreen()){$btnFull.addClass('active').attr('aria-pressed','true');}else{$btnBord.addClass('active').attr('aria-pressed','true');}}}});},_initZoom:function(){var self=this,$dialog,modalMain=self._getLayoutTemplate('modalMain'),modalId='#'+$h.MODAL_ID;if(!self.showPreview){return;}self.$modal=$(modalId);if(!self.$modal||!self.$modal.length){$dialog=$(document.createElement('div')).html(modalMain).insertAfter(self.$container);self.$modal=$(modalId).insertBefore($dialog);$dialog.remove();}$h.initModal(self.$modal);self.$modal.html(self._getModalContent());$.each($h.MODAL_EVENTS,function(key,event){self._listenModalEvent(event);});},_initZoomButtons:function(){var self=this,previewId=self.$modal.data('previewId')||'',$first,$last,thumbs=self.getFrames().toArray(),len=thumbs.length,$prev=self.$modal.find('.btn-prev'),$next=self.$modal.find('.btn-next');if(thumbs.length<2){$prev.hide();$next.hide();return;}else{$prev.show();$next.show();}if(!len){return;}$first=$(thumbs[0]);$last=$(thumbs[len-1]);$prev.removeAttr('disabled');$next.removeAttr('disabled');if($first.length&&$first.attr('id')===previewId){$prev.attr('disabled',true);}if($last.length&&$last.attr('id')===previewId){$next.attr('disabled',true);}},_maximizeZoomDialog:function(){var self=this,$modal=self.$modal,$head=$modal.find('.modal-header:visible'),$foot=$modal.find('.modal-footer:visible'),$body=$modal.find('.modal-body'),h=$(window).height(),diff=0;$modal.addClass('file-zoom-fullscreen');if($head&&$head.length){h-=$head.outerHeight(true);}if($foot&&$foot.length){h-=$foot.outerHeight(true);}if($body&&$body.length){diff=$body.outerHeight(true)-$body.height();h-=diff;}$modal.find('.kv-zoom-body').height(h);},_resizeZoomDialog:function(fullScreen){var self=this,$modal=self.$modal,$btnFull=$modal.find('.btn-fullscreen'),$btnBord=$modal.find('.btn-borderless');if($modal.hasClass('file-zoom-fullscreen')){$h.toggleFullScreen(false);if(!fullScreen){if(!$btnFull.hasClass('active')){$modal.removeClass('file-zoom-fullscreen');self.$modal.find('.kv-zoom-body').css('height',self.zoomModalHeight);}else{$btnFull.removeClass('active').attr('aria-pressed','false');}}else{if(!$btnFull.hasClass('active')){$modal.removeClass('file-zoom-fullscreen');self._resizeZoomDialog(true);if($btnBord.hasClass('active')){$btnBord.removeClass('active').attr('aria-pressed','false');}}}}else{if(!fullScreen){self._maximizeZoomDialog();return;}$h.toggleFullScreen(true);}$modal.focus();},_setZoomContent:function($frame,animate){var self=this,$content,tmplt,body,title,$body,$dataEl,config,previewId=$frame.attr('id'),$zoomPreview=self.$preview.find('#zoom-'+previewId),$modal=self.$modal,$tmp,$btnFull=$modal.find('.btn-fullscreen'),$btnBord=$modal.find('.btn-borderless'),cap,size,$btnTogh=$modal.find('.btn-toggleheader');tmplt=$zoomPreview.attr('data-template')||'generic';$content=$zoomPreview.find('.kv-file-content');body=$content.length?$content.html():'';cap=$frame.data('caption')||'';size=$frame.data('size')||'';title=cap+' '+size;$modal.find('.kv-zoom-title').attr('title',$('
    ').html(title).text()).html(title);$body=$modal.find('.kv-zoom-body');$modal.removeClass('kv-single-content');if(animate){$tmp=$body.addClass('file-thumb-loading').clone().insertAfter($body);$body.html(body).hide();$tmp.fadeOut('fast',function(){$body.fadeIn('fast',function(){$body.removeClass('file-thumb-loading');});$tmp.remove();});}else{$body.html(body);}config=self.previewZoomSettings[tmplt];if(config){$dataEl=$body.find('.kv-preview-data');$h.addCss($dataEl,'file-zoom-detail');$.each(config,function(key,value){$dataEl.css(key,value);if(($dataEl.attr('width')&&key==='width')||($dataEl.attr('height')&&key==='height')){$dataEl.removeAttr(key);}});}$modal.data('previewId',previewId);self._handler($modal.find('.btn-prev'),'click',function(){self._zoomSlideShow('prev',previewId);});self._handler($modal.find('.btn-next'),'click',function(){self._zoomSlideShow('next',previewId);});self._handler($btnFull,'click',function(){self._resizeZoomDialog(true);});self._handler($btnBord,'click',function(){self._resizeZoomDialog(false);});self._handler($btnTogh,'click',function(){var $header=$modal.find('.modal-header'),$floatBar=$modal.find('.modal-body .floating-buttons'),ht,$actions=$header.find('.kv-zoom-actions'),resize=function(height){var $body=self.$modal.find('.kv-zoom-body'),h=self.zoomModalHeight;if($modal.hasClass('file-zoom-fullscreen')){h=$body.outerHeight(true);if(!height){h=h-$header.outerHeight(true);}}$body.css('height',height?h+height:h);};if($header.is(':visible')){ht=$header.outerHeight(true);$header.slideUp('slow',function(){$actions.find('.btn').appendTo($floatBar);resize(ht);});}else{$floatBar.find('.btn').appendTo($actions);$header.slideDown('slow',function(){resize();});}$modal.focus();});self._handler($modal,'keydown',function(e){var key=e.which||e.keyCode,$prev=$(this).find('.btn-prev'),$next=$(this).find('.btn-next'),vId=$(this).data('previewId'),vPrevKey=self.rtl?39:37,vNextKey=self.rtl?37:39;if(key===vPrevKey&&$prev.length&&!$prev.attr('disabled')){self._zoomSlideShow('prev',vId);}if(key===vNextKey&&$next.length&&!$next.attr('disabled')){self._zoomSlideShow('next',vId);}});},_zoomPreview:function($btn){var self=this,$frame,$modal=self.$modal;if(!$btn.length){throw'Cannot zoom to detailed preview!';}$h.initModal($modal);$modal.html(self._getModalContent());$frame=$btn.closest($h.FRAMES);self._setZoomContent($frame);$modal.modal('show');self._initZoomButtons();},_zoomSlideShow:function(dir,previewId){var self=this,$btn=self.$modal.find('.kv-zoom-actions .btn-'+dir),$targFrame,i,thumbs=self.getFrames().toArray(),len=thumbs.length,out;if($btn.attr('disabled')){return;}for(i=0;i=len||!thumbs[out]){return;}$targFrame=$(thumbs[out]);if($targFrame.length){self._setZoomContent($targFrame,true);}self._initZoomButtons();self._raise('filezoom'+dir,{'previewId':previewId,modal:self.$modal});},_initZoomButton:function(){var self=this;self.$preview.find('.kv-file-zoom').each(function(){var $el=$(this);self._handler($el,'click',function(){self._zoomPreview($el);});});},_inputFileCount:function(){return this.$element.get(0).files.length;},_refreshPreview:function(){var self=this,files;if((!self._inputFileCount()&&!self.isAjaxUpload)||!self.showPreview||!self.isPreviewable){return;}if(self.isAjaxUpload){if(self.fileManager.count()>0){files=$.extend(true,{},self.fileManager.stack);self.fileManager.clear();self._clearFileInput();}else{files=self.$element.get(0).files;}}else{files=self.$element.get(0).files;}if(files&&files.length){self.readFiles(files);self._setFileDropZoneTitle();}},_clearObjects:function($el){$el.find('video audio').each(function(){this.pause();$(this).remove();});$el.find('img object div').each(function(){$(this).remove();});},_clearFileInput:function(){var self=this,$el=self.$element,$srcFrm,$tmpFrm,$tmpEl;if(!self._inputFileCount()){return;}$srcFrm=$el.closest('form');$tmpFrm=$(document.createElement('form'));$tmpEl=$(document.createElement('div'));$el.before($tmpEl);if($srcFrm.length){$srcFrm.after($tmpFrm);}else{$tmpEl.after($tmpFrm);}$tmpFrm.append($el).trigger('reset');$tmpEl.before($el).remove();$tmpFrm.remove();},_resetUpload:function(){var self=this;self.uploadCache={content:[],config:[],tags:[],append:true};self.$btnUpload.removeAttr('disabled');self._setProgress(0);self.$progress.hide();self._resetErrors(false);self._initAjax();self.fileManager.clearImages();self._resetCanvas();self.cacheInitialPreview={};if(self.overwriteInitial){self.initialPreview=[];self.initialPreviewConfig=[];self.initialPreviewThumbTags=[];self.previewCache.data={content:[],config:[],tags:[]};}},_resetCanvas:function(){var self=this;if(self.canvas&&self.imageCanvasContext){self.imageCanvasContext.clearRect(0,0,self.canvas.width,self.canvas.height);}},_hasInitialPreview:function(){var self=this;return!self.overwriteInitial&&self.previewCache.count(true);},_resetPreview:function(){var self=this,out,cap;if(self.previewCache.count(true)){out=self.previewCache.out();self._setPreviewContent(out.content);self._setInitThumbAttr();cap=self.initialCaption?self.initialCaption:out.caption;self._setCaption(cap);}else{self._clearPreview();self._initCaption();}if(self.showPreview){self._initZoom();self._initSortable();}},_clearDefaultPreview:function(){var self=this;self.$preview.find('.file-default-preview').remove();},_validateDefaultPreview:function(){var self=this;if(!self.showPreview||$h.isEmpty(self.defaultPreviewContent)){return;}self._setPreviewContent('
    '+self.defaultPreviewContent+'
    ');self.$container.removeClass('file-input-new');self._initClickable();},_resetPreviewThumbs:function(isAjax){var self=this,out;if(isAjax){self._clearPreview();self.clearFileStack();return;}if(self._hasInitialPreview()){out=self.previewCache.out();self._setPreviewContent(out.content);self._setInitThumbAttr();self._setCaption(out.caption);self._initPreviewActions();}else{self._clearPreview();}},_getLayoutTemplate:function(t){var self=this,template=self.layoutTemplates[t];if($h.isEmpty(self.customLayoutTags)){return template;}return $h.replaceTags(template,self.customLayoutTags);},_getPreviewTemplate:function(t){var self=this,template=self.previewTemplates[t];if($h.isEmpty(self.customPreviewTags)){return template;}return $h.replaceTags(template,self.customPreviewTags);},_getOutData:function(formdata,jqXHR,responseData,filesData){var self=this;jqXHR=jqXHR||{};responseData=responseData||{};filesData=filesData||self.fileManager.list();return{formdata:formdata,files:filesData,filenames:self.filenames,filescount:self.getFilesCount(),extra:self._getExtraData(),response:responseData,reader:self.reader,jqXHR:jqXHR};},_getMsgSelected:function(n){var self=this,strFiles=n===1?self.fileSingle:self.filePlural;return n>0?self.msgSelected.replace('{n}',n).replace('{files}',strFiles):self.msgNoFilesSelected;},_getFrame:function(id){var self=this,$frame=$('#'+id);if(!$frame.length){self._log($h.logMessages.invalidThumb,{id:id});return null;}return $frame;},_getThumbs:function(css){css=css||'';return this.getFrames(':not(.file-preview-initial)'+css);},_getExtraData:function(fileId,index){var self=this,data=self.uploadExtraData;if(typeof self.uploadExtraData==='function'){data=self.uploadExtraData(fileId,index);}return data;},_initXhr:function(xhrobj,fileId,fileCount){var self=this,fm=self.fileManager,func=function(event){var pct=0,total=event.total,loaded=event.loaded||event.position,stats=fm.getUploadStats(fileId,loaded,total);if(event.lengthComputable&&!self.enableResumableUpload){pct=$h.round(loaded/total*100);}if(fileId){self._setFileUploadStats(fileId,pct,fileCount,stats);}else{self._setProgress(pct,null,null,self._getStats(stats));}self._raise('fileajaxprogress',[stats]);};if(xhrobj.upload){if(self.progressDelay){func=$h.debounce(func,self.progressDelay);}xhrobj.upload.addEventListener('progress',func,false);}return xhrobj;},_initAjaxSettings:function(){var self=this;self._ajaxSettings=$.extend(true,{},self.ajaxSettings);self._ajaxDeleteSettings=$.extend(true,{},self.ajaxDeleteSettings);},_mergeAjaxCallback:function(funcName,srcFunc,type){var self=this,settings=self._ajaxSettings,flag=self.mergeAjaxCallbacks,targFunc;if(type==='delete'){settings=self._ajaxDeleteSettings;flag=self.mergeAjaxDeleteCallbacks;}targFunc=settings[funcName];if(flag&&typeof targFunc==='function'){if(flag==='before'){settings[funcName]=function(){targFunc.apply(this,arguments);srcFunc.apply(this,arguments);};}else{settings[funcName]=function(){srcFunc.apply(this,arguments);targFunc.apply(this,arguments);};}}else{settings[funcName]=srcFunc;}},_ajaxSubmit:function(fnBefore,fnSuccess,fnComplete,fnError,formdata,fileId,index,vUrl){var self=this,settings,defaults,data,processQueue;if(!self._raise('filepreajax',[formdata,fileId,index])){return;}formdata.append('initialPreview',JSON.stringify(self.initialPreview));formdata.append('initialPreviewConfig',JSON.stringify(self.initialPreviewConfig));formdata.append('initialPreviewThumbTags',JSON.stringify(self.initialPreviewThumbTags));self._initAjaxSettings();self._mergeAjaxCallback('beforeSend',fnBefore);self._mergeAjaxCallback('success',fnSuccess);self._mergeAjaxCallback('complete',fnComplete);self._mergeAjaxCallback('error',fnError);vUrl=vUrl||self.uploadUrlThumb||self.uploadUrl;if(typeof vUrl==='function'){vUrl=vUrl();}data=self._getExtraData(fileId,index)||{};if(typeof data==='object'){$.each(data,function(key,value){formdata.append(key,value);});}defaults={xhr:function(){var xhrobj=$.ajaxSettings.xhr();return self._initXhr(xhrobj,fileId,self.fileManager.count());},url:self._encodeURI(vUrl),type:'POST',dataType:'json',data:formdata,cache:false,processData:false,contentType:false};settings=$.extend(true,{},defaults,self._ajaxSettings);self.ajaxQueue.push(settings);processQueue=function(){var config,xhr;if(self.ajaxCurrentThreads0){self.hasInitData=true;content=out.initialPreview||[];config=out.initialPreviewConfig||[];tags=out.initialPreviewThumbTags||[];append=out.append===undefined||out.append;if(content.length>0&&!$h.isArray(content)){content=content.split(self.initialPreviewDelimiter);}if(content.length){self._mergeArray('initialPreview',content);self._mergeArray('initialPreviewConfig',config);self._mergeArray('initialPreviewThumbTags',tags);}if($thumb!==undefined){if(!allFiles){index=self.previewCache.add(content[0],config[0],tags[0],append);data=self.previewCache.get(index,false);$div=$(document.createElement('div')).html(data).hide().insertAfter($thumb);$newCache=$div.find('.kv-zoom-cache');if($newCache&&$newCache.length){$newCache.insertAfter($thumb);}$thumb.fadeOut('slow',function(){var $newThumb=$div.find('.file-preview-frame');if($newThumb&&$newThumb.length){$newThumb.insertBefore($thumb).fadeIn('slow').css('display:inline-block');}self._initPreviewActions();self._clearFileInput();$h.cleanZoomCache(self.$preview.find('#zoom-'+$thumb.attr('id')));$thumb.remove();$div.remove();self._initSortable();});}else{i=$thumb.attr('data-fileindex');self.uploadCache.content[i]=content[0];self.uploadCache.config[i]=config[0]||[];self.uploadCache.tags[i]=tags[0]||[];self.uploadCache.append=append;}}else{self.previewCache.set(content,config,tags,append);self._initPreview();self._initPreviewActions();}}},_initSuccessThumbs:function(){var self=this;if(!self.showPreview){return;}self._getThumbs($h.FRAMES+'.file-preview-success').each(function(){var $thumb=$(this),$preview=self.$preview,$remove=$thumb.find('.kv-file-remove');$remove.removeAttr('disabled');self._handler($remove,'click',function(){var id=$thumb.attr('id'),out=self._raise('filesuccessremove',[id,$thumb.attr('data-fileindex')]);$h.cleanMemory($thumb);if(out===false){return;}$thumb.fadeOut('slow',function(){$h.cleanZoomCache($preview.find('#zoom-'+id));$thumb.remove();if(!self.getFrames().length){self.reset();}});});});},_updateInitialPreview:function(){var self=this,u=self.uploadCache,i,j,len=0,data=self.cacheInitialPreview;if(data&&data.content){len=data.content.length;}if(self.showPreview){self.previewCache.set(u.content,u.config,u.tags,u.append);if(len){for(i=0;i0||!$.isEmptyObject(self.uploadExtraData),uploadFailed,$prog,fnBefore,errMsg,fnSuccess,fnComplete,fnError,updateUploadLog,op=self.ajaxOperations.uploadThumb,fileObj=fm.getFile(id),params={id:previewId,index:i,fileId:id},fileName=self.fileManager.getFileName(id,true);if(self.enableResumableUpload){return;}if(self.showPreview){$thumb=self.fileManager.getThumb(id);$prog=$thumb.find('.file-thumb-progress');$btnUpload=$thumb.find('.kv-file-upload');$btnDelete=$thumb.find('.kv-file-remove');$prog.show();}if(count===0||!hasPostData||(self.showPreview&&$btnUpload&&$btnUpload.hasClass('disabled'))||self._abort(params)){return;}updateUploadLog=function(){if(!uploadFailed){fm.removeFile(id);}else{fm.errors.push(id);}fm.setProcessed(id);if(fm.isProcessed()){self.fileBatchCompleted=true;}};chkComplete=function(){var $initThumbs;if(!self.fileBatchCompleted){return;}setTimeout(function(){var triggerReset=fm.count()===0,errCount=fm.errors.length;self._updateInitialPreview();self.unlock(triggerReset);if(triggerReset){self._clearFileInput();}$initThumbs=self.$preview.find('.file-preview-initial');if(self.uploadAsync&&$initThumbs.length){$h.addCss($initThumbs,$h.SORT_CSS);self._initSortable();}self._raise('filebatchuploadcomplete',[fm.stack,self._getExtraData()]);if(!self.retryErrorUploads||errCount===0){fm.clear();}self._setProgress(101);self.ajaxAborted=false;},self.processDelay);};fnBefore=function(jqXHR){outData=self._getOutData(formdata,jqXHR);fm.initStats(id);self.fileBatchCompleted=false;if(!isBatch){self.ajaxAborted=false;}if(self.showPreview){if(!$thumb.hasClass('file-preview-success')){self._setThumbStatus($thumb,'Loading');$h.addCss($thumb,'file-uploading');}$btnUpload.attr('disabled',true);$btnDelete.attr('disabled',true);}if(!isBatch){self.lock();}if(fm.errors.indexOf(id)!==-1){delete fm.errors[id];}self._raise('filepreupload',[outData,previewId,i]);$.extend(true,params,outData);if(self._abort(params)){jqXHR.abort();if(!isBatch){self._setThumbStatus($thumb,'New');$thumb.removeClass('file-uploading');$btnUpload.removeAttr('disabled');$btnDelete.removeAttr('disabled');self.unlock();}self._setProgressCancelled();}};fnSuccess=function(data,textStatus,jqXHR){var pid=self.showPreview&&$thumb.attr('id')?$thumb.attr('id'):previewId;outData=self._getOutData(formdata,jqXHR,data);$.extend(true,params,outData);setTimeout(function(){if($h.isEmpty(data)||$h.isEmpty(data.error)){if(self.showPreview){self._setThumbStatus($thumb,'Success');$btnUpload.hide();self._initUploadSuccess(data,$thumb,isBatch);self._setProgress(101,$prog);}self._raise('fileuploaded',[outData,pid,i]);if(!isBatch){self.fileManager.remove($thumb);}else{updateUploadLog();}}else{uploadFailed=true;errMsg=self._parseError(op,jqXHR,self.msgUploadError,self.fileManager.getFileName(id));self._showFileError(errMsg,params);self._setPreviewError($thumb,true);if(!self.retryErrorUploads){$btnUpload.hide();}if(isBatch){updateUploadLog();}self._setProgress(101,$('#'+pid).find('.file-thumb-progress'),self.msgUploadError);}},self.processDelay);};fnComplete=function(){setTimeout(function(){if(self.showPreview){$btnUpload.removeAttr('disabled');$btnDelete.removeAttr('disabled');$thumb.removeClass('file-uploading');}if(!isBatch){self.unlock(false);self._clearFileInput();}else{chkComplete();}self._initSuccessThumbs();},self.processDelay);};fnError=function(jqXHR,textStatus,errorThrown){errMsg=self._parseError(op,jqXHR,errorThrown,self.fileManager.getFileName(id));uploadFailed=true;setTimeout(function(){if(isBatch){updateUploadLog();}self.fileManager.setProgress(id,100);self._setPreviewError($thumb,true);if(!self.retryErrorUploads){$btnUpload.hide();}$.extend(true,params,self._getOutData(formdata,jqXHR));self._setProgress(101,$prog,self.msgAjaxProgressError.replace('{operation}',op));self._setProgress(101,$thumb.find('.file-thumb-progress'),self.msgUploadError);self._showFileError(errMsg,params);},self.processDelay);};formdata.append(self.uploadFileAttr,fileObj.file,fileName);self._setUploadData(formdata,{fileId:id});self._ajaxSubmit(fnBefore,fnSuccess,fnComplete,fnError,formdata,id,i);},_uploadBatch:function(){var self=this,fm=self.fileManager,total=fm.total(),params={},fnBefore,fnSuccess,fnError,fnComplete,hasPostData=total>0||!$.isEmptyObject(self.uploadExtraData),errMsg,setAllUploaded,formdata=new FormData(),op=self.ajaxOperations.uploadBatch;if(total===0||!hasPostData||self._abort(params)){return;}setAllUploaded=function(){self.fileManager.clear();self._clearFileInput();};fnBefore=function(jqXHR){self.lock();fm.initStats();var outData=self._getOutData(formdata,jqXHR);self.ajaxAborted=false;if(self.showPreview){self._getThumbs().each(function(){var $thumb=$(this),$btnUpload=$thumb.find('.kv-file-upload'),$btnDelete=$thumb.find('.kv-file-remove');if(!$thumb.hasClass('file-preview-success')){self._setThumbStatus($thumb,'Loading');$h.addCss($thumb,'file-uploading');}$btnUpload.attr('disabled',true);$btnDelete.attr('disabled',true);});}self._raise('filebatchpreupload',[outData]);if(self._abort(outData)){jqXHR.abort();self._getThumbs().each(function(){var $thumb=$(this),$btnUpload=$thumb.find('.kv-file-upload'),$btnDelete=$thumb.find('.kv-file-remove');if($thumb.hasClass('file-preview-loading')){self._setThumbStatus($thumb,'New');$thumb.removeClass('file-uploading');}$btnUpload.removeAttr('disabled');$btnDelete.removeAttr('disabled');});self._setProgressCancelled();}};fnSuccess=function(data,textStatus,jqXHR){var outData=self._getOutData(formdata,jqXHR,data),key=0,$thumbs=self._getThumbs(':not(.file-preview-success)'),keys=$h.isEmpty(data)||$h.isEmpty(data.errorkeys)?[]:data.errorkeys;if($h.isEmpty(data)||$h.isEmpty(data.error)){self._raise('filebatchuploadsuccess',[outData]);setAllUploaded();if(self.showPreview){$thumbs.each(function(){var $thumb=$(this);self._setThumbStatus($thumb,'Success');$thumb.removeClass('file-uploading');$thumb.find('.kv-file-upload').hide().removeAttr('disabled');});self._initUploadSuccess(data);}else{self.reset();}self._setProgress(101);}else{if(self.showPreview){$thumbs.each(function(){var $thumb=$(this);$thumb.removeClass('file-uploading');$thumb.find('.kv-file-upload').removeAttr('disabled');$thumb.find('.kv-file-remove').removeAttr('disabled');if(keys.length===0||$.inArray(key,keys)!==-1){self._setPreviewError($thumb,true);if(!self.retryErrorUploads){$thumb.find('.kv-file-upload').hide();self.fileManager.remove($thumb);}}else{$thumb.find('.kv-file-upload').hide();self._setThumbStatus($thumb,'Success');self.fileManager.remove($thumb);}if(!$thumb.hasClass('file-preview-error')||self.retryErrorUploads){key++;}});self._initUploadSuccess(data);}errMsg=self._parseError(op,jqXHR,self.msgUploadError);self._showFileError(errMsg,outData,'filebatchuploaderror');self._setProgress(101,self.$progress,self.msgUploadError);}};fnComplete=function(){self.unlock();self._initSuccessThumbs();self._clearFileInput();self._raise('filebatchuploadcomplete',[self.fileManager.stack,self._getExtraData()]);};fnError=function(jqXHR,textStatus,errorThrown){var outData=self._getOutData(formdata,jqXHR);errMsg=self._parseError(op,jqXHR,errorThrown);self._showFileError(errMsg,outData,'filebatchuploaderror');self.uploadFileCount=total-1;if(!self.showPreview){return;}self._getThumbs().each(function(){var $thumb=$(this);$thumb.removeClass('file-uploading');if(self.fileManager.getFile($thumb.attr('data-fileid'))){self._setPreviewError($thumb);}});self._getThumbs().removeClass('file-uploading');self._getThumbs(' .kv-file-upload').removeAttr('disabled');self._getThumbs(' .kv-file-delete').removeAttr('disabled');self._setProgress(101,self.$progress,self.msgAjaxProgressError.replace('{operation}',op));};var ctr=0;$.each(self.fileManager.stack,function(key,data){if(!$h.isEmpty(data.file)){formdata.append(self.uploadFileAttr,data.file,(data.nameFmt||('untitled_'+ctr)));}ctr++;});self._ajaxSubmit(fnBefore,fnSuccess,fnComplete,fnError,formdata);},_uploadExtraOnly:function(){var self=this,params={},fnBefore,fnSuccess,fnComplete,fnError,formdata=new FormData(),errMsg,op=self.ajaxOperations.uploadExtra;if(self._abort(params)){return;}fnBefore=function(jqXHR){self.lock();var outData=self._getOutData(formdata,jqXHR);self._raise('filebatchpreupload',[outData]);self._setProgress(50);params.data=outData;params.xhr=jqXHR;if(self._abort(params)){jqXHR.abort();self._setProgressCancelled();}};fnSuccess=function(data,textStatus,jqXHR){var outData=self._getOutData(formdata,jqXHR,data);if($h.isEmpty(data)||$h.isEmpty(data.error)){self._raise('filebatchuploadsuccess',[outData]);self._clearFileInput();self._initUploadSuccess(data);self._setProgress(101);}else{errMsg=self._parseError(op,jqXHR,self.msgUploadError);self._showFileError(errMsg,outData,'filebatchuploaderror');}};fnComplete=function(){self.unlock();self._clearFileInput();self._raise('filebatchuploadcomplete',[self.fileManager.stack,self._getExtraData()]);};fnError=function(jqXHR,textStatus,errorThrown){var outData=self._getOutData(formdata,jqXHR);errMsg=self._parseError(op,jqXHR,errorThrown);params.data=outData;self._showFileError(errMsg,outData,'filebatchuploaderror');self._setProgress(101,self.$progress,self.msgAjaxProgressError.replace('{operation}',op));};self._ajaxSubmit(fnBefore,fnSuccess,fnComplete,fnError,formdata);},_deleteFileIndex:function($frame){var self=this,ind=$frame.attr('data-fileindex'),rev=self.reversePreviewOrder;if(ind.substring(0,5)==='init_'){ind=parseInt(ind.replace('init_',''));self.initialPreview=$h.spliceArray(self.initialPreview,ind,rev);self.initialPreviewConfig=$h.spliceArray(self.initialPreviewConfig,ind,rev);self.initialPreviewThumbTags=$h.spliceArray(self.initialPreviewThumbTags,ind,rev);self.getFrames().each(function(){var $nFrame=$(this),nInd=$nFrame.attr('data-fileindex');if(nInd.substring(0,5)==='init_'){nInd=parseInt(nInd.replace('init_',''));if(nInd>ind){nInd--;$nFrame.attr('data-fileindex','init_'+nInd);}}});if(self.uploadAsync||self.enableResumableUpload){self.cacheInitialPreview=self.getPreview();}}},_initFileActions:function(){var self=this,$preview=self.$preview;if(!self.showPreview){return;}self._initZoomButton();self.getFrames(' .kv-file-remove').each(function(){var $el=$(this),$frame=$el.closest($h.FRAMES),hasError,id=$frame.attr('id'),ind=$frame.attr('data-fileindex'),n,cap,status;self._handler($el,'click',function(){status=self._raise('filepreremove',[id,ind]);if(status===false||!self._validateMinCount()){return false;}hasError=$frame.hasClass('file-preview-error');$h.cleanMemory($frame);$frame.fadeOut('slow',function(){$h.cleanZoomCache($preview.find('#zoom-'+id));self.fileManager.remove($frame);self._clearObjects($frame);$frame.remove();if(id&&hasError){self.$errorContainer.find('li[data-thumb-id="'+id+'"]').fadeOut('fast',function(){$(this).remove();if(!self._errorsExist()){self._resetErrors();}});}self._clearFileInput();var chk=self.previewCache.count(true),len=self.fileManager.count(),file,hasThumb=self.showPreview&&self.getFrames().length;if(len===0&&chk===0&&!hasThumb){self.reset();}else{n=chk+len;if(n>1){cap=self._getMsgSelected(n);}else{file=self.fileManager.getFirstFile();cap=file?file.nameFmt:'_';}self._setCaption(cap);}self._raise('fileremoved',[id,ind]);});});});self.getFrames(' .kv-file-upload').each(function(){var $el=$(this);self._handler($el,'click',function(){var $frame=$el.closest($h.FRAMES),id=$frame.attr('data-fileid');self.$progress.hide();if($frame.hasClass('file-preview-error')&&!self.retryErrorUploads){return;}self._uploadSingle(self.fileManager.getIndex(id),id,false);});});},_initPreviewActions:function(){var self=this,$preview=self.$preview,deleteExtraData=self.deleteExtraData||{},btnRemove=$h.FRAMES+' .kv-file-remove',settings=self.fileActionSettings,origClass=settings.removeClass,errClass=settings.removeErrorClass,resetProgress=function(){var hasFiles=self.isAjaxUpload?self.previewCache.count(true):self._inputFileCount();if(!self.getFrames().length&&!hasFiles){self._setCaption('');self.reset();self.initialCaption='';}};self._initZoomButton();$preview.find(btnRemove).each(function(){var $el=$(this),vUrl=$el.data('url')||self.deleteUrl,vKey=$el.data('key'),errMsg,fnBefore,fnSuccess,fnError,op=self.ajaxOperations.deleteThumb;if($h.isEmpty(vUrl)||vKey===undefined){return;}if(typeof vUrl==='function'){vUrl=vUrl();}var $frame=$el.closest($h.FRAMES),cache=self.previewCache.data,settings,params,config,fileName,extraData,index=$frame.attr('data-fileindex');index=parseInt(index.replace('init_',''));config=$h.isEmpty(cache.config)&&$h.isEmpty(cache.config[index])?null:cache.config[index];extraData=$h.isEmpty(config)||$h.isEmpty(config.extra)?deleteExtraData:config.extra;fileName=config.filename||config.caption||'';if(typeof extraData==='function'){extraData=extraData();}params={id:$el.attr('id'),key:vKey,extra:extraData};fnBefore=function(jqXHR){self.ajaxAborted=false;self._raise('filepredelete',[vKey,jqXHR,extraData]);if(self._abort()){jqXHR.abort();}else{$el.removeClass(errClass);$h.addCss($frame,'file-uploading');$h.addCss($el,'disabled '+origClass);}};fnSuccess=function(data,textStatus,jqXHR){var n,cap;if(!$h.isEmpty(data)&&!$h.isEmpty(data.error)){params.jqXHR=jqXHR;params.response=data;errMsg=self._parseError(op,jqXHR,self.msgDeleteError,fileName);self._showFileError(errMsg,params,'filedeleteerror');$frame.removeClass('file-uploading');$el.removeClass('disabled '+origClass).addClass(errClass);resetProgress();return;}$frame.removeClass('file-uploading').addClass('file-deleted');$frame.fadeOut('slow',function(){index=parseInt(($frame.attr('data-fileindex')).replace('init_',''));self.previewCache.unset(index);self._deleteFileIndex($frame);n=self.previewCache.count(true);cap=n>0?self._getMsgSelected(n):'';self._setCaption(cap);self._raise('filedeleted',[vKey,jqXHR,extraData]);$h.cleanZoomCache($preview.find('#zoom-'+$frame.attr('id')));self._clearObjects($frame);$frame.remove();resetProgress();});};fnError=function(jqXHR,textStatus,errorThrown){var errMsg=self._parseError(op,jqXHR,errorThrown,fileName);params.jqXHR=jqXHR;params.response={};self._showFileError(errMsg,params,'filedeleteerror');$frame.removeClass('file-uploading');$el.removeClass('disabled '+origClass).addClass(errClass);resetProgress();};self._initAjaxSettings();self._mergeAjaxCallback('beforeSend',fnBefore,'delete');self._mergeAjaxCallback('success',fnSuccess,'delete');self._mergeAjaxCallback('error',fnError,'delete');settings=$.extend(true,{},{url:self._encodeURI(vUrl),type:'POST',dataType:'json',data:$.extend(true,{},{key:vKey},extraData)},self._ajaxDeleteSettings);self._handler($el,'click',function(){if(!self._validateMinCount()){return false;}self.ajaxAborted=false;self._raise('filebeforedelete',[vKey,extraData]);if(self.ajaxAborted instanceof Promise){self.ajaxAborted.then(function(result){if(!result){$.ajax(settings);}});}else{if(!self.ajaxAborted){$.ajax(settings);}}});});},_hideFileIcon:function(){var self=this;if(self.overwriteInitial){self.$captionContainer.removeClass('icon-visible');}},_showFileIcon:function(){var self=this;$h.addCss(self.$captionContainer,'icon-visible');},_getSize:function(bytes,sizes){var self=this,size=parseFloat(bytes),i,func=self.fileSizeGetter,out;if(!$.isNumeric(bytes)||!$.isNumeric(size)){return'';}if(typeof func==='function'){out=func(size);}else{if(size===0){out='0.00 B';}else{i=Math.floor(Math.log(size)/Math.log(1024));if(!sizes){sizes=['B','KB','MB','GB','TB','PB','EB','ZB','YB'];}out=(size/Math.pow(1024,i)).toFixed(2)*1+' '+sizes[i];}}return self._getLayoutTemplate('size').replace('{sizeText}',out);},_getFileType:function(ftype){var self=this;return self.mimeTypeAliases[ftype]||ftype;},_generatePreviewTemplate:function(cat,data,fname,ftype,previewId,fileId,isError,size,frameClass,foot,ind,templ,attrs,zoomData){var self=this,caption=self.slug(fname),prevContent,zoomContent='',styleAttribs='',screenW=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,config,newCat=self.preferIconicPreview?'other':cat,title=caption,alt=caption,footer=foot||self._renderFileFooter(cat,caption,size,'auto',isError),hasIconSetting=self._getPreviewIcon(fname),typeCss='type-default',forcePrevIcon=hasIconSetting&&self.preferIconicPreview,forceZoomIcon=hasIconSetting&&self.preferIconicZoomPreview,getContent;config=screenW<400?(self.previewSettingsSmall[newCat]||self.defaults.previewSettingsSmall[newCat]):(self.previewSettings[newCat]||self.defaults.previewSettings[newCat]);if(config){$.each(config,function(key,val){styleAttribs+=key+':'+val+';';});}getContent=function(c,d,zoom,frameCss){var id=zoom?'zoom-'+previewId:previewId,tmplt=self._getPreviewTemplate(c),css=(frameClass||'')+' '+frameCss;if(self.frameClass){css=self.frameClass+' '+css;}if(zoom){css=css.replace(' '+$h.SORT_CSS,'');}tmplt=self._parseFilePreviewIcon(tmplt,fname);if(c==='text'){d=$h.htmlEncode(d);}if(cat==='object'&&!ftype){$.each(self.defaults.fileTypeSettings,function(key,func){if(key==='object'||key==='other'){return;}if(func(fname,ftype)){typeCss='type-'+key;}});}if(!$h.isEmpty(attrs)){if(attrs.title!==undefined&&attrs.title!==null){title=attrs.title;}if(attrs.alt!==undefined&&attrs.alt!==null){title=attrs.alt;}}return tmplt.setTokens({'previewId':id,'caption':caption,'title':title,'alt':alt,'frameClass':css,'type':self._getFileType(ftype),'fileindex':ind,'fileid':fileId||'','typeCss':typeCss,'footer':footer,'data':d,'template':templ||cat,'style':styleAttribs?'style="'+styleAttribs+'"':''});};ind=ind||previewId.slice(previewId.lastIndexOf('-')+1);if(self.fileActionSettings.showZoom){zoomContent=getContent((forceZoomIcon?'other':cat),zoomData?zoomData:data,true,'kv-zoom-thumb');}zoomContent='\n'+self._getLayoutTemplate('zoomCache').replace('{zoomContent}',zoomContent);if(typeof self.sanitizeZoomCache==='function'){zoomContent=self.sanitizeZoomCache(zoomContent);}prevContent=getContent((forcePrevIcon?'other':cat),data,false,'kv-preview-thumb');return prevContent+zoomContent;},_addToPreview:function($preview,content){var self=this;return self.reversePreviewOrder?$preview.prepend(content):$preview.append(content);},_previewDefault:function(file,previewId,isDisabled){var self=this,$preview=self.$preview;if(!self.showPreview){return;}var fname=$h.getFileName(file),ftype=file?file.type:'',content,size=file.size||0,caption=self._getFileName(file,''),isError=isDisabled===true&&!self.isAjaxUpload,data=$h.createObjectURL(file),fileId=self.fileManager.getId(file);self._clearDefaultPreview();content=self._generatePreviewTemplate('other',data,fname,ftype,previewId,fileId,isError,size);self._addToPreview($preview,content);self._setThumbAttr(previewId,caption,size);if(isDisabled===true&&self.isAjaxUpload){self._setThumbStatus($('#'+previewId),'Error');}},canPreview:function(file){var self=this;if(!file||!self.showPreview||!self.$preview||!self.$preview.length){return false;}var name=file.name||'',type=file.type||'',size=(file.size||0)/1000,cat=self._parseFileType(type,name),allowedTypes,allowedMimes,allowedExts,skipPreview,types=self.allowedPreviewTypes,mimes=self.allowedPreviewMimeTypes,exts=self.allowedPreviewExtensions||[],dTypes=self.disabledPreviewTypes,dMimes=self.disabledPreviewMimeTypes,dExts=self.disabledPreviewExtensions||[],maxSize=self.maxFilePreviewSize&&parseFloat(self.maxFilePreviewSize)||0,expAllExt=new RegExp('\\.('+exts.join('|')+')$','i'),expDisExt=new RegExp('\\.('+dExts.join('|')+')$','i');allowedTypes=!types||types.indexOf(cat)!==-1;allowedMimes=!mimes||mimes.indexOf(type)!==-1;allowedExts=!exts.length||$h.compare(name,expAllExt);skipPreview=(dTypes&&dTypes.indexOf(cat)!==-1)||(dMimes&&dMimes.indexOf(type)!==-1)||(dExts.length&&$h.compare(name,expDisExt))||(maxSize&&!isNaN(maxSize)&&size>maxSize);return!skipPreview&&(allowedTypes||allowedMimes||allowedExts);},_previewFile:function(i,file,theFile,previewId,data,fileInfo){if(!this.showPreview){return;}var self=this,fname=$h.getFileName(file),ftype=fileInfo.type,caption=fileInfo.name,cat=self._parseFileType(ftype,fname),content,$preview=self.$preview,fsize=file.size||0,iData=(cat==='text'||cat==='html'||cat==='image')?theFile.target.result:data,fileId=self.fileManager.getId(file);if(cat==='html'&&self.purifyHtml&&window.DOMPurify){iData=window.DOMPurify.sanitize(iData);}content=self._generatePreviewTemplate(cat,iData,fname,ftype,previewId,fileId,false,fsize);self._clearDefaultPreview();self._addToPreview($preview,content);var $thumb=$preview.find('#'+previewId),$img=$thumb.find('img'),id=$thumb.attr('data-fileid');self._validateImageOrientation($img,file,previewId,id,caption,ftype,fsize,iData);self._setThumbAttr(previewId,caption,fsize);self._initSortable();},_setThumbAttr:function(id,caption,size){var self=this,$frame=$('#'+id);if($frame.length){size=size&&size>0?self._getSize(size):'';$frame.data({'caption':caption,'size':size});}},_setInitThumbAttr:function(){var self=this,data=self.previewCache.data,len=self.previewCache.count(true),config,caption,size,previewId;if(len===0){return;}for(var i=0;i&"']/g,'_');},_updateFileDetails:function(numFiles){var self=this,$el=self.$element,label,n,log,nFiles,file,name=($h.isIE(9)&&$h.findFileName($el.val()))||($el[0].files[0]&&$el[0].files[0].name);if(!name&&self.fileManager.count()>0){file=self.fileManager.getFirstFile();label=file.nameFmt;}else{label=name?self.slug(name):'_';}n=self.isAjaxUpload?self.fileManager.count():numFiles;nFiles=self.previewCache.count(true)+n;log=n===1?label:self._getMsgSelected(nFiles);if(self.isError){self.$previewContainer.removeClass('file-thumb-loading');self.$previewStatus.html('');self.$captionContainer.removeClass('icon-visible');}else{self._showFileIcon();}self._setCaption(log,self.isError);self.$container.removeClass('file-input-new file-input-ajax-new');if(arguments.length===1){self._raise('fileselect',[numFiles,label]);}if(self.previewCache.count(true)){self._initPreviewActions();}},_setThumbStatus:function($thumb,status){var self=this;if(!self.showPreview){return;}var icon='indicator'+status,msg=icon+'Title',css='file-preview-'+status.toLowerCase(),$indicator=$thumb.find('.file-upload-indicator'),config=self.fileActionSettings;$thumb.removeClass('file-preview-success file-preview-error file-preview-paused file-preview-loading');if(status==='Success'){$thumb.find('.file-drag-handle').remove();}$indicator.html(config[icon]);$indicator.attr('title',config[msg]);$thumb.addClass(css);if(status==='Error'&&!self.retryErrorUploads){$thumb.find('.kv-file-upload').attr('disabled',true);}},_setProgressCancelled:function(){var self=this;self._setProgress(101,self.$progress,self.msgCancelled);},_setProgress:function(p,$el,error,stats){var self=this;$el=$el||self.$progress;if(!$el.length){return;}var pct=Math.min(p,100),out,pctLimit=self.progressUploadThreshold,t=p<=100?self.progressTemplate:self.progressCompleteTemplate,template=pct<100?self.progressTemplate:(error?(self.paused?self.progressPauseTemplate:self.progressErrorTemplate):t);if(p>=100){stats='';}if(!$h.isEmpty(template)){if(pctLimit&&pct>pctLimit&&p<=100){out=template.setTokens({'percent':pctLimit,'status':self.msgUploadThreshold});}else{out=template.setTokens({'percent':pct,'status':(p>100?self.msgUploadEnd:pct+'%')});}stats=stats||'';out=out.setTokens({stats:stats});$el.html(out);if(error){$el.find('[role="progressbar"]').html(error);}}},_setFileDropZoneTitle:function(){var self=this,$zone=self.$container.find('.file-drop-zone'),title=self.dropZoneTitle,strFiles;if(self.isClickable){strFiles=$h.isEmpty(self.$element.attr('multiple'))?self.fileSingle:self.filePlural;title+=self.dropZoneClickTitle.replace('{files}',strFiles);}$zone.find('.'+self.dropZoneTitleClass).remove();if(!self.showPreview||$zone.length===0||self.fileManager.count()>0||!self.dropZoneEnabled||(!self.isAjaxUpload&&self.$element.files)){return;}if($zone.find($h.FRAMES).length===0&&$h.isEmpty(self.defaultPreviewContent)){$zone.prepend('
    '+title+'
    ');}self.$container.removeClass('file-input-new');$h.addCss(self.$container,'file-input-ajax-new');},_getStats:function(stats){var self=this,pendingTime,t;if(!self.showUploadStats||!stats||!stats.bitrate){return'';}t=self._getLayoutTemplate('stats');pendingTime=(!stats.elapsed||!stats.bps)?self.msgCalculatingTime:self.msgPendingTime.setTokens({time:$h.getElapsed(Math.ceil(stats.pendingBytes/stats.bps))});return t.setTokens({uploadSpeed:stats.bitrate,pendingTime:pendingTime});},_setResumableProgress:function(pct,stats,$thumb){var self=this,rm=self.resumableManager,obj=$thumb?rm:self,$prog=$thumb?$thumb.find('.file-thumb-progress'):null;if(obj.lastProgress===0){obj.lastProgress=pct;}if(pct0&&self._getFileCount(len-1)=limit:dim<=limit;if(isValid){return;}msg=self['msgImage'+type+chk].setTokens({'name':fname,'size':limit});self._showFileError(msg,params);self._setPreviewError($thumb);},_getExifObj:function(data){var self=this,exifObj=null,error=$h.logMessages.exifWarning;if(data.slice(0,23)!=='data:image/jpeg;base64,'&&data.slice(0,22)!=='data:image/jpg;base64,'){exifObj=null;return;}try{exifObj=window.piexif?window.piexif.load(data):null;}catch(err){exifObj=null;error=err&&err.message||'';}if(!exifObj){self._log($h.logMessages.badExifParser,{details:error});}return exifObj;},setImageOrientation:function($img,$zoomImg,value,$thumb){var self=this,invalidImg=!$img||!$img.length,invalidZoomImg=!$zoomImg||!$zoomImg.length,$mark,isHidden=false,$div,zoomOnly=invalidImg&&$thumb&&$thumb.attr('data-template')==='image',ev;if(invalidImg&&invalidZoomImg){return;}ev='load.fileinputimageorient';if(zoomOnly){$img=$zoomImg;$zoomImg=null;$img.css(self.previewSettings.image);$div=$(document.createElement('div')).appendTo($thumb.find('.kv-file-content'));$mark=$(document.createElement('span')).insertBefore($img);$img.css('visibility','hidden').removeClass('file-zoom-detail').appendTo($div);}else{isHidden=!$img.is(':visible');}$img.off(ev).on(ev,function(){if(isHidden){self.$preview.removeClass('hide-content');$thumb.find('.kv-file-content').css('visibility','hidden');}var img=$img.get(0),zoomImg=$zoomImg&&$zoomImg.length?$zoomImg.get(0):null,h=img.offsetHeight,w=img.offsetWidth,r=$h.getRotation(value);if(isHidden){$thumb.find('.kv-file-content').css('visibility','visible');self.$preview.addClass('hide-content');}$img.data('orientation',value);if(zoomImg){$zoomImg.data('orientation',value);}if(value<5){$h.setTransform(img,r);$h.setTransform(zoomImg,r);return;}var offsetAngle=Math.atan(w/h),origFactor=Math.sqrt(Math.pow(h,2)+Math.pow(w,2)),scale=!origFactor?1:(h/Math.cos(Math.PI/2+offsetAngle))/origFactor,s=' scale('+Math.abs(scale)+')';$h.setTransform(img,r+s);$h.setTransform(zoomImg,r+s);if(zoomOnly){$img.css('visibility','visible').insertAfter($mark).addClass('file-zoom-detail');$mark.remove();$div.remove();}});},_validateImageOrientation:function($img,file,previewId,fileId,caption,ftype,fsize,iData){var self=this,exifObj,value,autoOrientImage=self.autoOrientImage;exifObj=autoOrientImage?self._getExifObj(iData):null;value=exifObj?exifObj['0th'][piexif.ImageIFD.Orientation]:null;if(!value){self._validateImage(previewId,fileId,caption,ftype,fsize,iData,exifObj);return;}self.setImageOrientation($img,$('#zoom-'+previewId+' img'),value,$('#'+previewId));self._raise('fileimageoriented',{'$img':$img,'file':file});self._validateImage(previewId,fileId,caption,ftype,fsize,iData,exifObj);},_validateImage:function(previewId,fileId,fname,ftype,fsize,iData,exifObj){var self=this,$preview=self.$preview,params,w1,w2,$thumb=$preview.find('#'+previewId),i=$thumb.attr('data-fileindex'),$img=$thumb.find('img');fname=fname||'Untitled';$img.one('load',function(){w1=$thumb.width();w2=$preview.width();if(w1>w2){$img.css('width','100%');}params={ind:i,id:previewId,fileId:fileId};self._checkDimensions(i,'Small',$img,$thumb,fname,'Width',params);self._checkDimensions(i,'Small',$img,$thumb,fname,'Height',params);if(!self.resizeImage){self._checkDimensions(i,'Large',$img,$thumb,fname,'Width',params);self._checkDimensions(i,'Large',$img,$thumb,fname,'Height',params);}self._raise('fileimageloaded',[previewId]);self.fileManager.addImage(fileId,{ind:i,img:$img,thumb:$thumb,pid:previewId,typ:ftype,siz:fsize,validated:false,imgData:iData,exifObj:exifObj});$thumb.data('exif',exifObj);self._validateAllImages();}).one('error',function(){self._raise('fileimageloaderror',[previewId]);}).each(function(){if(this.complete){$(this).trigger('load');}else{if(this.error){$(this).trigger('error');}}});},_validateAllImages:function(){var self=this,counter={val:0},numImgs=self.fileManager.getImageCount(),fsize,minSize=self.resizeIfSizeMoreThan;if(numImgs!==self.fileManager.totalImages){return;}self._raise('fileimagesloaded');if(!self.resizeImage){return;}$.each(self.fileManager.loadedImages,function(id,config){if(!config.validated){fsize=config.siz;if(fsize&&fsize>minSize*1000){self._getResizedImage(id,config,counter,numImgs);}config.validated=true;}});},_getResizedImage:function(id,config,counter,numImgs){var self=this,img=$(config.img)[0],width=img.naturalWidth,height=img.naturalHeight,blob,ratio=1,maxWidth=self.maxImageWidth||width,maxHeight=self.maxImageHeight||height,isValidImage=!!(width&&height),chkWidth,chkHeight,canvas=self.imageCanvas,dataURI,context=self.imageCanvasContext,type=config.typ,pid=config.pid,ind=config.ind,$thumb=config.thumb,throwError,msg,exifObj=config.exifObj,exifStr,file,params,evParams;throwError=function(msg,params,ev){if(self.isAjaxUpload){self._showFileError(msg,params,ev);}else{self._showError(msg,params,ev);}self._setPreviewError($thumb);};file=self.fileManager.getFile(id);params={id:pid,'index':ind,fileId:id};evParams=[id,pid,ind];if(!file||!isValidImage||(width<=maxWidth&&height<=maxHeight)){if(isValidImage&&file){self._raise('fileimageresized',evParams);}counter.val++;if(counter.val===numImgs){self._raise('fileimagesresized');}if(!isValidImage){throwError(self.msgImageResizeError,params,'fileimageresizeerror');return;}}type=type||self.resizeDefaultImageType;chkWidth=width>maxWidth;chkHeight=height>maxHeight;if(self.resizePreference==='width'){ratio=chkWidth?maxWidth/width:(chkHeight?maxHeight/height:1);}else{ratio=chkHeight?maxHeight/height:(chkWidth?maxWidth/width:1);}self._resetCanvas();width*=ratio;height*=ratio;canvas.width=width;canvas.height=height;try{context.drawImage(img,0,0,width,height);dataURI=canvas.toDataURL(type,self.resizeQuality);if(exifObj){exifStr=window.piexif.dump(exifObj);dataURI=window.piexif.insert(exifStr,dataURI);}blob=$h.dataURI2Blob(dataURI);self.fileManager.setFile(id,blob);self._raise('fileimageresized',evParams);counter.val++;if(counter.val===numImgs){self._raise('fileimagesresized',[undefined,undefined]);}if(!(blob instanceof Blob)){throwError(self.msgImageResizeError,params,'fileimageresizeerror');}}catch(err){counter.val++;if(counter.val===numImgs){self._raise('fileimagesresized',[undefined,undefined]);}msg=self.msgImageResizeException.replace('{errors}',err.message);throwError(msg,params,'fileimageresizeexception');}},_initBrowse:function($container){var self=this,$el=self.$element;if(self.showBrowse){self.$btnFile=$container.find('.btn-file').append($el);}else{$el.appendTo($container).attr('tabindex',-1);$h.addCss($el,'file-no-browse');}},_initClickable:function(){var self=this,$zone,$tmpZone;if(!self.isClickable){return;}$zone=self.$dropZone;if(!self.isAjaxUpload){$tmpZone=self.$preview.find('.file-default-preview');if($tmpZone.length){$zone=$tmpZone;}}$h.addCss($zone,'clickable');$zone.attr('tabindex',-1);self._handler($zone,'click',function(e){var $tar=$(e.target);if(!$(self.elErrorContainer+':visible').length&&(!$tar.parents('.file-preview-thumbnails').length||$tar.parents('.file-default-preview').length)){self.$element.data('zoneClicked',true).trigger('click');$zone.blur();}});},_initCaption:function(){var self=this,cap=self.initialCaption||'';if(self.overwriteInitial||$h.isEmpty(cap)){self.$caption.val('');return false;}self._setCaption(cap);return true;},_setCaption:function(content,isError){var self=this,title,out,icon,n,cap,file;if(!self.$caption.length){return;}self.$captionContainer.removeClass('icon-visible');if(isError){title=$('
    '+self.msgValidationError+'
    ').text();n=self.fileManager.count();if(n){file=self.fileManager.getFirstFile();cap=n===1&&file?file.nameFmt:self._getMsgSelected(n);}else{cap=self._getMsgSelected(self.msgNo);}out=$h.isEmpty(content)?cap:content;icon=''+self.msgValidationErrorIcon+'';}else{if($h.isEmpty(content)){return;}title=$('
    '+content+'
    ').text();out=title;icon=self._getLayoutTemplate('fileIcon');}self.$captionContainer.addClass('icon-visible');self.$caption.attr('title',title).val(out);self.$captionIcon.html(icon);},_createContainer:function(){var self=this,attribs={'class':'file-input file-input-new'+(self.rtl?' kv-rtl':'')},$container=$(document.createElement('div')).attr(attribs).html(self._renderMain());$container.insertBefore(self.$element);self._initBrowse($container);if(self.theme){$container.addClass('theme-'+self.theme);}return $container;},_refreshContainer:function(){var self=this,$container=self.$container,$el=self.$element;$el.insertAfter($container);$container.html(self._renderMain());self._initBrowse($container);self._validateDisabled();},_validateDisabled:function(){var self=this;self.$caption.attr({readonly:self.isDisabled});},_renderMain:function(){var self=this,dropCss=self.dropZoneEnabled?' file-drop-zone':'file-drop-disabled',close=!self.showClose?'':self._getLayoutTemplate('close'),preview=!self.showPreview?'':self._getLayoutTemplate('preview').setTokens({'class':self.previewClass,'dropClass':dropCss}),css=self.isDisabled?self.captionClass+' file-caption-disabled':self.captionClass,caption=self.captionTemplate.setTokens({'class':css+' kv-fileinput-caption'});return self.mainTemplate.setTokens({'class':self.mainClass+(!self.showBrowse&&self.showCaption?' no-browse':''),'preview':preview,'close':close,'caption':caption,'upload':self._renderButton('upload'),'remove':self._renderButton('remove'),'cancel':self._renderButton('cancel'),'pause':self._renderButton('pause'),'browse':self._renderButton('browse')});},_renderButton:function(type){var self=this,tmplt=self._getLayoutTemplate('btnDefault'),css=self[type+'Class'],title=self[type+'Title'],icon=self[type+'Icon'],label=self[type+'Label'],status=self.isDisabled?' disabled':'',btnType='button';switch(type){case'remove':if(!self.showRemove){return'';}break;case'cancel':if(!self.showCancel){return'';}css+=' kv-hidden';break;case'pause':if(!self.showPause){return'';}css+=' kv-hidden';break;case'upload':if(!self.showUpload){return'';}if(self.isAjaxUpload&&!self.isDisabled){tmplt=self._getLayoutTemplate('btnLink').replace('{href}',self.uploadUrl);}else{btnType='submit';}break;case'browse':if(!self.showBrowse){return'';}tmplt=self._getLayoutTemplate('btnBrowse');break;default:return'';}css+=type==='browse'?' btn-file':' fileinput-'+type+' fileinput-'+type+'-button';if(!$h.isEmpty(label)){label=' '+label+'';}return tmplt.setTokens({'type':btnType,'css':css,'title':title,'status':status,'icon':icon,'label':label});},_renderThumbProgress:function(){var self=this;return'
    '+self.progressInfoTemplate.setTokens({percent:101,status:self.msgUploadBegin,stats:''})+'
    ';},_renderFileFooter:function(cat,caption,size,width,isError){var self=this,config=self.fileActionSettings,rem=config.showRemove,drg=config.showDrag,upl=config.showUpload,zoom=config.showZoom,out,params,template=self._getLayoutTemplate('footer'),tInd=self._getLayoutTemplate('indicator'),ind=isError?config.indicatorError:config.indicatorNew,title=isError?config.indicatorErrorTitle:config.indicatorNewTitle,indicator=tInd.setTokens({'indicator':ind,'indicatorTitle':title});size=self._getSize(size);params={type:cat,caption:caption,size:size,width:width,progress:'',indicator:indicator};if(self.isAjaxUpload){params.progress=self._renderThumbProgress();params.actions=self._renderFileActions(params,upl,false,rem,zoom,drg,false,false,false);}else{params.actions=self._renderFileActions(params,false,false,false,zoom,drg,false,false,false);}out=template.setTokens(params);out=$h.replaceTags(out,self.previewThumbTags);return out;},_renderFileActions:function(cfg,showUpl,showDwn,showDel,showZoom,showDrag,disabled,url,key,isInit,dUrl,dFile){var self=this;if(!cfg.type&&isInit){cfg.type='image';}if(self.enableResumableUpload){showUpl=false;}else{if(typeof showUpl==='function'){showUpl=showUpl(cfg);}}if(typeof showDwn==='function'){showDwn=showDwn(cfg);}if(typeof showDel==='function'){showDel=showDel(cfg);}if(typeof showZoom==='function'){showZoom=showZoom(cfg);}if(typeof showDrag==='function'){showDrag=showDrag(cfg);}if(!showUpl&&!showDwn&&!showDel&&!showZoom&&!showDrag){return'';}var vUrl=url===false?'':' data-url="'+url+'"',btnZoom='',btnDrag='',css,vKey=key===false?'':' data-key="'+key+'"',btnDelete='',btnUpload='',btnDownload='',template=self._getLayoutTemplate('actions'),config=self.fileActionSettings,otherButtons=self.otherActionButtons.setTokens({'dataKey':vKey,'key':key}),removeClass=disabled?config.removeClass+' disabled':config.removeClass;if(showDel){btnDelete=self._getLayoutTemplate('actionDelete').setTokens({'removeClass':removeClass,'removeIcon':config.removeIcon,'removeTitle':config.removeTitle,'dataUrl':vUrl,'dataKey':vKey,'key':key});}if(showUpl){btnUpload=self._getLayoutTemplate('actionUpload').setTokens({'uploadClass':config.uploadClass,'uploadIcon':config.uploadIcon,'uploadTitle':config.uploadTitle});}if(showDwn){btnDownload=self._getLayoutTemplate('actionDownload').setTokens({'downloadClass':config.downloadClass,'downloadIcon':config.downloadIcon,'downloadTitle':config.downloadTitle,'downloadUrl':dUrl||self.initialPreviewDownloadUrl});btnDownload=btnDownload.setTokens({'filename':dFile,'key':key});}if(showZoom){btnZoom=self._getLayoutTemplate('actionZoom').setTokens({'zoomClass':config.zoomClass,'zoomIcon':config.zoomIcon,'zoomTitle':config.zoomTitle});}if(showDrag&&isInit){css='drag-handle-init '+config.dragClass;btnDrag=self._getLayoutTemplate('actionDrag').setTokens({'dragClass':css,'dragTitle':config.dragTitle,'dragIcon':config.dragIcon});}return template.setTokens({'delete':btnDelete,'upload':btnUpload,'download':btnDownload,'zoom':btnZoom,'drag':btnDrag,'other':otherButtons});},_browse:function(e){var self=this;if(e&&e.isDefaultPrevented()||!self._raise('filebrowse')){return;}if(self.isError&&!self.isAjaxUpload){self.clear();}self.$captionContainer.focus();},_change:function(e){var self=this;if(self.changeTriggered){return;}var $el=self.$element,isDragDrop=arguments.length>1,isAjaxUpload=self.isAjaxUpload,tfiles,files=isDragDrop?arguments[1]:$el.get(0).files,total,maxCount=!isAjaxUpload&&$h.isEmpty($el.attr('multiple'))?1:self.maxFileCount,len,ctr=self.fileManager.count(),isSingleUpload=$h.isEmpty($el.attr('multiple')),flagSingle=(isSingleUpload&&ctr>0),throwError=function(mesg,file,previewId,index){var p1=$.extend(true,{},self._getOutData(null,{},{},files),{id:previewId,index:index}),p2={id:previewId,index:index,file:file,files:files};return isAjaxUpload?self._showFileError(mesg,p1):self._showError(mesg,p2);},maxCountCheck=function(n,m){var msg=self.msgFilesTooMany.replace('{m}',m).replace('{n}',n);self.isError=throwError(msg,null,null,null);self.$captionContainer.removeClass('icon-visible');self._setCaption('',true);self.$container.removeClass('file-input-new file-input-ajax-new');};self.reader=null;self._resetUpload();self._hideFileIcon();if(self.dropZoneEnabled){self.$container.find('.file-drop-zone .'+self.dropZoneTitleClass).remove();}if(!isAjaxUpload){if(e.target&&e.target.files===undefined){files=e.target.value?[{name:e.target.value.replace(/^.+\\/,'')}]:[];}else{files=e.target.files||{};}}tfiles=files;if($h.isEmpty(tfiles)||tfiles.length===0){if(!isAjaxUpload){self.clear();}self._raise('fileselectnone');return;}self._resetErrors();len=tfiles.length;total=self._getFileCount(isAjaxUpload?(self.fileManager.count()+len):len);if(maxCount>0&&total>maxCount){if(!self.autoReplace||len>maxCount){maxCountCheck((self.autoReplace&&len>maxCount?len:total),maxCount);return;}if(total>maxCount){self._resetPreviewThumbs(isAjaxUpload);}}else{if(!isAjaxUpload||flagSingle){self._resetPreviewThumbs(false);if(flagSingle){self.clearFileStack();}}else{if(isAjaxUpload&&ctr===0&&(!self.previewCache.count(true)||self.overwriteInitial)){self._resetPreviewThumbs(true);}}}self.readFiles(tfiles);},_abort:function(params){var self=this,data;if(self.ajaxAborted&&typeof self.ajaxAborted==='object'&&self.ajaxAborted.message!==undefined){data=$.extend(true,{},self._getOutData(null),params);data.abortData=self.ajaxAborted.data||{};data.abortMessage=self.ajaxAborted.message;self._setProgress(101,self.$progress,self.msgCancelled);self._showFileError(self.ajaxAborted.message,data,'filecustomerror');self.cancel();return true;}return!!self.ajaxAborted;},_resetFileStack:function(){var self=this,i=0;self._getThumbs().each(function(){var $thumb=$(this),ind=$thumb.attr('data-fileindex'),pid=$thumb.attr('id');if(ind==='-1'||ind===-1){return;}if(!self.fileManager.getFile($thumb.attr('data-fileid'))){$thumb.attr({'id':self.previewInitId+'-'+i,'data-fileindex':i});i++;}else{$thumb.attr({'id':'uploaded-'+$h.uniqId(),'data-fileindex':'-1'});}self.$preview.find('#zoom-'+pid).attr({'id':'zoom-'+$thumb.attr('id'),'data-fileindex':$thumb.attr('data-fileindex')});});},_isFileSelectionValid:function(cnt){var self=this;cnt=cnt||0;if(self.required&&!self.getFilesCount()){self.$errorContainer.html('');self._showFileError(self.msgFileRequired);return false;}if(self.minFileCount>0&&self._getFileCount(cnt)=numFiles){if(self.isAjaxUpload&&self.fileManager.count()>0){self._raise('filebatchselected',[self.fileManager.stack]);}else{self._raise('filebatchselected',[files]);}$container.removeClass('file-thumb-loading');$status.html('');return;}var node=ctr+i,previewId=previewInitId+'-'+node,file=files[i],fSizeKB,j,msg,$thumb,fnText=settings.text,fnImage=settings.image,fnHtml=settings.html,typ,chk,typ1,typ2,caption=self._getFileName(file,''),fileSize=(file&&file.size||0)/1000,fileExtExpr='',previewData=$h.createObjectURL(file),fileCount=0,strTypes='',fileId,func,knownTypes=0,isText,isHtml,isImage,txtFlag,processFileLoaded=function(){var msg=msgProgress.setTokens({'index':i+1,'files':numFiles,'percent':50,'name':caption});setTimeout(function(){$status.html(msg);self._updateFileDetails(numFiles);readFile(i+1);},self.processDelay);self._raise('fileloaded',[file,previewId,i,reader]);};if(!file){return;}fileId=self.fileManager.getId(file);if(typLen>0){for(j=0;j0&&fileSize>self.maxFileSize){msg=self.msgSizeTooLarge.setTokens({'name':caption,'size':fSizeKB,'maxSize':self.maxFileSize});throwError(msg,file,previewId,i,fileId);return;}if(self.minFileSize!==null&&fileSize<=$h.getNum(self.minFileSize)){msg=self.msgSizeTooSmall.setTokens({'name':caption,'size':fSizeKB,'minSize':self.minFileSize});throwError(msg,file,previewId,i,fileId);return;}if(!$h.isEmpty(fileTypes)&&$h.isArray(fileTypes)){for(j=0;j0){for(i=0;i0){for(i=0;i0)?self.initialCaption:'';self.$caption.attr('title','').val(cap);$h.addCss(self.$container,'file-input-new');self._validateDefaultPreview();}if(self.$container.find($h.FRAMES).length===0){if(!self._initCaption()){self.$captionContainer.removeClass('icon-visible');}}self._hideFileIcon();self.$captionContainer.focus();self._setFileDropZoneTitle();self._raise('filecleared');return self.$element;},reset:function(){var self=this;if(!self._raise('filereset')){return;}self.lastProgress=0;self._resetPreview();self.$container.find('.fileinput-filename').text('');$h.addCss(self.$container,'file-input-new');if(self.getFrames().length||self.dropZoneEnabled){self.$container.removeClass('file-input-new');}self.clearFileStack();self._setFileDropZoneTitle();return self.$element;},disable:function(){var self=this;self.isDisabled=true;self._raise('filedisabled');self.$element.attr('disabled','disabled');self.$container.find('.kv-fileinput-caption').addClass('file-caption-disabled');self.$container.find('.fileinput-remove, .fileinput-upload, .file-preview-frame button').attr('disabled',true);$h.addCss(self.$container.find('.btn-file'),'disabled');self._initDragDrop();return self.$element;},enable:function(){var self=this;self.isDisabled=false;self._raise('fileenabled');self.$element.removeAttr('disabled');self.$container.find('.kv-fileinput-caption').removeClass('file-caption-disabled');self.$container.find('.fileinput-remove, .fileinput-upload, .file-preview-frame button').removeAttr('disabled');self.$container.find('.btn-file').removeClass('disabled');self._initDragDrop();return self.$element;},upload:function(){var self=this,fm=self.fileManager,totLen=fm.count(),i,outData,len,hasExtraData=!$.isEmptyObject(self._getExtraData());if(!self.isAjaxUpload||self.isDisabled||!self._isFileSelectionValid(totLen)){return;}self.lastProgress=0;self._resetUpload();if(totLen===0&&!hasExtraData){self._showFileError(self.msgUploadEmpty);return;}self.cancelling=false;self.$progress.show();self.lock();len=fm.count();if(totLen===0&&hasExtraData){self._setProgress(2);self._uploadExtraOnly();return;}if(self.enableResumableUpload){return self.resume();}if(self.uploadAsync||self.enableResumableUpload){outData=self._getOutData(null);self._raise('filebatchpreupload',[outData]);self.fileBatchCompleted=false;self.uploadCache={content:[],config:[],tags:[],append:true};for(i=0;i',next:'',toggleheader:'',fullscreen:'',borderless:'',close:''},previewZoomButtonClasses:{prev:'btn btn-navigate',next:'btn btn-navigate',toggleheader:'btn btn-sm btn-kv btn-default btn-outline-secondary',fullscreen:'btn btn-sm btn-kv btn-default btn-outline-secondary',borderless:'btn btn-sm btn-kv btn-default btn-outline-secondary',close:'btn btn-sm btn-kv btn-default btn-outline-secondary'},previewTemplates:{},previewContentTemplates:{},preferIconicPreview:false,preferIconicZoomPreview:false,allowedFileTypes:null,allowedFileExtensions:null,allowedPreviewTypes:undefined,allowedPreviewMimeTypes:null,allowedPreviewExtensions:null,disabledPreviewTypes:undefined,disabledPreviewExtensions:['msi','exe','com','zip','rar','app','vb','scr'],disabledPreviewMimeTypes:null,defaultPreviewContent:null,customLayoutTags:{},customPreviewTags:{},previewFileIcon:'',previewFileIconClass:'file-other-icon',previewFileIconSettings:{},previewFileExtSettings:{},buttonLabelClass:'hidden-xs',browseIcon:' ',browseClass:'btn btn-primary',removeIcon:'',removeClass:'btn btn-default btn-secondary',cancelIcon:'',cancelClass:'btn btn-default btn-secondary',pauseIcon:'',pauseClass:'btn btn-default btn-secondary',uploadIcon:'',uploadClass:'btn btn-default btn-secondary',uploadUrl:null,uploadUrlThumb:null,uploadAsync:true,uploadParamNames:{chunkCount:'chunkCount',chunkIndex:'chunkIndex',chunkSize:'chunkSize',chunkSizeStart:'chunkSizeStart',chunksUploaded:'chunksUploaded',fileBlob:'fileBlob',fileId:'fileId',fileName:'fileName',fileRelativePath:'fileRelativePath',fileSize:'fileSize',retryCount:'retryCount'},maxAjaxThreads:5,processDelay:100,queueDelay:10,progressDelay:0,enableResumableUpload:false,resumableUploadOptions:{fallback:null,testUrl:null,chunkSize:2*1024,maxThreads:4,maxRetries:3,showErrorLog:true},uploadExtraData:{},zoomModalHeight:480,minImageWidth:null,minImageHeight:null,maxImageWidth:null,maxImageHeight:null,resizeImage:false,resizePreference:'width',resizeQuality:0.92,resizeDefaultImageType:'image/jpeg',resizeIfSizeMoreThan:0,minFileSize:0,maxFileSize:0,maxFilePreviewSize:25600,minFileCount:0,maxFileCount:0,validateInitialCount:false,msgValidationErrorClass:'text-danger',msgValidationErrorIcon:' ',msgErrorClass:'file-error-message',progressThumbClass:'progress-bar progress-bar-striped active',progressClass:'progress-bar bg-success progress-bar-success progress-bar-striped active',progressInfoClass:'progress-bar bg-info progress-bar-info progress-bar-striped active',progressCompleteClass:'progress-bar bg-success progress-bar-success',progressPauseClass:'progress-bar bg-primary progress-bar-primary progress-bar-striped active',progressErrorClass:'progress-bar bg-danger progress-bar-danger',progressUploadThreshold:99,previewFileType:'image',elCaptionContainer:null,elCaptionText:null,elPreviewContainer:null,elPreviewImage:null,elPreviewStatus:null,elErrorContainer:null,errorCloseButton:$h.closeButton('kv-error-close'),slugCallback:null,dropZoneEnabled:true,dropZoneTitleClass:'file-drop-zone-title',fileActionSettings:{},otherActionButtons:'',textEncoding:'UTF-8',ajaxSettings:{},ajaxDeleteSettings:{},showAjaxErrorDetails:true,mergeAjaxCallbacks:false,mergeAjaxDeleteCallbacks:false,retryErrorUploads:true,reversePreviewOrder:false,usePdfRenderer:function(){var isIE11=!!window.MSInputMethodContext&&!!document.documentMode;return!!navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/i)||isIE11;},pdfRendererUrl:'',pdfRendererTemplate:''};$.fn.fileinputLocales.en={fileSingle:'file',filePlural:'files',browseLabel:'Browse …',removeLabel:'Remove',removeTitle:'Clear all unprocessed files',cancelLabel:'Cancel',cancelTitle:'Abort ongoing upload',pauseLabel:'Pause',pauseTitle:'Pause ongoing upload',uploadLabel:'Upload',uploadTitle:'Upload selected files',msgNo:'No',msgNoFilesSelected:'No files selected',msgCancelled:'Cancelled',msgPaused:'Paused',msgPlaceholder:'Select {files}...',msgZoomModalHeading:'Detailed Preview',msgFileRequired:'You must select a file to upload.',msgSizeTooSmall:'File "{name}" ({size} KB) is too small and must be larger than {minSize} KB.',msgSizeTooLarge:'File "{name}" ({size} KB) exceeds maximum allowed upload size of {maxSize} KB.',msgFilesTooLess:'You must select at least {n} {files} to upload.',msgFilesTooMany:'Number of files selected for upload ({n}) exceeds maximum allowed limit of {m}.',msgFileNotFound:'File "{name}" not found!',msgFileSecured:'Security restrictions prevent reading the file "{name}".',msgFileNotReadable:'File "{name}" is not readable.',msgFilePreviewAborted:'File preview aborted for "{name}".',msgFilePreviewError:'An error occurred while reading the file "{name}".',msgInvalidFileName:'Invalid or unsupported characters in file name "{name}".',msgInvalidFileType:'Invalid type for file "{name}". Only "{types}" files are supported.',msgInvalidFileExtension:'Invalid extension for file "{name}". Only "{extensions}" files are supported.',msgFileTypes:{'image':'image','html':'HTML','text':'text','video':'video','audio':'audio','flash':'flash','pdf':'PDF','object':'object'},msgUploadAborted:'The file upload was aborted',msgUploadThreshold:'Processing...',msgUploadBegin:'Initializing...',msgUploadEnd:'Done',msgUploadResume:'Resuming upload...',msgUploadEmpty:'No valid data available for upload.',msgUploadError:'Upload Error',msgDeleteError:'Delete Error',msgProgressError:'Error',msgValidationError:'Validation Error',msgLoading:'Loading file {index} of {files} …',msgProgress:'Loading file {index} of {files} - {name} - {percent}% completed.',msgSelected:'{n} {files} selected',msgFoldersNotAllowed:'Drag & drop files only! {n} folder(s) dropped were skipped.',msgImageWidthSmall:'Width of image file "{name}" must be at least {size} px.',msgImageHeightSmall:'Height of image file "{name}" must be at least {size} px.',msgImageWidthLarge:'Width of image file "{name}" cannot exceed {size} px.',msgImageHeightLarge:'Height of image file "{name}" cannot exceed {size} px.',msgImageResizeError:'Could not get the image dimensions to resize.',msgImageResizeException:'Error while resizing the image.
    {errors}
    ',msgAjaxError:'Something went wrong with the {operation} operation. Please try again later!',msgAjaxProgressError:'{operation} failed',msgDuplicateFile:'File "{name}" of same size "{size} KB" has already been selected earlier. Skipping duplicate selection.',msgResumableUploadRetriesExceeded:'Upload aborted beyond {max} retries for file {file}! Error Details:
    {error}
    ',msgPendingTime:'{time} remaining',msgCalculatingTime:'calculating time remaining',ajaxOperations:{deleteThumb:'file delete',uploadThumb:'file upload',uploadBatch:'batch file upload',uploadExtra:'form data upload'},dropZoneTitle:'Drag & drop files here …',dropZoneClickTitle:'
    (or click to select {files})',previewZoomButtonTitles:{prev:'View previous file',next:'View next file',toggleheader:'Toggle header',fullscreen:'Toggle full screen',borderless:'Toggle borderless mode',close:'Close detailed preview'}};$.fn.fileinputLocales.zh={fileSingle:'文件',filePlural:'个文件',browseLabel:'选择 …',removeLabel:'移除',removeTitle:'清除选中文件',cancelLabel:'取消',cancelTitle:'取消进行中的上传',pauseLabel:'Pause',pauseTitle:'Pause ongoing upload',uploadLabel:'上传',uploadTitle:'上传选中文件',msgNo:'没有',msgNoFilesSelected:'未选择文件',msgPaused:'Paused',msgCancelled:'取消',msgPlaceholder:'选择 {files}...',msgZoomModalHeading:'详细预览',msgFileRequired:'必须选择一个文件上传.',msgSizeTooSmall:'文件 "{name}" ({size} KB) 必须大于限定大小 {minSize} KB.',msgSizeTooLarge:'文件 "{name}" ({size} KB) 超过了允许大小 {maxSize} KB.',msgFilesTooLess:'你必须选择最少 {n} {files} 来上传. ',msgFilesTooMany:'选择的上传文件个数 ({n}) 超出最大文件的限制个数 {m}.',msgFileNotFound:'文件 "{name}" 未找到!',msgFileSecured:'安全限制,为了防止读取文件 "{name}".',msgFileNotReadable:'文件 "{name}" 不可读.',msgFilePreviewAborted:'取消 "{name}" 的预览.',msgFilePreviewError:'读取 "{name}" 时出现了一个错误.',msgInvalidFileName:'文件名 "{name}" 包含非法字符.',msgInvalidFileType:'不正确的类型 "{name}". 只支持 "{types}" 类型的文件.',msgInvalidFileExtension:'不正确的文件扩展名 "{name}". 只支持 "{extensions}" 的文件扩展名.',msgFileTypes:{'image':'image','html':'HTML','text':'text','video':'video','audio':'audio','flash':'flash','pdf':'PDF','object':'object'},msgUploadAborted:'该文件上传被中止',msgUploadThreshold:'处理中...',msgUploadBegin:'正在初始化...',msgUploadEnd:'完成',msgUploadResume:'Resuming upload...',msgUploadEmpty:'无效的文件上传.',msgUploadError:'Upload Error',msgDeleteError:'Delete Error',msgProgressError:'上传出错',msgValidationError:'验证错误',msgLoading:'加载第 {index} 文件 共 {files} …',msgProgress:'加载第 {index} 文件 共 {files} - {name} - {percent}% 完成.',msgSelected:'{n} {files} 选中',msgFoldersNotAllowed:'只支持拖拽文件! 跳过 {n} 拖拽的文件夹.',msgImageWidthSmall:'图像文件的"{name}"的宽度必须是至少{size}像素.',msgImageHeightSmall:'图像文件的"{name}"的高度必须至少为{size}像素.',msgImageWidthLarge:'图像文件"{name}"的宽度不能超过{size}像素.',msgImageHeightLarge:'图像文件"{name}"的高度不能超过{size}像素.',msgImageResizeError:'无法获取的图像尺寸调整。',msgImageResizeException:'调整图像大小时发生错误。
    {errors}
    ',msgAjaxError:'{operation} 发生错误. 请重试!',msgAjaxProgressError:'{operation} 失败',msgDuplicateFile:'File "{name}" of same size "{size} KB" has already been selected earlier. Skipping duplicate selection.',msgResumableUploadRetriesExceeded:'Upload aborted beyond {max} retries for file {file}! Error Details:
    {error}
    ',msgPendingTime:'{time} remaining',msgCalculatingTime:'calculating time remaining',ajaxOperations:{deleteThumb:'删除文件',uploadThumb:'上传文件',uploadBatch:'批量上传',uploadExtra:'表单数据上传'},dropZoneTitle:'拖拽文件到这里 …
    支持多文件同时上传',dropZoneClickTitle:'
    (或点击{files}按钮选择文件)',fileActionSettings:{removeTitle:'删除文件',uploadTitle:'上传文件',downloadTitle:'下载文件',uploadRetryTitle:'重试',zoomTitle:'查看详情',dragTitle:'移动 / 重置',indicatorNewTitle:'没有上传',indicatorSuccessTitle:'上传',indicatorErrorTitle:'上传错误',indicatorPausedTitle:'Upload Paused',indicatorLoadingTitle:'上传 ...'},previewZoomButtonTitles:{prev:'预览上一个文件',next:'预览下一个文件',toggleheader:'缩放',fullscreen:'全屏',borderless:'无边界模式',close:'关闭当前预览'}};$.fn.fileinput.Constructor=FileInput;$(document).ready(function(){var $input=$('input.file[type=file]');if($input.length){$input.fileinput();}});})); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/loading-sm.gif b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/loading-sm.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/loading-sm.gif rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/loading-sm.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/loading.gif b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/loading.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/loading.gif rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-fileinput/loading.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.css b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.css similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.css rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.css index 66b8cc688..b07486c31 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.css @@ -1,10 +1,10 @@ -/*! - * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select) - * - * Copyright 2012-2019 SnapAppointments, LLC - * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) - */ - +/*! + * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select) + * + * Copyright 2012-2019 SnapAppointments, LLC + * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) + */ + select.bs-select-hidden, .bootstrap-select > select.bs-select-hidden, select.selectpicker { diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.js index c3ab3bfa4..2a4b26e25 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.js @@ -1,3139 +1,3139 @@ -/*! - * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select) - * - * Copyright 2012-2019 SnapAppointments, LLC - * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) - */ - -(function (root, factory) { - if (root === undefined && window !== undefined) root = window; - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module unless amdModuleId is set - define(["jquery"], function (a0) { - return (factory(a0)); - }); - } else if (typeof module === 'object' && module.exports) { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like Node. - module.exports = factory(require("jquery")); - } else { - factory(root["jQuery"]); - } -}(this, function (jQuery) { - -(function ($) { - 'use strict'; - - var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']; - - var uriAttrs = [ - 'background', - 'cite', - 'href', - 'itemtype', - 'longdesc', - 'poster', - 'src', - 'xlink:href' - ]; - - var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; - - var DefaultWhitelist = { - // Global attributes allowed on any supplied element below. - '*': ['class', 'dir', 'id', 'lang', 'role', 'tabindex', 'style', ARIA_ATTRIBUTE_PATTERN], - a: ['target', 'href', 'title', 'rel'], - area: [], - b: [], - br: [], - col: [], - code: [], - div: [], - em: [], - hr: [], - h1: [], - h2: [], - h3: [], - h4: [], - h5: [], - h6: [], - i: [], - img: ['src', 'alt', 'title', 'width', 'height'], - li: [], - ol: [], - p: [], - pre: [], - s: [], - small: [], - span: [], - sub: [], - sup: [], - strong: [], - u: [], - ul: [] - } - - /** - * A pattern that recognizes a commonly useful subset of URLs that are safe. - * - * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts - */ - var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi; - - /** - * A pattern that matches safe data URLs. Only matches image, video and audio types. - * - * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts - */ - var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i; - - function allowedAttribute (attr, allowedAttributeList) { - var attrName = attr.nodeName.toLowerCase() - - if ($.inArray(attrName, allowedAttributeList) !== -1) { - if ($.inArray(attrName, uriAttrs) !== -1) { - return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) - } - - return true - } - - var regExp = $(allowedAttributeList).filter(function (index, value) { - return value instanceof RegExp - }) - - // Check if a regular expression validates the attribute. - for (var i = 0, l = regExp.length; i < l; i++) { - if (attrName.match(regExp[i])) { - return true - } - } - - return false - } - - function sanitizeHtml (unsafeElements, whiteList, sanitizeFn) { - if (sanitizeFn && typeof sanitizeFn === 'function') { - return sanitizeFn(unsafeElements); - } - - var whitelistKeys = Object.keys(whiteList); - - for (var i = 0, len = unsafeElements.length; i < len; i++) { - var elements = unsafeElements[i].querySelectorAll('*'); - - for (var j = 0, len2 = elements.length; j < len2; j++) { - var el = elements[j]; - var elName = el.nodeName.toLowerCase(); - - if (whitelistKeys.indexOf(elName) === -1) { - el.parentNode.removeChild(el); - - continue; - } - - var attributeList = [].slice.call(el.attributes); - var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []); - - for (var k = 0, len3 = attributeList.length; k < len3; k++) { - var attr = attributeList[k]; - - if (!allowedAttribute(attr, whitelistedAttributes)) { - el.removeAttribute(attr.nodeName); - } - } - } - } - } - - // Polyfill for browsers with no classList support - // Remove in v2 - if (!('classList' in document.createElement('_'))) { - (function (view) { - if (!('Element' in view)) return; - - var classListProp = 'classList', - protoProp = 'prototype', - elemCtrProto = view.Element[protoProp], - objCtr = Object, - classListGetter = function () { - var $elem = $(this); - - return { - add: function (classes) { - classes = Array.prototype.slice.call(arguments).join(' '); - return $elem.addClass(classes); - }, - remove: function (classes) { - classes = Array.prototype.slice.call(arguments).join(' '); - return $elem.removeClass(classes); - }, - toggle: function (classes, force) { - return $elem.toggleClass(classes, force); - }, - contains: function (classes) { - return $elem.hasClass(classes); - } - } - }; - - if (objCtr.defineProperty) { - var classListPropDesc = { - get: classListGetter, - enumerable: true, - configurable: true - }; - try { - objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); - } catch (ex) { // IE 8 doesn't support enumerable:true - // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36 - // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected - if (ex.number === undefined || ex.number === -0x7FF5EC54) { - classListPropDesc.enumerable = false; - objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); - } - } - } else if (objCtr[protoProp].__defineGetter__) { - elemCtrProto.__defineGetter__(classListProp, classListGetter); - } - }(window)); - } - - var testElement = document.createElement('_'); - - testElement.classList.add('c1', 'c2'); - - if (!testElement.classList.contains('c2')) { - var _add = DOMTokenList.prototype.add, - _remove = DOMTokenList.prototype.remove; - - DOMTokenList.prototype.add = function () { - Array.prototype.forEach.call(arguments, _add.bind(this)); - } - - DOMTokenList.prototype.remove = function () { - Array.prototype.forEach.call(arguments, _remove.bind(this)); - } - } - - testElement.classList.toggle('c3', false); - - // Polyfill for IE 10 and Firefox <24, where classList.toggle does not - // support the second argument. - if (testElement.classList.contains('c3')) { - var _toggle = DOMTokenList.prototype.toggle; - - DOMTokenList.prototype.toggle = function (token, force) { - if (1 in arguments && !this.contains(token) === !force) { - return force; - } else { - return _toggle.call(this, token); - } - }; - } - - testElement = null; - - // shallow array comparison - function isEqual (array1, array2) { - return array1.length === array2.length && array1.every(function (element, index) { - return element === array2[index]; - }); - }; - - // - if (!String.prototype.startsWith) { - (function () { - 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` - var defineProperty = (function () { - // IE 8 only supports `Object.defineProperty` on DOM elements - try { - var object = {}; - var $defineProperty = Object.defineProperty; - var result = $defineProperty(object, object, object) && $defineProperty; - } catch (error) { - } - return result; - }()); - var toString = {}.toString; - var startsWith = function (search) { - if (this == null) { - throw new TypeError(); - } - var string = String(this); - if (search && toString.call(search) == '[object RegExp]') { - throw new TypeError(); - } - var stringLength = string.length; - var searchString = String(search); - var searchLength = searchString.length; - var position = arguments.length > 1 ? arguments[1] : undefined; - // `ToInteger` - var pos = position ? Number(position) : 0; - if (pos != pos) { // better `isNaN` - pos = 0; - } - var start = Math.min(Math.max(pos, 0), stringLength); - // Avoid the `indexOf` call if no match is possible - if (searchLength + start > stringLength) { - return false; - } - var index = -1; - while (++index < searchLength) { - if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) { - return false; - } - } - return true; - }; - if (defineProperty) { - defineProperty(String.prototype, 'startsWith', { - 'value': startsWith, - 'configurable': true, - 'writable': true - }); - } else { - String.prototype.startsWith = startsWith; - } - }()); - } - - if (!Object.keys) { - Object.keys = function ( - o, // object - k, // key - r // result array - ) { - // initialize object and result - r = []; - // iterate over object keys - for (k in o) { - // fill result array with non-prototypical keys - r.hasOwnProperty.call(o, k) && r.push(k); - } - // return result - return r; - }; - } - - if (HTMLSelectElement && !HTMLSelectElement.prototype.hasOwnProperty('selectedOptions')) { - Object.defineProperty(HTMLSelectElement.prototype, 'selectedOptions', { - get: function () { - return this.querySelectorAll(':checked'); - } - }); - } - - function getSelectedOptions (select, ignoreDisabled) { - var selectedOptions = select.selectedOptions, - options = [], - opt; - - if (ignoreDisabled) { - for (var i = 0, len = selectedOptions.length; i < len; i++) { - opt = selectedOptions[i]; - - if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) { - options.push(opt); - } - } - - return options; - } - - return selectedOptions; - } - - // much faster than $.val() - function getSelectValues (select, selectedOptions) { - var value = [], - options = selectedOptions || select.selectedOptions, - opt; - - for (var i = 0, len = options.length; i < len; i++) { - opt = options[i]; - - if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) { - value.push(opt.value || opt.text); - } - } - - if (!select.multiple) { - return !value.length ? null : value[0]; - } - - return value; - } - - // set data-selected on select element if the value has been programmatically selected - // prior to initialization of bootstrap-select - // * consider removing or replacing an alternative method * - var valHooks = { - useDefault: false, - _set: $.valHooks.select.set - }; - - $.valHooks.select.set = function (elem, value) { - if (value && !valHooks.useDefault) $(elem).data('selected', true); - - return valHooks._set.apply(this, arguments); - }; - - var changedArguments = null; - - var EventIsSupported = (function () { - try { - new Event('change'); - return true; - } catch (e) { - return false; - } - })(); - - $.fn.triggerNative = function (eventName) { - var el = this[0], - event; - - if (el.dispatchEvent) { // for modern browsers & IE9+ - if (EventIsSupported) { - // For modern browsers - event = new Event(eventName, { - bubbles: true - }); - } else { - // For IE since it doesn't support Event constructor - event = document.createEvent('Event'); - event.initEvent(eventName, true, false); - } - - el.dispatchEvent(event); - } else if (el.fireEvent) { // for IE8 - event = document.createEventObject(); - event.eventType = eventName; - el.fireEvent('on' + eventName, event); - } else { - // fall back to jQuery.trigger - this.trigger(eventName); - } - }; - // - - function stringSearch (li, searchString, method, normalize) { - var stringTypes = [ - 'display', - 'subtext', - 'tokens' - ], - searchSuccess = false; - - for (var i = 0; i < stringTypes.length; i++) { - var stringType = stringTypes[i], - string = li[stringType]; - - if (string) { - string = string.toString(); - - // Strip HTML tags. This isn't perfect, but it's much faster than any other method - if (stringType === 'display') { - string = string.replace(/<[^>]+>/g, ''); - } - - if (normalize) string = normalizeToBase(string); - string = string.toUpperCase(); - - if (method === 'contains') { - searchSuccess = string.indexOf(searchString) >= 0; - } else { - searchSuccess = string.startsWith(searchString); - } - - if (searchSuccess) break; - } - } - - return searchSuccess; - } - - function toInteger (value) { - return parseInt(value, 10) || 0; - } - - // Borrowed from Lodash (_.deburr) - /** Used to map Latin Unicode letters to basic Latin letters. */ - var deburredLetters = { - // Latin-1 Supplement block. - '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', - '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', - '\xc7': 'C', '\xe7': 'c', - '\xd0': 'D', '\xf0': 'd', - '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', - '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', - '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', - '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', - '\xd1': 'N', '\xf1': 'n', - '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', - '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', - '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', - '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', - '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', - '\xc6': 'Ae', '\xe6': 'ae', - '\xde': 'Th', '\xfe': 'th', - '\xdf': 'ss', - // Latin Extended-A block. - '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', - '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', - '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', - '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', - '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', - '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', - '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', - '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', - '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', - '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', - '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', - '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', - '\u0134': 'J', '\u0135': 'j', - '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', - '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', - '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', - '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', - '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', - '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', - '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', - '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', - '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', - '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', - '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', - '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', - '\u0163': 't', '\u0165': 't', '\u0167': 't', - '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', - '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', - '\u0174': 'W', '\u0175': 'w', - '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', - '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', - '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', - '\u0132': 'IJ', '\u0133': 'ij', - '\u0152': 'Oe', '\u0153': 'oe', - '\u0149': "'n", '\u017f': 's' - }; - - /** Used to match Latin Unicode letters (excluding mathematical operators). */ - var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; - - /** Used to compose unicode character classes. */ - var rsComboMarksRange = '\\u0300-\\u036f', - reComboHalfMarksRange = '\\ufe20-\\ufe2f', - rsComboSymbolsRange = '\\u20d0-\\u20ff', - rsComboMarksExtendedRange = '\\u1ab0-\\u1aff', - rsComboMarksSupplementRange = '\\u1dc0-\\u1dff', - rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange; - - /** Used to compose unicode capture groups. */ - var rsCombo = '[' + rsComboRange + ']'; - - /** - * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and - * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). - */ - var reComboMark = RegExp(rsCombo, 'g'); - - function deburrLetter (key) { - return deburredLetters[key]; - }; - - function normalizeToBase (string) { - string = string.toString(); - return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); - } - - // List of HTML entities for escaping. - var escapeMap = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - '`': '`' - }; - - // Functions for escaping and unescaping strings to/from HTML interpolation. - var createEscaper = function (map) { - var escaper = function (match) { - return map[match]; - }; - // Regexes for identifying a key that needs to be escaped. - var source = '(?:' + Object.keys(map).join('|') + ')'; - var testRegexp = RegExp(source); - var replaceRegexp = RegExp(source, 'g'); - return function (string) { - string = string == null ? '' : '' + string; - return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; - }; - }; - - var htmlEscape = createEscaper(escapeMap); - - /** - * ------------------------------------------------------------------------ - * Constants - * ------------------------------------------------------------------------ - */ - - var keyCodeMap = { - 32: ' ', - 48: '0', - 49: '1', - 50: '2', - 51: '3', - 52: '4', - 53: '5', - 54: '6', - 55: '7', - 56: '8', - 57: '9', - 59: ';', - 65: 'A', - 66: 'B', - 67: 'C', - 68: 'D', - 69: 'E', - 70: 'F', - 71: 'G', - 72: 'H', - 73: 'I', - 74: 'J', - 75: 'K', - 76: 'L', - 77: 'M', - 78: 'N', - 79: 'O', - 80: 'P', - 81: 'Q', - 82: 'R', - 83: 'S', - 84: 'T', - 85: 'U', - 86: 'V', - 87: 'W', - 88: 'X', - 89: 'Y', - 90: 'Z', - 96: '0', - 97: '1', - 98: '2', - 99: '3', - 100: '4', - 101: '5', - 102: '6', - 103: '7', - 104: '8', - 105: '9' - }; - - var keyCodes = { - ESCAPE: 27, // KeyboardEvent.which value for Escape (Esc) key - ENTER: 13, // KeyboardEvent.which value for Enter key - SPACE: 32, // KeyboardEvent.which value for space key - TAB: 9, // KeyboardEvent.which value for tab key - ARROW_UP: 38, // KeyboardEvent.which value for up arrow key - ARROW_DOWN: 40 // KeyboardEvent.which value for down arrow key - } - - var version = { - success: false, - major: '3' - }; - - try { - version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.'); - version.major = version.full[0]; - version.success = true; - } catch (err) { - // do nothing - } - - var selectId = 0; - - var EVENT_KEY = '.bs.select'; - - var classNames = { - DISABLED: 'disabled', - DIVIDER: 'divider', - SHOW: 'open', - DROPUP: 'dropup', - MENU: 'dropdown-menu', - MENURIGHT: 'dropdown-menu-right', - MENULEFT: 'dropdown-menu-left', - // to-do: replace with more advanced template/customization options - BUTTONCLASS: 'btn-default', - POPOVERHEADER: 'popover-title', - ICONBASE: 'glyphicon', - TICKICON: 'glyphicon-ok' - } - - var Selector = { - MENU: '.' + classNames.MENU - } - - var elementTemplates = { - span: document.createElement('span'), - i: document.createElement('i'), - subtext: document.createElement('small'), - a: document.createElement('a'), - li: document.createElement('li'), - whitespace: document.createTextNode('\u00A0'), - fragment: document.createDocumentFragment() - } - - elementTemplates.a.setAttribute('role', 'option'); - elementTemplates.subtext.className = 'text-muted'; - - elementTemplates.text = elementTemplates.span.cloneNode(false); - elementTemplates.text.className = 'text'; - - elementTemplates.checkMark = elementTemplates.span.cloneNode(false); - - var REGEXP_ARROW = new RegExp(keyCodes.ARROW_UP + '|' + keyCodes.ARROW_DOWN); - var REGEXP_TAB_OR_ESCAPE = new RegExp('^' + keyCodes.TAB + '$|' + keyCodes.ESCAPE); - - var generateOption = { - li: function (content, classes, optgroup) { - var li = elementTemplates.li.cloneNode(false); - - if (content) { - if (content.nodeType === 1 || content.nodeType === 11) { - li.appendChild(content); - } else { - li.innerHTML = content; - } - } - - if (typeof classes !== 'undefined' && classes !== '') li.className = classes; - if (typeof optgroup !== 'undefined' && optgroup !== null) li.classList.add('optgroup-' + optgroup); - - return li; - }, - - a: function (text, classes, inline) { - var a = elementTemplates.a.cloneNode(true); - - if (text) { - if (text.nodeType === 11) { - a.appendChild(text); - } else { - a.insertAdjacentHTML('beforeend', text); - } - } - - if (typeof classes !== 'undefined' && classes !== '') a.className = classes; - if (version.major === '4') a.classList.add('dropdown-item'); - if (inline) a.setAttribute('style', inline); - - return a; - }, - - text: function (options, useFragment) { - var textElement = elementTemplates.text.cloneNode(false), - subtextElement, - iconElement; - - if (options.content) { - textElement.innerHTML = options.content; - } else { - textElement.textContent = options.text; - - if (options.icon) { - var whitespace = elementTemplates.whitespace.cloneNode(false); - - // need to use for icons in the button to prevent a breaking change - // note: switch to span in next major release - iconElement = (useFragment === true ? elementTemplates.i : elementTemplates.span).cloneNode(false); - iconElement.className = options.iconBase + ' ' + options.icon; - - elementTemplates.fragment.appendChild(iconElement); - elementTemplates.fragment.appendChild(whitespace); - } - - if (options.subtext) { - subtextElement = elementTemplates.subtext.cloneNode(false); - subtextElement.textContent = options.subtext; - textElement.appendChild(subtextElement); - } - } - - if (useFragment === true) { - while (textElement.childNodes.length > 0) { - elementTemplates.fragment.appendChild(textElement.childNodes[0]); - } - } else { - elementTemplates.fragment.appendChild(textElement); - } - - return elementTemplates.fragment; - }, - - label: function (options) { - var textElement = elementTemplates.text.cloneNode(false), - subtextElement, - iconElement; - - textElement.innerHTML = options.label; - - if (options.icon) { - var whitespace = elementTemplates.whitespace.cloneNode(false); - - iconElement = elementTemplates.span.cloneNode(false); - iconElement.className = options.iconBase + ' ' + options.icon; - - elementTemplates.fragment.appendChild(iconElement); - elementTemplates.fragment.appendChild(whitespace); - } - - if (options.subtext) { - subtextElement = elementTemplates.subtext.cloneNode(false); - subtextElement.textContent = options.subtext; - textElement.appendChild(subtextElement); - } - - elementTemplates.fragment.appendChild(textElement); - - return elementTemplates.fragment; - } - } - - var Selectpicker = function (element, options) { - var that = this; - - // bootstrap-select has been initialized - revert valHooks.select.set back to its original function - if (!valHooks.useDefault) { - $.valHooks.select.set = valHooks._set; - valHooks.useDefault = true; - } - - this.$element = $(element); - this.$newElement = null; - this.$button = null; - this.$menu = null; - this.options = options; - this.selectpicker = { - main: {}, - search: {}, - current: {}, // current changes if a search is in progress - view: {}, - keydown: { - keyHistory: '', - resetKeyHistory: { - start: function () { - return setTimeout(function () { - that.selectpicker.keydown.keyHistory = ''; - }, 800); - } - } - } - }; - // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a - // data-attribute) - if (this.options.title === null) { - this.options.title = this.$element.attr('title'); - } - - // Format window padding - var winPad = this.options.windowPadding; - if (typeof winPad === 'number') { - this.options.windowPadding = [winPad, winPad, winPad, winPad]; - } - - // Expose public methods - this.val = Selectpicker.prototype.val; - this.render = Selectpicker.prototype.render; - this.refresh = Selectpicker.prototype.refresh; - this.setStyle = Selectpicker.prototype.setStyle; - this.selectAll = Selectpicker.prototype.selectAll; - this.deselectAll = Selectpicker.prototype.deselectAll; - this.destroy = Selectpicker.prototype.destroy; - this.remove = Selectpicker.prototype.remove; - this.show = Selectpicker.prototype.show; - this.hide = Selectpicker.prototype.hide; - - this.init(); - }; - - Selectpicker.VERSION = '1.13.10'; - - // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both. - Selectpicker.DEFAULTS = { - noneSelectedText: 'Nothing selected', - noneResultsText: 'No results matched {0}', - countSelectedText: function (numSelected, numTotal) { - return (numSelected == 1) ? '{0} item selected' : '{0} items selected'; - }, - maxOptionsText: function (numAll, numGroup) { - return [ - (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)', - (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)' - ]; - }, - selectAllText: 'Select All', - deselectAllText: 'Deselect All', - doneButton: false, - doneButtonText: 'Close', - multipleSeparator: ', ', - styleBase: 'btn', - style: classNames.BUTTONCLASS, - size: 'auto', - title: null, - selectedTextFormat: 'values', - width: false, - container: false, - hideDisabled: false, - showSubtext: false, - showIcon: true, - showContent: true, - dropupAuto: true, - header: false, - liveSearch: false, - liveSearchPlaceholder: null, - liveSearchNormalize: false, - liveSearchStyle: 'contains', - actionsBox: false, - iconBase: classNames.ICONBASE, - tickIcon: classNames.TICKICON, - showTick: false, - template: { - caret: '' - }, - maxOptions: false, - mobile: false, - selectOnTab: false, - dropdownAlignRight: false, - windowPadding: 0, - virtualScroll: 600, - display: false, - sanitize: true, - sanitizeFn: null, - whiteList: DefaultWhitelist - }; - - Selectpicker.prototype = { - - constructor: Selectpicker, - - init: function () { - var that = this, - id = this.$element.attr('id'); - - selectId++; - this.selectId = 'bs-select-' + selectId; - - this.$element[0].classList.add('bs-select-hidden'); - - this.multiple = this.$element.prop('multiple'); - this.autofocus = this.$element.prop('autofocus'); - - if (this.$element[0].classList.contains('show-tick')) { - this.options.showTick = true; - } - - this.$newElement = this.createDropdown(); - this.$element - .after(this.$newElement) - .prependTo(this.$newElement); - - this.$button = this.$newElement.children('button'); - this.$menu = this.$newElement.children(Selector.MENU); - this.$menuInner = this.$menu.children('.inner'); - this.$searchbox = this.$menu.find('input'); - - this.$element[0].classList.remove('bs-select-hidden'); - - if (this.options.dropdownAlignRight === true) this.$menu[0].classList.add(classNames.MENURIGHT); - - if (typeof id !== 'undefined') { - this.$button.attr('data-id', id); - } - - this.checkDisabled(); - this.clickListener(); - - if (this.options.liveSearch) { - this.liveSearchListener(); - this.focusedParent = this.$searchbox[0]; - } else { - this.focusedParent = this.$menuInner[0]; - } - - this.setStyle(); - this.render(); - this.setWidth(); - if (this.options.container) { - this.selectPosition(); - } else { - this.$element.on('hide' + EVENT_KEY, function () { - if (that.isVirtual()) { - // empty menu on close - var menuInner = that.$menuInner[0], - emptyMenu = menuInner.firstChild.cloneNode(false); - - // replace the existing UL with an empty one - this is faster than $.empty() or innerHTML = '' - menuInner.replaceChild(emptyMenu, menuInner.firstChild); - menuInner.scrollTop = 0; - } - }); - } - this.$menu.data('this', this); - this.$newElement.data('this', this); - if (this.options.mobile) this.mobile(); - - this.$newElement.on({ - 'hide.bs.dropdown': function (e) { - that.$element.trigger('hide' + EVENT_KEY, e); - }, - 'hidden.bs.dropdown': function (e) { - that.$element.trigger('hidden' + EVENT_KEY, e); - }, - 'show.bs.dropdown': function (e) { - that.$element.trigger('show' + EVENT_KEY, e); - }, - 'shown.bs.dropdown': function (e) { - that.$element.trigger('shown' + EVENT_KEY, e); - } - }); - - if (that.$element[0].hasAttribute('required')) { - this.$element.on('invalid' + EVENT_KEY, function () { - that.$button[0].classList.add('bs-invalid'); - - that.$element - .on('shown' + EVENT_KEY + '.invalid', function () { - that.$element - .val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened - .off('shown' + EVENT_KEY + '.invalid'); - }) - .on('rendered' + EVENT_KEY, function () { - // if select is no longer invalid, remove the bs-invalid class - if (this.validity.valid) that.$button[0].classList.remove('bs-invalid'); - that.$element.off('rendered' + EVENT_KEY); - }); - - that.$button.on('blur' + EVENT_KEY, function () { - that.$element.trigger('focus').trigger('blur'); - that.$button.off('blur' + EVENT_KEY); - }); - }); - } - - setTimeout(function () { - that.createLi(); - that.$element.trigger('loaded' + EVENT_KEY); - }); - }, - - createDropdown: function () { - // Options - // If we are multiple or showTick option is set, then add the show-tick class - var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '', - multiselectable = this.multiple ? ' aria-multiselectable="true"' : '', - inputGroup = '', - autofocus = this.autofocus ? ' autofocus' : ''; - - if (version.major < 4 && this.$element.parent().hasClass('input-group')) { - inputGroup = ' input-group-btn'; - } - - // Elements - var drop, - header = '', - searchbox = '', - actionsbox = '', - donebutton = ''; - - if (this.options.header) { - header = - '
    ' + - '' + - this.options.header + - '
    '; - } - - if (this.options.liveSearch) { - searchbox = - ''; - } - - if (this.multiple && this.options.actionsBox) { - actionsbox = - '
    ' + - '
    ' + - '' + - '' + - '
    ' + - '
    '; - } - - if (this.multiple && this.options.doneButton) { - donebutton = - '
    ' + - '
    ' + - '' + - '
    ' + - '
    '; - } - - drop = - ''; - - return $(drop); - }, - - setPositionData: function () { - this.selectpicker.view.canHighlight = []; - this.selectpicker.view.size = 0; - - for (var i = 0; i < this.selectpicker.current.data.length; i++) { - var li = this.selectpicker.current.data[i], - canHighlight = true; - - if (li.type === 'divider') { - canHighlight = false; - li.height = this.sizeInfo.dividerHeight; - } else if (li.type === 'optgroup-label') { - canHighlight = false; - li.height = this.sizeInfo.dropdownHeaderHeight; - } else { - li.height = this.sizeInfo.liHeight; - } - - if (li.disabled) canHighlight = false; - - this.selectpicker.view.canHighlight.push(canHighlight); - - if (canHighlight) { - this.selectpicker.view.size++; - li.posinset = this.selectpicker.view.size; - } - - li.position = (i === 0 ? 0 : this.selectpicker.current.data[i - 1].position) + li.height; - } - }, - - isVirtual: function () { - return (this.options.virtualScroll !== false) && (this.selectpicker.main.elements.length >= this.options.virtualScroll) || this.options.virtualScroll === true; - }, - - createView: function (isSearching, setSize, refresh) { - var that = this, - scrollTop = 0, - active = [], - selected, - prevActive; - - this.selectpicker.current = isSearching ? this.selectpicker.search : this.selectpicker.main; - - this.setPositionData(); - - if (setSize) { - if (refresh) { - scrollTop = this.$menuInner[0].scrollTop; - } else if (!that.multiple) { - var element = that.$element[0], - selectedIndex = (element.options[element.selectedIndex] || {}).liIndex; - - if (typeof selectedIndex === 'number' && that.options.size !== false) { - var selectedData = that.selectpicker.main.data[selectedIndex], - position = selectedData && selectedData.position; - - if (position) { - scrollTop = position - ((that.sizeInfo.menuInnerHeight + that.sizeInfo.liHeight) / 2); - } - } - } - } - - scroll(scrollTop, true); - - this.$menuInner.off('scroll.createView').on('scroll.createView', function (e, updateValue) { - if (!that.noScroll) scroll(this.scrollTop, updateValue); - that.noScroll = false; - }); - - function scroll (scrollTop, init) { - var size = that.selectpicker.current.elements.length, - chunks = [], - chunkSize, - chunkCount, - firstChunk, - lastChunk, - currentChunk, - prevPositions, - positionIsDifferent, - previousElements, - menuIsDifferent = true, - isVirtual = that.isVirtual(); - - that.selectpicker.view.scrollTop = scrollTop; - - if (isVirtual === true) { - // if an option that is encountered that is wider than the current menu width, update the menu width accordingly - if (that.sizeInfo.hasScrollBar && that.$menu[0].offsetWidth > that.sizeInfo.totalMenuWidth) { - that.sizeInfo.menuWidth = that.$menu[0].offsetWidth; - that.sizeInfo.totalMenuWidth = that.sizeInfo.menuWidth + that.sizeInfo.scrollBarWidth; - that.$menu.css('min-width', that.sizeInfo.menuWidth); - } - } - - chunkSize = Math.ceil(that.sizeInfo.menuInnerHeight / that.sizeInfo.liHeight * 1.5); // number of options in a chunk - chunkCount = Math.round(size / chunkSize) || 1; // number of chunks - - for (var i = 0; i < chunkCount; i++) { - var endOfChunk = (i + 1) * chunkSize; - - if (i === chunkCount - 1) { - endOfChunk = size; - } - - chunks[i] = [ - (i) * chunkSize + (!i ? 0 : 1), - endOfChunk - ]; - - if (!size) break; - - if (currentChunk === undefined && scrollTop <= that.selectpicker.current.data[endOfChunk - 1].position - that.sizeInfo.menuInnerHeight) { - currentChunk = i; - } - } - - if (currentChunk === undefined) currentChunk = 0; - - prevPositions = [that.selectpicker.view.position0, that.selectpicker.view.position1]; - - // always display previous, current, and next chunks - firstChunk = Math.max(0, currentChunk - 1); - lastChunk = Math.min(chunkCount - 1, currentChunk + 1); - - that.selectpicker.view.position0 = isVirtual === false ? 0 : (Math.max(0, chunks[firstChunk][0]) || 0); - that.selectpicker.view.position1 = isVirtual === false ? size : (Math.min(size, chunks[lastChunk][1]) || 0); - - positionIsDifferent = prevPositions[0] !== that.selectpicker.view.position0 || prevPositions[1] !== that.selectpicker.view.position1; - - if (that.activeIndex !== undefined) { - prevActive = that.selectpicker.main.elements[that.prevActiveIndex]; - active = that.selectpicker.main.elements[that.activeIndex]; - selected = that.selectpicker.main.elements[that.selectedIndex]; - - if (init) { - if (that.activeIndex !== that.selectedIndex) { - that.defocusItem(active); - } - that.activeIndex = undefined; - } - - if (that.activeIndex && that.activeIndex !== that.selectedIndex) { - that.defocusItem(selected); - } - } - - if (that.prevActiveIndex !== undefined && that.prevActiveIndex !== that.activeIndex && that.prevActiveIndex !== that.selectedIndex) { - that.defocusItem(prevActive); - } - - if (init || positionIsDifferent) { - previousElements = that.selectpicker.view.visibleElements ? that.selectpicker.view.visibleElements.slice() : []; - - if (isVirtual === false) { - that.selectpicker.view.visibleElements = that.selectpicker.current.elements; - } else { - that.selectpicker.view.visibleElements = that.selectpicker.current.elements.slice(that.selectpicker.view.position0, that.selectpicker.view.position1); - } - - that.setOptionStatus(); - - // if searching, check to make sure the list has actually been updated before updating DOM - // this prevents unnecessary repaints - if (isSearching || (isVirtual === false && init)) menuIsDifferent = !isEqual(previousElements, that.selectpicker.view.visibleElements); - - // if virtual scroll is disabled and not searching, - // menu should never need to be updated more than once - if ((init || isVirtual === true) && menuIsDifferent) { - var menuInner = that.$menuInner[0], - menuFragment = document.createDocumentFragment(), - emptyMenu = menuInner.firstChild.cloneNode(false), - marginTop, - marginBottom, - elements = that.selectpicker.view.visibleElements, - toSanitize = []; - - // replace the existing UL with an empty one - this is faster than $.empty() - menuInner.replaceChild(emptyMenu, menuInner.firstChild); - - for (var i = 0, visibleElementsLen = elements.length; i < visibleElementsLen; i++) { - var element = elements[i], - elText, - elementData; - - if (that.options.sanitize) { - elText = element.lastChild; - - if (elText) { - elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0]; - - if (elementData && elementData.content && !elementData.sanitized) { - toSanitize.push(elText); - elementData.sanitized = true; - } - } - } - - menuFragment.appendChild(element); - } - - if (that.options.sanitize && toSanitize.length) { - sanitizeHtml(toSanitize, that.options.whiteList, that.options.sanitizeFn); - } - - if (isVirtual === true) { - marginTop = (that.selectpicker.view.position0 === 0 ? 0 : that.selectpicker.current.data[that.selectpicker.view.position0 - 1].position); - marginBottom = (that.selectpicker.view.position1 > size - 1 ? 0 : that.selectpicker.current.data[size - 1].position - that.selectpicker.current.data[that.selectpicker.view.position1 - 1].position); - - menuInner.firstChild.style.marginTop = marginTop + 'px'; - menuInner.firstChild.style.marginBottom = marginBottom + 'px'; - } else { - menuInner.firstChild.style.marginTop = 0; - menuInner.firstChild.style.marginBottom = 0; - } - - menuInner.firstChild.appendChild(menuFragment); - } - } - - that.prevActiveIndex = that.activeIndex; - - if (!that.options.liveSearch) { - that.$menuInner.trigger('focus'); - } else if (isSearching && init) { - var index = 0, - newActive; - - if (!that.selectpicker.view.canHighlight[index]) { - index = 1 + that.selectpicker.view.canHighlight.slice(1).indexOf(true); - } - - newActive = that.selectpicker.view.visibleElements[index]; - - that.defocusItem(that.selectpicker.view.currentActive); - - that.activeIndex = (that.selectpicker.current.data[index] || {}).index; - - that.focusItem(newActive); - } - } - - $(window) - .off('resize' + EVENT_KEY + '.' + this.selectId + '.createView') - .on('resize' + EVENT_KEY + '.' + this.selectId + '.createView', function () { - var isActive = that.$newElement.hasClass(classNames.SHOW); - - if (isActive) scroll(that.$menuInner[0].scrollTop); - }); - }, - - focusItem: function (li, liData, noStyle) { - if (li) { - liData = liData || this.selectpicker.main.data[this.activeIndex]; - var a = li.firstChild; - - if (a) { - a.setAttribute('aria-setsize', this.selectpicker.view.size); - a.setAttribute('aria-posinset', liData.posinset); - - if (noStyle !== true) { - this.focusedParent.setAttribute('aria-activedescendant', a.id); - li.classList.add('active'); - a.classList.add('active'); - } - } - } - }, - - defocusItem: function (li) { - if (li) { - li.classList.remove('active'); - if (li.firstChild) li.firstChild.classList.remove('active'); - } - }, - - setPlaceholder: function () { - var updateIndex = false; - - if (this.options.title && !this.multiple) { - if (!this.selectpicker.view.titleOption) this.selectpicker.view.titleOption = document.createElement('option'); - - // this option doesn't create a new
  • element, but does add a new option at the start, - // so startIndex should increase to prevent having to check every option for the bs-title-option class - updateIndex = true; - - var element = this.$element[0], - isSelected = false, - titleNotAppended = !this.selectpicker.view.titleOption.parentNode; - - if (titleNotAppended) { - // Use native JS to prepend option (faster) - this.selectpicker.view.titleOption.className = 'bs-title-option'; - this.selectpicker.view.titleOption.value = ''; - - // Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option. - // the selected item may have been changed by user or programmatically before the bootstrap select plugin runs, - // if so, the select will have the data-selected attribute - var $opt = $(element.options[element.selectedIndex]); - isSelected = $opt.attr('selected') === undefined && this.$element.data('selected') === undefined; - } - - if (titleNotAppended || this.selectpicker.view.titleOption.index !== 0) { - element.insertBefore(this.selectpicker.view.titleOption, element.firstChild); - } - - // Set selected *after* appending to select, - // otherwise the option doesn't get selected in IE - // set using selectedIndex, as setting the selected attr to true here doesn't work in IE11 - if (isSelected) element.selectedIndex = 0; - } - - return updateIndex; - }, - - createLi: function () { - var that = this, - iconBase = this.options.iconBase, - optionSelector = ':not([hidden]):not([data-hidden="true"])', - mainElements = [], - mainData = [], - widestOptionLength = 0, - optID = 0, - startIndex = this.setPlaceholder() ? 1 : 0; // append the titleOption if necessary and skip the first option in the loop - - if (this.options.hideDisabled) optionSelector += ':not(:disabled)'; - - if ((that.options.showTick || that.multiple) && !elementTemplates.checkMark.parentNode) { - elementTemplates.checkMark.className = iconBase + ' ' + that.options.tickIcon + ' check-mark'; - elementTemplates.a.appendChild(elementTemplates.checkMark); - } - - var selectOptions = this.$element[0].querySelectorAll('select > *' + optionSelector); - - function addDivider (config) { - var previousData = mainData[mainData.length - 1]; - - // ensure optgroup doesn't create back-to-back dividers - if ( - previousData && - previousData.type === 'divider' && - (previousData.optID || config.optID) - ) { - return; - } - - config = config || {}; - config.type = 'divider'; - - mainElements.push( - generateOption.li( - false, - classNames.DIVIDER, - (config.optID ? config.optID + 'div' : undefined) - ) - ); - - mainData.push(config); - } - - function addOption (option, config) { - config = config || {}; - - config.divider = option.getAttribute('data-divider') === 'true'; - - if (config.divider) { - addDivider({ - optID: config.optID - }); - } else { - var liIndex = mainData.length, - cssText = option.style.cssText, - inlineStyle = cssText ? htmlEscape(cssText) : '', - optionClass = (option.className || '') + (config.optgroupClass || ''); - - if (config.optID) optionClass = 'opt ' + optionClass; - - config.text = option.textContent; - - config.content = option.getAttribute('data-content'); - config.tokens = option.getAttribute('data-tokens'); - config.subtext = option.getAttribute('data-subtext'); - config.icon = option.getAttribute('data-icon'); - config.iconBase = iconBase; - - var textElement = generateOption.text(config); - var liElement = generateOption.li( - generateOption.a( - textElement, - optionClass, - inlineStyle - ), - '', - config.optID - ); - - if (liElement.firstChild) { - liElement.firstChild.id = that.selectId + '-' + liIndex; - } - - mainElements.push(liElement); - - option.liIndex = liIndex; - - config.display = config.content || config.text; - config.type = 'option'; - config.index = liIndex; - config.option = option; - config.disabled = config.disabled || option.disabled; - - mainData.push(config); - - var combinedLength = 0; - - // count the number of characters in the option - not perfect, but should work in most cases - if (config.display) combinedLength += config.display.length; - if (config.subtext) combinedLength += config.subtext.length; - // if there is an icon, ensure this option's width is checked - if (config.icon) combinedLength += 1; - - if (combinedLength > widestOptionLength) { - widestOptionLength = combinedLength; - - // guess which option is the widest - // use this when calculating menu width - // not perfect, but it's fast, and the width will be updating accordingly when scrolling - that.selectpicker.view.widestOption = mainElements[mainElements.length - 1]; - } - } - } - - function addOptgroup (index, selectOptions) { - var optgroup = selectOptions[index], - previous = selectOptions[index - 1], - next = selectOptions[index + 1], - options = optgroup.querySelectorAll('option' + optionSelector); - - if (!options.length) return; - - var config = { - label: htmlEscape(optgroup.label), - subtext: optgroup.getAttribute('data-subtext'), - icon: optgroup.getAttribute('data-icon'), - iconBase: iconBase - }, - optgroupClass = ' ' + (optgroup.className || ''), - headerIndex, - lastIndex; - - optID++; - - if (previous) { - addDivider({ optID: optID }); - } - - var labelElement = generateOption.label(config); - - mainElements.push( - generateOption.li(labelElement, 'dropdown-header' + optgroupClass, optID) - ); - - mainData.push({ - display: config.label, - subtext: config.subtext, - type: 'optgroup-label', - optID: optID - }); - - for (var j = 0, len = options.length; j < len; j++) { - var option = options[j]; - - if (j === 0) { - headerIndex = mainData.length - 1; - lastIndex = headerIndex + len; - } - - addOption(option, { - headerIndex: headerIndex, - lastIndex: lastIndex, - optID: optID, - optgroupClass: optgroupClass, - disabled: optgroup.disabled - }); - } - - if (next) { - addDivider({ optID: optID }); - } - } - - for (var len = selectOptions.length; startIndex < len; startIndex++) { - var item = selectOptions[startIndex]; - - if (item.tagName !== 'OPTGROUP') { - addOption(item, {}); - } else { - addOptgroup(startIndex, selectOptions); - } - } - - this.selectpicker.main.elements = mainElements; - this.selectpicker.main.data = mainData; - - this.selectpicker.current = this.selectpicker.main; - }, - - findLis: function () { - return this.$menuInner.find('.inner > li'); - }, - - render: function () { - // ensure titleOption is appended and selected (if necessary) before getting selectedOptions - this.setPlaceholder(); - - var that = this, - element = this.$element[0], - selectedOptions = getSelectedOptions(element, this.options.hideDisabled), - selectedCount = selectedOptions.length, - button = this.$button[0], - buttonInner = button.querySelector('.filter-option-inner-inner'), - multipleSeparator = document.createTextNode(this.options.multipleSeparator), - titleFragment = elementTemplates.fragment.cloneNode(false), - showCount, - countMax, - hasContent = false; - - button.classList.toggle('bs-placeholder', that.multiple ? !selectedCount : !getSelectValues(element, selectedOptions)); - - this.tabIndex(); - - if (this.options.selectedTextFormat === 'static') { - titleFragment = generateOption.text({ text: this.options.title }, true); - } else { - showCount = this.multiple && this.options.selectedTextFormat.indexOf('count') !== -1 && selectedCount > 1; - - // determine if the number of selected options will be shown (showCount === true) - if (showCount) { - countMax = this.options.selectedTextFormat.split('>'); - showCount = (countMax.length > 1 && selectedCount > countMax[1]) || (countMax.length === 1 && selectedCount >= 2); - } - - // only loop through all selected options if the count won't be shown - if (showCount === false) { - for (var selectedIndex = 0; selectedIndex < selectedCount; selectedIndex++) { - if (selectedIndex < 50) { - var option = selectedOptions[selectedIndex], - titleOptions = {}, - thisData = { - content: option.getAttribute('data-content'), - subtext: option.getAttribute('data-subtext'), - icon: option.getAttribute('data-icon') - }; - - if (this.multiple && selectedIndex > 0) { - titleFragment.appendChild(multipleSeparator.cloneNode(false)); - } - - if (option.title) { - titleOptions.text = option.title; - } else if (thisData.content && that.options.showContent) { - titleOptions.content = thisData.content.toString(); - hasContent = true; - } else { - if (that.options.showIcon) { - titleOptions.icon = thisData.icon; - titleOptions.iconBase = this.options.iconBase; - } - if (that.options.showSubtext && !that.multiple && thisData.subtext) titleOptions.subtext = ' ' + thisData.subtext; - titleOptions.text = option.textContent.trim(); - } - - titleFragment.appendChild(generateOption.text(titleOptions, true)); - } else { - break; - } - } - - // add ellipsis - if (selectedCount > 49) { - titleFragment.appendChild(document.createTextNode('...')); - } - } else { - var optionSelector = ':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])'; - if (this.options.hideDisabled) optionSelector += ':not(:disabled)'; - - // If this is a multiselect, and selectedTextFormat is count, then show 1 of 2 selected, etc. - var totalCount = this.$element[0].querySelectorAll('select > option' + optionSelector + ', optgroup' + optionSelector + ' option' + optionSelector).length, - tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedCount, totalCount) : this.options.countSelectedText; - - titleFragment = generateOption.text({ - text: tr8nText.replace('{0}', selectedCount.toString()).replace('{1}', totalCount.toString()) - }, true); - } - } - - if (this.options.title == undefined) { - // use .attr to ensure undefined is returned if title attribute is not set - this.options.title = this.$element.attr('title'); - } - - // If the select doesn't have a title, then use the default, or if nothing is set at all, use noneSelectedText - if (!titleFragment.childNodes.length) { - titleFragment = generateOption.text({ - text: typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText - }, true); - } - - // strip all HTML tags and trim the result, then unescape any escaped tags - button.title = titleFragment.textContent.replace(/<[^>]*>?/g, '').trim(); - - if (this.options.sanitize && hasContent) { - sanitizeHtml([titleFragment], that.options.whiteList, that.options.sanitizeFn); - } - - buttonInner.innerHTML = ''; - buttonInner.appendChild(titleFragment); - - if (version.major < 4 && this.$newElement[0].classList.contains('bs3-has-addon')) { - var filterExpand = button.querySelector('.filter-expand'), - clone = buttonInner.cloneNode(true); - - clone.className = 'filter-expand'; - - if (filterExpand) { - button.replaceChild(clone, filterExpand); - } else { - button.appendChild(clone); - } - } - - this.$element.trigger('rendered' + EVENT_KEY); - }, - - /** - * @param [style] - * @param [status] - */ - setStyle: function (newStyle, status) { - var button = this.$button[0], - newElement = this.$newElement[0], - style = this.options.style.trim(), - buttonClass; - - if (this.$element.attr('class')) { - this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, '')); - } - - if (version.major < 4) { - newElement.classList.add('bs3'); - - if (newElement.parentNode.classList.contains('input-group') && - (newElement.previousElementSibling || newElement.nextElementSibling) && - (newElement.previousElementSibling || newElement.nextElementSibling).classList.contains('input-group-addon') - ) { - newElement.classList.add('bs3-has-addon'); - } - } - - if (newStyle) { - buttonClass = newStyle.trim(); - } else { - buttonClass = style; - } - - if (status == 'add') { - if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' ')); - } else if (status == 'remove') { - if (buttonClass) button.classList.remove.apply(button.classList, buttonClass.split(' ')); - } else { - if (style) button.classList.remove.apply(button.classList, style.split(' ')); - if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' ')); - } - }, - - liHeight: function (refresh) { - if (!refresh && (this.options.size === false || this.sizeInfo)) return; - - if (!this.sizeInfo) this.sizeInfo = {}; - - var newElement = document.createElement('div'), - menu = document.createElement('div'), - menuInner = document.createElement('div'), - menuInnerInner = document.createElement('ul'), - divider = document.createElement('li'), - dropdownHeader = document.createElement('li'), - li = document.createElement('li'), - a = document.createElement('a'), - text = document.createElement('span'), - header = this.options.header && this.$menu.find('.' + classNames.POPOVERHEADER).length > 0 ? this.$menu.find('.' + classNames.POPOVERHEADER)[0].cloneNode(true) : null, - search = this.options.liveSearch ? document.createElement('div') : null, - actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null, - doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null, - firstOption = this.$element.find('option')[0]; - - this.sizeInfo.selectWidth = this.$newElement[0].offsetWidth; - - text.className = 'text'; - a.className = 'dropdown-item ' + (firstOption ? firstOption.className : ''); - newElement.className = this.$menu[0].parentNode.className + ' ' + classNames.SHOW; - newElement.style.width = this.sizeInfo.selectWidth + 'px'; - if (this.options.width === 'auto') menu.style.minWidth = 0; - menu.className = classNames.MENU + ' ' + classNames.SHOW; - menuInner.className = 'inner ' + classNames.SHOW; - menuInnerInner.className = classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : ''); - divider.className = classNames.DIVIDER; - dropdownHeader.className = 'dropdown-header'; - - text.appendChild(document.createTextNode('\u200b')); - a.appendChild(text); - li.appendChild(a); - dropdownHeader.appendChild(text.cloneNode(true)); - - if (this.selectpicker.view.widestOption) { - menuInnerInner.appendChild(this.selectpicker.view.widestOption.cloneNode(true)); - } - - menuInnerInner.appendChild(li); - menuInnerInner.appendChild(divider); - menuInnerInner.appendChild(dropdownHeader); - if (header) menu.appendChild(header); - if (search) { - var input = document.createElement('input'); - search.className = 'bs-searchbox'; - input.className = 'form-control'; - search.appendChild(input); - menu.appendChild(search); - } - if (actions) menu.appendChild(actions); - menuInner.appendChild(menuInnerInner); - menu.appendChild(menuInner); - if (doneButton) menu.appendChild(doneButton); - newElement.appendChild(menu); - - document.body.appendChild(newElement); - - var liHeight = li.offsetHeight, - dropdownHeaderHeight = dropdownHeader ? dropdownHeader.offsetHeight : 0, - headerHeight = header ? header.offsetHeight : 0, - searchHeight = search ? search.offsetHeight : 0, - actionsHeight = actions ? actions.offsetHeight : 0, - doneButtonHeight = doneButton ? doneButton.offsetHeight : 0, - dividerHeight = $(divider).outerHeight(true), - // fall back to jQuery if getComputedStyle is not supported - menuStyle = window.getComputedStyle ? window.getComputedStyle(menu) : false, - menuWidth = menu.offsetWidth, - $menu = menuStyle ? null : $(menu), - menuPadding = { - vert: toInteger(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) + - toInteger(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) + - toInteger(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) + - toInteger(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')), - horiz: toInteger(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) + - toInteger(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) + - toInteger(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) + - toInteger(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth')) - }, - menuExtras = { - vert: menuPadding.vert + - toInteger(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) + - toInteger(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2, - horiz: menuPadding.horiz + - toInteger(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) + - toInteger(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2 - }, - scrollBarWidth; - - menuInner.style.overflowY = 'scroll'; - - scrollBarWidth = menu.offsetWidth - menuWidth; - - document.body.removeChild(newElement); - - this.sizeInfo.liHeight = liHeight; - this.sizeInfo.dropdownHeaderHeight = dropdownHeaderHeight; - this.sizeInfo.headerHeight = headerHeight; - this.sizeInfo.searchHeight = searchHeight; - this.sizeInfo.actionsHeight = actionsHeight; - this.sizeInfo.doneButtonHeight = doneButtonHeight; - this.sizeInfo.dividerHeight = dividerHeight; - this.sizeInfo.menuPadding = menuPadding; - this.sizeInfo.menuExtras = menuExtras; - this.sizeInfo.menuWidth = menuWidth; - this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth; - this.sizeInfo.scrollBarWidth = scrollBarWidth; - this.sizeInfo.selectHeight = this.$newElement[0].offsetHeight; - - this.setPositionData(); - }, - - getSelectPosition: function () { - var that = this, - $window = $(window), - pos = that.$newElement.offset(), - $container = $(that.options.container), - containerPos; - - if (that.options.container && $container.length && !$container.is('body')) { - containerPos = $container.offset(); - containerPos.top += parseInt($container.css('borderTopWidth')); - containerPos.left += parseInt($container.css('borderLeftWidth')); - } else { - containerPos = { top: 0, left: 0 }; - } - - var winPad = that.options.windowPadding; - - this.sizeInfo.selectOffsetTop = pos.top - containerPos.top - $window.scrollTop(); - this.sizeInfo.selectOffsetBot = $window.height() - this.sizeInfo.selectOffsetTop - this.sizeInfo.selectHeight - containerPos.top - winPad[2]; - this.sizeInfo.selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft(); - this.sizeInfo.selectOffsetRight = $window.width() - this.sizeInfo.selectOffsetLeft - this.sizeInfo.selectWidth - containerPos.left - winPad[1]; - this.sizeInfo.selectOffsetTop -= winPad[0]; - this.sizeInfo.selectOffsetLeft -= winPad[3]; - }, - - setMenuSize: function (isAuto) { - this.getSelectPosition(); - - var selectWidth = this.sizeInfo.selectWidth, - liHeight = this.sizeInfo.liHeight, - headerHeight = this.sizeInfo.headerHeight, - searchHeight = this.sizeInfo.searchHeight, - actionsHeight = this.sizeInfo.actionsHeight, - doneButtonHeight = this.sizeInfo.doneButtonHeight, - divHeight = this.sizeInfo.dividerHeight, - menuPadding = this.sizeInfo.menuPadding, - menuInnerHeight, - menuHeight, - divLength = 0, - minHeight, - _minHeight, - maxHeight, - menuInnerMinHeight, - estimate; - - if (this.options.dropupAuto) { - // Get the estimated height of the menu without scrollbars. - // This is useful for smaller menus, where there might be plenty of room - // below the button without setting dropup, but we can't know - // the exact height of the menu until createView is called later - estimate = liHeight * this.selectpicker.current.elements.length + menuPadding.vert; - this.$newElement.toggleClass(classNames.DROPUP, this.sizeInfo.selectOffsetTop - this.sizeInfo.selectOffsetBot > this.sizeInfo.menuExtras.vert && estimate + this.sizeInfo.menuExtras.vert + 50 > this.sizeInfo.selectOffsetBot); - } - - if (this.options.size === 'auto') { - _minHeight = this.selectpicker.current.elements.length > 3 ? this.sizeInfo.liHeight * 3 + this.sizeInfo.menuExtras.vert - 2 : 0; - menuHeight = this.sizeInfo.selectOffsetBot - this.sizeInfo.menuExtras.vert; - minHeight = _minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight; - menuInnerMinHeight = Math.max(_minHeight - menuPadding.vert, 0); - - if (this.$newElement.hasClass(classNames.DROPUP)) { - menuHeight = this.sizeInfo.selectOffsetTop - this.sizeInfo.menuExtras.vert; - } - - maxHeight = menuHeight; - menuInnerHeight = menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert; - } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) { - for (var i = 0; i < this.options.size; i++) { - if (this.selectpicker.current.data[i].type === 'divider') divLength++; - } - - menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert; - menuInnerHeight = menuHeight - menuPadding.vert; - maxHeight = menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight; - minHeight = menuInnerMinHeight = ''; - } - - if (this.options.dropdownAlignRight === 'auto') { - this.$menu.toggleClass(classNames.MENURIGHT, this.sizeInfo.selectOffsetLeft > this.sizeInfo.selectOffsetRight && this.sizeInfo.selectOffsetRight < (this.sizeInfo.totalMenuWidth - selectWidth)); - } - - this.$menu.css({ - 'max-height': maxHeight + 'px', - 'overflow': 'hidden', - 'min-height': minHeight + 'px' - }); - - this.$menuInner.css({ - 'max-height': menuInnerHeight + 'px', - 'overflow-y': 'auto', - 'min-height': menuInnerMinHeight + 'px' - }); - - // ensure menuInnerHeight is always a positive number to prevent issues calculating chunkSize in createView - this.sizeInfo.menuInnerHeight = Math.max(menuInnerHeight, 1); - - if (this.selectpicker.current.data.length && this.selectpicker.current.data[this.selectpicker.current.data.length - 1].position > this.sizeInfo.menuInnerHeight) { - this.sizeInfo.hasScrollBar = true; - this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth + this.sizeInfo.scrollBarWidth; - - this.$menu.css('min-width', this.sizeInfo.totalMenuWidth); - } - - if (this.dropdown && this.dropdown._popper) this.dropdown._popper.update(); - }, - - setSize: function (refresh) { - this.liHeight(refresh); - - if (this.options.header) this.$menu.css('padding-top', 0); - if (this.options.size === false) return; - - var that = this, - $window = $(window); - - this.setMenuSize(); - - if (this.options.liveSearch) { - this.$searchbox - .off('input.setMenuSize propertychange.setMenuSize') - .on('input.setMenuSize propertychange.setMenuSize', function () { - return that.setMenuSize(); - }); - } - - if (this.options.size === 'auto') { - $window - .off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize') - .on('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize', function () { - return that.setMenuSize(); - }); - } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) { - $window.off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize'); - } - - that.createView(false, true, refresh); - }, - - setWidth: function () { - var that = this; - - if (this.options.width === 'auto') { - requestAnimationFrame(function () { - that.$menu.css('min-width', '0'); - - that.$element.on('loaded' + EVENT_KEY, function () { - that.liHeight(); - that.setMenuSize(); - - // Get correct width if element is hidden - var $selectClone = that.$newElement.clone().appendTo('body'), - btnWidth = $selectClone.css('width', 'auto').children('button').outerWidth(); - - $selectClone.remove(); - - // Set width to whatever's larger, button title or longest option - that.sizeInfo.selectWidth = Math.max(that.sizeInfo.totalMenuWidth, btnWidth); - that.$newElement.css('width', that.sizeInfo.selectWidth + 'px'); - }); - }); - } else if (this.options.width === 'fit') { - // Remove inline min-width so width can be changed from 'auto' - this.$menu.css('min-width', ''); - this.$newElement.css('width', '').addClass('fit-width'); - } else if (this.options.width) { - // Remove inline min-width so width can be changed from 'auto' - this.$menu.css('min-width', ''); - this.$newElement.css('width', this.options.width); - } else { - // Remove inline min-width/width so width can be changed - this.$menu.css('min-width', ''); - this.$newElement.css('width', ''); - } - // Remove fit-width class if width is changed programmatically - if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') { - this.$newElement[0].classList.remove('fit-width'); - } - }, - - selectPosition: function () { - this.$bsContainer = $('
    '); - - var that = this, - $container = $(this.options.container), - pos, - containerPos, - actualHeight, - getPlacement = function ($element) { - var containerPosition = {}, - // fall back to dropdown's default display setting if display is not manually set - display = that.options.display || ( - // Bootstrap 3 doesn't have $.fn.dropdown.Constructor.Default - $.fn.dropdown.Constructor.Default ? $.fn.dropdown.Constructor.Default.display - : false - ); - - that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass(classNames.DROPUP, $element.hasClass(classNames.DROPUP)); - pos = $element.offset(); - - if (!$container.is('body')) { - containerPos = $container.offset(); - containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop(); - containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft(); - } else { - containerPos = { top: 0, left: 0 }; - } - - actualHeight = $element.hasClass(classNames.DROPUP) ? 0 : $element[0].offsetHeight; - - // Bootstrap 4+ uses Popper for menu positioning - if (version.major < 4 || display === 'static') { - containerPosition.top = pos.top - containerPos.top + actualHeight; - containerPosition.left = pos.left - containerPos.left; - } - - containerPosition.width = $element[0].offsetWidth; - - that.$bsContainer.css(containerPosition); - }; - - this.$button.on('click.bs.dropdown.data-api', function () { - if (that.isDisabled()) { - return; - } - - getPlacement(that.$newElement); - - that.$bsContainer - .appendTo(that.options.container) - .toggleClass(classNames.SHOW, !that.$button.hasClass(classNames.SHOW)) - .append(that.$menu); - }); - - $(window) - .off('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId) - .on('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId, function () { - var isActive = that.$newElement.hasClass(classNames.SHOW); - - if (isActive) getPlacement(that.$newElement); - }); - - this.$element.on('hide' + EVENT_KEY, function () { - that.$menu.data('height', that.$menu.height()); - that.$bsContainer.detach(); - }); - }, - - setOptionStatus: function (selectedOnly) { - var that = this; - - that.noScroll = false; - - if (that.selectpicker.view.visibleElements && that.selectpicker.view.visibleElements.length) { - for (var i = 0; i < that.selectpicker.view.visibleElements.length; i++) { - var liData = that.selectpicker.current.data[i + that.selectpicker.view.position0], - option = liData.option; - - if (option) { - if (selectedOnly !== true) { - that.setDisabled( - liData.index, - liData.disabled - ); - } - - that.setSelected( - liData.index, - option.selected - ); - } - } - } - }, - - /** - * @param {number} index - the index of the option that is being changed - * @param {boolean} selected - true if the option is being selected, false if being deselected - */ - setSelected: function (index, selected) { - var li = this.selectpicker.main.elements[index], - liData = this.selectpicker.main.data[index], - activeIndexIsSet = this.activeIndex !== undefined, - thisIsActive = this.activeIndex === index, - prevActive, - a, - // if current option is already active - // OR - // if the current option is being selected, it's NOT multiple, and - // activeIndex is undefined: - // - when the menu is first being opened, OR - // - after a search has been performed, OR - // - when retainActive is false when selecting a new option (i.e. index of the newly selected option is not the same as the current activeIndex) - keepActive = thisIsActive || (selected && !this.multiple && !activeIndexIsSet); - - liData.selected = selected; - - a = li.firstChild; - - if (selected) { - this.selectedIndex = index; - } - - li.classList.toggle('selected', selected); - - if (keepActive) { - this.focusItem(li, liData); - this.selectpicker.view.currentActive = li; - this.activeIndex = index; - } else { - this.defocusItem(li); - } - - if (a) { - a.classList.toggle('selected', selected); - - if (selected) { - a.setAttribute('aria-selected', true); - } else { - if (this.multiple) { - a.setAttribute('aria-selected', false); - } else { - a.removeAttribute('aria-selected'); - } - } - } - - if (!keepActive && !activeIndexIsSet && selected && this.prevActiveIndex !== undefined) { - prevActive = this.selectpicker.main.elements[this.prevActiveIndex]; - - this.defocusItem(prevActive); - } - }, - - /** - * @param {number} index - the index of the option that is being disabled - * @param {boolean} disabled - true if the option is being disabled, false if being enabled - */ - setDisabled: function (index, disabled) { - var li = this.selectpicker.main.elements[index], - a; - - this.selectpicker.main.data[index].disabled = disabled; - - a = li.firstChild; - - li.classList.toggle(classNames.DISABLED, disabled); - - if (a) { - if (version.major === '4') a.classList.toggle(classNames.DISABLED, disabled); - - if (disabled) { - a.setAttribute('aria-disabled', disabled); - a.setAttribute('tabindex', -1); - } else { - a.removeAttribute('aria-disabled'); - a.setAttribute('tabindex', 0); - } - } - }, - - isDisabled: function () { - return this.$element[0].disabled; - }, - - checkDisabled: function () { - var that = this; - - if (this.isDisabled()) { - this.$newElement[0].classList.add(classNames.DISABLED); - this.$button.addClass(classNames.DISABLED).attr('tabindex', -1).attr('aria-disabled', true); - } else { - if (this.$button[0].classList.contains(classNames.DISABLED)) { - this.$newElement[0].classList.remove(classNames.DISABLED); - this.$button.removeClass(classNames.DISABLED).attr('aria-disabled', false); - } - - if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) { - this.$button.removeAttr('tabindex'); - } - } - - this.$button.on('click', function () { - return !that.isDisabled(); - }); - }, - - tabIndex: function () { - if (this.$element.data('tabindex') !== this.$element.attr('tabindex') && - (this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) { - this.$element.data('tabindex', this.$element.attr('tabindex')); - this.$button.attr('tabindex', this.$element.data('tabindex')); - } - - this.$element.attr('tabindex', -98); - }, - - clickListener: function () { - var that = this, - $document = $(document); - - $document.data('spaceSelect', false); - - this.$button.on('keyup', function (e) { - if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) { - e.preventDefault(); - $document.data('spaceSelect', false); - } - }); - - this.$newElement.on('show.bs.dropdown', function () { - if (version.major > 3 && !that.dropdown) { - that.dropdown = that.$button.data('bs.dropdown'); - that.dropdown._menu = that.$menu[0]; - } - }); - - this.$button.on('click.bs.dropdown.data-api', function () { - if (!that.$newElement.hasClass(classNames.SHOW)) { - that.setSize(); - } - }); - - function setFocus () { - if (that.options.liveSearch) { - that.$searchbox.trigger('focus'); - } else { - that.$menuInner.trigger('focus'); - } - } - - function checkPopperExists () { - if (that.dropdown && that.dropdown._popper && that.dropdown._popper.state.isCreated) { - setFocus(); - } else { - requestAnimationFrame(checkPopperExists); - } - } - - this.$element.on('shown' + EVENT_KEY, function () { - if (that.$menuInner[0].scrollTop !== that.selectpicker.view.scrollTop) { - that.$menuInner[0].scrollTop = that.selectpicker.view.scrollTop; - } - - if (version.major > 3) { - requestAnimationFrame(checkPopperExists); - } else { - setFocus(); - } - }); - - // ensure posinset and setsize are correct before selecting an option via a click - this.$menuInner.on('mouseenter', 'li a', function (e) { - var hoverLi = this.parentElement, - position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0, - index = Array.prototype.indexOf.call(hoverLi.parentElement.children, hoverLi), - hoverData = that.selectpicker.current.data[index + position0]; - - that.focusItem(hoverLi, hoverData, true); - }); - - this.$menuInner.on('click', 'li a', function (e, retainActive) { - var $this = $(this), - element = that.$element[0], - position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0, - clickedData = that.selectpicker.current.data[$this.parent().index() + position0], - clickedIndex = clickedData.index, - prevValue = getSelectValues(element), - prevIndex = element.selectedIndex, - prevOption = element.options[prevIndex], - triggerChange = true; - - // Don't close on multi choice menu - if (that.multiple && that.options.maxOptions !== 1) { - e.stopPropagation(); - } - - e.preventDefault(); - - // Don't run if the select is disabled - if (!that.isDisabled() && !$this.parent().hasClass(classNames.DISABLED)) { - var $options = that.$element.find('option'), - option = clickedData.option, - $option = $(option), - state = option.selected, - $optgroup = $option.parent('optgroup'), - $optgroupOptions = $optgroup.find('option'), - maxOptions = that.options.maxOptions, - maxOptionsGrp = $optgroup.data('maxOptions') || false; - - if (clickedIndex === that.activeIndex) retainActive = true; - - if (!retainActive) { - that.prevActiveIndex = that.activeIndex; - that.activeIndex = undefined; - } - - if (!that.multiple) { // Deselect all others if not multi select box - prevOption.selected = false; - option.selected = true; - that.setSelected(clickedIndex, true); - } else { // Toggle the one we have chosen if we are multi select. - option.selected = !state; - - that.setSelected(clickedIndex, !state); - $this.trigger('blur'); - - if (maxOptions !== false || maxOptionsGrp !== false) { - var maxReached = maxOptions < $options.filter(':selected').length, - maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length; - - if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) { - if (maxOptions && maxOptions == 1) { - $options.prop('selected', false); - $option.prop('selected', true); - - for (var i = 0; i < $options.length; i++) { - that.setSelected(i, false); - } - - that.setSelected(clickedIndex, true); - } else if (maxOptionsGrp && maxOptionsGrp == 1) { - $optgroup.find('option:selected').prop('selected', false); - $option.prop('selected', true); - - for (var i = 0; i < $optgroupOptions.length; i++) { - var option = $optgroupOptions[i]; - that.setSelected($options.index(option), false); - } - - that.setSelected(clickedIndex, true); - } else { - var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText, - maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText, - maxTxt = maxOptionsArr[0].replace('{n}', maxOptions), - maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp), - $notify = $('
    '); - // If {var} is set in array, replace it - /** @deprecated */ - if (maxOptionsArr[2]) { - maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]); - maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]); - } - - $option.prop('selected', false); - - that.$menu.append($notify); - - if (maxOptions && maxReached) { - $notify.append($('
    ' + maxTxt + '
    ')); - triggerChange = false; - that.$element.trigger('maxReached' + EVENT_KEY); - } - - if (maxOptionsGrp && maxReachedGrp) { - $notify.append($('
    ' + maxTxtGrp + '
    ')); - triggerChange = false; - that.$element.trigger('maxReachedGrp' + EVENT_KEY); - } - - setTimeout(function () { - that.setSelected(clickedIndex, false); - }, 10); - - $notify.delay(750).fadeOut(300, function () { - $(this).remove(); - }); - } - } - } - } - - if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) { - that.$button.trigger('focus'); - } else if (that.options.liveSearch) { - that.$searchbox.trigger('focus'); - } - - // Trigger select 'change' - if (triggerChange) { - if (that.multiple || prevIndex !== element.selectedIndex) { - // $option.prop('selected') is current option state (selected/unselected). prevValue is the value of the select prior to being changed. - changedArguments = [option.index, $option.prop('selected'), prevValue]; - that.$element - .triggerNative('change'); - } - } - } - }); - - this.$menu.on('click', 'li.' + classNames.DISABLED + ' a, .' + classNames.POPOVERHEADER + ', .' + classNames.POPOVERHEADER + ' :not(.close)', function (e) { - if (e.currentTarget == this) { - e.preventDefault(); - e.stopPropagation(); - if (that.options.liveSearch && !$(e.target).hasClass('close')) { - that.$searchbox.trigger('focus'); - } else { - that.$button.trigger('focus'); - } - } - }); - - this.$menuInner.on('click', '.divider, .dropdown-header', function (e) { - e.preventDefault(); - e.stopPropagation(); - if (that.options.liveSearch) { - that.$searchbox.trigger('focus'); - } else { - that.$button.trigger('focus'); - } - }); - - this.$menu.on('click', '.' + classNames.POPOVERHEADER + ' .close', function () { - that.$button.trigger('click'); - }); - - this.$searchbox.on('click', function (e) { - e.stopPropagation(); - }); - - this.$menu.on('click', '.actions-btn', function (e) { - if (that.options.liveSearch) { - that.$searchbox.trigger('focus'); - } else { - that.$button.trigger('focus'); - } - - e.preventDefault(); - e.stopPropagation(); - - if ($(this).hasClass('bs-select-all')) { - that.selectAll(); - } else { - that.deselectAll(); - } - }); - - this.$element - .on('change' + EVENT_KEY, function () { - that.render(); - that.$element.trigger('changed' + EVENT_KEY, changedArguments); - changedArguments = null; - }) - .on('focus' + EVENT_KEY, function () { - if (!that.options.mobile) that.$button.trigger('focus'); - }); - }, - - liveSearchListener: function () { - var that = this, - noResults = document.createElement('li'); - - this.$button.on('click.bs.dropdown.data-api', function () { - if (!!that.$searchbox.val()) { - that.$searchbox.val(''); - } - }); - - this.$searchbox.on('click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api', function (e) { - e.stopPropagation(); - }); - - this.$searchbox.on('input propertychange', function () { - var searchValue = that.$searchbox.val(); - - that.selectpicker.search.elements = []; - that.selectpicker.search.data = []; - - if (searchValue) { - var i, - searchMatch = [], - q = searchValue.toUpperCase(), - cache = {}, - cacheArr = [], - searchStyle = that._searchStyle(), - normalizeSearch = that.options.liveSearchNormalize; - - if (normalizeSearch) q = normalizeToBase(q); - - that._$lisSelected = that.$menuInner.find('.selected'); - - for (var i = 0; i < that.selectpicker.main.data.length; i++) { - var li = that.selectpicker.main.data[i]; - - if (!cache[i]) { - cache[i] = stringSearch(li, q, searchStyle, normalizeSearch); - } - - if (cache[i] && li.headerIndex !== undefined && cacheArr.indexOf(li.headerIndex) === -1) { - if (li.headerIndex > 0) { - cache[li.headerIndex - 1] = true; - cacheArr.push(li.headerIndex - 1); - } - - cache[li.headerIndex] = true; - cacheArr.push(li.headerIndex); - - cache[li.lastIndex + 1] = true; - } - - if (cache[i] && li.type !== 'optgroup-label') cacheArr.push(i); - } - - for (var i = 0, cacheLen = cacheArr.length; i < cacheLen; i++) { - var index = cacheArr[i], - prevIndex = cacheArr[i - 1], - li = that.selectpicker.main.data[index], - liPrev = that.selectpicker.main.data[prevIndex]; - - if (li.type !== 'divider' || (li.type === 'divider' && liPrev && liPrev.type !== 'divider' && cacheLen - 1 !== i)) { - that.selectpicker.search.data.push(li); - searchMatch.push(that.selectpicker.main.elements[index]); - } - } - - that.activeIndex = undefined; - that.noScroll = true; - that.$menuInner.scrollTop(0); - that.selectpicker.search.elements = searchMatch; - that.createView(true); - - if (!searchMatch.length) { - noResults.className = 'no-results'; - noResults.innerHTML = that.options.noneResultsText.replace('{0}', '"' + htmlEscape(searchValue) + '"'); - that.$menuInner[0].firstChild.appendChild(noResults); - } - } else { - that.$menuInner.scrollTop(0); - that.createView(false); - } - }); - }, - - _searchStyle: function () { - return this.options.liveSearchStyle || 'contains'; - }, - - val: function (value) { - var element = this.$element[0]; - - if (typeof value !== 'undefined') { - var prevValue = getSelectValues(element); - - changedArguments = [null, null, prevValue]; - - this.$element - .val(value) - .trigger('changed' + EVENT_KEY, changedArguments); - - if (this.$newElement.hasClass(classNames.SHOW)) { - if (this.multiple) { - this.setOptionStatus(true); - } else { - var liSelectedIndex = (element.options[element.selectedIndex] || {}).liIndex; - - if (typeof liSelectedIndex === 'number') { - this.setSelected(this.selectedIndex, false); - this.setSelected(liSelectedIndex, true); - } - } - } - - this.render(); - - changedArguments = null; - - return this.$element; - } else { - return this.$element.val(); - } - }, - - changeAll: function (status) { - if (!this.multiple) return; - if (typeof status === 'undefined') status = true; - - var element = this.$element[0], - previousSelected = 0, - currentSelected = 0, - prevValue = getSelectValues(element); - - element.classList.add('bs-select-hidden'); - - for (var i = 0, len = this.selectpicker.current.elements.length; i < len; i++) { - var liData = this.selectpicker.current.data[i], - option = liData.option; - - if (option && !liData.disabled && liData.type !== 'divider') { - if (liData.selected) previousSelected++; - option.selected = status; - if (status) currentSelected++; - } - } - - element.classList.remove('bs-select-hidden'); - - if (previousSelected === currentSelected) return; - - this.setOptionStatus(); - - changedArguments = [null, null, prevValue]; - - this.$element - .triggerNative('change'); - }, - - selectAll: function () { - return this.changeAll(true); - }, - - deselectAll: function () { - return this.changeAll(false); - }, - - toggle: function (e) { - e = e || window.event; - - if (e) e.stopPropagation(); - - this.$button.trigger('click.bs.dropdown.data-api'); - }, - - keydown: function (e) { - var $this = $(this), - isToggle = $this.hasClass('dropdown-toggle'), - $parent = isToggle ? $this.closest('.dropdown') : $this.closest(Selector.MENU), - that = $parent.data('this'), - $items = that.findLis(), - index, - isActive, - liActive, - activeLi, - offset, - updateScroll = false, - downOnTab = e.which === keyCodes.TAB && !isToggle && !that.options.selectOnTab, - isArrowKey = REGEXP_ARROW.test(e.which) || downOnTab, - scrollTop = that.$menuInner[0].scrollTop, - isVirtual = that.isVirtual(), - position0 = isVirtual === true ? that.selectpicker.view.position0 : 0; - - isActive = that.$newElement.hasClass(classNames.SHOW); - - if ( - !isActive && - ( - isArrowKey || - (e.which >= 48 && e.which <= 57) || - (e.which >= 96 && e.which <= 105) || - (e.which >= 65 && e.which <= 90) - ) - ) { - that.$button.trigger('click.bs.dropdown.data-api'); - - if (that.options.liveSearch) { - that.$searchbox.trigger('focus'); - return; - } - } - - if (e.which === keyCodes.ESCAPE && isActive) { - e.preventDefault(); - that.$button.trigger('click.bs.dropdown.data-api').trigger('focus'); - } - - if (isArrowKey) { // if up or down - if (!$items.length) return; - - liActive = that.selectpicker.main.elements[that.activeIndex]; - index = liActive ? Array.prototype.indexOf.call(liActive.parentElement.children, liActive) : -1; - - if (index !== -1) { - that.defocusItem(liActive); - } - - if (e.which === keyCodes.ARROW_UP) { // up - if (index !== -1) index--; - if (index + position0 < 0) index += $items.length; - - if (!that.selectpicker.view.canHighlight[index + position0]) { - index = that.selectpicker.view.canHighlight.slice(0, index + position0).lastIndexOf(true) - position0; - if (index === -1) index = $items.length - 1; - } - } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down - index++; - if (index + position0 >= that.selectpicker.view.canHighlight.length) index = 0; - - if (!that.selectpicker.view.canHighlight[index + position0]) { - index = index + 1 + that.selectpicker.view.canHighlight.slice(index + position0 + 1).indexOf(true); - } - } - - e.preventDefault(); - - var liActiveIndex = position0 + index; - - if (e.which === keyCodes.ARROW_UP) { // up - // scroll to bottom and highlight last option - if (position0 === 0 && index === $items.length - 1) { - that.$menuInner[0].scrollTop = that.$menuInner[0].scrollHeight; - - liActiveIndex = that.selectpicker.current.elements.length - 1; - } else { - activeLi = that.selectpicker.current.data[liActiveIndex]; - offset = activeLi.position - activeLi.height; - - updateScroll = offset < scrollTop; - } - } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down - // scroll to top and highlight first option - if (index === 0) { - that.$menuInner[0].scrollTop = 0; - - liActiveIndex = 0; - } else { - activeLi = that.selectpicker.current.data[liActiveIndex]; - offset = activeLi.position - that.sizeInfo.menuInnerHeight; - - updateScroll = offset > scrollTop; - } - } - - liActive = that.selectpicker.current.elements[liActiveIndex]; - - that.activeIndex = that.selectpicker.current.data[liActiveIndex].index; - - that.focusItem(liActive); - - that.selectpicker.view.currentActive = liActive; - - if (updateScroll) that.$menuInner[0].scrollTop = offset; - - if (that.options.liveSearch) { - that.$searchbox.trigger('focus'); - } else { - $this.trigger('focus'); - } - } else if ( - (!$this.is('input') && !REGEXP_TAB_OR_ESCAPE.test(e.which)) || - (e.which === keyCodes.SPACE && that.selectpicker.keydown.keyHistory) - ) { - var searchMatch, - matches = [], - keyHistory; - - e.preventDefault(); - - that.selectpicker.keydown.keyHistory += keyCodeMap[e.which]; - - if (that.selectpicker.keydown.resetKeyHistory.cancel) clearTimeout(that.selectpicker.keydown.resetKeyHistory.cancel); - that.selectpicker.keydown.resetKeyHistory.cancel = that.selectpicker.keydown.resetKeyHistory.start(); - - keyHistory = that.selectpicker.keydown.keyHistory; - - // if all letters are the same, set keyHistory to just the first character when searching - if (/^(.)\1+$/.test(keyHistory)) { - keyHistory = keyHistory.charAt(0); - } - - // find matches - for (var i = 0; i < that.selectpicker.current.data.length; i++) { - var li = that.selectpicker.current.data[i], - hasMatch; - - hasMatch = stringSearch(li, keyHistory, 'startsWith', true); - - if (hasMatch && that.selectpicker.view.canHighlight[i]) { - matches.push(li.index); - } - } - - if (matches.length) { - var matchIndex = 0; - - $items.removeClass('active').find('a').removeClass('active'); - - // either only one key has been pressed or they are all the same key - if (keyHistory.length === 1) { - matchIndex = matches.indexOf(that.activeIndex); - - if (matchIndex === -1 || matchIndex === matches.length - 1) { - matchIndex = 0; - } else { - matchIndex++; - } - } - - searchMatch = matches[matchIndex]; - - activeLi = that.selectpicker.main.data[searchMatch]; - - if (scrollTop - activeLi.position > 0) { - offset = activeLi.position - activeLi.height; - updateScroll = true; - } else { - offset = activeLi.position - that.sizeInfo.menuInnerHeight; - // if the option is already visible at the current scroll position, just keep it the same - updateScroll = activeLi.position > scrollTop + that.sizeInfo.menuInnerHeight; - } - - liActive = that.selectpicker.main.elements[searchMatch]; - - that.activeIndex = matches[matchIndex]; - - that.focusItem(liActive); - - if (liActive) liActive.firstChild.focus(); - - if (updateScroll) that.$menuInner[0].scrollTop = offset; - - $this.trigger('focus'); - } - } - - // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu. - if ( - isActive && - ( - (e.which === keyCodes.SPACE && !that.selectpicker.keydown.keyHistory) || - e.which === keyCodes.ENTER || - (e.which === keyCodes.TAB && that.options.selectOnTab) - ) - ) { - if (e.which !== keyCodes.SPACE) e.preventDefault(); - - if (!that.options.liveSearch || e.which !== keyCodes.SPACE) { - that.$menuInner.find('.active a').trigger('click', true); // retain active class - $this.trigger('focus'); - - if (!that.options.liveSearch) { - // Prevent screen from scrolling if the user hits the spacebar - e.preventDefault(); - // Fixes spacebar selection of dropdown items in FF & IE - $(document).data('spaceSelect', true); - } - } - } - }, - - mobile: function () { - this.$element[0].classList.add('mobile-device'); - }, - - refresh: function () { - // update options if data attributes have been changed - var config = $.extend({}, this.options, this.$element.data()); - this.options = config; - - this.checkDisabled(); - this.setStyle(); - this.render(); - this.createLi(); - this.setWidth(); - - this.setSize(true); - - this.$element.trigger('refreshed' + EVENT_KEY); - }, - - hide: function () { - this.$newElement.hide(); - }, - - show: function () { - this.$newElement.show(); - }, - - remove: function () { - this.$newElement.remove(); - this.$element.remove(); - }, - - destroy: function () { - this.$newElement.before(this.$element).remove(); - - if (this.$bsContainer) { - this.$bsContainer.remove(); - } else { - this.$menu.remove(); - } - - this.$element - .off(EVENT_KEY) - .removeData('selectpicker') - .removeClass('bs-select-hidden selectpicker'); - - $(window).off(EVENT_KEY + '.' + this.selectId); - } - }; - - // SELECTPICKER PLUGIN DEFINITION - // ============================== - function Plugin (option) { - // get the args of the outer function.. - var args = arguments; - // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them - // to get lost/corrupted in android 2.3 and IE9 #715 #775 - var _option = option; - - [].shift.apply(args); - - // if the version was not set successfully - if (!version.success) { - // try to retreive it again - try { - version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.'); - } catch (err) { - // fall back to use BootstrapVersion if set - if (Selectpicker.BootstrapVersion) { - version.full = Selectpicker.BootstrapVersion.split(' ')[0].split('.'); - } else { - version.full = [version.major, '0', '0']; - - console.warn( - 'There was an issue retrieving Bootstrap\'s version. ' + - 'Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. ' + - 'If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.', - err - ); - } - } - - version.major = version.full[0]; - version.success = true; - } - - if (version.major === '4') { - // some defaults need to be changed if using Bootstrap 4 - // check to see if they have already been manually changed before forcing them to update - var toUpdate = []; - - if (Selectpicker.DEFAULTS.style === classNames.BUTTONCLASS) toUpdate.push({ name: 'style', className: 'BUTTONCLASS' }); - if (Selectpicker.DEFAULTS.iconBase === classNames.ICONBASE) toUpdate.push({ name: 'iconBase', className: 'ICONBASE' }); - if (Selectpicker.DEFAULTS.tickIcon === classNames.TICKICON) toUpdate.push({ name: 'tickIcon', className: 'TICKICON' }); - - classNames.DIVIDER = 'dropdown-divider'; - classNames.SHOW = 'show'; - classNames.BUTTONCLASS = 'btn-light'; - classNames.POPOVERHEADER = 'popover-header'; - classNames.ICONBASE = ''; - classNames.TICKICON = 'bs-ok-default'; - - for (var i = 0; i < toUpdate.length; i++) { - var option = toUpdate[i]; - Selectpicker.DEFAULTS[option.name] = classNames[option.className]; - } - } - - var value; - var chain = this.each(function () { - var $this = $(this); - if ($this.is('select')) { - var data = $this.data('selectpicker'), - options = typeof _option == 'object' && _option; - - if (!data) { - var dataAttributes = $this.data(); - - for (var dataAttr in dataAttributes) { - if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) { - delete dataAttributes[dataAttr]; - } - } - - var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, dataAttributes, options); - config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), dataAttributes.template, options.template); - $this.data('selectpicker', (data = new Selectpicker(this, config))); - } else if (options) { - for (var i in options) { - if (options.hasOwnProperty(i)) { - data.options[i] = options[i]; - } - } - } - - if (typeof _option == 'string') { - if (data[_option] instanceof Function) { - value = data[_option].apply(data, args); - } else { - value = data.options[_option]; - } - } - } - }); - - if (typeof value !== 'undefined') { - // noinspection JSUnusedAssignment - return value; - } else { - return chain; - } - } - - var old = $.fn.selectpicker; - $.fn.selectpicker = Plugin; - $.fn.selectpicker.Constructor = Selectpicker; - - // SELECTPICKER NO CONFLICT - // ======================== - $.fn.selectpicker.noConflict = function () { - $.fn.selectpicker = old; - return this; - }; - - $(document) - .off('keydown.bs.dropdown.data-api') - .on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown) - .on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) { - e.stopPropagation(); - }); - - // SELECTPICKER DATA-API - // ===================== - $(window).on('load' + EVENT_KEY + '.data-api', function () { - $('.selectpicker').each(function () { - var $selectpicker = $(this); - Plugin.call($selectpicker, $selectpicker.data()); - }) - }); -})(jQuery); - - -})); +/*! + * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select) + * + * Copyright 2012-2019 SnapAppointments, LLC + * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) + */ + +(function (root, factory) { + if (root === undefined && window !== undefined) root = window; + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module unless amdModuleId is set + define(["jquery"], function (a0) { + return (factory(a0)); + }); + } else if (typeof module === 'object' && module.exports) { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(require("jquery")); + } else { + factory(root["jQuery"]); + } +}(this, function (jQuery) { + +(function ($) { + 'use strict'; + + var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']; + + var uriAttrs = [ + 'background', + 'cite', + 'href', + 'itemtype', + 'longdesc', + 'poster', + 'src', + 'xlink:href' + ]; + + var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; + + var DefaultWhitelist = { + // Global attributes allowed on any supplied element below. + '*': ['class', 'dir', 'id', 'lang', 'role', 'tabindex', 'style', ARIA_ATTRIBUTE_PATTERN], + a: ['target', 'href', 'title', 'rel'], + area: [], + b: [], + br: [], + col: [], + code: [], + div: [], + em: [], + hr: [], + h1: [], + h2: [], + h3: [], + h4: [], + h5: [], + h6: [], + i: [], + img: ['src', 'alt', 'title', 'width', 'height'], + li: [], + ol: [], + p: [], + pre: [], + s: [], + small: [], + span: [], + sub: [], + sup: [], + strong: [], + u: [], + ul: [] + } + + /** + * A pattern that recognizes a commonly useful subset of URLs that are safe. + * + * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts + */ + var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi; + + /** + * A pattern that matches safe data URLs. Only matches image, video and audio types. + * + * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts + */ + var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i; + + function allowedAttribute (attr, allowedAttributeList) { + var attrName = attr.nodeName.toLowerCase() + + if ($.inArray(attrName, allowedAttributeList) !== -1) { + if ($.inArray(attrName, uriAttrs) !== -1) { + return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) + } + + return true + } + + var regExp = $(allowedAttributeList).filter(function (index, value) { + return value instanceof RegExp + }) + + // Check if a regular expression validates the attribute. + for (var i = 0, l = regExp.length; i < l; i++) { + if (attrName.match(regExp[i])) { + return true + } + } + + return false + } + + function sanitizeHtml (unsafeElements, whiteList, sanitizeFn) { + if (sanitizeFn && typeof sanitizeFn === 'function') { + return sanitizeFn(unsafeElements); + } + + var whitelistKeys = Object.keys(whiteList); + + for (var i = 0, len = unsafeElements.length; i < len; i++) { + var elements = unsafeElements[i].querySelectorAll('*'); + + for (var j = 0, len2 = elements.length; j < len2; j++) { + var el = elements[j]; + var elName = el.nodeName.toLowerCase(); + + if (whitelistKeys.indexOf(elName) === -1) { + el.parentNode.removeChild(el); + + continue; + } + + var attributeList = [].slice.call(el.attributes); + var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []); + + for (var k = 0, len3 = attributeList.length; k < len3; k++) { + var attr = attributeList[k]; + + if (!allowedAttribute(attr, whitelistedAttributes)) { + el.removeAttribute(attr.nodeName); + } + } + } + } + } + + // Polyfill for browsers with no classList support + // Remove in v2 + if (!('classList' in document.createElement('_'))) { + (function (view) { + if (!('Element' in view)) return; + + var classListProp = 'classList', + protoProp = 'prototype', + elemCtrProto = view.Element[protoProp], + objCtr = Object, + classListGetter = function () { + var $elem = $(this); + + return { + add: function (classes) { + classes = Array.prototype.slice.call(arguments).join(' '); + return $elem.addClass(classes); + }, + remove: function (classes) { + classes = Array.prototype.slice.call(arguments).join(' '); + return $elem.removeClass(classes); + }, + toggle: function (classes, force) { + return $elem.toggleClass(classes, force); + }, + contains: function (classes) { + return $elem.hasClass(classes); + } + } + }; + + if (objCtr.defineProperty) { + var classListPropDesc = { + get: classListGetter, + enumerable: true, + configurable: true + }; + try { + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } catch (ex) { // IE 8 doesn't support enumerable:true + // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36 + // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected + if (ex.number === undefined || ex.number === -0x7FF5EC54) { + classListPropDesc.enumerable = false; + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } + } + } else if (objCtr[protoProp].__defineGetter__) { + elemCtrProto.__defineGetter__(classListProp, classListGetter); + } + }(window)); + } + + var testElement = document.createElement('_'); + + testElement.classList.add('c1', 'c2'); + + if (!testElement.classList.contains('c2')) { + var _add = DOMTokenList.prototype.add, + _remove = DOMTokenList.prototype.remove; + + DOMTokenList.prototype.add = function () { + Array.prototype.forEach.call(arguments, _add.bind(this)); + } + + DOMTokenList.prototype.remove = function () { + Array.prototype.forEach.call(arguments, _remove.bind(this)); + } + } + + testElement.classList.toggle('c3', false); + + // Polyfill for IE 10 and Firefox <24, where classList.toggle does not + // support the second argument. + if (testElement.classList.contains('c3')) { + var _toggle = DOMTokenList.prototype.toggle; + + DOMTokenList.prototype.toggle = function (token, force) { + if (1 in arguments && !this.contains(token) === !force) { + return force; + } else { + return _toggle.call(this, token); + } + }; + } + + testElement = null; + + // shallow array comparison + function isEqual (array1, array2) { + return array1.length === array2.length && array1.every(function (element, index) { + return element === array2[index]; + }); + }; + + // + if (!String.prototype.startsWith) { + (function () { + 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` + var defineProperty = (function () { + // IE 8 only supports `Object.defineProperty` on DOM elements + try { + var object = {}; + var $defineProperty = Object.defineProperty; + var result = $defineProperty(object, object, object) && $defineProperty; + } catch (error) { + } + return result; + }()); + var toString = {}.toString; + var startsWith = function (search) { + if (this == null) { + throw new TypeError(); + } + var string = String(this); + if (search && toString.call(search) == '[object RegExp]') { + throw new TypeError(); + } + var stringLength = string.length; + var searchString = String(search); + var searchLength = searchString.length; + var position = arguments.length > 1 ? arguments[1] : undefined; + // `ToInteger` + var pos = position ? Number(position) : 0; + if (pos != pos) { // better `isNaN` + pos = 0; + } + var start = Math.min(Math.max(pos, 0), stringLength); + // Avoid the `indexOf` call if no match is possible + if (searchLength + start > stringLength) { + return false; + } + var index = -1; + while (++index < searchLength) { + if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) { + return false; + } + } + return true; + }; + if (defineProperty) { + defineProperty(String.prototype, 'startsWith', { + 'value': startsWith, + 'configurable': true, + 'writable': true + }); + } else { + String.prototype.startsWith = startsWith; + } + }()); + } + + if (!Object.keys) { + Object.keys = function ( + o, // object + k, // key + r // result array + ) { + // initialize object and result + r = []; + // iterate over object keys + for (k in o) { + // fill result array with non-prototypical keys + r.hasOwnProperty.call(o, k) && r.push(k); + } + // return result + return r; + }; + } + + if (HTMLSelectElement && !HTMLSelectElement.prototype.hasOwnProperty('selectedOptions')) { + Object.defineProperty(HTMLSelectElement.prototype, 'selectedOptions', { + get: function () { + return this.querySelectorAll(':checked'); + } + }); + } + + function getSelectedOptions (select, ignoreDisabled) { + var selectedOptions = select.selectedOptions, + options = [], + opt; + + if (ignoreDisabled) { + for (var i = 0, len = selectedOptions.length; i < len; i++) { + opt = selectedOptions[i]; + + if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) { + options.push(opt); + } + } + + return options; + } + + return selectedOptions; + } + + // much faster than $.val() + function getSelectValues (select, selectedOptions) { + var value = [], + options = selectedOptions || select.selectedOptions, + opt; + + for (var i = 0, len = options.length; i < len; i++) { + opt = options[i]; + + if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) { + value.push(opt.value || opt.text); + } + } + + if (!select.multiple) { + return !value.length ? null : value[0]; + } + + return value; + } + + // set data-selected on select element if the value has been programmatically selected + // prior to initialization of bootstrap-select + // * consider removing or replacing an alternative method * + var valHooks = { + useDefault: false, + _set: $.valHooks.select.set + }; + + $.valHooks.select.set = function (elem, value) { + if (value && !valHooks.useDefault) $(elem).data('selected', true); + + return valHooks._set.apply(this, arguments); + }; + + var changedArguments = null; + + var EventIsSupported = (function () { + try { + new Event('change'); + return true; + } catch (e) { + return false; + } + })(); + + $.fn.triggerNative = function (eventName) { + var el = this[0], + event; + + if (el.dispatchEvent) { // for modern browsers & IE9+ + if (EventIsSupported) { + // For modern browsers + event = new Event(eventName, { + bubbles: true + }); + } else { + // For IE since it doesn't support Event constructor + event = document.createEvent('Event'); + event.initEvent(eventName, true, false); + } + + el.dispatchEvent(event); + } else if (el.fireEvent) { // for IE8 + event = document.createEventObject(); + event.eventType = eventName; + el.fireEvent('on' + eventName, event); + } else { + // fall back to jQuery.trigger + this.trigger(eventName); + } + }; + // + + function stringSearch (li, searchString, method, normalize) { + var stringTypes = [ + 'display', + 'subtext', + 'tokens' + ], + searchSuccess = false; + + for (var i = 0; i < stringTypes.length; i++) { + var stringType = stringTypes[i], + string = li[stringType]; + + if (string) { + string = string.toString(); + + // Strip HTML tags. This isn't perfect, but it's much faster than any other method + if (stringType === 'display') { + string = string.replace(/<[^>]+>/g, ''); + } + + if (normalize) string = normalizeToBase(string); + string = string.toUpperCase(); + + if (method === 'contains') { + searchSuccess = string.indexOf(searchString) >= 0; + } else { + searchSuccess = string.startsWith(searchString); + } + + if (searchSuccess) break; + } + } + + return searchSuccess; + } + + function toInteger (value) { + return parseInt(value, 10) || 0; + } + + // Borrowed from Lodash (_.deburr) + /** Used to map Latin Unicode letters to basic Latin letters. */ + var deburredLetters = { + // Latin-1 Supplement block. + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss', + // Latin Extended-A block. + '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', + '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', + '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', + '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', + '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', + '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', + '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', + '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', + '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', + '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', + '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', + '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', + '\u0134': 'J', '\u0135': 'j', + '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', + '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', + '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', + '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', + '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', + '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', + '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', + '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', + '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', + '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', + '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', + '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', + '\u0163': 't', '\u0165': 't', '\u0167': 't', + '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', + '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', + '\u0174': 'W', '\u0175': 'w', + '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', + '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', + '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', + '\u0132': 'IJ', '\u0133': 'ij', + '\u0152': 'Oe', '\u0153': 'oe', + '\u0149': "'n", '\u017f': 's' + }; + + /** Used to match Latin Unicode letters (excluding mathematical operators). */ + var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; + + /** Used to compose unicode character classes. */ + var rsComboMarksRange = '\\u0300-\\u036f', + reComboHalfMarksRange = '\\ufe20-\\ufe2f', + rsComboSymbolsRange = '\\u20d0-\\u20ff', + rsComboMarksExtendedRange = '\\u1ab0-\\u1aff', + rsComboMarksSupplementRange = '\\u1dc0-\\u1dff', + rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange; + + /** Used to compose unicode capture groups. */ + var rsCombo = '[' + rsComboRange + ']'; + + /** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ + var reComboMark = RegExp(rsCombo, 'g'); + + function deburrLetter (key) { + return deburredLetters[key]; + }; + + function normalizeToBase (string) { + string = string.toString(); + return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); + } + + // List of HTML entities for escaping. + var escapeMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; + + // Functions for escaping and unescaping strings to/from HTML interpolation. + var createEscaper = function (map) { + var escaper = function (match) { + return map[match]; + }; + // Regexes for identifying a key that needs to be escaped. + var source = '(?:' + Object.keys(map).join('|') + ')'; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, 'g'); + return function (string) { + string = string == null ? '' : '' + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; + }; + }; + + var htmlEscape = createEscaper(escapeMap); + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var keyCodeMap = { + 32: ' ', + 48: '0', + 49: '1', + 50: '2', + 51: '3', + 52: '4', + 53: '5', + 54: '6', + 55: '7', + 56: '8', + 57: '9', + 59: ';', + 65: 'A', + 66: 'B', + 67: 'C', + 68: 'D', + 69: 'E', + 70: 'F', + 71: 'G', + 72: 'H', + 73: 'I', + 74: 'J', + 75: 'K', + 76: 'L', + 77: 'M', + 78: 'N', + 79: 'O', + 80: 'P', + 81: 'Q', + 82: 'R', + 83: 'S', + 84: 'T', + 85: 'U', + 86: 'V', + 87: 'W', + 88: 'X', + 89: 'Y', + 90: 'Z', + 96: '0', + 97: '1', + 98: '2', + 99: '3', + 100: '4', + 101: '5', + 102: '6', + 103: '7', + 104: '8', + 105: '9' + }; + + var keyCodes = { + ESCAPE: 27, // KeyboardEvent.which value for Escape (Esc) key + ENTER: 13, // KeyboardEvent.which value for Enter key + SPACE: 32, // KeyboardEvent.which value for space key + TAB: 9, // KeyboardEvent.which value for tab key + ARROW_UP: 38, // KeyboardEvent.which value for up arrow key + ARROW_DOWN: 40 // KeyboardEvent.which value for down arrow key + } + + var version = { + success: false, + major: '3' + }; + + try { + version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.'); + version.major = version.full[0]; + version.success = true; + } catch (err) { + // do nothing + } + + var selectId = 0; + + var EVENT_KEY = '.bs.select'; + + var classNames = { + DISABLED: 'disabled', + DIVIDER: 'divider', + SHOW: 'open', + DROPUP: 'dropup', + MENU: 'dropdown-menu', + MENURIGHT: 'dropdown-menu-right', + MENULEFT: 'dropdown-menu-left', + // to-do: replace with more advanced template/customization options + BUTTONCLASS: 'btn-default', + POPOVERHEADER: 'popover-title', + ICONBASE: 'glyphicon', + TICKICON: 'glyphicon-ok' + } + + var Selector = { + MENU: '.' + classNames.MENU + } + + var elementTemplates = { + span: document.createElement('span'), + i: document.createElement('i'), + subtext: document.createElement('small'), + a: document.createElement('a'), + li: document.createElement('li'), + whitespace: document.createTextNode('\u00A0'), + fragment: document.createDocumentFragment() + } + + elementTemplates.a.setAttribute('role', 'option'); + elementTemplates.subtext.className = 'text-muted'; + + elementTemplates.text = elementTemplates.span.cloneNode(false); + elementTemplates.text.className = 'text'; + + elementTemplates.checkMark = elementTemplates.span.cloneNode(false); + + var REGEXP_ARROW = new RegExp(keyCodes.ARROW_UP + '|' + keyCodes.ARROW_DOWN); + var REGEXP_TAB_OR_ESCAPE = new RegExp('^' + keyCodes.TAB + '$|' + keyCodes.ESCAPE); + + var generateOption = { + li: function (content, classes, optgroup) { + var li = elementTemplates.li.cloneNode(false); + + if (content) { + if (content.nodeType === 1 || content.nodeType === 11) { + li.appendChild(content); + } else { + li.innerHTML = content; + } + } + + if (typeof classes !== 'undefined' && classes !== '') li.className = classes; + if (typeof optgroup !== 'undefined' && optgroup !== null) li.classList.add('optgroup-' + optgroup); + + return li; + }, + + a: function (text, classes, inline) { + var a = elementTemplates.a.cloneNode(true); + + if (text) { + if (text.nodeType === 11) { + a.appendChild(text); + } else { + a.insertAdjacentHTML('beforeend', text); + } + } + + if (typeof classes !== 'undefined' && classes !== '') a.className = classes; + if (version.major === '4') a.classList.add('dropdown-item'); + if (inline) a.setAttribute('style', inline); + + return a; + }, + + text: function (options, useFragment) { + var textElement = elementTemplates.text.cloneNode(false), + subtextElement, + iconElement; + + if (options.content) { + textElement.innerHTML = options.content; + } else { + textElement.textContent = options.text; + + if (options.icon) { + var whitespace = elementTemplates.whitespace.cloneNode(false); + + // need to use for icons in the button to prevent a breaking change + // note: switch to span in next major release + iconElement = (useFragment === true ? elementTemplates.i : elementTemplates.span).cloneNode(false); + iconElement.className = options.iconBase + ' ' + options.icon; + + elementTemplates.fragment.appendChild(iconElement); + elementTemplates.fragment.appendChild(whitespace); + } + + if (options.subtext) { + subtextElement = elementTemplates.subtext.cloneNode(false); + subtextElement.textContent = options.subtext; + textElement.appendChild(subtextElement); + } + } + + if (useFragment === true) { + while (textElement.childNodes.length > 0) { + elementTemplates.fragment.appendChild(textElement.childNodes[0]); + } + } else { + elementTemplates.fragment.appendChild(textElement); + } + + return elementTemplates.fragment; + }, + + label: function (options) { + var textElement = elementTemplates.text.cloneNode(false), + subtextElement, + iconElement; + + textElement.innerHTML = options.label; + + if (options.icon) { + var whitespace = elementTemplates.whitespace.cloneNode(false); + + iconElement = elementTemplates.span.cloneNode(false); + iconElement.className = options.iconBase + ' ' + options.icon; + + elementTemplates.fragment.appendChild(iconElement); + elementTemplates.fragment.appendChild(whitespace); + } + + if (options.subtext) { + subtextElement = elementTemplates.subtext.cloneNode(false); + subtextElement.textContent = options.subtext; + textElement.appendChild(subtextElement); + } + + elementTemplates.fragment.appendChild(textElement); + + return elementTemplates.fragment; + } + } + + var Selectpicker = function (element, options) { + var that = this; + + // bootstrap-select has been initialized - revert valHooks.select.set back to its original function + if (!valHooks.useDefault) { + $.valHooks.select.set = valHooks._set; + valHooks.useDefault = true; + } + + this.$element = $(element); + this.$newElement = null; + this.$button = null; + this.$menu = null; + this.options = options; + this.selectpicker = { + main: {}, + search: {}, + current: {}, // current changes if a search is in progress + view: {}, + keydown: { + keyHistory: '', + resetKeyHistory: { + start: function () { + return setTimeout(function () { + that.selectpicker.keydown.keyHistory = ''; + }, 800); + } + } + } + }; + // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a + // data-attribute) + if (this.options.title === null) { + this.options.title = this.$element.attr('title'); + } + + // Format window padding + var winPad = this.options.windowPadding; + if (typeof winPad === 'number') { + this.options.windowPadding = [winPad, winPad, winPad, winPad]; + } + + // Expose public methods + this.val = Selectpicker.prototype.val; + this.render = Selectpicker.prototype.render; + this.refresh = Selectpicker.prototype.refresh; + this.setStyle = Selectpicker.prototype.setStyle; + this.selectAll = Selectpicker.prototype.selectAll; + this.deselectAll = Selectpicker.prototype.deselectAll; + this.destroy = Selectpicker.prototype.destroy; + this.remove = Selectpicker.prototype.remove; + this.show = Selectpicker.prototype.show; + this.hide = Selectpicker.prototype.hide; + + this.init(); + }; + + Selectpicker.VERSION = '1.13.10'; + + // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both. + Selectpicker.DEFAULTS = { + noneSelectedText: 'Nothing selected', + noneResultsText: 'No results matched {0}', + countSelectedText: function (numSelected, numTotal) { + return (numSelected == 1) ? '{0} item selected' : '{0} items selected'; + }, + maxOptionsText: function (numAll, numGroup) { + return [ + (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)', + (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)' + ]; + }, + selectAllText: 'Select All', + deselectAllText: 'Deselect All', + doneButton: false, + doneButtonText: 'Close', + multipleSeparator: ', ', + styleBase: 'btn', + style: classNames.BUTTONCLASS, + size: 'auto', + title: null, + selectedTextFormat: 'values', + width: false, + container: false, + hideDisabled: false, + showSubtext: false, + showIcon: true, + showContent: true, + dropupAuto: true, + header: false, + liveSearch: false, + liveSearchPlaceholder: null, + liveSearchNormalize: false, + liveSearchStyle: 'contains', + actionsBox: false, + iconBase: classNames.ICONBASE, + tickIcon: classNames.TICKICON, + showTick: false, + template: { + caret: '' + }, + maxOptions: false, + mobile: false, + selectOnTab: false, + dropdownAlignRight: false, + windowPadding: 0, + virtualScroll: 600, + display: false, + sanitize: true, + sanitizeFn: null, + whiteList: DefaultWhitelist + }; + + Selectpicker.prototype = { + + constructor: Selectpicker, + + init: function () { + var that = this, + id = this.$element.attr('id'); + + selectId++; + this.selectId = 'bs-select-' + selectId; + + this.$element[0].classList.add('bs-select-hidden'); + + this.multiple = this.$element.prop('multiple'); + this.autofocus = this.$element.prop('autofocus'); + + if (this.$element[0].classList.contains('show-tick')) { + this.options.showTick = true; + } + + this.$newElement = this.createDropdown(); + this.$element + .after(this.$newElement) + .prependTo(this.$newElement); + + this.$button = this.$newElement.children('button'); + this.$menu = this.$newElement.children(Selector.MENU); + this.$menuInner = this.$menu.children('.inner'); + this.$searchbox = this.$menu.find('input'); + + this.$element[0].classList.remove('bs-select-hidden'); + + if (this.options.dropdownAlignRight === true) this.$menu[0].classList.add(classNames.MENURIGHT); + + if (typeof id !== 'undefined') { + this.$button.attr('data-id', id); + } + + this.checkDisabled(); + this.clickListener(); + + if (this.options.liveSearch) { + this.liveSearchListener(); + this.focusedParent = this.$searchbox[0]; + } else { + this.focusedParent = this.$menuInner[0]; + } + + this.setStyle(); + this.render(); + this.setWidth(); + if (this.options.container) { + this.selectPosition(); + } else { + this.$element.on('hide' + EVENT_KEY, function () { + if (that.isVirtual()) { + // empty menu on close + var menuInner = that.$menuInner[0], + emptyMenu = menuInner.firstChild.cloneNode(false); + + // replace the existing UL with an empty one - this is faster than $.empty() or innerHTML = '' + menuInner.replaceChild(emptyMenu, menuInner.firstChild); + menuInner.scrollTop = 0; + } + }); + } + this.$menu.data('this', this); + this.$newElement.data('this', this); + if (this.options.mobile) this.mobile(); + + this.$newElement.on({ + 'hide.bs.dropdown': function (e) { + that.$element.trigger('hide' + EVENT_KEY, e); + }, + 'hidden.bs.dropdown': function (e) { + that.$element.trigger('hidden' + EVENT_KEY, e); + }, + 'show.bs.dropdown': function (e) { + that.$element.trigger('show' + EVENT_KEY, e); + }, + 'shown.bs.dropdown': function (e) { + that.$element.trigger('shown' + EVENT_KEY, e); + } + }); + + if (that.$element[0].hasAttribute('required')) { + this.$element.on('invalid' + EVENT_KEY, function () { + that.$button[0].classList.add('bs-invalid'); + + that.$element + .on('shown' + EVENT_KEY + '.invalid', function () { + that.$element + .val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened + .off('shown' + EVENT_KEY + '.invalid'); + }) + .on('rendered' + EVENT_KEY, function () { + // if select is no longer invalid, remove the bs-invalid class + if (this.validity.valid) that.$button[0].classList.remove('bs-invalid'); + that.$element.off('rendered' + EVENT_KEY); + }); + + that.$button.on('blur' + EVENT_KEY, function () { + that.$element.trigger('focus').trigger('blur'); + that.$button.off('blur' + EVENT_KEY); + }); + }); + } + + setTimeout(function () { + that.createLi(); + that.$element.trigger('loaded' + EVENT_KEY); + }); + }, + + createDropdown: function () { + // Options + // If we are multiple or showTick option is set, then add the show-tick class + var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '', + multiselectable = this.multiple ? ' aria-multiselectable="true"' : '', + inputGroup = '', + autofocus = this.autofocus ? ' autofocus' : ''; + + if (version.major < 4 && this.$element.parent().hasClass('input-group')) { + inputGroup = ' input-group-btn'; + } + + // Elements + var drop, + header = '', + searchbox = '', + actionsbox = '', + donebutton = ''; + + if (this.options.header) { + header = + '
    ' + + '' + + this.options.header + + '
    '; + } + + if (this.options.liveSearch) { + searchbox = + ''; + } + + if (this.multiple && this.options.actionsBox) { + actionsbox = + '
    ' + + '
    ' + + '' + + '' + + '
    ' + + '
    '; + } + + if (this.multiple && this.options.doneButton) { + donebutton = + '
    ' + + '
    ' + + '' + + '
    ' + + '
    '; + } + + drop = + ''; + + return $(drop); + }, + + setPositionData: function () { + this.selectpicker.view.canHighlight = []; + this.selectpicker.view.size = 0; + + for (var i = 0; i < this.selectpicker.current.data.length; i++) { + var li = this.selectpicker.current.data[i], + canHighlight = true; + + if (li.type === 'divider') { + canHighlight = false; + li.height = this.sizeInfo.dividerHeight; + } else if (li.type === 'optgroup-label') { + canHighlight = false; + li.height = this.sizeInfo.dropdownHeaderHeight; + } else { + li.height = this.sizeInfo.liHeight; + } + + if (li.disabled) canHighlight = false; + + this.selectpicker.view.canHighlight.push(canHighlight); + + if (canHighlight) { + this.selectpicker.view.size++; + li.posinset = this.selectpicker.view.size; + } + + li.position = (i === 0 ? 0 : this.selectpicker.current.data[i - 1].position) + li.height; + } + }, + + isVirtual: function () { + return (this.options.virtualScroll !== false) && (this.selectpicker.main.elements.length >= this.options.virtualScroll) || this.options.virtualScroll === true; + }, + + createView: function (isSearching, setSize, refresh) { + var that = this, + scrollTop = 0, + active = [], + selected, + prevActive; + + this.selectpicker.current = isSearching ? this.selectpicker.search : this.selectpicker.main; + + this.setPositionData(); + + if (setSize) { + if (refresh) { + scrollTop = this.$menuInner[0].scrollTop; + } else if (!that.multiple) { + var element = that.$element[0], + selectedIndex = (element.options[element.selectedIndex] || {}).liIndex; + + if (typeof selectedIndex === 'number' && that.options.size !== false) { + var selectedData = that.selectpicker.main.data[selectedIndex], + position = selectedData && selectedData.position; + + if (position) { + scrollTop = position - ((that.sizeInfo.menuInnerHeight + that.sizeInfo.liHeight) / 2); + } + } + } + } + + scroll(scrollTop, true); + + this.$menuInner.off('scroll.createView').on('scroll.createView', function (e, updateValue) { + if (!that.noScroll) scroll(this.scrollTop, updateValue); + that.noScroll = false; + }); + + function scroll (scrollTop, init) { + var size = that.selectpicker.current.elements.length, + chunks = [], + chunkSize, + chunkCount, + firstChunk, + lastChunk, + currentChunk, + prevPositions, + positionIsDifferent, + previousElements, + menuIsDifferent = true, + isVirtual = that.isVirtual(); + + that.selectpicker.view.scrollTop = scrollTop; + + if (isVirtual === true) { + // if an option that is encountered that is wider than the current menu width, update the menu width accordingly + if (that.sizeInfo.hasScrollBar && that.$menu[0].offsetWidth > that.sizeInfo.totalMenuWidth) { + that.sizeInfo.menuWidth = that.$menu[0].offsetWidth; + that.sizeInfo.totalMenuWidth = that.sizeInfo.menuWidth + that.sizeInfo.scrollBarWidth; + that.$menu.css('min-width', that.sizeInfo.menuWidth); + } + } + + chunkSize = Math.ceil(that.sizeInfo.menuInnerHeight / that.sizeInfo.liHeight * 1.5); // number of options in a chunk + chunkCount = Math.round(size / chunkSize) || 1; // number of chunks + + for (var i = 0; i < chunkCount; i++) { + var endOfChunk = (i + 1) * chunkSize; + + if (i === chunkCount - 1) { + endOfChunk = size; + } + + chunks[i] = [ + (i) * chunkSize + (!i ? 0 : 1), + endOfChunk + ]; + + if (!size) break; + + if (currentChunk === undefined && scrollTop <= that.selectpicker.current.data[endOfChunk - 1].position - that.sizeInfo.menuInnerHeight) { + currentChunk = i; + } + } + + if (currentChunk === undefined) currentChunk = 0; + + prevPositions = [that.selectpicker.view.position0, that.selectpicker.view.position1]; + + // always display previous, current, and next chunks + firstChunk = Math.max(0, currentChunk - 1); + lastChunk = Math.min(chunkCount - 1, currentChunk + 1); + + that.selectpicker.view.position0 = isVirtual === false ? 0 : (Math.max(0, chunks[firstChunk][0]) || 0); + that.selectpicker.view.position1 = isVirtual === false ? size : (Math.min(size, chunks[lastChunk][1]) || 0); + + positionIsDifferent = prevPositions[0] !== that.selectpicker.view.position0 || prevPositions[1] !== that.selectpicker.view.position1; + + if (that.activeIndex !== undefined) { + prevActive = that.selectpicker.main.elements[that.prevActiveIndex]; + active = that.selectpicker.main.elements[that.activeIndex]; + selected = that.selectpicker.main.elements[that.selectedIndex]; + + if (init) { + if (that.activeIndex !== that.selectedIndex) { + that.defocusItem(active); + } + that.activeIndex = undefined; + } + + if (that.activeIndex && that.activeIndex !== that.selectedIndex) { + that.defocusItem(selected); + } + } + + if (that.prevActiveIndex !== undefined && that.prevActiveIndex !== that.activeIndex && that.prevActiveIndex !== that.selectedIndex) { + that.defocusItem(prevActive); + } + + if (init || positionIsDifferent) { + previousElements = that.selectpicker.view.visibleElements ? that.selectpicker.view.visibleElements.slice() : []; + + if (isVirtual === false) { + that.selectpicker.view.visibleElements = that.selectpicker.current.elements; + } else { + that.selectpicker.view.visibleElements = that.selectpicker.current.elements.slice(that.selectpicker.view.position0, that.selectpicker.view.position1); + } + + that.setOptionStatus(); + + // if searching, check to make sure the list has actually been updated before updating DOM + // this prevents unnecessary repaints + if (isSearching || (isVirtual === false && init)) menuIsDifferent = !isEqual(previousElements, that.selectpicker.view.visibleElements); + + // if virtual scroll is disabled and not searching, + // menu should never need to be updated more than once + if ((init || isVirtual === true) && menuIsDifferent) { + var menuInner = that.$menuInner[0], + menuFragment = document.createDocumentFragment(), + emptyMenu = menuInner.firstChild.cloneNode(false), + marginTop, + marginBottom, + elements = that.selectpicker.view.visibleElements, + toSanitize = []; + + // replace the existing UL with an empty one - this is faster than $.empty() + menuInner.replaceChild(emptyMenu, menuInner.firstChild); + + for (var i = 0, visibleElementsLen = elements.length; i < visibleElementsLen; i++) { + var element = elements[i], + elText, + elementData; + + if (that.options.sanitize) { + elText = element.lastChild; + + if (elText) { + elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0]; + + if (elementData && elementData.content && !elementData.sanitized) { + toSanitize.push(elText); + elementData.sanitized = true; + } + } + } + + menuFragment.appendChild(element); + } + + if (that.options.sanitize && toSanitize.length) { + sanitizeHtml(toSanitize, that.options.whiteList, that.options.sanitizeFn); + } + + if (isVirtual === true) { + marginTop = (that.selectpicker.view.position0 === 0 ? 0 : that.selectpicker.current.data[that.selectpicker.view.position0 - 1].position); + marginBottom = (that.selectpicker.view.position1 > size - 1 ? 0 : that.selectpicker.current.data[size - 1].position - that.selectpicker.current.data[that.selectpicker.view.position1 - 1].position); + + menuInner.firstChild.style.marginTop = marginTop + 'px'; + menuInner.firstChild.style.marginBottom = marginBottom + 'px'; + } else { + menuInner.firstChild.style.marginTop = 0; + menuInner.firstChild.style.marginBottom = 0; + } + + menuInner.firstChild.appendChild(menuFragment); + } + } + + that.prevActiveIndex = that.activeIndex; + + if (!that.options.liveSearch) { + that.$menuInner.trigger('focus'); + } else if (isSearching && init) { + var index = 0, + newActive; + + if (!that.selectpicker.view.canHighlight[index]) { + index = 1 + that.selectpicker.view.canHighlight.slice(1).indexOf(true); + } + + newActive = that.selectpicker.view.visibleElements[index]; + + that.defocusItem(that.selectpicker.view.currentActive); + + that.activeIndex = (that.selectpicker.current.data[index] || {}).index; + + that.focusItem(newActive); + } + } + + $(window) + .off('resize' + EVENT_KEY + '.' + this.selectId + '.createView') + .on('resize' + EVENT_KEY + '.' + this.selectId + '.createView', function () { + var isActive = that.$newElement.hasClass(classNames.SHOW); + + if (isActive) scroll(that.$menuInner[0].scrollTop); + }); + }, + + focusItem: function (li, liData, noStyle) { + if (li) { + liData = liData || this.selectpicker.main.data[this.activeIndex]; + var a = li.firstChild; + + if (a) { + a.setAttribute('aria-setsize', this.selectpicker.view.size); + a.setAttribute('aria-posinset', liData.posinset); + + if (noStyle !== true) { + this.focusedParent.setAttribute('aria-activedescendant', a.id); + li.classList.add('active'); + a.classList.add('active'); + } + } + } + }, + + defocusItem: function (li) { + if (li) { + li.classList.remove('active'); + if (li.firstChild) li.firstChild.classList.remove('active'); + } + }, + + setPlaceholder: function () { + var updateIndex = false; + + if (this.options.title && !this.multiple) { + if (!this.selectpicker.view.titleOption) this.selectpicker.view.titleOption = document.createElement('option'); + + // this option doesn't create a new
  • element, but does add a new option at the start, + // so startIndex should increase to prevent having to check every option for the bs-title-option class + updateIndex = true; + + var element = this.$element[0], + isSelected = false, + titleNotAppended = !this.selectpicker.view.titleOption.parentNode; + + if (titleNotAppended) { + // Use native JS to prepend option (faster) + this.selectpicker.view.titleOption.className = 'bs-title-option'; + this.selectpicker.view.titleOption.value = ''; + + // Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option. + // the selected item may have been changed by user or programmatically before the bootstrap select plugin runs, + // if so, the select will have the data-selected attribute + var $opt = $(element.options[element.selectedIndex]); + isSelected = $opt.attr('selected') === undefined && this.$element.data('selected') === undefined; + } + + if (titleNotAppended || this.selectpicker.view.titleOption.index !== 0) { + element.insertBefore(this.selectpicker.view.titleOption, element.firstChild); + } + + // Set selected *after* appending to select, + // otherwise the option doesn't get selected in IE + // set using selectedIndex, as setting the selected attr to true here doesn't work in IE11 + if (isSelected) element.selectedIndex = 0; + } + + return updateIndex; + }, + + createLi: function () { + var that = this, + iconBase = this.options.iconBase, + optionSelector = ':not([hidden]):not([data-hidden="true"])', + mainElements = [], + mainData = [], + widestOptionLength = 0, + optID = 0, + startIndex = this.setPlaceholder() ? 1 : 0; // append the titleOption if necessary and skip the first option in the loop + + if (this.options.hideDisabled) optionSelector += ':not(:disabled)'; + + if ((that.options.showTick || that.multiple) && !elementTemplates.checkMark.parentNode) { + elementTemplates.checkMark.className = iconBase + ' ' + that.options.tickIcon + ' check-mark'; + elementTemplates.a.appendChild(elementTemplates.checkMark); + } + + var selectOptions = this.$element[0].querySelectorAll('select > *' + optionSelector); + + function addDivider (config) { + var previousData = mainData[mainData.length - 1]; + + // ensure optgroup doesn't create back-to-back dividers + if ( + previousData && + previousData.type === 'divider' && + (previousData.optID || config.optID) + ) { + return; + } + + config = config || {}; + config.type = 'divider'; + + mainElements.push( + generateOption.li( + false, + classNames.DIVIDER, + (config.optID ? config.optID + 'div' : undefined) + ) + ); + + mainData.push(config); + } + + function addOption (option, config) { + config = config || {}; + + config.divider = option.getAttribute('data-divider') === 'true'; + + if (config.divider) { + addDivider({ + optID: config.optID + }); + } else { + var liIndex = mainData.length, + cssText = option.style.cssText, + inlineStyle = cssText ? htmlEscape(cssText) : '', + optionClass = (option.className || '') + (config.optgroupClass || ''); + + if (config.optID) optionClass = 'opt ' + optionClass; + + config.text = option.textContent; + + config.content = option.getAttribute('data-content'); + config.tokens = option.getAttribute('data-tokens'); + config.subtext = option.getAttribute('data-subtext'); + config.icon = option.getAttribute('data-icon'); + config.iconBase = iconBase; + + var textElement = generateOption.text(config); + var liElement = generateOption.li( + generateOption.a( + textElement, + optionClass, + inlineStyle + ), + '', + config.optID + ); + + if (liElement.firstChild) { + liElement.firstChild.id = that.selectId + '-' + liIndex; + } + + mainElements.push(liElement); + + option.liIndex = liIndex; + + config.display = config.content || config.text; + config.type = 'option'; + config.index = liIndex; + config.option = option; + config.disabled = config.disabled || option.disabled; + + mainData.push(config); + + var combinedLength = 0; + + // count the number of characters in the option - not perfect, but should work in most cases + if (config.display) combinedLength += config.display.length; + if (config.subtext) combinedLength += config.subtext.length; + // if there is an icon, ensure this option's width is checked + if (config.icon) combinedLength += 1; + + if (combinedLength > widestOptionLength) { + widestOptionLength = combinedLength; + + // guess which option is the widest + // use this when calculating menu width + // not perfect, but it's fast, and the width will be updating accordingly when scrolling + that.selectpicker.view.widestOption = mainElements[mainElements.length - 1]; + } + } + } + + function addOptgroup (index, selectOptions) { + var optgroup = selectOptions[index], + previous = selectOptions[index - 1], + next = selectOptions[index + 1], + options = optgroup.querySelectorAll('option' + optionSelector); + + if (!options.length) return; + + var config = { + label: htmlEscape(optgroup.label), + subtext: optgroup.getAttribute('data-subtext'), + icon: optgroup.getAttribute('data-icon'), + iconBase: iconBase + }, + optgroupClass = ' ' + (optgroup.className || ''), + headerIndex, + lastIndex; + + optID++; + + if (previous) { + addDivider({ optID: optID }); + } + + var labelElement = generateOption.label(config); + + mainElements.push( + generateOption.li(labelElement, 'dropdown-header' + optgroupClass, optID) + ); + + mainData.push({ + display: config.label, + subtext: config.subtext, + type: 'optgroup-label', + optID: optID + }); + + for (var j = 0, len = options.length; j < len; j++) { + var option = options[j]; + + if (j === 0) { + headerIndex = mainData.length - 1; + lastIndex = headerIndex + len; + } + + addOption(option, { + headerIndex: headerIndex, + lastIndex: lastIndex, + optID: optID, + optgroupClass: optgroupClass, + disabled: optgroup.disabled + }); + } + + if (next) { + addDivider({ optID: optID }); + } + } + + for (var len = selectOptions.length; startIndex < len; startIndex++) { + var item = selectOptions[startIndex]; + + if (item.tagName !== 'OPTGROUP') { + addOption(item, {}); + } else { + addOptgroup(startIndex, selectOptions); + } + } + + this.selectpicker.main.elements = mainElements; + this.selectpicker.main.data = mainData; + + this.selectpicker.current = this.selectpicker.main; + }, + + findLis: function () { + return this.$menuInner.find('.inner > li'); + }, + + render: function () { + // ensure titleOption is appended and selected (if necessary) before getting selectedOptions + this.setPlaceholder(); + + var that = this, + element = this.$element[0], + selectedOptions = getSelectedOptions(element, this.options.hideDisabled), + selectedCount = selectedOptions.length, + button = this.$button[0], + buttonInner = button.querySelector('.filter-option-inner-inner'), + multipleSeparator = document.createTextNode(this.options.multipleSeparator), + titleFragment = elementTemplates.fragment.cloneNode(false), + showCount, + countMax, + hasContent = false; + + button.classList.toggle('bs-placeholder', that.multiple ? !selectedCount : !getSelectValues(element, selectedOptions)); + + this.tabIndex(); + + if (this.options.selectedTextFormat === 'static') { + titleFragment = generateOption.text({ text: this.options.title }, true); + } else { + showCount = this.multiple && this.options.selectedTextFormat.indexOf('count') !== -1 && selectedCount > 1; + + // determine if the number of selected options will be shown (showCount === true) + if (showCount) { + countMax = this.options.selectedTextFormat.split('>'); + showCount = (countMax.length > 1 && selectedCount > countMax[1]) || (countMax.length === 1 && selectedCount >= 2); + } + + // only loop through all selected options if the count won't be shown + if (showCount === false) { + for (var selectedIndex = 0; selectedIndex < selectedCount; selectedIndex++) { + if (selectedIndex < 50) { + var option = selectedOptions[selectedIndex], + titleOptions = {}, + thisData = { + content: option.getAttribute('data-content'), + subtext: option.getAttribute('data-subtext'), + icon: option.getAttribute('data-icon') + }; + + if (this.multiple && selectedIndex > 0) { + titleFragment.appendChild(multipleSeparator.cloneNode(false)); + } + + if (option.title) { + titleOptions.text = option.title; + } else if (thisData.content && that.options.showContent) { + titleOptions.content = thisData.content.toString(); + hasContent = true; + } else { + if (that.options.showIcon) { + titleOptions.icon = thisData.icon; + titleOptions.iconBase = this.options.iconBase; + } + if (that.options.showSubtext && !that.multiple && thisData.subtext) titleOptions.subtext = ' ' + thisData.subtext; + titleOptions.text = option.textContent.trim(); + } + + titleFragment.appendChild(generateOption.text(titleOptions, true)); + } else { + break; + } + } + + // add ellipsis + if (selectedCount > 49) { + titleFragment.appendChild(document.createTextNode('...')); + } + } else { + var optionSelector = ':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])'; + if (this.options.hideDisabled) optionSelector += ':not(:disabled)'; + + // If this is a multiselect, and selectedTextFormat is count, then show 1 of 2 selected, etc. + var totalCount = this.$element[0].querySelectorAll('select > option' + optionSelector + ', optgroup' + optionSelector + ' option' + optionSelector).length, + tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedCount, totalCount) : this.options.countSelectedText; + + titleFragment = generateOption.text({ + text: tr8nText.replace('{0}', selectedCount.toString()).replace('{1}', totalCount.toString()) + }, true); + } + } + + if (this.options.title == undefined) { + // use .attr to ensure undefined is returned if title attribute is not set + this.options.title = this.$element.attr('title'); + } + + // If the select doesn't have a title, then use the default, or if nothing is set at all, use noneSelectedText + if (!titleFragment.childNodes.length) { + titleFragment = generateOption.text({ + text: typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText + }, true); + } + + // strip all HTML tags and trim the result, then unescape any escaped tags + button.title = titleFragment.textContent.replace(/<[^>]*>?/g, '').trim(); + + if (this.options.sanitize && hasContent) { + sanitizeHtml([titleFragment], that.options.whiteList, that.options.sanitizeFn); + } + + buttonInner.innerHTML = ''; + buttonInner.appendChild(titleFragment); + + if (version.major < 4 && this.$newElement[0].classList.contains('bs3-has-addon')) { + var filterExpand = button.querySelector('.filter-expand'), + clone = buttonInner.cloneNode(true); + + clone.className = 'filter-expand'; + + if (filterExpand) { + button.replaceChild(clone, filterExpand); + } else { + button.appendChild(clone); + } + } + + this.$element.trigger('rendered' + EVENT_KEY); + }, + + /** + * @param [style] + * @param [status] + */ + setStyle: function (newStyle, status) { + var button = this.$button[0], + newElement = this.$newElement[0], + style = this.options.style.trim(), + buttonClass; + + if (this.$element.attr('class')) { + this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, '')); + } + + if (version.major < 4) { + newElement.classList.add('bs3'); + + if (newElement.parentNode.classList.contains('input-group') && + (newElement.previousElementSibling || newElement.nextElementSibling) && + (newElement.previousElementSibling || newElement.nextElementSibling).classList.contains('input-group-addon') + ) { + newElement.classList.add('bs3-has-addon'); + } + } + + if (newStyle) { + buttonClass = newStyle.trim(); + } else { + buttonClass = style; + } + + if (status == 'add') { + if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' ')); + } else if (status == 'remove') { + if (buttonClass) button.classList.remove.apply(button.classList, buttonClass.split(' ')); + } else { + if (style) button.classList.remove.apply(button.classList, style.split(' ')); + if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' ')); + } + }, + + liHeight: function (refresh) { + if (!refresh && (this.options.size === false || this.sizeInfo)) return; + + if (!this.sizeInfo) this.sizeInfo = {}; + + var newElement = document.createElement('div'), + menu = document.createElement('div'), + menuInner = document.createElement('div'), + menuInnerInner = document.createElement('ul'), + divider = document.createElement('li'), + dropdownHeader = document.createElement('li'), + li = document.createElement('li'), + a = document.createElement('a'), + text = document.createElement('span'), + header = this.options.header && this.$menu.find('.' + classNames.POPOVERHEADER).length > 0 ? this.$menu.find('.' + classNames.POPOVERHEADER)[0].cloneNode(true) : null, + search = this.options.liveSearch ? document.createElement('div') : null, + actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null, + doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null, + firstOption = this.$element.find('option')[0]; + + this.sizeInfo.selectWidth = this.$newElement[0].offsetWidth; + + text.className = 'text'; + a.className = 'dropdown-item ' + (firstOption ? firstOption.className : ''); + newElement.className = this.$menu[0].parentNode.className + ' ' + classNames.SHOW; + newElement.style.width = this.sizeInfo.selectWidth + 'px'; + if (this.options.width === 'auto') menu.style.minWidth = 0; + menu.className = classNames.MENU + ' ' + classNames.SHOW; + menuInner.className = 'inner ' + classNames.SHOW; + menuInnerInner.className = classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : ''); + divider.className = classNames.DIVIDER; + dropdownHeader.className = 'dropdown-header'; + + text.appendChild(document.createTextNode('\u200b')); + a.appendChild(text); + li.appendChild(a); + dropdownHeader.appendChild(text.cloneNode(true)); + + if (this.selectpicker.view.widestOption) { + menuInnerInner.appendChild(this.selectpicker.view.widestOption.cloneNode(true)); + } + + menuInnerInner.appendChild(li); + menuInnerInner.appendChild(divider); + menuInnerInner.appendChild(dropdownHeader); + if (header) menu.appendChild(header); + if (search) { + var input = document.createElement('input'); + search.className = 'bs-searchbox'; + input.className = 'form-control'; + search.appendChild(input); + menu.appendChild(search); + } + if (actions) menu.appendChild(actions); + menuInner.appendChild(menuInnerInner); + menu.appendChild(menuInner); + if (doneButton) menu.appendChild(doneButton); + newElement.appendChild(menu); + + document.body.appendChild(newElement); + + var liHeight = li.offsetHeight, + dropdownHeaderHeight = dropdownHeader ? dropdownHeader.offsetHeight : 0, + headerHeight = header ? header.offsetHeight : 0, + searchHeight = search ? search.offsetHeight : 0, + actionsHeight = actions ? actions.offsetHeight : 0, + doneButtonHeight = doneButton ? doneButton.offsetHeight : 0, + dividerHeight = $(divider).outerHeight(true), + // fall back to jQuery if getComputedStyle is not supported + menuStyle = window.getComputedStyle ? window.getComputedStyle(menu) : false, + menuWidth = menu.offsetWidth, + $menu = menuStyle ? null : $(menu), + menuPadding = { + vert: toInteger(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) + + toInteger(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) + + toInteger(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) + + toInteger(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')), + horiz: toInteger(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) + + toInteger(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) + + toInteger(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) + + toInteger(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth')) + }, + menuExtras = { + vert: menuPadding.vert + + toInteger(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) + + toInteger(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2, + horiz: menuPadding.horiz + + toInteger(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) + + toInteger(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2 + }, + scrollBarWidth; + + menuInner.style.overflowY = 'scroll'; + + scrollBarWidth = menu.offsetWidth - menuWidth; + + document.body.removeChild(newElement); + + this.sizeInfo.liHeight = liHeight; + this.sizeInfo.dropdownHeaderHeight = dropdownHeaderHeight; + this.sizeInfo.headerHeight = headerHeight; + this.sizeInfo.searchHeight = searchHeight; + this.sizeInfo.actionsHeight = actionsHeight; + this.sizeInfo.doneButtonHeight = doneButtonHeight; + this.sizeInfo.dividerHeight = dividerHeight; + this.sizeInfo.menuPadding = menuPadding; + this.sizeInfo.menuExtras = menuExtras; + this.sizeInfo.menuWidth = menuWidth; + this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth; + this.sizeInfo.scrollBarWidth = scrollBarWidth; + this.sizeInfo.selectHeight = this.$newElement[0].offsetHeight; + + this.setPositionData(); + }, + + getSelectPosition: function () { + var that = this, + $window = $(window), + pos = that.$newElement.offset(), + $container = $(that.options.container), + containerPos; + + if (that.options.container && $container.length && !$container.is('body')) { + containerPos = $container.offset(); + containerPos.top += parseInt($container.css('borderTopWidth')); + containerPos.left += parseInt($container.css('borderLeftWidth')); + } else { + containerPos = { top: 0, left: 0 }; + } + + var winPad = that.options.windowPadding; + + this.sizeInfo.selectOffsetTop = pos.top - containerPos.top - $window.scrollTop(); + this.sizeInfo.selectOffsetBot = $window.height() - this.sizeInfo.selectOffsetTop - this.sizeInfo.selectHeight - containerPos.top - winPad[2]; + this.sizeInfo.selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft(); + this.sizeInfo.selectOffsetRight = $window.width() - this.sizeInfo.selectOffsetLeft - this.sizeInfo.selectWidth - containerPos.left - winPad[1]; + this.sizeInfo.selectOffsetTop -= winPad[0]; + this.sizeInfo.selectOffsetLeft -= winPad[3]; + }, + + setMenuSize: function (isAuto) { + this.getSelectPosition(); + + var selectWidth = this.sizeInfo.selectWidth, + liHeight = this.sizeInfo.liHeight, + headerHeight = this.sizeInfo.headerHeight, + searchHeight = this.sizeInfo.searchHeight, + actionsHeight = this.sizeInfo.actionsHeight, + doneButtonHeight = this.sizeInfo.doneButtonHeight, + divHeight = this.sizeInfo.dividerHeight, + menuPadding = this.sizeInfo.menuPadding, + menuInnerHeight, + menuHeight, + divLength = 0, + minHeight, + _minHeight, + maxHeight, + menuInnerMinHeight, + estimate; + + if (this.options.dropupAuto) { + // Get the estimated height of the menu without scrollbars. + // This is useful for smaller menus, where there might be plenty of room + // below the button without setting dropup, but we can't know + // the exact height of the menu until createView is called later + estimate = liHeight * this.selectpicker.current.elements.length + menuPadding.vert; + this.$newElement.toggleClass(classNames.DROPUP, this.sizeInfo.selectOffsetTop - this.sizeInfo.selectOffsetBot > this.sizeInfo.menuExtras.vert && estimate + this.sizeInfo.menuExtras.vert + 50 > this.sizeInfo.selectOffsetBot); + } + + if (this.options.size === 'auto') { + _minHeight = this.selectpicker.current.elements.length > 3 ? this.sizeInfo.liHeight * 3 + this.sizeInfo.menuExtras.vert - 2 : 0; + menuHeight = this.sizeInfo.selectOffsetBot - this.sizeInfo.menuExtras.vert; + minHeight = _minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight; + menuInnerMinHeight = Math.max(_minHeight - menuPadding.vert, 0); + + if (this.$newElement.hasClass(classNames.DROPUP)) { + menuHeight = this.sizeInfo.selectOffsetTop - this.sizeInfo.menuExtras.vert; + } + + maxHeight = menuHeight; + menuInnerHeight = menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert; + } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) { + for (var i = 0; i < this.options.size; i++) { + if (this.selectpicker.current.data[i].type === 'divider') divLength++; + } + + menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert; + menuInnerHeight = menuHeight - menuPadding.vert; + maxHeight = menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight; + minHeight = menuInnerMinHeight = ''; + } + + if (this.options.dropdownAlignRight === 'auto') { + this.$menu.toggleClass(classNames.MENURIGHT, this.sizeInfo.selectOffsetLeft > this.sizeInfo.selectOffsetRight && this.sizeInfo.selectOffsetRight < (this.sizeInfo.totalMenuWidth - selectWidth)); + } + + this.$menu.css({ + 'max-height': maxHeight + 'px', + 'overflow': 'hidden', + 'min-height': minHeight + 'px' + }); + + this.$menuInner.css({ + 'max-height': menuInnerHeight + 'px', + 'overflow-y': 'auto', + 'min-height': menuInnerMinHeight + 'px' + }); + + // ensure menuInnerHeight is always a positive number to prevent issues calculating chunkSize in createView + this.sizeInfo.menuInnerHeight = Math.max(menuInnerHeight, 1); + + if (this.selectpicker.current.data.length && this.selectpicker.current.data[this.selectpicker.current.data.length - 1].position > this.sizeInfo.menuInnerHeight) { + this.sizeInfo.hasScrollBar = true; + this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth + this.sizeInfo.scrollBarWidth; + + this.$menu.css('min-width', this.sizeInfo.totalMenuWidth); + } + + if (this.dropdown && this.dropdown._popper) this.dropdown._popper.update(); + }, + + setSize: function (refresh) { + this.liHeight(refresh); + + if (this.options.header) this.$menu.css('padding-top', 0); + if (this.options.size === false) return; + + var that = this, + $window = $(window); + + this.setMenuSize(); + + if (this.options.liveSearch) { + this.$searchbox + .off('input.setMenuSize propertychange.setMenuSize') + .on('input.setMenuSize propertychange.setMenuSize', function () { + return that.setMenuSize(); + }); + } + + if (this.options.size === 'auto') { + $window + .off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize') + .on('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize', function () { + return that.setMenuSize(); + }); + } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) { + $window.off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize'); + } + + that.createView(false, true, refresh); + }, + + setWidth: function () { + var that = this; + + if (this.options.width === 'auto') { + requestAnimationFrame(function () { + that.$menu.css('min-width', '0'); + + that.$element.on('loaded' + EVENT_KEY, function () { + that.liHeight(); + that.setMenuSize(); + + // Get correct width if element is hidden + var $selectClone = that.$newElement.clone().appendTo('body'), + btnWidth = $selectClone.css('width', 'auto').children('button').outerWidth(); + + $selectClone.remove(); + + // Set width to whatever's larger, button title or longest option + that.sizeInfo.selectWidth = Math.max(that.sizeInfo.totalMenuWidth, btnWidth); + that.$newElement.css('width', that.sizeInfo.selectWidth + 'px'); + }); + }); + } else if (this.options.width === 'fit') { + // Remove inline min-width so width can be changed from 'auto' + this.$menu.css('min-width', ''); + this.$newElement.css('width', '').addClass('fit-width'); + } else if (this.options.width) { + // Remove inline min-width so width can be changed from 'auto' + this.$menu.css('min-width', ''); + this.$newElement.css('width', this.options.width); + } else { + // Remove inline min-width/width so width can be changed + this.$menu.css('min-width', ''); + this.$newElement.css('width', ''); + } + // Remove fit-width class if width is changed programmatically + if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') { + this.$newElement[0].classList.remove('fit-width'); + } + }, + + selectPosition: function () { + this.$bsContainer = $('
    '); + + var that = this, + $container = $(this.options.container), + pos, + containerPos, + actualHeight, + getPlacement = function ($element) { + var containerPosition = {}, + // fall back to dropdown's default display setting if display is not manually set + display = that.options.display || ( + // Bootstrap 3 doesn't have $.fn.dropdown.Constructor.Default + $.fn.dropdown.Constructor.Default ? $.fn.dropdown.Constructor.Default.display + : false + ); + + that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass(classNames.DROPUP, $element.hasClass(classNames.DROPUP)); + pos = $element.offset(); + + if (!$container.is('body')) { + containerPos = $container.offset(); + containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop(); + containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft(); + } else { + containerPos = { top: 0, left: 0 }; + } + + actualHeight = $element.hasClass(classNames.DROPUP) ? 0 : $element[0].offsetHeight; + + // Bootstrap 4+ uses Popper for menu positioning + if (version.major < 4 || display === 'static') { + containerPosition.top = pos.top - containerPos.top + actualHeight; + containerPosition.left = pos.left - containerPos.left; + } + + containerPosition.width = $element[0].offsetWidth; + + that.$bsContainer.css(containerPosition); + }; + + this.$button.on('click.bs.dropdown.data-api', function () { + if (that.isDisabled()) { + return; + } + + getPlacement(that.$newElement); + + that.$bsContainer + .appendTo(that.options.container) + .toggleClass(classNames.SHOW, !that.$button.hasClass(classNames.SHOW)) + .append(that.$menu); + }); + + $(window) + .off('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId) + .on('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId, function () { + var isActive = that.$newElement.hasClass(classNames.SHOW); + + if (isActive) getPlacement(that.$newElement); + }); + + this.$element.on('hide' + EVENT_KEY, function () { + that.$menu.data('height', that.$menu.height()); + that.$bsContainer.detach(); + }); + }, + + setOptionStatus: function (selectedOnly) { + var that = this; + + that.noScroll = false; + + if (that.selectpicker.view.visibleElements && that.selectpicker.view.visibleElements.length) { + for (var i = 0; i < that.selectpicker.view.visibleElements.length; i++) { + var liData = that.selectpicker.current.data[i + that.selectpicker.view.position0], + option = liData.option; + + if (option) { + if (selectedOnly !== true) { + that.setDisabled( + liData.index, + liData.disabled + ); + } + + that.setSelected( + liData.index, + option.selected + ); + } + } + } + }, + + /** + * @param {number} index - the index of the option that is being changed + * @param {boolean} selected - true if the option is being selected, false if being deselected + */ + setSelected: function (index, selected) { + var li = this.selectpicker.main.elements[index], + liData = this.selectpicker.main.data[index], + activeIndexIsSet = this.activeIndex !== undefined, + thisIsActive = this.activeIndex === index, + prevActive, + a, + // if current option is already active + // OR + // if the current option is being selected, it's NOT multiple, and + // activeIndex is undefined: + // - when the menu is first being opened, OR + // - after a search has been performed, OR + // - when retainActive is false when selecting a new option (i.e. index of the newly selected option is not the same as the current activeIndex) + keepActive = thisIsActive || (selected && !this.multiple && !activeIndexIsSet); + + liData.selected = selected; + + a = li.firstChild; + + if (selected) { + this.selectedIndex = index; + } + + li.classList.toggle('selected', selected); + + if (keepActive) { + this.focusItem(li, liData); + this.selectpicker.view.currentActive = li; + this.activeIndex = index; + } else { + this.defocusItem(li); + } + + if (a) { + a.classList.toggle('selected', selected); + + if (selected) { + a.setAttribute('aria-selected', true); + } else { + if (this.multiple) { + a.setAttribute('aria-selected', false); + } else { + a.removeAttribute('aria-selected'); + } + } + } + + if (!keepActive && !activeIndexIsSet && selected && this.prevActiveIndex !== undefined) { + prevActive = this.selectpicker.main.elements[this.prevActiveIndex]; + + this.defocusItem(prevActive); + } + }, + + /** + * @param {number} index - the index of the option that is being disabled + * @param {boolean} disabled - true if the option is being disabled, false if being enabled + */ + setDisabled: function (index, disabled) { + var li = this.selectpicker.main.elements[index], + a; + + this.selectpicker.main.data[index].disabled = disabled; + + a = li.firstChild; + + li.classList.toggle(classNames.DISABLED, disabled); + + if (a) { + if (version.major === '4') a.classList.toggle(classNames.DISABLED, disabled); + + if (disabled) { + a.setAttribute('aria-disabled', disabled); + a.setAttribute('tabindex', -1); + } else { + a.removeAttribute('aria-disabled'); + a.setAttribute('tabindex', 0); + } + } + }, + + isDisabled: function () { + return this.$element[0].disabled; + }, + + checkDisabled: function () { + var that = this; + + if (this.isDisabled()) { + this.$newElement[0].classList.add(classNames.DISABLED); + this.$button.addClass(classNames.DISABLED).attr('tabindex', -1).attr('aria-disabled', true); + } else { + if (this.$button[0].classList.contains(classNames.DISABLED)) { + this.$newElement[0].classList.remove(classNames.DISABLED); + this.$button.removeClass(classNames.DISABLED).attr('aria-disabled', false); + } + + if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) { + this.$button.removeAttr('tabindex'); + } + } + + this.$button.on('click', function () { + return !that.isDisabled(); + }); + }, + + tabIndex: function () { + if (this.$element.data('tabindex') !== this.$element.attr('tabindex') && + (this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) { + this.$element.data('tabindex', this.$element.attr('tabindex')); + this.$button.attr('tabindex', this.$element.data('tabindex')); + } + + this.$element.attr('tabindex', -98); + }, + + clickListener: function () { + var that = this, + $document = $(document); + + $document.data('spaceSelect', false); + + this.$button.on('keyup', function (e) { + if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) { + e.preventDefault(); + $document.data('spaceSelect', false); + } + }); + + this.$newElement.on('show.bs.dropdown', function () { + if (version.major > 3 && !that.dropdown) { + that.dropdown = that.$button.data('bs.dropdown'); + that.dropdown._menu = that.$menu[0]; + } + }); + + this.$button.on('click.bs.dropdown.data-api', function () { + if (!that.$newElement.hasClass(classNames.SHOW)) { + that.setSize(); + } + }); + + function setFocus () { + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } else { + that.$menuInner.trigger('focus'); + } + } + + function checkPopperExists () { + if (that.dropdown && that.dropdown._popper && that.dropdown._popper.state.isCreated) { + setFocus(); + } else { + requestAnimationFrame(checkPopperExists); + } + } + + this.$element.on('shown' + EVENT_KEY, function () { + if (that.$menuInner[0].scrollTop !== that.selectpicker.view.scrollTop) { + that.$menuInner[0].scrollTop = that.selectpicker.view.scrollTop; + } + + if (version.major > 3) { + requestAnimationFrame(checkPopperExists); + } else { + setFocus(); + } + }); + + // ensure posinset and setsize are correct before selecting an option via a click + this.$menuInner.on('mouseenter', 'li a', function (e) { + var hoverLi = this.parentElement, + position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0, + index = Array.prototype.indexOf.call(hoverLi.parentElement.children, hoverLi), + hoverData = that.selectpicker.current.data[index + position0]; + + that.focusItem(hoverLi, hoverData, true); + }); + + this.$menuInner.on('click', 'li a', function (e, retainActive) { + var $this = $(this), + element = that.$element[0], + position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0, + clickedData = that.selectpicker.current.data[$this.parent().index() + position0], + clickedIndex = clickedData.index, + prevValue = getSelectValues(element), + prevIndex = element.selectedIndex, + prevOption = element.options[prevIndex], + triggerChange = true; + + // Don't close on multi choice menu + if (that.multiple && that.options.maxOptions !== 1) { + e.stopPropagation(); + } + + e.preventDefault(); + + // Don't run if the select is disabled + if (!that.isDisabled() && !$this.parent().hasClass(classNames.DISABLED)) { + var $options = that.$element.find('option'), + option = clickedData.option, + $option = $(option), + state = option.selected, + $optgroup = $option.parent('optgroup'), + $optgroupOptions = $optgroup.find('option'), + maxOptions = that.options.maxOptions, + maxOptionsGrp = $optgroup.data('maxOptions') || false; + + if (clickedIndex === that.activeIndex) retainActive = true; + + if (!retainActive) { + that.prevActiveIndex = that.activeIndex; + that.activeIndex = undefined; + } + + if (!that.multiple) { // Deselect all others if not multi select box + prevOption.selected = false; + option.selected = true; + that.setSelected(clickedIndex, true); + } else { // Toggle the one we have chosen if we are multi select. + option.selected = !state; + + that.setSelected(clickedIndex, !state); + $this.trigger('blur'); + + if (maxOptions !== false || maxOptionsGrp !== false) { + var maxReached = maxOptions < $options.filter(':selected').length, + maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length; + + if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) { + if (maxOptions && maxOptions == 1) { + $options.prop('selected', false); + $option.prop('selected', true); + + for (var i = 0; i < $options.length; i++) { + that.setSelected(i, false); + } + + that.setSelected(clickedIndex, true); + } else if (maxOptionsGrp && maxOptionsGrp == 1) { + $optgroup.find('option:selected').prop('selected', false); + $option.prop('selected', true); + + for (var i = 0; i < $optgroupOptions.length; i++) { + var option = $optgroupOptions[i]; + that.setSelected($options.index(option), false); + } + + that.setSelected(clickedIndex, true); + } else { + var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText, + maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText, + maxTxt = maxOptionsArr[0].replace('{n}', maxOptions), + maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp), + $notify = $('
    '); + // If {var} is set in array, replace it + /** @deprecated */ + if (maxOptionsArr[2]) { + maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]); + maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]); + } + + $option.prop('selected', false); + + that.$menu.append($notify); + + if (maxOptions && maxReached) { + $notify.append($('
    ' + maxTxt + '
    ')); + triggerChange = false; + that.$element.trigger('maxReached' + EVENT_KEY); + } + + if (maxOptionsGrp && maxReachedGrp) { + $notify.append($('
    ' + maxTxtGrp + '
    ')); + triggerChange = false; + that.$element.trigger('maxReachedGrp' + EVENT_KEY); + } + + setTimeout(function () { + that.setSelected(clickedIndex, false); + }, 10); + + $notify.delay(750).fadeOut(300, function () { + $(this).remove(); + }); + } + } + } + } + + if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) { + that.$button.trigger('focus'); + } else if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } + + // Trigger select 'change' + if (triggerChange) { + if (that.multiple || prevIndex !== element.selectedIndex) { + // $option.prop('selected') is current option state (selected/unselected). prevValue is the value of the select prior to being changed. + changedArguments = [option.index, $option.prop('selected'), prevValue]; + that.$element + .triggerNative('change'); + } + } + } + }); + + this.$menu.on('click', 'li.' + classNames.DISABLED + ' a, .' + classNames.POPOVERHEADER + ', .' + classNames.POPOVERHEADER + ' :not(.close)', function (e) { + if (e.currentTarget == this) { + e.preventDefault(); + e.stopPropagation(); + if (that.options.liveSearch && !$(e.target).hasClass('close')) { + that.$searchbox.trigger('focus'); + } else { + that.$button.trigger('focus'); + } + } + }); + + this.$menuInner.on('click', '.divider, .dropdown-header', function (e) { + e.preventDefault(); + e.stopPropagation(); + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } else { + that.$button.trigger('focus'); + } + }); + + this.$menu.on('click', '.' + classNames.POPOVERHEADER + ' .close', function () { + that.$button.trigger('click'); + }); + + this.$searchbox.on('click', function (e) { + e.stopPropagation(); + }); + + this.$menu.on('click', '.actions-btn', function (e) { + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } else { + that.$button.trigger('focus'); + } + + e.preventDefault(); + e.stopPropagation(); + + if ($(this).hasClass('bs-select-all')) { + that.selectAll(); + } else { + that.deselectAll(); + } + }); + + this.$element + .on('change' + EVENT_KEY, function () { + that.render(); + that.$element.trigger('changed' + EVENT_KEY, changedArguments); + changedArguments = null; + }) + .on('focus' + EVENT_KEY, function () { + if (!that.options.mobile) that.$button.trigger('focus'); + }); + }, + + liveSearchListener: function () { + var that = this, + noResults = document.createElement('li'); + + this.$button.on('click.bs.dropdown.data-api', function () { + if (!!that.$searchbox.val()) { + that.$searchbox.val(''); + } + }); + + this.$searchbox.on('click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api', function (e) { + e.stopPropagation(); + }); + + this.$searchbox.on('input propertychange', function () { + var searchValue = that.$searchbox.val(); + + that.selectpicker.search.elements = []; + that.selectpicker.search.data = []; + + if (searchValue) { + var i, + searchMatch = [], + q = searchValue.toUpperCase(), + cache = {}, + cacheArr = [], + searchStyle = that._searchStyle(), + normalizeSearch = that.options.liveSearchNormalize; + + if (normalizeSearch) q = normalizeToBase(q); + + that._$lisSelected = that.$menuInner.find('.selected'); + + for (var i = 0; i < that.selectpicker.main.data.length; i++) { + var li = that.selectpicker.main.data[i]; + + if (!cache[i]) { + cache[i] = stringSearch(li, q, searchStyle, normalizeSearch); + } + + if (cache[i] && li.headerIndex !== undefined && cacheArr.indexOf(li.headerIndex) === -1) { + if (li.headerIndex > 0) { + cache[li.headerIndex - 1] = true; + cacheArr.push(li.headerIndex - 1); + } + + cache[li.headerIndex] = true; + cacheArr.push(li.headerIndex); + + cache[li.lastIndex + 1] = true; + } + + if (cache[i] && li.type !== 'optgroup-label') cacheArr.push(i); + } + + for (var i = 0, cacheLen = cacheArr.length; i < cacheLen; i++) { + var index = cacheArr[i], + prevIndex = cacheArr[i - 1], + li = that.selectpicker.main.data[index], + liPrev = that.selectpicker.main.data[prevIndex]; + + if (li.type !== 'divider' || (li.type === 'divider' && liPrev && liPrev.type !== 'divider' && cacheLen - 1 !== i)) { + that.selectpicker.search.data.push(li); + searchMatch.push(that.selectpicker.main.elements[index]); + } + } + + that.activeIndex = undefined; + that.noScroll = true; + that.$menuInner.scrollTop(0); + that.selectpicker.search.elements = searchMatch; + that.createView(true); + + if (!searchMatch.length) { + noResults.className = 'no-results'; + noResults.innerHTML = that.options.noneResultsText.replace('{0}', '"' + htmlEscape(searchValue) + '"'); + that.$menuInner[0].firstChild.appendChild(noResults); + } + } else { + that.$menuInner.scrollTop(0); + that.createView(false); + } + }); + }, + + _searchStyle: function () { + return this.options.liveSearchStyle || 'contains'; + }, + + val: function (value) { + var element = this.$element[0]; + + if (typeof value !== 'undefined') { + var prevValue = getSelectValues(element); + + changedArguments = [null, null, prevValue]; + + this.$element + .val(value) + .trigger('changed' + EVENT_KEY, changedArguments); + + if (this.$newElement.hasClass(classNames.SHOW)) { + if (this.multiple) { + this.setOptionStatus(true); + } else { + var liSelectedIndex = (element.options[element.selectedIndex] || {}).liIndex; + + if (typeof liSelectedIndex === 'number') { + this.setSelected(this.selectedIndex, false); + this.setSelected(liSelectedIndex, true); + } + } + } + + this.render(); + + changedArguments = null; + + return this.$element; + } else { + return this.$element.val(); + } + }, + + changeAll: function (status) { + if (!this.multiple) return; + if (typeof status === 'undefined') status = true; + + var element = this.$element[0], + previousSelected = 0, + currentSelected = 0, + prevValue = getSelectValues(element); + + element.classList.add('bs-select-hidden'); + + for (var i = 0, len = this.selectpicker.current.elements.length; i < len; i++) { + var liData = this.selectpicker.current.data[i], + option = liData.option; + + if (option && !liData.disabled && liData.type !== 'divider') { + if (liData.selected) previousSelected++; + option.selected = status; + if (status) currentSelected++; + } + } + + element.classList.remove('bs-select-hidden'); + + if (previousSelected === currentSelected) return; + + this.setOptionStatus(); + + changedArguments = [null, null, prevValue]; + + this.$element + .triggerNative('change'); + }, + + selectAll: function () { + return this.changeAll(true); + }, + + deselectAll: function () { + return this.changeAll(false); + }, + + toggle: function (e) { + e = e || window.event; + + if (e) e.stopPropagation(); + + this.$button.trigger('click.bs.dropdown.data-api'); + }, + + keydown: function (e) { + var $this = $(this), + isToggle = $this.hasClass('dropdown-toggle'), + $parent = isToggle ? $this.closest('.dropdown') : $this.closest(Selector.MENU), + that = $parent.data('this'), + $items = that.findLis(), + index, + isActive, + liActive, + activeLi, + offset, + updateScroll = false, + downOnTab = e.which === keyCodes.TAB && !isToggle && !that.options.selectOnTab, + isArrowKey = REGEXP_ARROW.test(e.which) || downOnTab, + scrollTop = that.$menuInner[0].scrollTop, + isVirtual = that.isVirtual(), + position0 = isVirtual === true ? that.selectpicker.view.position0 : 0; + + isActive = that.$newElement.hasClass(classNames.SHOW); + + if ( + !isActive && + ( + isArrowKey || + (e.which >= 48 && e.which <= 57) || + (e.which >= 96 && e.which <= 105) || + (e.which >= 65 && e.which <= 90) + ) + ) { + that.$button.trigger('click.bs.dropdown.data-api'); + + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + return; + } + } + + if (e.which === keyCodes.ESCAPE && isActive) { + e.preventDefault(); + that.$button.trigger('click.bs.dropdown.data-api').trigger('focus'); + } + + if (isArrowKey) { // if up or down + if (!$items.length) return; + + liActive = that.selectpicker.main.elements[that.activeIndex]; + index = liActive ? Array.prototype.indexOf.call(liActive.parentElement.children, liActive) : -1; + + if (index !== -1) { + that.defocusItem(liActive); + } + + if (e.which === keyCodes.ARROW_UP) { // up + if (index !== -1) index--; + if (index + position0 < 0) index += $items.length; + + if (!that.selectpicker.view.canHighlight[index + position0]) { + index = that.selectpicker.view.canHighlight.slice(0, index + position0).lastIndexOf(true) - position0; + if (index === -1) index = $items.length - 1; + } + } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down + index++; + if (index + position0 >= that.selectpicker.view.canHighlight.length) index = 0; + + if (!that.selectpicker.view.canHighlight[index + position0]) { + index = index + 1 + that.selectpicker.view.canHighlight.slice(index + position0 + 1).indexOf(true); + } + } + + e.preventDefault(); + + var liActiveIndex = position0 + index; + + if (e.which === keyCodes.ARROW_UP) { // up + // scroll to bottom and highlight last option + if (position0 === 0 && index === $items.length - 1) { + that.$menuInner[0].scrollTop = that.$menuInner[0].scrollHeight; + + liActiveIndex = that.selectpicker.current.elements.length - 1; + } else { + activeLi = that.selectpicker.current.data[liActiveIndex]; + offset = activeLi.position - activeLi.height; + + updateScroll = offset < scrollTop; + } + } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down + // scroll to top and highlight first option + if (index === 0) { + that.$menuInner[0].scrollTop = 0; + + liActiveIndex = 0; + } else { + activeLi = that.selectpicker.current.data[liActiveIndex]; + offset = activeLi.position - that.sizeInfo.menuInnerHeight; + + updateScroll = offset > scrollTop; + } + } + + liActive = that.selectpicker.current.elements[liActiveIndex]; + + that.activeIndex = that.selectpicker.current.data[liActiveIndex].index; + + that.focusItem(liActive); + + that.selectpicker.view.currentActive = liActive; + + if (updateScroll) that.$menuInner[0].scrollTop = offset; + + if (that.options.liveSearch) { + that.$searchbox.trigger('focus'); + } else { + $this.trigger('focus'); + } + } else if ( + (!$this.is('input') && !REGEXP_TAB_OR_ESCAPE.test(e.which)) || + (e.which === keyCodes.SPACE && that.selectpicker.keydown.keyHistory) + ) { + var searchMatch, + matches = [], + keyHistory; + + e.preventDefault(); + + that.selectpicker.keydown.keyHistory += keyCodeMap[e.which]; + + if (that.selectpicker.keydown.resetKeyHistory.cancel) clearTimeout(that.selectpicker.keydown.resetKeyHistory.cancel); + that.selectpicker.keydown.resetKeyHistory.cancel = that.selectpicker.keydown.resetKeyHistory.start(); + + keyHistory = that.selectpicker.keydown.keyHistory; + + // if all letters are the same, set keyHistory to just the first character when searching + if (/^(.)\1+$/.test(keyHistory)) { + keyHistory = keyHistory.charAt(0); + } + + // find matches + for (var i = 0; i < that.selectpicker.current.data.length; i++) { + var li = that.selectpicker.current.data[i], + hasMatch; + + hasMatch = stringSearch(li, keyHistory, 'startsWith', true); + + if (hasMatch && that.selectpicker.view.canHighlight[i]) { + matches.push(li.index); + } + } + + if (matches.length) { + var matchIndex = 0; + + $items.removeClass('active').find('a').removeClass('active'); + + // either only one key has been pressed or they are all the same key + if (keyHistory.length === 1) { + matchIndex = matches.indexOf(that.activeIndex); + + if (matchIndex === -1 || matchIndex === matches.length - 1) { + matchIndex = 0; + } else { + matchIndex++; + } + } + + searchMatch = matches[matchIndex]; + + activeLi = that.selectpicker.main.data[searchMatch]; + + if (scrollTop - activeLi.position > 0) { + offset = activeLi.position - activeLi.height; + updateScroll = true; + } else { + offset = activeLi.position - that.sizeInfo.menuInnerHeight; + // if the option is already visible at the current scroll position, just keep it the same + updateScroll = activeLi.position > scrollTop + that.sizeInfo.menuInnerHeight; + } + + liActive = that.selectpicker.main.elements[searchMatch]; + + that.activeIndex = matches[matchIndex]; + + that.focusItem(liActive); + + if (liActive) liActive.firstChild.focus(); + + if (updateScroll) that.$menuInner[0].scrollTop = offset; + + $this.trigger('focus'); + } + } + + // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu. + if ( + isActive && + ( + (e.which === keyCodes.SPACE && !that.selectpicker.keydown.keyHistory) || + e.which === keyCodes.ENTER || + (e.which === keyCodes.TAB && that.options.selectOnTab) + ) + ) { + if (e.which !== keyCodes.SPACE) e.preventDefault(); + + if (!that.options.liveSearch || e.which !== keyCodes.SPACE) { + that.$menuInner.find('.active a').trigger('click', true); // retain active class + $this.trigger('focus'); + + if (!that.options.liveSearch) { + // Prevent screen from scrolling if the user hits the spacebar + e.preventDefault(); + // Fixes spacebar selection of dropdown items in FF & IE + $(document).data('spaceSelect', true); + } + } + } + }, + + mobile: function () { + this.$element[0].classList.add('mobile-device'); + }, + + refresh: function () { + // update options if data attributes have been changed + var config = $.extend({}, this.options, this.$element.data()); + this.options = config; + + this.checkDisabled(); + this.setStyle(); + this.render(); + this.createLi(); + this.setWidth(); + + this.setSize(true); + + this.$element.trigger('refreshed' + EVENT_KEY); + }, + + hide: function () { + this.$newElement.hide(); + }, + + show: function () { + this.$newElement.show(); + }, + + remove: function () { + this.$newElement.remove(); + this.$element.remove(); + }, + + destroy: function () { + this.$newElement.before(this.$element).remove(); + + if (this.$bsContainer) { + this.$bsContainer.remove(); + } else { + this.$menu.remove(); + } + + this.$element + .off(EVENT_KEY) + .removeData('selectpicker') + .removeClass('bs-select-hidden selectpicker'); + + $(window).off(EVENT_KEY + '.' + this.selectId); + } + }; + + // SELECTPICKER PLUGIN DEFINITION + // ============================== + function Plugin (option) { + // get the args of the outer function.. + var args = arguments; + // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them + // to get lost/corrupted in android 2.3 and IE9 #715 #775 + var _option = option; + + [].shift.apply(args); + + // if the version was not set successfully + if (!version.success) { + // try to retreive it again + try { + version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.'); + } catch (err) { + // fall back to use BootstrapVersion if set + if (Selectpicker.BootstrapVersion) { + version.full = Selectpicker.BootstrapVersion.split(' ')[0].split('.'); + } else { + version.full = [version.major, '0', '0']; + + console.warn( + 'There was an issue retrieving Bootstrap\'s version. ' + + 'Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. ' + + 'If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.', + err + ); + } + } + + version.major = version.full[0]; + version.success = true; + } + + if (version.major === '4') { + // some defaults need to be changed if using Bootstrap 4 + // check to see if they have already been manually changed before forcing them to update + var toUpdate = []; + + if (Selectpicker.DEFAULTS.style === classNames.BUTTONCLASS) toUpdate.push({ name: 'style', className: 'BUTTONCLASS' }); + if (Selectpicker.DEFAULTS.iconBase === classNames.ICONBASE) toUpdate.push({ name: 'iconBase', className: 'ICONBASE' }); + if (Selectpicker.DEFAULTS.tickIcon === classNames.TICKICON) toUpdate.push({ name: 'tickIcon', className: 'TICKICON' }); + + classNames.DIVIDER = 'dropdown-divider'; + classNames.SHOW = 'show'; + classNames.BUTTONCLASS = 'btn-light'; + classNames.POPOVERHEADER = 'popover-header'; + classNames.ICONBASE = ''; + classNames.TICKICON = 'bs-ok-default'; + + for (var i = 0; i < toUpdate.length; i++) { + var option = toUpdate[i]; + Selectpicker.DEFAULTS[option.name] = classNames[option.className]; + } + } + + var value; + var chain = this.each(function () { + var $this = $(this); + if ($this.is('select')) { + var data = $this.data('selectpicker'), + options = typeof _option == 'object' && _option; + + if (!data) { + var dataAttributes = $this.data(); + + for (var dataAttr in dataAttributes) { + if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) { + delete dataAttributes[dataAttr]; + } + } + + var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, dataAttributes, options); + config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), dataAttributes.template, options.template); + $this.data('selectpicker', (data = new Selectpicker(this, config))); + } else if (options) { + for (var i in options) { + if (options.hasOwnProperty(i)) { + data.options[i] = options[i]; + } + } + } + + if (typeof _option == 'string') { + if (data[_option] instanceof Function) { + value = data[_option].apply(data, args); + } else { + value = data.options[_option]; + } + } + } + }); + + if (typeof value !== 'undefined') { + // noinspection JSUnusedAssignment + return value; + } else { + return chain; + } + } + + var old = $.fn.selectpicker; + $.fn.selectpicker = Plugin; + $.fn.selectpicker.Constructor = Selectpicker; + + // SELECTPICKER NO CONFLICT + // ======================== + $.fn.selectpicker.noConflict = function () { + $.fn.selectpicker = old; + return this; + }; + + $(document) + .off('keydown.bs.dropdown.data-api') + .on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown) + .on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) { + e.stopPropagation(); + }); + + // SELECTPICKER DATA-API + // ===================== + $(window).on('load' + EVENT_KEY + '.data-api', function () { + $('.selectpicker').each(function () { + var $selectpicker = $(this); + Plugin.call($selectpicker, $selectpicker.data()); + }) + }); +})(jQuery); + + +})); //# sourceMappingURL=bootstrap-select.js.map \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.css b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.css similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.css rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.css index 579ee12c2..dafcce3a0 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.css @@ -1,6 +1,6 @@ -/*! - * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select) - * - * Copyright 2012-2019 SnapAppointments, LLC - * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) +/*! + * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select) + * + * Copyright 2012-2019 SnapAppointments, LLC + * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) */.bootstrap-select>select.bs-select-hidden,select.bs-select-hidden,select.selectpicker{display:none!important}.bootstrap-select{width:220px\0;vertical-align:middle}.bootstrap-select>.dropdown-toggle{position:relative;width:100%;text-align:right;white-space:nowrap;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between}.bootstrap-select>.dropdown-toggle:after{margin-top:-1px}.bootstrap-select>.dropdown-toggle.bs-placeholder,.bootstrap-select>.dropdown-toggle.bs-placeholder:active,.bootstrap-select>.dropdown-toggle.bs-placeholder:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder:hover{color:#999}.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-danger,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-danger:active,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-danger:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-danger:hover,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-dark,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-dark:active,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-dark:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-dark:hover,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-info,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-info:active,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-info:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-info:hover,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-primary,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-primary:active,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-primary:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-primary:hover,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-secondary,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-secondary:active,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-secondary:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-secondary:hover,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-success,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-success:active,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-success:focus,.bootstrap-select>.dropdown-toggle.bs-placeholder.btn-success:hover{color:rgba(255,255,255,.5)}.bootstrap-select>select{position:absolute!important;bottom:0;left:50%;display:block!important;width:.5px!important;height:100%!important;padding:0!important;opacity:0!important;border:none;z-index:0!important}.bootstrap-select>select.mobile-device{top:0;left:0;display:block!important;width:100%!important;z-index:2!important}.bootstrap-select.is-invalid .dropdown-toggle,.error .bootstrap-select .dropdown-toggle,.has-error .bootstrap-select .dropdown-toggle,.was-validated .bootstrap-select .selectpicker:invalid+.dropdown-toggle{border-color:#b94a48}.bootstrap-select.is-valid .dropdown-toggle,.was-validated .bootstrap-select .selectpicker:valid+.dropdown-toggle{border-color:#28a745}.bootstrap-select.fit-width{width:auto!important}.bootstrap-select:not([class*=col-]):not([class*=form-control]):not(.input-group-btn){width:220px}.bootstrap-select .dropdown-toggle:focus,.bootstrap-select>select.mobile-device:focus+.dropdown-toggle{outline:thin dotted #333!important;outline:5px auto -webkit-focus-ring-color!important;outline-offset:-2px}.bootstrap-select.form-control{margin-bottom:0;padding:0;border:none;height:auto}:not(.input-group)>.bootstrap-select.form-control:not([class*=col-]){width:100%}.bootstrap-select.form-control.input-group-btn{float:none;z-index:auto}.form-inline .bootstrap-select,.form-inline .bootstrap-select.form-control:not([class*=col-]){width:auto}.bootstrap-select:not(.input-group-btn),.bootstrap-select[class*=col-]{float:none;display:inline-block;margin-left:0}.bootstrap-select.dropdown-menu-right,.bootstrap-select[class*=col-].dropdown-menu-right,.row .bootstrap-select[class*=col-].dropdown-menu-right{float:right}.form-group .bootstrap-select,.form-horizontal .bootstrap-select,.form-inline .bootstrap-select{margin-bottom:0}.form-group-lg .bootstrap-select.form-control,.form-group-sm .bootstrap-select.form-control{padding:0}.form-group-lg .bootstrap-select.form-control .dropdown-toggle,.form-group-sm .bootstrap-select.form-control .dropdown-toggle{height:100%;font-size:inherit;line-height:inherit;border-radius:inherit}.bootstrap-select.form-control-lg .dropdown-toggle,.bootstrap-select.form-control-sm .dropdown-toggle{font-size:inherit;line-height:inherit;border-radius:inherit}.bootstrap-select.form-control-sm .dropdown-toggle{padding:.25rem .5rem}.bootstrap-select.form-control-lg .dropdown-toggle{padding:.5rem 1rem}.form-inline .bootstrap-select .form-control{width:100%}.bootstrap-select.disabled,.bootstrap-select>.disabled{cursor:not-allowed}.bootstrap-select.disabled:focus,.bootstrap-select>.disabled:focus{outline:0!important}.bootstrap-select.bs-container{position:absolute;top:0;left:0;height:0!important;padding:0!important}.bootstrap-select.bs-container .dropdown-menu{z-index:1060}.bootstrap-select .dropdown-toggle .filter-option{position:static;top:0;left:0;float:left;height:100%;width:100%;text-align:left;overflow:hidden;-webkit-box-flex:0;-webkit-flex:0 1 auto;-ms-flex:0 1 auto;flex:0 1 auto}.bs3.bootstrap-select .dropdown-toggle .filter-option{padding-right:inherit}.input-group .bs3-has-addon.bootstrap-select .dropdown-toggle .filter-option{position:absolute;padding-top:inherit;padding-bottom:inherit;padding-left:inherit;float:none}.input-group .bs3-has-addon.bootstrap-select .dropdown-toggle .filter-option .filter-option-inner{padding-right:inherit}.bootstrap-select .dropdown-toggle .filter-option-inner-inner{overflow:hidden}.bootstrap-select .dropdown-toggle .filter-expand{width:0!important;float:left;opacity:0!important;overflow:hidden}.bootstrap-select .dropdown-toggle .caret{position:absolute;top:50%;right:12px;margin-top:-2px;vertical-align:middle}.input-group .bootstrap-select.form-control .dropdown-toggle{border-radius:inherit}.bootstrap-select[class*=col-] .dropdown-toggle{width:100%}.bootstrap-select .dropdown-menu{min-width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bootstrap-select .dropdown-menu>.inner:focus{outline:0!important}.bootstrap-select .dropdown-menu.inner{position:static;float:none;border:0;padding:0;margin:0;border-radius:0;-webkit-box-shadow:none;box-shadow:none}.bootstrap-select .dropdown-menu li{position:relative}.bootstrap-select .dropdown-menu li.active small{color:rgba(255,255,255,.5)!important}.bootstrap-select .dropdown-menu li.disabled a{cursor:not-allowed}.bootstrap-select .dropdown-menu li a{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.bootstrap-select .dropdown-menu li a.opt{position:relative;padding-left:2.25em}.bootstrap-select .dropdown-menu li a span.check-mark{display:none}.bootstrap-select .dropdown-menu li a span.text{display:inline-block}.bootstrap-select .dropdown-menu li small{padding-left:.5em}.bootstrap-select .dropdown-menu .notify{position:absolute;bottom:5px;width:96%;margin:0 2%;min-height:26px;padding:3px 5px;background:#f5f5f5;border:1px solid #e3e3e3;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05);pointer-events:none;opacity:.9;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bootstrap-select .no-results{padding:3px;background:#f5f5f5;margin:0 5px;white-space:nowrap}.bootstrap-select.fit-width .dropdown-toggle .filter-option{position:static;display:inline;padding:0}.bootstrap-select.fit-width .dropdown-toggle .filter-option-inner,.bootstrap-select.fit-width .dropdown-toggle .filter-option-inner-inner{display:inline}.bootstrap-select.fit-width .dropdown-toggle .bs-caret:before{content:'\00a0'}.bootstrap-select.fit-width .dropdown-toggle .caret{position:static;top:auto;margin-top:-1px}.bootstrap-select.show-tick .dropdown-menu .selected span.check-mark{position:absolute;display:inline-block;right:15px;top:5px}.bootstrap-select.show-tick .dropdown-menu li a span.text{margin-right:34px}.bootstrap-select .bs-ok-default:after{content:'';display:block;width:.5em;height:1em;border-style:solid;border-width:0 .26em .26em 0;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.bootstrap-select.show-menu-arrow.open>.dropdown-toggle,.bootstrap-select.show-menu-arrow.show>.dropdown-toggle{z-index:1061}.bootstrap-select.show-menu-arrow .dropdown-toggle .filter-option:before{content:'';border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid rgba(204,204,204,.2);position:absolute;bottom:-4px;left:9px;display:none}.bootstrap-select.show-menu-arrow .dropdown-toggle .filter-option:after{content:'';border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;position:absolute;bottom:-4px;left:10px;display:none}.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle .filter-option:before{bottom:auto;top:-4px;border-top:7px solid rgba(204,204,204,.2);border-bottom:0}.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle .filter-option:after{bottom:auto;top:-4px;border-top:6px solid #fff;border-bottom:0}.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle .filter-option:before{right:12px;left:auto}.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle .filter-option:after{right:13px;left:auto}.bootstrap-select.show-menu-arrow.open>.dropdown-toggle .filter-option:after,.bootstrap-select.show-menu-arrow.open>.dropdown-toggle .filter-option:before,.bootstrap-select.show-menu-arrow.show>.dropdown-toggle .filter-option:after,.bootstrap-select.show-menu-arrow.show>.dropdown-toggle .filter-option:before{display:block}.bs-actionsbox,.bs-donebutton,.bs-searchbox{padding:4px 8px}.bs-actionsbox{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bs-actionsbox .btn-group button{width:50%}.bs-donebutton{float:left;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bs-donebutton .btn-group button{width:100%}.bs-searchbox+.bs-actionsbox{padding:0 8px 4px}.bs-searchbox .form-control{margin-bottom:0;width:100%;float:none} \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.js index 058acb90e..f9cb0638d 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-select/bootstrap-select.min.js @@ -1,9 +1,9 @@ -/*! - * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select) - * - * Copyright 2012-2019 SnapAppointments, LLC - * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) - */ - -!function(e,t){void 0===e&&void 0!==window&&(e=window),"function"==typeof define&&define.amd?define(["jquery"],function(e){return t(e)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(e.jQuery)}(this,function(e){!function(z){"use strict";var d=["sanitize","whiteList","sanitizeFn"],r=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],e={"*":["class","dir","id","lang","role","tabindex","style",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},l=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,a=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;function v(e,t){var i=e.nodeName.toLowerCase();if(-1!==z.inArray(i,t))return-1===z.inArray(i,r)||Boolean(e.nodeValue.match(l)||e.nodeValue.match(a));for(var s=z(t).filter(function(e,t){return t instanceof RegExp}),n=0,o=s.length;n]+>/g,"")),s&&(a=w(a)),a=a.toUpperCase(),o="contains"===i?0<=a.indexOf(t):a.startsWith(t)))break}return o}function A(e){return parseInt(e,10)||0}z.fn.triggerNative=function(e){var t,i=this[0];i.dispatchEvent?(u?t=new Event(e,{bubbles:!0}):(t=document.createEvent("Event")).initEvent(e,!0,!1),i.dispatchEvent(t)):i.fireEvent?((t=document.createEventObject()).eventType=e,i.fireEvent("on"+e,t)):this.trigger(e)};var f={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"},m=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,g=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]","g");function b(e){return f[e]}function w(e){return(e=e.toString())&&e.replace(m,b).replace(g,"")}var I,x,$,y,S,E=(I={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},x=function(e){return I[e]},$="(?:"+Object.keys(I).join("|")+")",y=RegExp($),S=RegExp($,"g"),function(e){return e=null==e?"":""+e,y.test(e)?e.replace(S,x):e}),C={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},L=27,N=13,D=32,H=9,B=38,W=40,M={success:!1,major:"3"};try{M.full=(z.fn.dropdown.Constructor.VERSION||"").split(" ")[0].split("."),M.major=M.full[0],M.success=!0}catch(e){}var R=0,U=".bs.select",j={DISABLED:"disabled",DIVIDER:"divider",SHOW:"open",DROPUP:"dropup",MENU:"dropdown-menu",MENURIGHT:"dropdown-menu-right",MENULEFT:"dropdown-menu-left",BUTTONCLASS:"btn-default",POPOVERHEADER:"popover-title",ICONBASE:"glyphicon",TICKICON:"glyphicon-ok"},V={MENU:"."+j.MENU},F={span:document.createElement("span"),i:document.createElement("i"),subtext:document.createElement("small"),a:document.createElement("a"),li:document.createElement("li"),whitespace:document.createTextNode("\xa0"),fragment:document.createDocumentFragment()};F.a.setAttribute("role","option"),F.subtext.className="text-muted",F.text=F.span.cloneNode(!1),F.text.className="text",F.checkMark=F.span.cloneNode(!1);var _=new RegExp(B+"|"+W),G=new RegExp("^"+H+"$|"+L),q=function(e,t,i){var s=F.li.cloneNode(!1);return e&&(1===e.nodeType||11===e.nodeType?s.appendChild(e):s.innerHTML=e),void 0!==t&&""!==t&&(s.className=t),null!=i&&s.classList.add("optgroup-"+i),s},K=function(e,t,i){var s=F.a.cloneNode(!0);return e&&(11===e.nodeType?s.appendChild(e):s.insertAdjacentHTML("beforeend",e)),void 0!==t&&""!==t&&(s.className=t),"4"===M.major&&s.classList.add("dropdown-item"),i&&s.setAttribute("style",i),s},Y=function(e,t){var i,s,n=F.text.cloneNode(!1);if(e.content)n.innerHTML=e.content;else{if(n.textContent=e.text,e.icon){var o=F.whitespace.cloneNode(!1);(s=(!0===t?F.i:F.span).cloneNode(!1)).className=e.iconBase+" "+e.icon,F.fragment.appendChild(s),F.fragment.appendChild(o)}e.subtext&&((i=F.subtext.cloneNode(!1)).textContent=e.subtext,n.appendChild(i))}if(!0===t)for(;0'},maxOptions:!1,mobile:!1,selectOnTab:!1,dropdownAlignRight:!1,windowPadding:0,virtualScroll:600,display:!1,sanitize:!0,sanitizeFn:null,whiteList:e},J.prototype={constructor:J,init:function(){var i=this,e=this.$element.attr("id");R++,this.selectId="bs-select-"+R,this.$element[0].classList.add("bs-select-hidden"),this.multiple=this.$element.prop("multiple"),this.autofocus=this.$element.prop("autofocus"),this.$element[0].classList.contains("show-tick")&&(this.options.showTick=!0),this.$newElement=this.createDropdown(),this.$element.after(this.$newElement).prependTo(this.$newElement),this.$button=this.$newElement.children("button"),this.$menu=this.$newElement.children(V.MENU),this.$menuInner=this.$menu.children(".inner"),this.$searchbox=this.$menu.find("input"),this.$element[0].classList.remove("bs-select-hidden"),!0===this.options.dropdownAlignRight&&this.$menu[0].classList.add(j.MENURIGHT),void 0!==e&&this.$button.attr("data-id",e),this.checkDisabled(),this.clickListener(),this.options.liveSearch?(this.liveSearchListener(),this.focusedParent=this.$searchbox[0]):this.focusedParent=this.$menuInner[0],this.setStyle(),this.render(),this.setWidth(),this.options.container?this.selectPosition():this.$element.on("hide"+U,function(){if(i.isVirtual()){var e=i.$menuInner[0],t=e.firstChild.cloneNode(!1);e.replaceChild(t,e.firstChild),e.scrollTop=0}}),this.$menu.data("this",this),this.$newElement.data("this",this),this.options.mobile&&this.mobile(),this.$newElement.on({"hide.bs.dropdown":function(e){i.$element.trigger("hide"+U,e)},"hidden.bs.dropdown":function(e){i.$element.trigger("hidden"+U,e)},"show.bs.dropdown":function(e){i.$element.trigger("show"+U,e)},"shown.bs.dropdown":function(e){i.$element.trigger("shown"+U,e)}}),i.$element[0].hasAttribute("required")&&this.$element.on("invalid"+U,function(){i.$button[0].classList.add("bs-invalid"),i.$element.on("shown"+U+".invalid",function(){i.$element.val(i.$element.val()).off("shown"+U+".invalid")}).on("rendered"+U,function(){this.validity.valid&&i.$button[0].classList.remove("bs-invalid"),i.$element.off("rendered"+U)}),i.$button.on("blur"+U,function(){i.$element.trigger("focus").trigger("blur"),i.$button.off("blur"+U)})}),setTimeout(function(){i.createLi(),i.$element.trigger("loaded"+U)})},createDropdown:function(){var e=this.multiple||this.options.showTick?" show-tick":"",t=this.multiple?' aria-multiselectable="true"':"",i="",s=this.autofocus?" autofocus":"";M.major<4&&this.$element.parent().hasClass("input-group")&&(i=" input-group-btn");var n,o="",r="",l="",a="";return this.options.header&&(o='
    '+this.options.header+"
    "),this.options.liveSearch&&(r=''),this.multiple&&this.options.actionsBox&&(l='
    "),this.multiple&&this.options.doneButton&&(a='
    "),n='",z(n)},setPositionData:function(){this.selectpicker.view.canHighlight=[];for(var e=this.selectpicker.view.size=0;e=this.options.virtualScroll||!0===this.options.virtualScroll},createView:function(A,e,t){var L,N,D=this,i=0,H=[];if(this.selectpicker.current=A?this.selectpicker.search:this.selectpicker.main,this.setPositionData(),e)if(t)i=this.$menuInner[0].scrollTop;else if(!D.multiple){var s=D.$element[0],n=(s.options[s.selectedIndex]||{}).liIndex;if("number"==typeof n&&!1!==D.options.size){var o=D.selectpicker.main.data[n],r=o&&o.position;r&&(i=r-(D.sizeInfo.menuInnerHeight+D.sizeInfo.liHeight)/2)}}function l(e,t){var i,s,n,o,r,l,a,c,d,h,p=D.selectpicker.current.elements.length,u=[],f=!0,m=D.isVirtual();D.selectpicker.view.scrollTop=e,!0===m&&D.sizeInfo.hasScrollBar&&D.$menu[0].offsetWidth>D.sizeInfo.totalMenuWidth&&(D.sizeInfo.menuWidth=D.$menu[0].offsetWidth,D.sizeInfo.totalMenuWidth=D.sizeInfo.menuWidth+D.sizeInfo.scrollBarWidth,D.$menu.css("min-width",D.sizeInfo.menuWidth)),i=Math.ceil(D.sizeInfo.menuInnerHeight/D.sizeInfo.liHeight*1.5),s=Math.round(p/i)||1;for(var v=0;vp-1?0:D.selectpicker.current.data[p-1].position-D.selectpicker.current.data[D.selectpicker.view.position1-1].position,I.firstChild.style.marginTop=b+"px",w+"px"):I.firstChild.style.marginTop=0,I.firstChild.appendChild(x)}if(D.prevActiveIndex=D.activeIndex,D.options.liveSearch){if(A&&t){var z,T=0;D.selectpicker.view.canHighlight[T]||(T=1+D.selectpicker.view.canHighlight.slice(1).indexOf(!0)),z=D.selectpicker.view.visibleElements[T],D.defocusItem(D.selectpicker.view.currentActive),D.activeIndex=(D.selectpicker.current.data[T]||{}).index,D.focusItem(z)}}else D.$menuInner.trigger("focus")}l(i,!0),this.$menuInner.off("scroll.createView").on("scroll.createView",function(e,t){D.noScroll||l(this.scrollTop,t),D.noScroll=!1}),z(window).off("resize"+U+"."+this.selectId+".createView").on("resize"+U+"."+this.selectId+".createView",function(){D.$newElement.hasClass(j.SHOW)&&l(D.$menuInner[0].scrollTop)})},focusItem:function(e,t,i){if(e){t=t||this.selectpicker.main.data[this.activeIndex];var s=e.firstChild;s&&(s.setAttribute("aria-setsize",this.selectpicker.view.size),s.setAttribute("aria-posinset",t.posinset),!0!==i&&(this.focusedParent.setAttribute("aria-activedescendant",s.id),e.classList.add("active"),s.classList.add("active")))}},defocusItem:function(e){e&&(e.classList.remove("active"),e.firstChild&&e.firstChild.classList.remove("active"))},setPlaceholder:function(){var e=!1;if(this.options.title&&!this.multiple){this.selectpicker.view.titleOption||(this.selectpicker.view.titleOption=document.createElement("option")),e=!0;var t=this.$element[0],i=!1,s=!this.selectpicker.view.titleOption.parentNode;if(s)this.selectpicker.view.titleOption.className="bs-title-option",this.selectpicker.view.titleOption.value="",i=void 0===z(t.options[t.selectedIndex]).attr("selected")&&void 0===this.$element.data("selected");(s||0!==this.selectpicker.view.titleOption.index)&&t.insertBefore(this.selectpicker.view.titleOption,t.firstChild),i&&(t.selectedIndex=0)}return e},createLi:function(){var c=this,f=this.options.iconBase,m=':not([hidden]):not([data-hidden="true"])',v=[],g=[],d=0,b=0,e=this.setPlaceholder()?1:0;this.options.hideDisabled&&(m+=":not(:disabled)"),!c.options.showTick&&!c.multiple||F.checkMark.parentNode||(F.checkMark.className=f+" "+c.options.tickIcon+" check-mark",F.a.appendChild(F.checkMark));var t=this.$element[0].querySelectorAll("select > *"+m);function w(e){var t=g[g.length-1];t&&"divider"===t.type&&(t.optID||e.optID)||((e=e||{}).type="divider",v.push(q(!1,j.DIVIDER,e.optID?e.optID+"div":void 0)),g.push(e))}function I(e,t){if((t=t||{}).divider="true"===e.getAttribute("data-divider"),t.divider)w({optID:t.optID});else{var i=g.length,s=e.style.cssText,n=s?E(s):"",o=(e.className||"")+(t.optgroupClass||"");t.optID&&(o="opt "+o),t.text=e.textContent,t.content=e.getAttribute("data-content"),t.tokens=e.getAttribute("data-tokens"),t.subtext=e.getAttribute("data-subtext"),t.icon=e.getAttribute("data-icon"),t.iconBase=f;var r=Y(t),l=q(K(r,o,n),"",t.optID);l.firstChild&&(l.firstChild.id=c.selectId+"-"+i),v.push(l),e.liIndex=i,t.display=t.content||t.text,t.type="option",t.index=i,t.option=e,t.disabled=t.disabled||e.disabled,g.push(t);var a=0;t.display&&(a+=t.display.length),t.subtext&&(a+=t.subtext.length),t.icon&&(a+=1),d li")},render:function(){this.setPlaceholder();var e,t,i=this,s=this.$element[0],n=function(e,t){var i,s=e.selectedOptions,n=[];if(t){for(var o=0,r=s.length;o")).length&&o>t[1]||1===t.length&&2<=o),!1===e){for(var h=0;h option"+m+", optgroup"+m+" option"+m).length,g="function"==typeof this.options.countSelectedText?this.options.countSelectedText(o,v):this.options.countSelectedText;c=Y({text:g.replace("{0}",o.toString()).replace("{1}",v.toString())},!0)}if(null==this.options.title&&(this.options.title=this.$element.attr("title")),c.childNodes.length||(c=Y({text:void 0!==this.options.title?this.options.title:this.options.noneSelectedText},!0)),r.title=c.textContent.replace(/<[^>]*>?/g,"").trim(),this.options.sanitize&&d&&P([c],i.options.whiteList,i.options.sanitizeFn),l.innerHTML="",l.appendChild(c),M.major<4&&this.$newElement[0].classList.contains("bs3-has-addon")){var b=r.querySelector(".filter-expand"),w=l.cloneNode(!0);w.className="filter-expand",b?r.replaceChild(w,b):r.appendChild(w)}this.$element.trigger("rendered"+U)},setStyle:function(e,t){var i,s=this.$button[0],n=this.$newElement[0],o=this.options.style.trim();this.$element.attr("class")&&this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi,"")),M.major<4&&(n.classList.add("bs3"),n.parentNode.classList.contains("input-group")&&(n.previousElementSibling||n.nextElementSibling)&&(n.previousElementSibling||n.nextElementSibling).classList.contains("input-group-addon")&&n.classList.add("bs3-has-addon")),i=e?e.trim():o,"add"==t?i&&s.classList.add.apply(s.classList,i.split(" ")):"remove"==t?i&&s.classList.remove.apply(s.classList,i.split(" ")):(o&&s.classList.remove.apply(s.classList,o.split(" ")),i&&s.classList.add.apply(s.classList,i.split(" ")))},liHeight:function(e){if(e||!1!==this.options.size&&!this.sizeInfo){this.sizeInfo||(this.sizeInfo={});var t=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("ul"),o=document.createElement("li"),r=document.createElement("li"),l=document.createElement("li"),a=document.createElement("a"),c=document.createElement("span"),d=this.options.header&&0this.sizeInfo.menuExtras.vert&&l+this.sizeInfo.menuExtras.vert+50>this.sizeInfo.selectOffsetBot)),"auto"===this.options.size)n=3this.options.size){for(var g=0;gthis.sizeInfo.selectOffsetRight&&this.sizeInfo.selectOffsetRightthis.sizeInfo.menuInnerHeight&&(this.sizeInfo.hasScrollBar=!0,this.sizeInfo.totalMenuWidth=this.sizeInfo.menuWidth+this.sizeInfo.scrollBarWidth,this.$menu.css("min-width",this.sizeInfo.totalMenuWidth)),this.dropdown&&this.dropdown._popper&&this.dropdown._popper.update()},setSize:function(e){if(this.liHeight(e),this.options.header&&this.$menu.css("padding-top",0),!1!==this.options.size){var t=this,i=z(window);this.setMenuSize(),this.options.liveSearch&&this.$searchbox.off("input.setMenuSize propertychange.setMenuSize").on("input.setMenuSize propertychange.setMenuSize",function(){return t.setMenuSize()}),"auto"===this.options.size?i.off("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize").on("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize",function(){return t.setMenuSize()}):this.options.size&&"auto"!=this.options.size&&this.selectpicker.current.elements.length>this.options.size&&i.off("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize"),t.createView(!1,!0,e)}},setWidth:function(){var i=this;"auto"===this.options.width?requestAnimationFrame(function(){i.$menu.css("min-width","0"),i.$element.on("loaded"+U,function(){i.liHeight(),i.setMenuSize();var e=i.$newElement.clone().appendTo("body"),t=e.css("width","auto").children("button").outerWidth();e.remove(),i.sizeInfo.selectWidth=Math.max(i.sizeInfo.totalMenuWidth,t),i.$newElement.css("width",i.sizeInfo.selectWidth+"px")})}):"fit"===this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width","").addClass("fit-width")):this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width",this.options.width)):(this.$menu.css("min-width",""),this.$newElement.css("width","")),this.$newElement.hasClass("fit-width")&&"fit"!==this.options.width&&this.$newElement[0].classList.remove("fit-width")},selectPosition:function(){this.$bsContainer=z('
    ');var s,n,o,r=this,l=z(this.options.container),e=function(e){var t={},i=r.options.display||!!z.fn.dropdown.Constructor.Default&&z.fn.dropdown.Constructor.Default.display;r.$bsContainer.addClass(e.attr("class").replace(/form-control|fit-width/gi,"")).toggleClass(j.DROPUP,e.hasClass(j.DROPUP)),s=e.offset(),l.is("body")?n={top:0,left:0}:((n=l.offset()).top+=parseInt(l.css("borderTopWidth"))-l.scrollTop(),n.left+=parseInt(l.css("borderLeftWidth"))-l.scrollLeft()),o=e.hasClass(j.DROPUP)?0:e[0].offsetHeight,(M.major<4||"static"===i)&&(t.top=s.top-n.top+o,t.left=s.left-n.left),t.width=e[0].offsetWidth,r.$bsContainer.css(t)};this.$button.on("click.bs.dropdown.data-api",function(){r.isDisabled()||(e(r.$newElement),r.$bsContainer.appendTo(r.options.container).toggleClass(j.SHOW,!r.$button.hasClass(j.SHOW)).append(r.$menu))}),z(window).off("resize"+U+"."+this.selectId+" scroll"+U+"."+this.selectId).on("resize"+U+"."+this.selectId+" scroll"+U+"."+this.selectId,function(){r.$newElement.hasClass(j.SHOW)&&e(r.$newElement)}),this.$element.on("hide"+U,function(){r.$menu.data("height",r.$menu.height()),r.$bsContainer.detach()})},setOptionStatus:function(e){var t=this;if(t.noScroll=!1,t.selectpicker.view.visibleElements&&t.selectpicker.view.visibleElements.length)for(var i=0;i
    ');$[2]&&(y=y.replace("{var}",$[2][1"+y+"
    ")),d=!1,C.$element.trigger("maxReached"+U)),b&&I&&(E.append(z("
    "+S+"
    ")),d=!1,C.$element.trigger("maxReachedGrp"+U)),setTimeout(function(){C.setSelected(r,!1)},10),E.delay(750).fadeOut(300,function(){z(this).remove()})}}}else c.selected=!1,p.selected=!0,C.setSelected(r,!0);!C.multiple||C.multiple&&1===C.options.maxOptions?C.$button.trigger("focus"):C.options.liveSearch&&C.$searchbox.trigger("focus"),d&&(C.multiple||a!==s.selectedIndex)&&(T=[p.index,u.prop("selected"),l],C.$element.triggerNative("change"))}}),this.$menu.on("click","li."+j.DISABLED+" a, ."+j.POPOVERHEADER+", ."+j.POPOVERHEADER+" :not(.close)",function(e){e.currentTarget==this&&(e.preventDefault(),e.stopPropagation(),C.options.liveSearch&&!z(e.target).hasClass("close")?C.$searchbox.trigger("focus"):C.$button.trigger("focus"))}),this.$menuInner.on("click",".divider, .dropdown-header",function(e){e.preventDefault(),e.stopPropagation(),C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus")}),this.$menu.on("click","."+j.POPOVERHEADER+" .close",function(){C.$button.trigger("click")}),this.$searchbox.on("click",function(e){e.stopPropagation()}),this.$menu.on("click",".actions-btn",function(e){C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus"),e.preventDefault(),e.stopPropagation(),z(this).hasClass("bs-select-all")?C.selectAll():C.deselectAll()}),this.$element.on("change"+U,function(){C.render(),C.$element.trigger("changed"+U,T),T=null}).on("focus"+U,function(){C.options.mobile||C.$button.trigger("focus")})},liveSearchListener:function(){var u=this,f=document.createElement("li");this.$button.on("click.bs.dropdown.data-api",function(){u.$searchbox.val()&&u.$searchbox.val("")}),this.$searchbox.on("click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api",function(e){e.stopPropagation()}),this.$searchbox.on("input propertychange",function(){var e=u.$searchbox.val();if(u.selectpicker.search.elements=[],u.selectpicker.search.data=[],e){var t=[],i=e.toUpperCase(),s={},n=[],o=u._searchStyle(),r=u.options.liveSearchNormalize;r&&(i=w(i)),u._$lisSelected=u.$menuInner.find(".selected");for(var l=0;l=a.selectpicker.view.canHighlight.length&&(t=0),a.selectpicker.view.canHighlight[t+f]||(t=t+1+a.selectpicker.view.canHighlight.slice(t+f+1).indexOf(!0))),e.preventDefault();var m=f+t;e.which===B?0===f&&t===c.length-1?(a.$menuInner[0].scrollTop=a.$menuInner[0].scrollHeight,m=a.selectpicker.current.elements.length-1):d=(o=(n=a.selectpicker.current.data[m]).position-n.height)u+a.sizeInfo.menuInnerHeight),s=a.selectpicker.main.elements[v],a.activeIndex=b[x],a.focusItem(s),s&&s.firstChild.focus(),d&&(a.$menuInner[0].scrollTop=o),r.trigger("focus")}}i&&(e.which===D&&!a.selectpicker.keydown.keyHistory||e.which===N||e.which===H&&a.options.selectOnTab)&&(e.which!==D&&e.preventDefault(),a.options.liveSearch&&e.which===D||(a.$menuInner.find(".active a").trigger("click",!0),r.trigger("focus"),a.options.liveSearch||(e.preventDefault(),z(document).data("spaceSelect",!0))))}},mobile:function(){this.$element[0].classList.add("mobile-device")},refresh:function(){var e=z.extend({},this.options,this.$element.data());this.options=e,this.checkDisabled(),this.setStyle(),this.render(),this.createLi(),this.setWidth(),this.setSize(!0),this.$element.trigger("refreshed"+U)},hide:function(){this.$newElement.hide()},show:function(){this.$newElement.show()},remove:function(){this.$newElement.remove(),this.$element.remove()},destroy:function(){this.$newElement.before(this.$element).remove(),this.$bsContainer?this.$bsContainer.remove():this.$menu.remove(),this.$element.off(U).removeData("selectpicker").removeClass("bs-select-hidden selectpicker"),z(window).off(U+"."+this.selectId)}};var X=z.fn.selectpicker;z.fn.selectpicker=Q,z.fn.selectpicker.Constructor=J,z.fn.selectpicker.noConflict=function(){return z.fn.selectpicker=X,this},z(document).off("keydown.bs.dropdown.data-api").on("keydown"+U,'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',J.prototype.keydown).on("focusin.modal",'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',function(e){e.stopPropagation()}),z(window).on("load"+U+".data-api",function(){z(".selectpicker").each(function(){var e=z(this);Q.call(e,e.data())})})}(e)}); +/*! + * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select) + * + * Copyright 2012-2019 SnapAppointments, LLC + * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE) + */ + +!function(e,t){void 0===e&&void 0!==window&&(e=window),"function"==typeof define&&define.amd?define(["jquery"],function(e){return t(e)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(e.jQuery)}(this,function(e){!function(z){"use strict";var d=["sanitize","whiteList","sanitizeFn"],r=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],e={"*":["class","dir","id","lang","role","tabindex","style",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},l=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,a=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;function v(e,t){var i=e.nodeName.toLowerCase();if(-1!==z.inArray(i,t))return-1===z.inArray(i,r)||Boolean(e.nodeValue.match(l)||e.nodeValue.match(a));for(var s=z(t).filter(function(e,t){return t instanceof RegExp}),n=0,o=s.length;n]+>/g,"")),s&&(a=w(a)),a=a.toUpperCase(),o="contains"===i?0<=a.indexOf(t):a.startsWith(t)))break}return o}function A(e){return parseInt(e,10)||0}z.fn.triggerNative=function(e){var t,i=this[0];i.dispatchEvent?(u?t=new Event(e,{bubbles:!0}):(t=document.createEvent("Event")).initEvent(e,!0,!1),i.dispatchEvent(t)):i.fireEvent?((t=document.createEventObject()).eventType=e,i.fireEvent("on"+e,t)):this.trigger(e)};var f={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"},m=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,g=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]","g");function b(e){return f[e]}function w(e){return(e=e.toString())&&e.replace(m,b).replace(g,"")}var I,x,$,y,S,E=(I={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},x=function(e){return I[e]},$="(?:"+Object.keys(I).join("|")+")",y=RegExp($),S=RegExp($,"g"),function(e){return e=null==e?"":""+e,y.test(e)?e.replace(S,x):e}),C={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},L=27,N=13,D=32,H=9,B=38,W=40,M={success:!1,major:"3"};try{M.full=(z.fn.dropdown.Constructor.VERSION||"").split(" ")[0].split("."),M.major=M.full[0],M.success=!0}catch(e){}var R=0,U=".bs.select",j={DISABLED:"disabled",DIVIDER:"divider",SHOW:"open",DROPUP:"dropup",MENU:"dropdown-menu",MENURIGHT:"dropdown-menu-right",MENULEFT:"dropdown-menu-left",BUTTONCLASS:"btn-default",POPOVERHEADER:"popover-title",ICONBASE:"glyphicon",TICKICON:"glyphicon-ok"},V={MENU:"."+j.MENU},F={span:document.createElement("span"),i:document.createElement("i"),subtext:document.createElement("small"),a:document.createElement("a"),li:document.createElement("li"),whitespace:document.createTextNode("\xa0"),fragment:document.createDocumentFragment()};F.a.setAttribute("role","option"),F.subtext.className="text-muted",F.text=F.span.cloneNode(!1),F.text.className="text",F.checkMark=F.span.cloneNode(!1);var _=new RegExp(B+"|"+W),G=new RegExp("^"+H+"$|"+L),q=function(e,t,i){var s=F.li.cloneNode(!1);return e&&(1===e.nodeType||11===e.nodeType?s.appendChild(e):s.innerHTML=e),void 0!==t&&""!==t&&(s.className=t),null!=i&&s.classList.add("optgroup-"+i),s},K=function(e,t,i){var s=F.a.cloneNode(!0);return e&&(11===e.nodeType?s.appendChild(e):s.insertAdjacentHTML("beforeend",e)),void 0!==t&&""!==t&&(s.className=t),"4"===M.major&&s.classList.add("dropdown-item"),i&&s.setAttribute("style",i),s},Y=function(e,t){var i,s,n=F.text.cloneNode(!1);if(e.content)n.innerHTML=e.content;else{if(n.textContent=e.text,e.icon){var o=F.whitespace.cloneNode(!1);(s=(!0===t?F.i:F.span).cloneNode(!1)).className=e.iconBase+" "+e.icon,F.fragment.appendChild(s),F.fragment.appendChild(o)}e.subtext&&((i=F.subtext.cloneNode(!1)).textContent=e.subtext,n.appendChild(i))}if(!0===t)for(;0'},maxOptions:!1,mobile:!1,selectOnTab:!1,dropdownAlignRight:!1,windowPadding:0,virtualScroll:600,display:!1,sanitize:!0,sanitizeFn:null,whiteList:e},J.prototype={constructor:J,init:function(){var i=this,e=this.$element.attr("id");R++,this.selectId="bs-select-"+R,this.$element[0].classList.add("bs-select-hidden"),this.multiple=this.$element.prop("multiple"),this.autofocus=this.$element.prop("autofocus"),this.$element[0].classList.contains("show-tick")&&(this.options.showTick=!0),this.$newElement=this.createDropdown(),this.$element.after(this.$newElement).prependTo(this.$newElement),this.$button=this.$newElement.children("button"),this.$menu=this.$newElement.children(V.MENU),this.$menuInner=this.$menu.children(".inner"),this.$searchbox=this.$menu.find("input"),this.$element[0].classList.remove("bs-select-hidden"),!0===this.options.dropdownAlignRight&&this.$menu[0].classList.add(j.MENURIGHT),void 0!==e&&this.$button.attr("data-id",e),this.checkDisabled(),this.clickListener(),this.options.liveSearch?(this.liveSearchListener(),this.focusedParent=this.$searchbox[0]):this.focusedParent=this.$menuInner[0],this.setStyle(),this.render(),this.setWidth(),this.options.container?this.selectPosition():this.$element.on("hide"+U,function(){if(i.isVirtual()){var e=i.$menuInner[0],t=e.firstChild.cloneNode(!1);e.replaceChild(t,e.firstChild),e.scrollTop=0}}),this.$menu.data("this",this),this.$newElement.data("this",this),this.options.mobile&&this.mobile(),this.$newElement.on({"hide.bs.dropdown":function(e){i.$element.trigger("hide"+U,e)},"hidden.bs.dropdown":function(e){i.$element.trigger("hidden"+U,e)},"show.bs.dropdown":function(e){i.$element.trigger("show"+U,e)},"shown.bs.dropdown":function(e){i.$element.trigger("shown"+U,e)}}),i.$element[0].hasAttribute("required")&&this.$element.on("invalid"+U,function(){i.$button[0].classList.add("bs-invalid"),i.$element.on("shown"+U+".invalid",function(){i.$element.val(i.$element.val()).off("shown"+U+".invalid")}).on("rendered"+U,function(){this.validity.valid&&i.$button[0].classList.remove("bs-invalid"),i.$element.off("rendered"+U)}),i.$button.on("blur"+U,function(){i.$element.trigger("focus").trigger("blur"),i.$button.off("blur"+U)})}),setTimeout(function(){i.createLi(),i.$element.trigger("loaded"+U)})},createDropdown:function(){var e=this.multiple||this.options.showTick?" show-tick":"",t=this.multiple?' aria-multiselectable="true"':"",i="",s=this.autofocus?" autofocus":"";M.major<4&&this.$element.parent().hasClass("input-group")&&(i=" input-group-btn");var n,o="",r="",l="",a="";return this.options.header&&(o='
    '+this.options.header+"
    "),this.options.liveSearch&&(r=''),this.multiple&&this.options.actionsBox&&(l='
    "),this.multiple&&this.options.doneButton&&(a='
    "),n='",z(n)},setPositionData:function(){this.selectpicker.view.canHighlight=[];for(var e=this.selectpicker.view.size=0;e=this.options.virtualScroll||!0===this.options.virtualScroll},createView:function(A,e,t){var L,N,D=this,i=0,H=[];if(this.selectpicker.current=A?this.selectpicker.search:this.selectpicker.main,this.setPositionData(),e)if(t)i=this.$menuInner[0].scrollTop;else if(!D.multiple){var s=D.$element[0],n=(s.options[s.selectedIndex]||{}).liIndex;if("number"==typeof n&&!1!==D.options.size){var o=D.selectpicker.main.data[n],r=o&&o.position;r&&(i=r-(D.sizeInfo.menuInnerHeight+D.sizeInfo.liHeight)/2)}}function l(e,t){var i,s,n,o,r,l,a,c,d,h,p=D.selectpicker.current.elements.length,u=[],f=!0,m=D.isVirtual();D.selectpicker.view.scrollTop=e,!0===m&&D.sizeInfo.hasScrollBar&&D.$menu[0].offsetWidth>D.sizeInfo.totalMenuWidth&&(D.sizeInfo.menuWidth=D.$menu[0].offsetWidth,D.sizeInfo.totalMenuWidth=D.sizeInfo.menuWidth+D.sizeInfo.scrollBarWidth,D.$menu.css("min-width",D.sizeInfo.menuWidth)),i=Math.ceil(D.sizeInfo.menuInnerHeight/D.sizeInfo.liHeight*1.5),s=Math.round(p/i)||1;for(var v=0;vp-1?0:D.selectpicker.current.data[p-1].position-D.selectpicker.current.data[D.selectpicker.view.position1-1].position,I.firstChild.style.marginTop=b+"px",w+"px"):I.firstChild.style.marginTop=0,I.firstChild.appendChild(x)}if(D.prevActiveIndex=D.activeIndex,D.options.liveSearch){if(A&&t){var z,T=0;D.selectpicker.view.canHighlight[T]||(T=1+D.selectpicker.view.canHighlight.slice(1).indexOf(!0)),z=D.selectpicker.view.visibleElements[T],D.defocusItem(D.selectpicker.view.currentActive),D.activeIndex=(D.selectpicker.current.data[T]||{}).index,D.focusItem(z)}}else D.$menuInner.trigger("focus")}l(i,!0),this.$menuInner.off("scroll.createView").on("scroll.createView",function(e,t){D.noScroll||l(this.scrollTop,t),D.noScroll=!1}),z(window).off("resize"+U+"."+this.selectId+".createView").on("resize"+U+"."+this.selectId+".createView",function(){D.$newElement.hasClass(j.SHOW)&&l(D.$menuInner[0].scrollTop)})},focusItem:function(e,t,i){if(e){t=t||this.selectpicker.main.data[this.activeIndex];var s=e.firstChild;s&&(s.setAttribute("aria-setsize",this.selectpicker.view.size),s.setAttribute("aria-posinset",t.posinset),!0!==i&&(this.focusedParent.setAttribute("aria-activedescendant",s.id),e.classList.add("active"),s.classList.add("active")))}},defocusItem:function(e){e&&(e.classList.remove("active"),e.firstChild&&e.firstChild.classList.remove("active"))},setPlaceholder:function(){var e=!1;if(this.options.title&&!this.multiple){this.selectpicker.view.titleOption||(this.selectpicker.view.titleOption=document.createElement("option")),e=!0;var t=this.$element[0],i=!1,s=!this.selectpicker.view.titleOption.parentNode;if(s)this.selectpicker.view.titleOption.className="bs-title-option",this.selectpicker.view.titleOption.value="",i=void 0===z(t.options[t.selectedIndex]).attr("selected")&&void 0===this.$element.data("selected");(s||0!==this.selectpicker.view.titleOption.index)&&t.insertBefore(this.selectpicker.view.titleOption,t.firstChild),i&&(t.selectedIndex=0)}return e},createLi:function(){var c=this,f=this.options.iconBase,m=':not([hidden]):not([data-hidden="true"])',v=[],g=[],d=0,b=0,e=this.setPlaceholder()?1:0;this.options.hideDisabled&&(m+=":not(:disabled)"),!c.options.showTick&&!c.multiple||F.checkMark.parentNode||(F.checkMark.className=f+" "+c.options.tickIcon+" check-mark",F.a.appendChild(F.checkMark));var t=this.$element[0].querySelectorAll("select > *"+m);function w(e){var t=g[g.length-1];t&&"divider"===t.type&&(t.optID||e.optID)||((e=e||{}).type="divider",v.push(q(!1,j.DIVIDER,e.optID?e.optID+"div":void 0)),g.push(e))}function I(e,t){if((t=t||{}).divider="true"===e.getAttribute("data-divider"),t.divider)w({optID:t.optID});else{var i=g.length,s=e.style.cssText,n=s?E(s):"",o=(e.className||"")+(t.optgroupClass||"");t.optID&&(o="opt "+o),t.text=e.textContent,t.content=e.getAttribute("data-content"),t.tokens=e.getAttribute("data-tokens"),t.subtext=e.getAttribute("data-subtext"),t.icon=e.getAttribute("data-icon"),t.iconBase=f;var r=Y(t),l=q(K(r,o,n),"",t.optID);l.firstChild&&(l.firstChild.id=c.selectId+"-"+i),v.push(l),e.liIndex=i,t.display=t.content||t.text,t.type="option",t.index=i,t.option=e,t.disabled=t.disabled||e.disabled,g.push(t);var a=0;t.display&&(a+=t.display.length),t.subtext&&(a+=t.subtext.length),t.icon&&(a+=1),d li")},render:function(){this.setPlaceholder();var e,t,i=this,s=this.$element[0],n=function(e,t){var i,s=e.selectedOptions,n=[];if(t){for(var o=0,r=s.length;o")).length&&o>t[1]||1===t.length&&2<=o),!1===e){for(var h=0;h option"+m+", optgroup"+m+" option"+m).length,g="function"==typeof this.options.countSelectedText?this.options.countSelectedText(o,v):this.options.countSelectedText;c=Y({text:g.replace("{0}",o.toString()).replace("{1}",v.toString())},!0)}if(null==this.options.title&&(this.options.title=this.$element.attr("title")),c.childNodes.length||(c=Y({text:void 0!==this.options.title?this.options.title:this.options.noneSelectedText},!0)),r.title=c.textContent.replace(/<[^>]*>?/g,"").trim(),this.options.sanitize&&d&&P([c],i.options.whiteList,i.options.sanitizeFn),l.innerHTML="",l.appendChild(c),M.major<4&&this.$newElement[0].classList.contains("bs3-has-addon")){var b=r.querySelector(".filter-expand"),w=l.cloneNode(!0);w.className="filter-expand",b?r.replaceChild(w,b):r.appendChild(w)}this.$element.trigger("rendered"+U)},setStyle:function(e,t){var i,s=this.$button[0],n=this.$newElement[0],o=this.options.style.trim();this.$element.attr("class")&&this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi,"")),M.major<4&&(n.classList.add("bs3"),n.parentNode.classList.contains("input-group")&&(n.previousElementSibling||n.nextElementSibling)&&(n.previousElementSibling||n.nextElementSibling).classList.contains("input-group-addon")&&n.classList.add("bs3-has-addon")),i=e?e.trim():o,"add"==t?i&&s.classList.add.apply(s.classList,i.split(" ")):"remove"==t?i&&s.classList.remove.apply(s.classList,i.split(" ")):(o&&s.classList.remove.apply(s.classList,o.split(" ")),i&&s.classList.add.apply(s.classList,i.split(" ")))},liHeight:function(e){if(e||!1!==this.options.size&&!this.sizeInfo){this.sizeInfo||(this.sizeInfo={});var t=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("ul"),o=document.createElement("li"),r=document.createElement("li"),l=document.createElement("li"),a=document.createElement("a"),c=document.createElement("span"),d=this.options.header&&0this.sizeInfo.menuExtras.vert&&l+this.sizeInfo.menuExtras.vert+50>this.sizeInfo.selectOffsetBot)),"auto"===this.options.size)n=3this.options.size){for(var g=0;gthis.sizeInfo.selectOffsetRight&&this.sizeInfo.selectOffsetRightthis.sizeInfo.menuInnerHeight&&(this.sizeInfo.hasScrollBar=!0,this.sizeInfo.totalMenuWidth=this.sizeInfo.menuWidth+this.sizeInfo.scrollBarWidth,this.$menu.css("min-width",this.sizeInfo.totalMenuWidth)),this.dropdown&&this.dropdown._popper&&this.dropdown._popper.update()},setSize:function(e){if(this.liHeight(e),this.options.header&&this.$menu.css("padding-top",0),!1!==this.options.size){var t=this,i=z(window);this.setMenuSize(),this.options.liveSearch&&this.$searchbox.off("input.setMenuSize propertychange.setMenuSize").on("input.setMenuSize propertychange.setMenuSize",function(){return t.setMenuSize()}),"auto"===this.options.size?i.off("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize").on("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize",function(){return t.setMenuSize()}):this.options.size&&"auto"!=this.options.size&&this.selectpicker.current.elements.length>this.options.size&&i.off("resize"+U+"."+this.selectId+".setMenuSize scroll"+U+"."+this.selectId+".setMenuSize"),t.createView(!1,!0,e)}},setWidth:function(){var i=this;"auto"===this.options.width?requestAnimationFrame(function(){i.$menu.css("min-width","0"),i.$element.on("loaded"+U,function(){i.liHeight(),i.setMenuSize();var e=i.$newElement.clone().appendTo("body"),t=e.css("width","auto").children("button").outerWidth();e.remove(),i.sizeInfo.selectWidth=Math.max(i.sizeInfo.totalMenuWidth,t),i.$newElement.css("width",i.sizeInfo.selectWidth+"px")})}):"fit"===this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width","").addClass("fit-width")):this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width",this.options.width)):(this.$menu.css("min-width",""),this.$newElement.css("width","")),this.$newElement.hasClass("fit-width")&&"fit"!==this.options.width&&this.$newElement[0].classList.remove("fit-width")},selectPosition:function(){this.$bsContainer=z('
    ');var s,n,o,r=this,l=z(this.options.container),e=function(e){var t={},i=r.options.display||!!z.fn.dropdown.Constructor.Default&&z.fn.dropdown.Constructor.Default.display;r.$bsContainer.addClass(e.attr("class").replace(/form-control|fit-width/gi,"")).toggleClass(j.DROPUP,e.hasClass(j.DROPUP)),s=e.offset(),l.is("body")?n={top:0,left:0}:((n=l.offset()).top+=parseInt(l.css("borderTopWidth"))-l.scrollTop(),n.left+=parseInt(l.css("borderLeftWidth"))-l.scrollLeft()),o=e.hasClass(j.DROPUP)?0:e[0].offsetHeight,(M.major<4||"static"===i)&&(t.top=s.top-n.top+o,t.left=s.left-n.left),t.width=e[0].offsetWidth,r.$bsContainer.css(t)};this.$button.on("click.bs.dropdown.data-api",function(){r.isDisabled()||(e(r.$newElement),r.$bsContainer.appendTo(r.options.container).toggleClass(j.SHOW,!r.$button.hasClass(j.SHOW)).append(r.$menu))}),z(window).off("resize"+U+"."+this.selectId+" scroll"+U+"."+this.selectId).on("resize"+U+"."+this.selectId+" scroll"+U+"."+this.selectId,function(){r.$newElement.hasClass(j.SHOW)&&e(r.$newElement)}),this.$element.on("hide"+U,function(){r.$menu.data("height",r.$menu.height()),r.$bsContainer.detach()})},setOptionStatus:function(e){var t=this;if(t.noScroll=!1,t.selectpicker.view.visibleElements&&t.selectpicker.view.visibleElements.length)for(var i=0;i
    ');$[2]&&(y=y.replace("{var}",$[2][1"+y+"
  • ")),d=!1,C.$element.trigger("maxReached"+U)),b&&I&&(E.append(z("
    "+S+"
    ")),d=!1,C.$element.trigger("maxReachedGrp"+U)),setTimeout(function(){C.setSelected(r,!1)},10),E.delay(750).fadeOut(300,function(){z(this).remove()})}}}else c.selected=!1,p.selected=!0,C.setSelected(r,!0);!C.multiple||C.multiple&&1===C.options.maxOptions?C.$button.trigger("focus"):C.options.liveSearch&&C.$searchbox.trigger("focus"),d&&(C.multiple||a!==s.selectedIndex)&&(T=[p.index,u.prop("selected"),l],C.$element.triggerNative("change"))}}),this.$menu.on("click","li."+j.DISABLED+" a, ."+j.POPOVERHEADER+", ."+j.POPOVERHEADER+" :not(.close)",function(e){e.currentTarget==this&&(e.preventDefault(),e.stopPropagation(),C.options.liveSearch&&!z(e.target).hasClass("close")?C.$searchbox.trigger("focus"):C.$button.trigger("focus"))}),this.$menuInner.on("click",".divider, .dropdown-header",function(e){e.preventDefault(),e.stopPropagation(),C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus")}),this.$menu.on("click","."+j.POPOVERHEADER+" .close",function(){C.$button.trigger("click")}),this.$searchbox.on("click",function(e){e.stopPropagation()}),this.$menu.on("click",".actions-btn",function(e){C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus"),e.preventDefault(),e.stopPropagation(),z(this).hasClass("bs-select-all")?C.selectAll():C.deselectAll()}),this.$element.on("change"+U,function(){C.render(),C.$element.trigger("changed"+U,T),T=null}).on("focus"+U,function(){C.options.mobile||C.$button.trigger("focus")})},liveSearchListener:function(){var u=this,f=document.createElement("li");this.$button.on("click.bs.dropdown.data-api",function(){u.$searchbox.val()&&u.$searchbox.val("")}),this.$searchbox.on("click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api",function(e){e.stopPropagation()}),this.$searchbox.on("input propertychange",function(){var e=u.$searchbox.val();if(u.selectpicker.search.elements=[],u.selectpicker.search.data=[],e){var t=[],i=e.toUpperCase(),s={},n=[],o=u._searchStyle(),r=u.options.liveSearchNormalize;r&&(i=w(i)),u._$lisSelected=u.$menuInner.find(".selected");for(var l=0;l=a.selectpicker.view.canHighlight.length&&(t=0),a.selectpicker.view.canHighlight[t+f]||(t=t+1+a.selectpicker.view.canHighlight.slice(t+f+1).indexOf(!0))),e.preventDefault();var m=f+t;e.which===B?0===f&&t===c.length-1?(a.$menuInner[0].scrollTop=a.$menuInner[0].scrollHeight,m=a.selectpicker.current.elements.length-1):d=(o=(n=a.selectpicker.current.data[m]).position-n.height)u+a.sizeInfo.menuInnerHeight),s=a.selectpicker.main.elements[v],a.activeIndex=b[x],a.focusItem(s),s&&s.firstChild.focus(),d&&(a.$menuInner[0].scrollTop=o),r.trigger("focus")}}i&&(e.which===D&&!a.selectpicker.keydown.keyHistory||e.which===N||e.which===H&&a.options.selectOnTab)&&(e.which!==D&&e.preventDefault(),a.options.liveSearch&&e.which===D||(a.$menuInner.find(".active a").trigger("click",!0),r.trigger("focus"),a.options.liveSearch||(e.preventDefault(),z(document).data("spaceSelect",!0))))}},mobile:function(){this.$element[0].classList.add("mobile-device")},refresh:function(){var e=z.extend({},this.options,this.$element.data());this.options=e,this.checkDisabled(),this.setStyle(),this.render(),this.createLi(),this.setWidth(),this.setSize(!0),this.$element.trigger("refreshed"+U)},hide:function(){this.$newElement.hide()},show:function(){this.$newElement.show()},remove:function(){this.$newElement.remove(),this.$element.remove()},destroy:function(){this.$newElement.before(this.$element).remove(),this.$bsContainer?this.$bsContainer.remove():this.$menu.remove(),this.$element.off(U).removeData("selectpicker").removeClass("bs-select-hidden selectpicker"),z(window).off(U+"."+this.selectId)}};var X=z.fn.selectpicker;z.fn.selectpicker=Q,z.fn.selectpicker.Constructor=J,z.fn.selectpicker.noConflict=function(){return z.fn.selectpicker=X,this},z(document).off("keydown.bs.dropdown.data-api").on("keydown"+U,'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',J.prototype.keydown).on("focusin.modal",'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',function(e){e.stopPropagation()}),z(window).on("load"+U+".data-api",function(){z(".selectpicker").each(function(){var e=z(this);Q.call(e,e.data())})})}(e)}); //# sourceMappingURL=bootstrap-select.min.js.map \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.css b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.css rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js index 866a86189..f31dd538c 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js @@ -1,7 +1,7 @@ -/** - * @author zhixin wen - * version: 1.11.0 - * https://github.com/wenzhixin/bootstrap-table/ - */ -(function(j){var k=null;var m=function(u){var s=arguments,r=true,t=1;u=u.replace(/%s/g,function(){var v=s[t++];if(typeof v==="undefined"){r=false;return""}return v});return r?u:""};var c=function(t,v,u,s){var r="";j.each(t,function(w,x){if(x[v]===s){r=x[u];return false}return true});return r};var i=function(s,t){var r=-1;j.each(s,function(u,v){if(v.field===t){r=u;return false}return true});return r};var l=function(u){var y,x,w,A=0,B=[];for(y=0;y").addClass("fixed-table-scroll-inner"),u=j("
    ").addClass("fixed-table-scroll-outer"),s,r;u.append(t);j("body").append(u);s=t[0].offsetWidth;u.css("overflow","scroll");r=t[0].offsetWidth;if(s===r){r=u[0].clientWidth}u.remove();k=s-r}return k};var q=function(s,u,t,r){var v=u;if(typeof u==="string"){var w=u.split(".");if(w.length>1){v=window;j.each(w,function(x,y){v=v[y]})}else{v=window[u]}}if(typeof v==="object"){return v}if(typeof v==="function"){return v.apply(s,t)}if(!v&&typeof u==="string"&&m.apply(this,[u].concat(t))){return m.apply(this,[u].concat(t))}return r};var f=function(s,r,w){var x=Object.getOwnPropertyNames(s),u=Object.getOwnPropertyNames(r),v="";if(w){if(x.length!==u.length){return false}}for(var t=0;t-1){if(s[v]!==r[v]){return false}}}return true};var p=function(r){if(typeof r==="string"){return r.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`")}return r};var d=function(s){var r=0;s.children().each(function(){if(r0||!!navigator.userAgent.match(/Trident.*rv\:11\./))};var h=function(){if(!Object.keys){Object.keys=(function(){var t=Object.prototype.hasOwnProperty,u=!({toString:null}).propertyIsEnumerable("toString"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],r=s.length;return function(x){if(typeof x!=="object"&&(typeof x!=="function"||x===null)){throw new TypeError("Object.keys called on non-object")}var v=[],y,w;for(y in x){if(t.call(x,y)){v.push(y)}}if(u){for(w=0;w','
    ',this.options.paginationVAlign==="top"||this.options.paginationVAlign==="both"?'
    ':"",'
    ','
    ','
    ','
    ',this.options.formatLoadingMessage(),"
    ","
    ",'',this.options.paginationVAlign==="bottom"||this.options.paginationVAlign==="both"?'
    ':"","
    ","
    "].join(""));this.$container.insertAfter(this.$el);this.$tableContainer=this.$container.find(".fixed-table-container");this.$tableHeader=this.$container.find(".fixed-table-header");this.$tableBody=this.$container.find(".fixed-table-body");this.$tableLoading=this.$container.find(".fixed-table-loading");this.$tableFooter=this.$container.find(".fixed-table-footer");this.$toolbar=this.$container.find(".fixed-table-toolbar");this.$pagination=this.$container.find(".fixed-table-pagination");this.$tableBody.append(this.$el);this.$container.after('
    ');this.$el.addClass(this.options.classes);if(this.options.striped){this.$el.addClass("table-striped")}if(j.inArray("table-no-bordered",this.options.classes.split(" "))!==-1){this.$tableContainer.addClass("table-no-bordered")}};e.prototype.initTable=function(){var t=this,s=[],u=[];this.$header=this.$el.find(">thead");if(!this.$header.length){this.$header=j("").appendTo(this.$el)}this.$header.find("tr").each(function(){var v=[];j(this).find("th").each(function(){if(typeof j(this).data("field")!=="undefined"){j(this).data("field",j(this).data("field")+"")}v.push(j.extend({},{title:j(this).html(),"class":j(this).attr("class"),titleTooltip:j(this).attr("title"),rowspan:j(this).attr("rowspan")?+j(this).attr("rowspan"):undefined,colspan:j(this).attr("colspan")?+j(this).attr("colspan"):undefined},j(this).data()))});s.push(v)});if(!j.isArray(this.options.columns[0])){this.options.columns=[this.options.columns]}this.options.columns=j.extend(true,[],s,this.options.columns);this.columns=[];l(this.options.columns);j.each(this.options.columns,function(w,v){j.each(v,function(x,y){y=j.extend({},e.COLUMN_DEFAULTS,y);if(typeof y.fieldIndex!=="undefined"){t.columns[y.fieldIndex]=y}t.options.columns[w][x]=y})});if(this.options.data.length){return}var r=[];this.$el.find(">tbody>tr").each(function(w){var v={};v._id=j(this).attr("id");v._class=j(this).attr("class");v._data=g(j(this).data());j(this).find(">td").each(function(z){var E=j(this),B=+E.attr("colspan")||1,C=+E.attr("rowspan")||1,A,y;for(;r[w]&&r[w][z];z++){}for(A=z;A");if(v===0&&!t.options.cardView&&t.options.detailView){s.push(m('
    ',t.options.columns.length))}j.each(u,function(B,A){var F="",C="",E="",w="",D=m(' class="%s"',A["class"]),z=t.options.sortOrder||A.order,y="px",x=A.width;if(A.width!==undefined&&(!t.options.cardView)){if(typeof A.width==="string"){if(A.width.indexOf("%")!==-1){y="%"}}}if(A.width&&typeof A.width==="string"){x=A.width.replace("%","").replace("px","")}C=m("text-align: %s; ",A.halign?A.halign:A.align);E=m("text-align: %s; ",A.align);w=m("vertical-align: %s; ",A.valign);w+=m("width: %s; ",(A.checkbox||A.radio)&&!x?"36px":(x?x+y:undefined));if(typeof A.fieldIndex!=="undefined"){t.header.fields[A.fieldIndex]=A.field;t.header.styles[A.fieldIndex]=E+w;t.header.classes[A.fieldIndex]=D;t.header.formatters[A.fieldIndex]=A.formatter;t.header.events[A.fieldIndex]=A.events;t.header.sorters[A.fieldIndex]=A.sorter;t.header.sortNames[A.fieldIndex]=A.sortName;t.header.cellStyles[A.fieldIndex]=A.cellStyle;t.header.searchables[A.fieldIndex]=A.searchable;if(!A.visible){return}if(t.options.cardView&&(!A.cardVisible)){return}r[A.field]=A}s.push("");s.push(m('
    ',t.options.sortable&&A.sortable?"sortable both":""));F=A.title;if(A.checkbox){if(!t.options.singleSelect&&t.options.checkboxHeader){F=''}t.header.stateField=A.field}if(A.radio){F="";t.header.stateField=A.field;t.options.singleSelect=true}s.push(F);s.push("
    ");s.push('
    ');s.push("
    ");s.push("")});s.push("")});this.$header.html(s.join(""));this.$header.find("th[data-field]").each(function(u){j(this).data(r[j(this).data("field")])});this.$container.off("click",".th-inner").on("click",".th-inner",function(u){var v=j(this);if(t.options.detailView){if(v.closest(".bootstrap-table")[0]!==t.$container[0]){return false}}if(t.options.sortable&&v.parent().data().sortable){t.onSort(u)}});this.$header.children().children().off("keypress").on("keypress",function(v){if(t.options.sortable&&j(this).data().sortable){var u=v.keyCode||v.which;if(u==13){t.onSort(v)}}});j(window).off("resize.bootstrap-table");if(!this.options.showHeader||this.options.cardView){this.$header.hide();this.$tableHeader.hide();this.$tableLoading.css("top",0)}else{this.$header.show();this.$tableHeader.show();this.$tableLoading.css("top",this.$header.outerHeight()+1);this.getCaret();j(window).on("resize.bootstrap-table",j.proxy(this.resetWidth,this))}this.$selectAll=this.$header.find('[name="btSelectAll"]');this.$selectAll.off("click").on("click",function(){var u=j(this).prop("checked");t[u?"checkAll":"uncheckAll"]();t.updateSelected()})};e.prototype.initFooter=function(){if(!this.options.showFooter||this.options.cardView){this.$tableFooter.hide()}else{this.$tableFooter.show()}};e.prototype.initData=function(s,r){if(r==="append"){this.data=this.data.concat(s)}else{if(r==="prepend"){this.data=[].concat(s).concat(this.data)}else{this.data=s||this.options.data}}if(r==="append"){this.options.data=this.options.data.concat(s)}else{if(r==="prepend"){this.options.data=[].concat(s).concat(this.options.data)}else{this.options.data=this.data}}if(this.options.sidePagination==="server"){return}this.initSort()};e.prototype.initSort=function(){var u=this,t=this.options.sortName,r=this.options.sortOrder==="desc"?-1:1,s=j.inArray(this.options.sortName,this.header.fields);if(this.options.customSort!==j.noop){this.options.customSort.apply(this,[this.options.sortName,this.options.sortOrder]);return}if(s!==-1){if(this.options.sortStable){j.each(this.data,function(v,w){if(!w.hasOwnProperty("_position")){w._position=v}})}this.data.sort(function(w,v){if(u.header.sortNames[s]){t=u.header.sortNames[s]}var y=o(w,t,u.options.escape),z=o(v,t,u.options.escape),x=q(u.header,u.header.sorters[s],[y,z]);if(x!==undefined){return r*x}if(y===undefined||y===null){y=""}if(z===undefined||z===null){z=""}if(u.options.sortStable&&y===z){y=w._position;z=v._position}if(j.isNumeric(y)&&j.isNumeric(z)){y=parseFloat(y);z=parseFloat(z);if(y
    ',this.options.toolbarAlign)).appendTo(this.$toolbar).append(j(this.options.toolbar))}t=[m('
    ',this.options.buttonsAlign,this.options.buttonsAlign)];if(typeof this.options.icons==="string"){this.options.icons=q(null,this.options.icons)}if(this.options.showSearch){t.push(m('")}if(this.options.showPaginationSwitch){t.push(m('")}if(this.options.showRefresh){t.push(m('")}if(this.options.showToggle){t.push(m('")}if(this.options.showColumns){t.push(m('
    ',this.options.formatColumns()),'",'","
    ")}t.push("
    ");if(this.showToolbar||t.length>2){this.$toolbar.append(t.join(""))}if(this.options.showPaginationSwitch){this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",j.proxy(this.togglePagination,this))}if(this.options.showRefresh){this.$toolbar.find('button[name="refresh"]').off("click").on("click",j.proxy(this.refresh,this))}if(this.options.showToggle){this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){u.toggleView()})}if(this.options.showSearch){this.$toolbar.find('button[name="showSearch"]').off("click").on("click",function(){j(".search-collapse").slideToggle()})}if(this.options.showColumns){s=this.$toolbar.find(".keep-open");if(r<=this.options.minimumCountColumns){s.find("input").prop("disabled",true)}s.find("li").off("click").on("click",function(x){x.stopImmediatePropagation()});s.find("input").off("click").on("click",function(){var x=j(this);u.toggleColumn(j(this).val(),x.prop("checked"),false);u.trigger("column-switch",j(this).data("field"),x.prop("checked"))})}if(this.options.search){t=[];t.push('");this.$toolbar.append(t.join(""));v=this.$toolbar.find(".search input");v.off("keyup drop").on("keyup drop",function(x){if(u.options.searchOnEnterKey&&x.keyCode!==13){return}if(j.inArray(x.keyCode,[37,38,39,40])>-1){return}clearTimeout(w);w=setTimeout(function(){u.onSearch(x)},u.options.searchTimeOut)});if(b()){v.off("mouseup").on("mouseup",function(x){clearTimeout(w);w=setTimeout(function(){u.onSearch(x)},u.options.searchTimeOut)})}}};e.prototype.onSearch=function(r){var s=j.trim(j(r.currentTarget).val());if(this.options.trimOnSearch&&j(r.currentTarget).val()!==s){j(r.currentTarget).val(s)}if(s===this.searchText){return}this.searchText=s;this.options.searchText=s;this.options.pageNumber=1;this.initSearch();this.updatePagination();this.trigger("search",s)};e.prototype.initSearch=function(){var t=this;if(this.options.sidePagination!=="server"){if(this.options.customSearch!==j.noop){this.options.customSearch.apply(this,[this.searchText]);return}var r=this.searchText&&(this.options.escape?p(this.searchText):this.searchText).toLowerCase();var u=j.isEmptyObject(this.filterColumns)?null:this.filterColumns;this.data=u?j.grep(this.options.data,function(w,v){for(var s in u){if(j.isArray(u[s])&&j.inArray(w[s],u[s])===-1||w[s]!==u[s]){return false}}return true}):this.options.data;this.data=r?j.grep(this.data,function(A,x){for(var v=0;v-1){r=true}}}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1;this.options.totalPages=this.totalPages}if(this.totalPages>0&&this.options.pageNumber>this.totalPages){this.options.pageNumber=this.totalPages}this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1;this.pageTo=this.options.pageNumber*this.options.pageSize;if(this.pageTo>this.options.totalRows){this.pageTo=this.options.totalRows}x.push('
    ','',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),"");if(!this.options.onlyInfoPagination){x.push('');var F=[m('',this.options.paginationVAlign==="top"||this.options.paginationVAlign==="both"?"dropdown":"dropup"),'",'");x.push(this.options.formatRecordsPerPage(F.join("")));x.push("");x.push("
    ",'")}this.$pagination.html(x.join(""));if(!this.options.onlyInfoPagination){w=this.$pagination.find(".page-list a");G=this.$pagination.find(".page-first");I=this.$pagination.find(".page-pre");E=this.$pagination.find(".page-next");y=this.$pagination.find(".page-last");u=this.$pagination.find(".page-number");if(this.options.smartDisplay){if(this.totalPages<=1){this.$pagination.find("div.pagination").hide()}if(t.length<2||this.options.totalRows<=t[0]){this.$pagination.find("span.page-list").hide()}this.$pagination[this.getData().length?"show":"hide"]()}if(r){this.options.pageSize=this.options.formatAllRows()}w.off("click").on("click",j.proxy(this.onPageListChange,this));G.off("click").on("click",j.proxy(this.onPageFirst,this));I.off("click").on("click",j.proxy(this.onPagePre,this));E.off("click").on("click",j.proxy(this.onPageNext,this));y.off("click").on("click",j.proxy(this.onPageLast,this));u.off("click").on("click",j.proxy(this.onPageNumber,this))}if(this.options.showPageGo){var v=this,C=this.$pagination.find("ul.pagination"),B=C.find("li.pageGo");if(!B.length){B=j(['
  • ',m('',this.options.pageNumber),'","
  • "].join("")).appendTo(C);B.find("button").click(function(){var K=parseInt(B.find("input").val())||1;if(K<1||K>v.options.totalPages){K=1}v.selectPage(K)})}}};e.prototype.updatePagination=function(r){if(r&&j(r.currentTarget).hasClass("disabled")){return}if(!this.options.maintainSelected){this.resetRows()}this.initPagination();if(this.options.sidePagination==="server"){this.initServer()}else{this.initBody()}this.trigger("page-change",this.options.pageNumber,this.options.pageSize)};e.prototype.onPageListChange=function(r){var s=j(r.currentTarget);s.parent().addClass("active").siblings().removeClass("active");this.options.pageSize=s.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+s.text();this.$toolbar.find(".page-size").text(this.options.pageSize);this.updatePagination(r)};e.prototype.onPageFirst=function(r){this.options.pageNumber=1;this.updatePagination(r)};e.prototype.onPagePre=function(r){if((this.options.pageNumber-1)===0){this.options.pageNumber=this.options.totalPages}else{this.options.pageNumber--}this.updatePagination(r)};e.prototype.onPageNext=function(r){if((this.options.pageNumber+1)>this.options.totalPages){this.options.pageNumber=1}else{this.options.pageNumber++}this.updatePagination(r)};e.prototype.onPageLast=function(r){this.options.pageNumber=this.totalPages;this.updatePagination(r)};e.prototype.onPageNumber=function(r){if(this.options.pageNumber===+j(r.currentTarget).text()){return}this.options.pageNumber=+j(r.currentTarget).text();this.updatePagination(r)};e.prototype.initBody=function(x){var z=this,y=[],v=this.getData();this.trigger("pre-body",v);this.$body=this.$el.find(">tbody");if(!this.$body.length){this.$body=j("").appendTo(this.$el)}if(!this.options.pagination||this.options.sidePagination==="server"){this.pageFrom=1;this.pageTo=v.length}for(var w=this.pageFrom-1;w");if(this.options.cardView){y.push(m('
    ',this.header.fields.length))}if(!this.options.cardView&&this.options.detailView){y.push("",'',m('',this.options.iconsPrefix,this.options.icons.detailOpen),"","")}j.each(this.header.fields,function(I,L){var P="",M=o(C,L,z.options.escape),K="",E={},Q="",J=z.header.classes[I],G="",O="",R="",H="",F=z.columns[I];if(z.fromHtml&&typeof M==="undefined"){return}if(!F.visible){return}if(z.options.cardView&&!F.cardVisible){return}r=m('style="%s"',s.concat(z.header.styles[I]).join("; "));if(C["_"+L+"_id"]){Q=m(' id="%s"',C["_"+L+"_id"])}if(C["_"+L+"_class"]){J=m(' class="%s"',C["_"+L+"_class"])}if(C["_"+L+"_rowspan"]){O=m(' rowspan="%s"',C["_"+L+"_rowspan"])}if(C["_"+L+"_colspan"]){R=m(' colspan="%s"',C["_"+L+"_colspan"])}if(C["_"+L+"_title"]){H=m(' title="%s"',C["_"+L+"_title"])}E=q(z.header,z.header.cellStyles[I],[M,C,w,L],E);if(E.classes){J=m(' class="%s"',E.classes)}if(E.css){var D=[];for(var N in E.css){D.push(N+": "+E.css[N])}r=m('style="%s"',D.concat(z.header.styles[I]).join("; "))}M=q(F,z.header.formatters[I],[M,C,w],M);if(C["_"+L+"_data"]&&!j.isEmptyObject(C["_"+L+"_data"])){j.each(C["_"+L+"_data"],function(T,S){if(T==="index"){return}G+=m(' data-%s="%s"',T,S)})}if(F.checkbox||F.radio){K=F.checkbox?"checkbox":K;K=F.radio?"radio":K;P=[m(z.options.cardView?'
    ':'',F["class"]||""),"",z.header.formatters[I]&&typeof M==="string"?M:"",z.options.cardView?"
    ":""].join("");C[z.header.stateField]=M===true||(M&&M.checked)}else{M=typeof M==="undefined"||M===null?z.options.undefinedText:M;P=z.options.cardView?['
    ',z.options.showHeader?m('%s',r,c(z.columns,"field","title",L)):"",m('%s',M),"
    "].join(""):[m("",Q,J,r,G,O,R,H),M,""].join("");if(z.options.cardView&&z.options.smartDisplay&&M===""){P='
    '}}y.push(P)});if(this.options.cardView){y.push("
    ")}y.push("")}if(!y.length){y.push('',m('%s',this.$header.find("th").length,this.options.formatNoMatches()),"")}this.$body.html(y.join(""));if(!x){this.scrollTo(0)}this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(J){var D=j(this),F=D.parent(),M=z.data[F.data("index")],H=D[0].cellIndex,G=z.getVisibleFields(),K=G[z.options.detailView&&!z.options.cardView?H-1:H],E=z.columns[i(z.columns,K)],L=o(M,K,z.options.escape);if(D.find(".detail-icon").length){return}z.trigger(J.type==="click"?"click-cell":"dbl-click-cell",K,L,M,D);z.trigger(J.type==="click"?"click-row":"dbl-click-row",M,F,K);if(J.type==="click"&&z.options.clickToSelect&&E.clickToSelect){var I=F.find(m('[name="%s"]',z.options.selectItemName));if(I.length){I[0].click()}}});this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var H=j(this),G=H.parent().parent(),E=G.data("index"),I=v[E];if(G.next().is("tr.detail-view")){H.find("i").attr("class",m("%s %s",z.options.iconsPrefix,z.options.icons.detailOpen));G.next().remove();z.trigger("collapse-row",E,I)}else{H.find("i").attr("class",m("%s %s",z.options.iconsPrefix,z.options.icons.detailClose));G.after(m('',G.find("td").length));var D=G.next().find("td");var F=q(z.options,z.options.detailFormatter,[E,I,D],"");if(D.length===1){D.append(F)}z.trigger("expand-row",E,I,D)}z.resetView()});this.$selectItem=this.$body.find(m('[name="%s"]',this.options.selectItemName));this.$selectItem.off("click").on("click",function(E){E.stopImmediatePropagation();var F=j(this),D=F.prop("checked"),G=z.data[F.data("index")];if(z.options.maintainSelected&&j(this).is(":radio")){j.each(z.options.data,function(H,I){I[z.header.stateField]=false})}G[z.header.stateField]=D;if(z.options.singleSelect){z.$selectItem.not(this).each(function(){z.data[j(this).data("index")][z.header.stateField]=false});z.$selectItem.filter(":checked").not(this).prop("checked",false)}z.updateSelected();z.trigger(D?"check":"uncheck",G,F)});j.each(this.header.events,function(G,F){if(!F){return}if(typeof F==="string"){F=q(null,F)}var H=z.header.fields[G],D=j.inArray(H,z.getVisibleFields());if(z.options.detailView&&!z.options.cardView){D+=1}for(var E in F){z.$body.find(">tr:not(.no-records-found)").each(function(){var M=j(this),N=M.find(z.options.cardView?".card-view":"td").eq(D),J=E.indexOf(" "),I=E.substring(0,J),K=E.substring(J+1),L=F[E];N.find(K).off(I).on(I,function(Q){var O=M.data("index"),R=z.data[O],P=R[H];L.apply(this,[Q,P,R,O])})})}});this.updateSelected();this.resetView();this.trigger("post-body",v)};e.prototype.initServer=function(r,w,s){var u=this,v={},x={searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder},t;if(this.options.pagination){x.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize;x.pageNumber=this.options.pageNumber}if(!this.options.firstLoad&&isFirstLoad){isFirstLoad=false;return}if(!(s||this.options.url)&&!this.options.ajax){return}if(this.options.queryParamsType==="limit"){x={search:x.searchText,sort:x.sortName,order:x.sortOrder};if(this.options.pagination){x.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1);x.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize}}if(!(j.isEmptyObject(this.filterColumnsPartial))){x.filter=JSON.stringify(this.filterColumnsPartial,null)}v=q(this.options,this.options.queryParams,[x],v);j.extend(v,w||{});if(v===false){return}if(!r){this.$tableLoading.show()}t=j.extend({},q(null,this.options.ajaxOptions),{type:this.options.method,url:s||this.options.url,data:this.options.contentType==="application/json"&&this.options.method==="post"?JSON.stringify(v):v,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(y){y=q(u.options,u.options.responseHandler,[y],y);u.load(y);u.trigger("load-success",y);if(!r){u.$tableLoading.hide()}},error:function(y){u.trigger("load-error",y.status,y);if(!r){u.$tableLoading.hide()}}});if(this.options.ajax){q(this,this.options.ajax,[t],null)}else{if(this._xhr&&this._xhr.readyState!==4){this._xhr.abort()}this._xhr=j.ajax(t)}};e.prototype.initSearchText=function(){if(this.options.search){if(this.options.searchText!==""){var r=this.$toolbar.find(".search input");r.val(this.options.searchText);this.onSearch({currentTarget:r})}}};e.prototype.getCaret=function(){var r=this;j.each(this.$header.find("th"),function(s,t){j(t).find(".sortable").removeClass("desc asc").addClass((j(t).data("field")===r.options.sortName||j(t).data("sortName")===r.options.sortName)?r.options.sortOrder:"both")})};e.prototype.updateSelected=function(){var r=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;var s=j(".left-fixed-table-columns input[name=btSelectItem]");if(s.length>0){r=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===s.filter(":enabled").filter(":checked").length}this.$selectAll.add(this.$selectAll_).prop("checked",r);this.$selectItem.each(function(){j(this).closest("tr")[j(this).prop("checked")?"addClass":"removeClass"]("selected")})};e.prototype.updateRows=function(){var r=this;this.$selectItem.each(function(){r.data[j(this).data("index")][r.header.stateField]=j(this).prop("checked")})};e.prototype.resetRows=function(){var r=this;j.each(this.data,function(s,t){r.$selectAll.prop("checked",false);r.$selectItem.prop("checked",false);if(r.header.stateField){t[r.header.stateField]=false}})};e.prototype.trigger=function(s){var r=Array.prototype.slice.call(arguments,1);s+=".bs.table";this.options[e.EVENTS[s]].apply(this.options,r);this.$el.trigger(j.Event(s),r);this.options.onAll(s,r);this.$el.trigger(j.Event("all.bs.table"),[s,r])};e.prototype.resetHeader=function(){clearTimeout(this.timeoutId_);this.timeoutId_=setTimeout(j.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)};e.prototype.fitHeader=function(){var t=this,u,r,x,y;if(t.$el.is(":hidden")){t.timeoutId_=setTimeout(j.proxy(t.fitHeader,t),100);return}u=this.$tableBody.get(0);r=u.scrollWidth>u.clientWidth&&u.scrollHeight>u.clientHeight+this.$header.outerHeight()?a():0;this.$el.css("margin-top",-this.$header.outerHeight());x=j(":focus");if(x.length>0){var z=x.parents("th");if(z.length>0){var A=z.attr("data-field");if(A!==undefined){var s=this.$header.find("[data-field='"+A+"']");if(s.length>0){s.find(":input").addClass("focus-temp")}}}}this.$header_=this.$header.clone(true,true);this.$selectAll_=this.$header_.find('[name="btSelectAll"]');this.$tableHeader.css({"margin-right":r}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_);y=j(".focus-temp:visible:eq(0)");if(y.length>0){y.focus();this.$header.find(".focus-temp").removeClass("focus-temp")}this.$header.find("th[data-field]").each(function(B){t.$header_.find(m('th[data-field="%s"]',j(this).data("field"))).data(j(this).data())});var w=this.getVisibleFields(),v=this.$header_.find("th");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(C){var E=j(this),B=C;if(t.options.detailView&&!t.options.cardView){if(C===0){t.$header_.find("th.detail").find(".fht-cell").width(E.innerWidth())}B=C-1}var D=t.$header_.find(m('th[data-field="%s"]',w[B]));if(D.length>1){D=j(v[E[0].cellIndex])}D.find(".fht-cell").width(E.innerWidth())});this.$tableBody.off("scroll").on("scroll",function(){t.$tableHeader.scrollLeft(j(this).scrollLeft());if(t.options.showFooter&&!t.options.cardView){t.$tableFooter.scrollLeft(j(this).scrollLeft())}});t.trigger("post-header")};e.prototype.resetFooter=function(){var s=this,t=s.getData(),r=[];if(!this.options.showFooter||this.options.cardView){return}if(!this.options.cardView&&this.options.detailView){r.push('
     
    ')}j.each(this.columns,function(x,z){var w,B="",v="",A=[],y={},u=m(' class="%s"',z["class"]);if(!z.visible){return}if(s.options.cardView&&(!z.cardVisible)){return}B=m("text-align: %s; ",z.falign?z.falign:z.align);v=m("vertical-align: %s; ",z.valign);y=q(null,s.options.footerStyle);if(y&&y.css){for(w in y.css){A.push(w+": "+y.css[w])}}r.push("");r.push('
    ');r.push(q(z,z.footerFormatter,[t]," ")||" ");r.push("
    ");r.push('
    ');r.push("
    ");r.push("")});this.$tableFooter.find("tr").html(r.join(""));this.$tableFooter.show();clearTimeout(this.timeoutFooter_);this.timeoutFooter_=setTimeout(j.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0)};e.prototype.fitFooter=function(){var u=this,r,t,s;clearTimeout(this.timeoutFooter_);if(this.$el.is(":hidden")){this.timeoutFooter_=setTimeout(j.proxy(this.fitFooter,this),100);return}t=this.$el.css("width");s=t>this.$tableBody.width()?a():0;this.$tableFooter.css({"margin-right":s}).find("table").css("width",t).attr("class",this.$el.attr("class"));r=this.$tableFooter.find("td");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(v){var w=j(this);r.eq(v).find(".fht-cell").width(w.innerWidth()+1)})};e.prototype.toggleColumn=function(r,s,u){if(r===-1){return}this.columns[r].visible=s;this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var t=this.$toolbar.find(".keep-open input").prop("disabled",false);if(u){t.filter(m('[value="%s"]',r)).prop("checked",s)}if(t.filter(":checked").length<=this.options.minimumCountColumns){t.filter(":checked").prop("disabled",true)}}};e.prototype.toggleRow=function(r,t,s){if(r===-1){return}this.$body.find(typeof r!=="undefined"?m('tr[data-index="%s"]',r):m('tr[data-uniqueid="%s"]',t))[s?"show":"hide"]()};e.prototype.getVisibleFields=function(){var s=this,r=[];j.each(this.header.fields,function(t,v){var u=s.columns[i(s.columns,v)];if(!u.visible){return}r.push(v)});return r};e.prototype.resetView=function(u){var s=0;if(u&&u.height){this.options.height=u.height}this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length);if(this.options.height){var t=d(this.$toolbar),v=d(this.$pagination),r=this.options.height-t-v;this.$tableContainer.css("height",r+"px")}if(this.options.cardView){this.$el.css("margin-top","0");this.$tableContainer.css("padding-bottom","0");this.$tableFooter.hide();return}if(this.options.showHeader&&this.options.height){this.$tableHeader.show();this.resetHeader();s+=this.$header.outerHeight()}else{this.$tableHeader.hide();this.trigger("post-header")}if(this.options.showFooter){this.resetFooter();if(this.options.height){s+=this.$tableFooter.outerHeight()+1}}this.getCaret();this.$tableContainer.css("padding-bottom",s+"px");this.trigger("reset-view")};e.prototype.getData=function(r){return(this.searchText||!j.isEmptyObject(this.filterColumns)||!j.isEmptyObject(this.filterColumnsPartial))?(r?this.data.slice(this.pageFrom-1,this.pageTo):this.data):(r?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data)};e.prototype.load=function(s){var r=false;if(this.options.sidePagination==="server"){this.options.totalRows=s.total;r=s.fixedScroll;s=s[this.options.dataField]}else{if(!j.isArray(s)){r=s.fixedScroll;s=s.data}}this.initData(s);this.initSearch();this.initPagination();this.initBody(r)};e.prototype.append=function(r){this.initData(r,"append");this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.prepend=function(r){this.initData(r,"prepend");this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.remove=function(u){var r=this.options.data.length,s,t;if(!u.hasOwnProperty("field")||!u.hasOwnProperty("values")){return}for(s=r-1;s>=0;s--){t=this.options.data[s];if(!t.hasOwnProperty(u.field)){continue}if(j.inArray(t[u.field],u.values)!==-1){this.options.data.splice(s,1)}}if(r===this.options.data.length){return}this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.removeAll=function(){if(this.options.data.length>0){this.options.data.splice(0,this.options.data.length);this.initSearch();this.initPagination();this.initBody(true)}};e.prototype.getRowByUniqueId=function(x){var w=this.options.uniqueId,r=this.options.data.length,s=null,t,v,u;for(t=r-1;t>=0;t--){v=this.options.data[t];if(v.hasOwnProperty(w)){u=v[w]}else{if(v._data.hasOwnProperty(w)){u=v._data[w]}else{continue}}if(typeof u==="string"){x=x.toString()}else{if(typeof u==="number"){if((Number(u)===u)&&(u%1===0)){x=parseInt(x)}else{if((u===Number(u))&&(u!==0)){x=parseFloat(x)}}}}if(u===x){s=v;break}}return s};e.prototype.removeByUniqueId=function(t){var r=this.options.data.length,s=this.getRowByUniqueId(t);if(s){this.options.data.splice(this.options.data.indexOf(s),1)}if(r===this.options.data.length){return}this.initSearch();this.initPagination();this.initBody(true)};e.prototype.updateByUniqueId=function(t){var r=this;var s=j.isArray(t)?t:[t];j.each(s,function(u,w){var v;if(!w.hasOwnProperty("id")||!w.hasOwnProperty("row")){return}v=j.inArray(r.getRowByUniqueId(w.id),r.options.data);if(v===-1){return}j.extend(r.options.data[v],w.row)});this.initSearch();this.initSort();this.initBody(true)};e.prototype.insertRow=function(r){if(!r.hasOwnProperty("index")||!r.hasOwnProperty("row")){return}this.data.splice(r.index,0,r.row);this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.updateRow=function(t){var r=this;var s=j.isArray(t)?t:[t];j.each(s,function(u,v){if(!v.hasOwnProperty("index")||!v.hasOwnProperty("row")){return}j.extend(r.options.data[v.index],v.row)});this.initSearch();this.initSort();this.initBody(true)};e.prototype.showRow=function(r){if(!r.hasOwnProperty("index")&&!r.hasOwnProperty("uniqueId")){return}this.toggleRow(r.index,r.uniqueId,true)};e.prototype.hideRow=function(r){if(!r.hasOwnProperty("index")&&!r.hasOwnProperty("uniqueId")){return}this.toggleRow(r.index,r.uniqueId,false)};e.prototype.getRowsHidden=function(r){var t=j(this.$body[0]).children().filter(":hidden"),s=0;if(r){for(;str"),r;if(this.options.detailView&&!this.options.cardView){t+=1}r=x.eq(y).find(">td").eq(t);if(y<0||t<0||y>=this.data.length){return}for(w=y;wtd").eq(v).hide()}}r.attr("rowspan",u).attr("colspan",s).show()};e.prototype.updateCell=function(r){if(!r.hasOwnProperty("index")||!r.hasOwnProperty("field")||!r.hasOwnProperty("value")){return}this.data[r.index][r.field]=r.value;if(r.reinit===false){return}this.initSort();this.initBody(true)};e.prototype.getOptions=function(){return this.options};e.prototype.getSelections=function(){var r=this;return j.grep(this.options.data,function(s){return s[r.header.stateField]})};e.prototype.getAllSelections=function(){var r=this;return j.grep(this.options.data,function(s){return s[r.header.stateField]})};e.prototype.checkAll=function(){this.checkAll_(true)};e.prototype.uncheckAll=function(){this.checkAll_(false)};e.prototype.checkInvert=function(){var s=this;var t=s.$selectItem.filter(":enabled");var r=t.filter(":checked");t.each(function(){j(this).prop("checked",!j(this).prop("checked"))});s.updateRows();s.updateSelected();s.trigger("uncheck-some",r);r=s.getSelections();s.trigger("check-some",r)};e.prototype.checkAll_=function(r){var s;if(!r){s=this.getSelections()}this.$selectAll.add(this.$selectAll_).prop("checked",r);this.$selectItem.filter(":enabled").prop("checked",r);this.updateRows();if(r){s=this.getSelections()}this.trigger(r?"check-all":"uncheck-all",s)};e.prototype.check=function(r){this.check_(true,r)};e.prototype.uncheck=function(r){this.check_(false,r)};e.prototype.check_=function(t,r){var s=this.$selectItem.filter(m('[data-index="%s"]',r)).prop("checked",t); +/** + * @author zhixin wen + * version: 1.11.0 + * https://github.com/wenzhixin/bootstrap-table/ + */ +(function(j){var k=null;var m=function(u){var s=arguments,r=true,t=1;u=u.replace(/%s/g,function(){var v=s[t++];if(typeof v==="undefined"){r=false;return""}return v});return r?u:""};var c=function(t,v,u,s){var r="";j.each(t,function(w,x){if(x[v]===s){r=x[u];return false}return true});return r};var i=function(s,t){var r=-1;j.each(s,function(u,v){if(v.field===t){r=u;return false}return true});return r};var l=function(u){var y,x,w,A=0,B=[];for(y=0;y").addClass("fixed-table-scroll-inner"),u=j("
    ").addClass("fixed-table-scroll-outer"),s,r;u.append(t);j("body").append(u);s=t[0].offsetWidth;u.css("overflow","scroll");r=t[0].offsetWidth;if(s===r){r=u[0].clientWidth}u.remove();k=s-r}return k};var q=function(s,u,t,r){var v=u;if(typeof u==="string"){var w=u.split(".");if(w.length>1){v=window;j.each(w,function(x,y){v=v[y]})}else{v=window[u]}}if(typeof v==="object"){return v}if(typeof v==="function"){return v.apply(s,t)}if(!v&&typeof u==="string"&&m.apply(this,[u].concat(t))){return m.apply(this,[u].concat(t))}return r};var f=function(s,r,w){var x=Object.getOwnPropertyNames(s),u=Object.getOwnPropertyNames(r),v="";if(w){if(x.length!==u.length){return false}}for(var t=0;t-1){if(s[v]!==r[v]){return false}}}return true};var p=function(r){if(typeof r==="string"){return r.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`")}return r};var d=function(s){var r=0;s.children().each(function(){if(r0||!!navigator.userAgent.match(/Trident.*rv\:11\./))};var h=function(){if(!Object.keys){Object.keys=(function(){var t=Object.prototype.hasOwnProperty,u=!({toString:null}).propertyIsEnumerable("toString"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],r=s.length;return function(x){if(typeof x!=="object"&&(typeof x!=="function"||x===null)){throw new TypeError("Object.keys called on non-object")}var v=[],y,w;for(y in x){if(t.call(x,y)){v.push(y)}}if(u){for(w=0;w','
    ',this.options.paginationVAlign==="top"||this.options.paginationVAlign==="both"?'
    ':"",'
    ','
    ','
    ','
    ',this.options.formatLoadingMessage(),"
    ","
    ",'',this.options.paginationVAlign==="bottom"||this.options.paginationVAlign==="both"?'
    ':"","
    ","
    "].join(""));this.$container.insertAfter(this.$el);this.$tableContainer=this.$container.find(".fixed-table-container");this.$tableHeader=this.$container.find(".fixed-table-header");this.$tableBody=this.$container.find(".fixed-table-body");this.$tableLoading=this.$container.find(".fixed-table-loading");this.$tableFooter=this.$container.find(".fixed-table-footer");this.$toolbar=this.$container.find(".fixed-table-toolbar");this.$pagination=this.$container.find(".fixed-table-pagination");this.$tableBody.append(this.$el);this.$container.after('
    ');this.$el.addClass(this.options.classes);if(this.options.striped){this.$el.addClass("table-striped")}if(j.inArray("table-no-bordered",this.options.classes.split(" "))!==-1){this.$tableContainer.addClass("table-no-bordered")}};e.prototype.initTable=function(){var t=this,s=[],u=[];this.$header=this.$el.find(">thead");if(!this.$header.length){this.$header=j("").appendTo(this.$el)}this.$header.find("tr").each(function(){var v=[];j(this).find("th").each(function(){if(typeof j(this).data("field")!=="undefined"){j(this).data("field",j(this).data("field")+"")}v.push(j.extend({},{title:j(this).html(),"class":j(this).attr("class"),titleTooltip:j(this).attr("title"),rowspan:j(this).attr("rowspan")?+j(this).attr("rowspan"):undefined,colspan:j(this).attr("colspan")?+j(this).attr("colspan"):undefined},j(this).data()))});s.push(v)});if(!j.isArray(this.options.columns[0])){this.options.columns=[this.options.columns]}this.options.columns=j.extend(true,[],s,this.options.columns);this.columns=[];l(this.options.columns);j.each(this.options.columns,function(w,v){j.each(v,function(x,y){y=j.extend({},e.COLUMN_DEFAULTS,y);if(typeof y.fieldIndex!=="undefined"){t.columns[y.fieldIndex]=y}t.options.columns[w][x]=y})});if(this.options.data.length){return}var r=[];this.$el.find(">tbody>tr").each(function(w){var v={};v._id=j(this).attr("id");v._class=j(this).attr("class");v._data=g(j(this).data());j(this).find(">td").each(function(z){var E=j(this),B=+E.attr("colspan")||1,C=+E.attr("rowspan")||1,A,y;for(;r[w]&&r[w][z];z++){}for(A=z;A");if(v===0&&!t.options.cardView&&t.options.detailView){s.push(m('
    ',t.options.columns.length))}j.each(u,function(B,A){var F="",C="",E="",w="",D=m(' class="%s"',A["class"]),z=t.options.sortOrder||A.order,y="px",x=A.width;if(A.width!==undefined&&(!t.options.cardView)){if(typeof A.width==="string"){if(A.width.indexOf("%")!==-1){y="%"}}}if(A.width&&typeof A.width==="string"){x=A.width.replace("%","").replace("px","")}C=m("text-align: %s; ",A.halign?A.halign:A.align);E=m("text-align: %s; ",A.align);w=m("vertical-align: %s; ",A.valign);w+=m("width: %s; ",(A.checkbox||A.radio)&&!x?"36px":(x?x+y:undefined));if(typeof A.fieldIndex!=="undefined"){t.header.fields[A.fieldIndex]=A.field;t.header.styles[A.fieldIndex]=E+w;t.header.classes[A.fieldIndex]=D;t.header.formatters[A.fieldIndex]=A.formatter;t.header.events[A.fieldIndex]=A.events;t.header.sorters[A.fieldIndex]=A.sorter;t.header.sortNames[A.fieldIndex]=A.sortName;t.header.cellStyles[A.fieldIndex]=A.cellStyle;t.header.searchables[A.fieldIndex]=A.searchable;if(!A.visible){return}if(t.options.cardView&&(!A.cardVisible)){return}r[A.field]=A}s.push("");s.push(m('
    ',t.options.sortable&&A.sortable?"sortable both":""));F=A.title;if(A.checkbox){if(!t.options.singleSelect&&t.options.checkboxHeader){F=''}t.header.stateField=A.field}if(A.radio){F="";t.header.stateField=A.field;t.options.singleSelect=true}s.push(F);s.push("
    ");s.push('
    ');s.push("
    ");s.push("")});s.push("")});this.$header.html(s.join(""));this.$header.find("th[data-field]").each(function(u){j(this).data(r[j(this).data("field")])});this.$container.off("click",".th-inner").on("click",".th-inner",function(u){var v=j(this);if(t.options.detailView){if(v.closest(".bootstrap-table")[0]!==t.$container[0]){return false}}if(t.options.sortable&&v.parent().data().sortable){t.onSort(u)}});this.$header.children().children().off("keypress").on("keypress",function(v){if(t.options.sortable&&j(this).data().sortable){var u=v.keyCode||v.which;if(u==13){t.onSort(v)}}});j(window).off("resize.bootstrap-table");if(!this.options.showHeader||this.options.cardView){this.$header.hide();this.$tableHeader.hide();this.$tableLoading.css("top",0)}else{this.$header.show();this.$tableHeader.show();this.$tableLoading.css("top",this.$header.outerHeight()+1);this.getCaret();j(window).on("resize.bootstrap-table",j.proxy(this.resetWidth,this))}this.$selectAll=this.$header.find('[name="btSelectAll"]');this.$selectAll.off("click").on("click",function(){var u=j(this).prop("checked");t[u?"checkAll":"uncheckAll"]();t.updateSelected()})};e.prototype.initFooter=function(){if(!this.options.showFooter||this.options.cardView){this.$tableFooter.hide()}else{this.$tableFooter.show()}};e.prototype.initData=function(s,r){if(r==="append"){this.data=this.data.concat(s)}else{if(r==="prepend"){this.data=[].concat(s).concat(this.data)}else{this.data=s||this.options.data}}if(r==="append"){this.options.data=this.options.data.concat(s)}else{if(r==="prepend"){this.options.data=[].concat(s).concat(this.options.data)}else{this.options.data=this.data}}if(this.options.sidePagination==="server"){return}this.initSort()};e.prototype.initSort=function(){var u=this,t=this.options.sortName,r=this.options.sortOrder==="desc"?-1:1,s=j.inArray(this.options.sortName,this.header.fields);if(this.options.customSort!==j.noop){this.options.customSort.apply(this,[this.options.sortName,this.options.sortOrder]);return}if(s!==-1){if(this.options.sortStable){j.each(this.data,function(v,w){if(!w.hasOwnProperty("_position")){w._position=v}})}this.data.sort(function(w,v){if(u.header.sortNames[s]){t=u.header.sortNames[s]}var y=o(w,t,u.options.escape),z=o(v,t,u.options.escape),x=q(u.header,u.header.sorters[s],[y,z]);if(x!==undefined){return r*x}if(y===undefined||y===null){y=""}if(z===undefined||z===null){z=""}if(u.options.sortStable&&y===z){y=w._position;z=v._position}if(j.isNumeric(y)&&j.isNumeric(z)){y=parseFloat(y);z=parseFloat(z);if(y
    ',this.options.toolbarAlign)).appendTo(this.$toolbar).append(j(this.options.toolbar))}t=[m('
    ',this.options.buttonsAlign,this.options.buttonsAlign)];if(typeof this.options.icons==="string"){this.options.icons=q(null,this.options.icons)}if(this.options.showSearch){t.push(m('")}if(this.options.showPaginationSwitch){t.push(m('")}if(this.options.showRefresh){t.push(m('")}if(this.options.showToggle){t.push(m('")}if(this.options.showColumns){t.push(m('
    ',this.options.formatColumns()),'",'","
    ")}t.push("
    ");if(this.showToolbar||t.length>2){this.$toolbar.append(t.join(""))}if(this.options.showPaginationSwitch){this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",j.proxy(this.togglePagination,this))}if(this.options.showRefresh){this.$toolbar.find('button[name="refresh"]').off("click").on("click",j.proxy(this.refresh,this))}if(this.options.showToggle){this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){u.toggleView()})}if(this.options.showSearch){this.$toolbar.find('button[name="showSearch"]').off("click").on("click",function(){j(".search-collapse").slideToggle()})}if(this.options.showColumns){s=this.$toolbar.find(".keep-open");if(r<=this.options.minimumCountColumns){s.find("input").prop("disabled",true)}s.find("li").off("click").on("click",function(x){x.stopImmediatePropagation()});s.find("input").off("click").on("click",function(){var x=j(this);u.toggleColumn(j(this).val(),x.prop("checked"),false);u.trigger("column-switch",j(this).data("field"),x.prop("checked"))})}if(this.options.search){t=[];t.push('");this.$toolbar.append(t.join(""));v=this.$toolbar.find(".search input");v.off("keyup drop").on("keyup drop",function(x){if(u.options.searchOnEnterKey&&x.keyCode!==13){return}if(j.inArray(x.keyCode,[37,38,39,40])>-1){return}clearTimeout(w);w=setTimeout(function(){u.onSearch(x)},u.options.searchTimeOut)});if(b()){v.off("mouseup").on("mouseup",function(x){clearTimeout(w);w=setTimeout(function(){u.onSearch(x)},u.options.searchTimeOut)})}}};e.prototype.onSearch=function(r){var s=j.trim(j(r.currentTarget).val());if(this.options.trimOnSearch&&j(r.currentTarget).val()!==s){j(r.currentTarget).val(s)}if(s===this.searchText){return}this.searchText=s;this.options.searchText=s;this.options.pageNumber=1;this.initSearch();this.updatePagination();this.trigger("search",s)};e.prototype.initSearch=function(){var t=this;if(this.options.sidePagination!=="server"){if(this.options.customSearch!==j.noop){this.options.customSearch.apply(this,[this.searchText]);return}var r=this.searchText&&(this.options.escape?p(this.searchText):this.searchText).toLowerCase();var u=j.isEmptyObject(this.filterColumns)?null:this.filterColumns;this.data=u?j.grep(this.options.data,function(w,v){for(var s in u){if(j.isArray(u[s])&&j.inArray(w[s],u[s])===-1||w[s]!==u[s]){return false}}return true}):this.options.data;this.data=r?j.grep(this.data,function(A,x){for(var v=0;v-1){r=true}}}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1;this.options.totalPages=this.totalPages}if(this.totalPages>0&&this.options.pageNumber>this.totalPages){this.options.pageNumber=this.totalPages}this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1;this.pageTo=this.options.pageNumber*this.options.pageSize;if(this.pageTo>this.options.totalRows){this.pageTo=this.options.totalRows}x.push('
    ','',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),"");if(!this.options.onlyInfoPagination){x.push('');var F=[m('',this.options.paginationVAlign==="top"||this.options.paginationVAlign==="both"?"dropdown":"dropup"),'",'");x.push(this.options.formatRecordsPerPage(F.join("")));x.push("");x.push("
    ",'")}this.$pagination.html(x.join(""));if(!this.options.onlyInfoPagination){w=this.$pagination.find(".page-list a");G=this.$pagination.find(".page-first");I=this.$pagination.find(".page-pre");E=this.$pagination.find(".page-next");y=this.$pagination.find(".page-last");u=this.$pagination.find(".page-number");if(this.options.smartDisplay){if(this.totalPages<=1){this.$pagination.find("div.pagination").hide()}if(t.length<2||this.options.totalRows<=t[0]){this.$pagination.find("span.page-list").hide()}this.$pagination[this.getData().length?"show":"hide"]()}if(r){this.options.pageSize=this.options.formatAllRows()}w.off("click").on("click",j.proxy(this.onPageListChange,this));G.off("click").on("click",j.proxy(this.onPageFirst,this));I.off("click").on("click",j.proxy(this.onPagePre,this));E.off("click").on("click",j.proxy(this.onPageNext,this));y.off("click").on("click",j.proxy(this.onPageLast,this));u.off("click").on("click",j.proxy(this.onPageNumber,this))}if(this.options.showPageGo){var v=this,C=this.$pagination.find("ul.pagination"),B=C.find("li.pageGo");if(!B.length){B=j(['
  • ',m('',this.options.pageNumber),'","
  • "].join("")).appendTo(C);B.find("button").click(function(){var K=parseInt(B.find("input").val())||1;if(K<1||K>v.options.totalPages){K=1}v.selectPage(K)})}}};e.prototype.updatePagination=function(r){if(r&&j(r.currentTarget).hasClass("disabled")){return}if(!this.options.maintainSelected){this.resetRows()}this.initPagination();if(this.options.sidePagination==="server"){this.initServer()}else{this.initBody()}this.trigger("page-change",this.options.pageNumber,this.options.pageSize)};e.prototype.onPageListChange=function(r){var s=j(r.currentTarget);s.parent().addClass("active").siblings().removeClass("active");this.options.pageSize=s.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+s.text();this.$toolbar.find(".page-size").text(this.options.pageSize);this.updatePagination(r)};e.prototype.onPageFirst=function(r){this.options.pageNumber=1;this.updatePagination(r)};e.prototype.onPagePre=function(r){if((this.options.pageNumber-1)===0){this.options.pageNumber=this.options.totalPages}else{this.options.pageNumber--}this.updatePagination(r)};e.prototype.onPageNext=function(r){if((this.options.pageNumber+1)>this.options.totalPages){this.options.pageNumber=1}else{this.options.pageNumber++}this.updatePagination(r)};e.prototype.onPageLast=function(r){this.options.pageNumber=this.totalPages;this.updatePagination(r)};e.prototype.onPageNumber=function(r){if(this.options.pageNumber===+j(r.currentTarget).text()){return}this.options.pageNumber=+j(r.currentTarget).text();this.updatePagination(r)};e.prototype.initBody=function(x){var z=this,y=[],v=this.getData();this.trigger("pre-body",v);this.$body=this.$el.find(">tbody");if(!this.$body.length){this.$body=j("").appendTo(this.$el)}if(!this.options.pagination||this.options.sidePagination==="server"){this.pageFrom=1;this.pageTo=v.length}for(var w=this.pageFrom-1;w");if(this.options.cardView){y.push(m('
    ',this.header.fields.length))}if(!this.options.cardView&&this.options.detailView){y.push("",'',m('',this.options.iconsPrefix,this.options.icons.detailOpen),"","")}j.each(this.header.fields,function(I,L){var P="",M=o(C,L,z.options.escape),K="",E={},Q="",J=z.header.classes[I],G="",O="",R="",H="",F=z.columns[I];if(z.fromHtml&&typeof M==="undefined"){return}if(!F.visible){return}if(z.options.cardView&&!F.cardVisible){return}r=m('style="%s"',s.concat(z.header.styles[I]).join("; "));if(C["_"+L+"_id"]){Q=m(' id="%s"',C["_"+L+"_id"])}if(C["_"+L+"_class"]){J=m(' class="%s"',C["_"+L+"_class"])}if(C["_"+L+"_rowspan"]){O=m(' rowspan="%s"',C["_"+L+"_rowspan"])}if(C["_"+L+"_colspan"]){R=m(' colspan="%s"',C["_"+L+"_colspan"])}if(C["_"+L+"_title"]){H=m(' title="%s"',C["_"+L+"_title"])}E=q(z.header,z.header.cellStyles[I],[M,C,w,L],E);if(E.classes){J=m(' class="%s"',E.classes)}if(E.css){var D=[];for(var N in E.css){D.push(N+": "+E.css[N])}r=m('style="%s"',D.concat(z.header.styles[I]).join("; "))}M=q(F,z.header.formatters[I],[M,C,w],M);if(C["_"+L+"_data"]&&!j.isEmptyObject(C["_"+L+"_data"])){j.each(C["_"+L+"_data"],function(T,S){if(T==="index"){return}G+=m(' data-%s="%s"',T,S)})}if(F.checkbox||F.radio){K=F.checkbox?"checkbox":K;K=F.radio?"radio":K;P=[m(z.options.cardView?'
    ':'',F["class"]||""),"",z.header.formatters[I]&&typeof M==="string"?M:"",z.options.cardView?"
    ":""].join("");C[z.header.stateField]=M===true||(M&&M.checked)}else{M=typeof M==="undefined"||M===null?z.options.undefinedText:M;P=z.options.cardView?['
    ',z.options.showHeader?m('%s',r,c(z.columns,"field","title",L)):"",m('%s',M),"
    "].join(""):[m("",Q,J,r,G,O,R,H),M,""].join("");if(z.options.cardView&&z.options.smartDisplay&&M===""){P='
    '}}y.push(P)});if(this.options.cardView){y.push("
    ")}y.push("")}if(!y.length){y.push('',m('%s',this.$header.find("th").length,this.options.formatNoMatches()),"")}this.$body.html(y.join(""));if(!x){this.scrollTo(0)}this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(J){var D=j(this),F=D.parent(),M=z.data[F.data("index")],H=D[0].cellIndex,G=z.getVisibleFields(),K=G[z.options.detailView&&!z.options.cardView?H-1:H],E=z.columns[i(z.columns,K)],L=o(M,K,z.options.escape);if(D.find(".detail-icon").length){return}z.trigger(J.type==="click"?"click-cell":"dbl-click-cell",K,L,M,D);z.trigger(J.type==="click"?"click-row":"dbl-click-row",M,F,K);if(J.type==="click"&&z.options.clickToSelect&&E.clickToSelect){var I=F.find(m('[name="%s"]',z.options.selectItemName));if(I.length){I[0].click()}}});this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var H=j(this),G=H.parent().parent(),E=G.data("index"),I=v[E];if(G.next().is("tr.detail-view")){H.find("i").attr("class",m("%s %s",z.options.iconsPrefix,z.options.icons.detailOpen));G.next().remove();z.trigger("collapse-row",E,I)}else{H.find("i").attr("class",m("%s %s",z.options.iconsPrefix,z.options.icons.detailClose));G.after(m('',G.find("td").length));var D=G.next().find("td");var F=q(z.options,z.options.detailFormatter,[E,I,D],"");if(D.length===1){D.append(F)}z.trigger("expand-row",E,I,D)}z.resetView()});this.$selectItem=this.$body.find(m('[name="%s"]',this.options.selectItemName));this.$selectItem.off("click").on("click",function(E){E.stopImmediatePropagation();var F=j(this),D=F.prop("checked"),G=z.data[F.data("index")];if(z.options.maintainSelected&&j(this).is(":radio")){j.each(z.options.data,function(H,I){I[z.header.stateField]=false})}G[z.header.stateField]=D;if(z.options.singleSelect){z.$selectItem.not(this).each(function(){z.data[j(this).data("index")][z.header.stateField]=false});z.$selectItem.filter(":checked").not(this).prop("checked",false)}z.updateSelected();z.trigger(D?"check":"uncheck",G,F)});j.each(this.header.events,function(G,F){if(!F){return}if(typeof F==="string"){F=q(null,F)}var H=z.header.fields[G],D=j.inArray(H,z.getVisibleFields());if(z.options.detailView&&!z.options.cardView){D+=1}for(var E in F){z.$body.find(">tr:not(.no-records-found)").each(function(){var M=j(this),N=M.find(z.options.cardView?".card-view":"td").eq(D),J=E.indexOf(" "),I=E.substring(0,J),K=E.substring(J+1),L=F[E];N.find(K).off(I).on(I,function(Q){var O=M.data("index"),R=z.data[O],P=R[H];L.apply(this,[Q,P,R,O])})})}});this.updateSelected();this.resetView();this.trigger("post-body",v)};e.prototype.initServer=function(r,w,s){var u=this,v={},x={searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder},t;if(this.options.pagination){x.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize;x.pageNumber=this.options.pageNumber}if(!this.options.firstLoad&&isFirstLoad){isFirstLoad=false;return}if(!(s||this.options.url)&&!this.options.ajax){return}if(this.options.queryParamsType==="limit"){x={search:x.searchText,sort:x.sortName,order:x.sortOrder};if(this.options.pagination){x.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1);x.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize}}if(!(j.isEmptyObject(this.filterColumnsPartial))){x.filter=JSON.stringify(this.filterColumnsPartial,null)}v=q(this.options,this.options.queryParams,[x],v);j.extend(v,w||{});if(v===false){return}if(!r){this.$tableLoading.show()}t=j.extend({},q(null,this.options.ajaxOptions),{type:this.options.method,url:s||this.options.url,data:this.options.contentType==="application/json"&&this.options.method==="post"?JSON.stringify(v):v,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(y){y=q(u.options,u.options.responseHandler,[y],y);u.load(y);u.trigger("load-success",y);if(!r){u.$tableLoading.hide()}},error:function(y){u.trigger("load-error",y.status,y);if(!r){u.$tableLoading.hide()}}});if(this.options.ajax){q(this,this.options.ajax,[t],null)}else{if(this._xhr&&this._xhr.readyState!==4){this._xhr.abort()}this._xhr=j.ajax(t)}};e.prototype.initSearchText=function(){if(this.options.search){if(this.options.searchText!==""){var r=this.$toolbar.find(".search input");r.val(this.options.searchText);this.onSearch({currentTarget:r})}}};e.prototype.getCaret=function(){var r=this;j.each(this.$header.find("th"),function(s,t){j(t).find(".sortable").removeClass("desc asc").addClass((j(t).data("field")===r.options.sortName||j(t).data("sortName")===r.options.sortName)?r.options.sortOrder:"both")})};e.prototype.updateSelected=function(){var r=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;var s=j(".left-fixed-table-columns input[name=btSelectItem]");if(s.length>0){r=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===s.filter(":enabled").filter(":checked").length}this.$selectAll.add(this.$selectAll_).prop("checked",r);this.$selectItem.each(function(){j(this).closest("tr")[j(this).prop("checked")?"addClass":"removeClass"]("selected")})};e.prototype.updateRows=function(){var r=this;this.$selectItem.each(function(){r.data[j(this).data("index")][r.header.stateField]=j(this).prop("checked")})};e.prototype.resetRows=function(){var r=this;j.each(this.data,function(s,t){r.$selectAll.prop("checked",false);r.$selectItem.prop("checked",false);if(r.header.stateField){t[r.header.stateField]=false}})};e.prototype.trigger=function(s){var r=Array.prototype.slice.call(arguments,1);s+=".bs.table";this.options[e.EVENTS[s]].apply(this.options,r);this.$el.trigger(j.Event(s),r);this.options.onAll(s,r);this.$el.trigger(j.Event("all.bs.table"),[s,r])};e.prototype.resetHeader=function(){clearTimeout(this.timeoutId_);this.timeoutId_=setTimeout(j.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)};e.prototype.fitHeader=function(){var t=this,u,r,x,y;if(t.$el.is(":hidden")){t.timeoutId_=setTimeout(j.proxy(t.fitHeader,t),100);return}u=this.$tableBody.get(0);r=u.scrollWidth>u.clientWidth&&u.scrollHeight>u.clientHeight+this.$header.outerHeight()?a():0;this.$el.css("margin-top",-this.$header.outerHeight());x=j(":focus");if(x.length>0){var z=x.parents("th");if(z.length>0){var A=z.attr("data-field");if(A!==undefined){var s=this.$header.find("[data-field='"+A+"']");if(s.length>0){s.find(":input").addClass("focus-temp")}}}}this.$header_=this.$header.clone(true,true);this.$selectAll_=this.$header_.find('[name="btSelectAll"]');this.$tableHeader.css({"margin-right":r}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_);y=j(".focus-temp:visible:eq(0)");if(y.length>0){y.focus();this.$header.find(".focus-temp").removeClass("focus-temp")}this.$header.find("th[data-field]").each(function(B){t.$header_.find(m('th[data-field="%s"]',j(this).data("field"))).data(j(this).data())});var w=this.getVisibleFields(),v=this.$header_.find("th");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(C){var E=j(this),B=C;if(t.options.detailView&&!t.options.cardView){if(C===0){t.$header_.find("th.detail").find(".fht-cell").width(E.innerWidth())}B=C-1}var D=t.$header_.find(m('th[data-field="%s"]',w[B]));if(D.length>1){D=j(v[E[0].cellIndex])}D.find(".fht-cell").width(E.innerWidth())});this.$tableBody.off("scroll").on("scroll",function(){t.$tableHeader.scrollLeft(j(this).scrollLeft());if(t.options.showFooter&&!t.options.cardView){t.$tableFooter.scrollLeft(j(this).scrollLeft())}});t.trigger("post-header")};e.prototype.resetFooter=function(){var s=this,t=s.getData(),r=[];if(!this.options.showFooter||this.options.cardView){return}if(!this.options.cardView&&this.options.detailView){r.push('
     
    ')}j.each(this.columns,function(x,z){var w,B="",v="",A=[],y={},u=m(' class="%s"',z["class"]);if(!z.visible){return}if(s.options.cardView&&(!z.cardVisible)){return}B=m("text-align: %s; ",z.falign?z.falign:z.align);v=m("vertical-align: %s; ",z.valign);y=q(null,s.options.footerStyle);if(y&&y.css){for(w in y.css){A.push(w+": "+y.css[w])}}r.push("");r.push('
    ');r.push(q(z,z.footerFormatter,[t]," ")||" ");r.push("
    ");r.push('
    ');r.push("");r.push("")});this.$tableFooter.find("tr").html(r.join(""));this.$tableFooter.show();clearTimeout(this.timeoutFooter_);this.timeoutFooter_=setTimeout(j.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0)};e.prototype.fitFooter=function(){var u=this,r,t,s;clearTimeout(this.timeoutFooter_);if(this.$el.is(":hidden")){this.timeoutFooter_=setTimeout(j.proxy(this.fitFooter,this),100);return}t=this.$el.css("width");s=t>this.$tableBody.width()?a():0;this.$tableFooter.css({"margin-right":s}).find("table").css("width",t).attr("class",this.$el.attr("class"));r=this.$tableFooter.find("td");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(v){var w=j(this);r.eq(v).find(".fht-cell").width(w.innerWidth()+1)})};e.prototype.toggleColumn=function(r,s,u){if(r===-1){return}this.columns[r].visible=s;this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var t=this.$toolbar.find(".keep-open input").prop("disabled",false);if(u){t.filter(m('[value="%s"]',r)).prop("checked",s)}if(t.filter(":checked").length<=this.options.minimumCountColumns){t.filter(":checked").prop("disabled",true)}}};e.prototype.toggleRow=function(r,t,s){if(r===-1){return}this.$body.find(typeof r!=="undefined"?m('tr[data-index="%s"]',r):m('tr[data-uniqueid="%s"]',t))[s?"show":"hide"]()};e.prototype.getVisibleFields=function(){var s=this,r=[];j.each(this.header.fields,function(t,v){var u=s.columns[i(s.columns,v)];if(!u.visible){return}r.push(v)});return r};e.prototype.resetView=function(u){var s=0;if(u&&u.height){this.options.height=u.height}this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length);if(this.options.height){var t=d(this.$toolbar),v=d(this.$pagination),r=this.options.height-t-v;this.$tableContainer.css("height",r+"px")}if(this.options.cardView){this.$el.css("margin-top","0");this.$tableContainer.css("padding-bottom","0");this.$tableFooter.hide();return}if(this.options.showHeader&&this.options.height){this.$tableHeader.show();this.resetHeader();s+=this.$header.outerHeight()}else{this.$tableHeader.hide();this.trigger("post-header")}if(this.options.showFooter){this.resetFooter();if(this.options.height){s+=this.$tableFooter.outerHeight()+1}}this.getCaret();this.$tableContainer.css("padding-bottom",s+"px");this.trigger("reset-view")};e.prototype.getData=function(r){return(this.searchText||!j.isEmptyObject(this.filterColumns)||!j.isEmptyObject(this.filterColumnsPartial))?(r?this.data.slice(this.pageFrom-1,this.pageTo):this.data):(r?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data)};e.prototype.load=function(s){var r=false;if(this.options.sidePagination==="server"){this.options.totalRows=s.total;r=s.fixedScroll;s=s[this.options.dataField]}else{if(!j.isArray(s)){r=s.fixedScroll;s=s.data}}this.initData(s);this.initSearch();this.initPagination();this.initBody(r)};e.prototype.append=function(r){this.initData(r,"append");this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.prepend=function(r){this.initData(r,"prepend");this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.remove=function(u){var r=this.options.data.length,s,t;if(!u.hasOwnProperty("field")||!u.hasOwnProperty("values")){return}for(s=r-1;s>=0;s--){t=this.options.data[s];if(!t.hasOwnProperty(u.field)){continue}if(j.inArray(t[u.field],u.values)!==-1){this.options.data.splice(s,1)}}if(r===this.options.data.length){return}this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.removeAll=function(){if(this.options.data.length>0){this.options.data.splice(0,this.options.data.length);this.initSearch();this.initPagination();this.initBody(true)}};e.prototype.getRowByUniqueId=function(x){var w=this.options.uniqueId,r=this.options.data.length,s=null,t,v,u;for(t=r-1;t>=0;t--){v=this.options.data[t];if(v.hasOwnProperty(w)){u=v[w]}else{if(v._data.hasOwnProperty(w)){u=v._data[w]}else{continue}}if(typeof u==="string"){x=x.toString()}else{if(typeof u==="number"){if((Number(u)===u)&&(u%1===0)){x=parseInt(x)}else{if((u===Number(u))&&(u!==0)){x=parseFloat(x)}}}}if(u===x){s=v;break}}return s};e.prototype.removeByUniqueId=function(t){var r=this.options.data.length,s=this.getRowByUniqueId(t);if(s){this.options.data.splice(this.options.data.indexOf(s),1)}if(r===this.options.data.length){return}this.initSearch();this.initPagination();this.initBody(true)};e.prototype.updateByUniqueId=function(t){var r=this;var s=j.isArray(t)?t:[t];j.each(s,function(u,w){var v;if(!w.hasOwnProperty("id")||!w.hasOwnProperty("row")){return}v=j.inArray(r.getRowByUniqueId(w.id),r.options.data);if(v===-1){return}j.extend(r.options.data[v],w.row)});this.initSearch();this.initSort();this.initBody(true)};e.prototype.insertRow=function(r){if(!r.hasOwnProperty("index")||!r.hasOwnProperty("row")){return}this.data.splice(r.index,0,r.row);this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.updateRow=function(t){var r=this;var s=j.isArray(t)?t:[t];j.each(s,function(u,v){if(!v.hasOwnProperty("index")||!v.hasOwnProperty("row")){return}j.extend(r.options.data[v.index],v.row)});this.initSearch();this.initSort();this.initBody(true)};e.prototype.showRow=function(r){if(!r.hasOwnProperty("index")&&!r.hasOwnProperty("uniqueId")){return}this.toggleRow(r.index,r.uniqueId,true)};e.prototype.hideRow=function(r){if(!r.hasOwnProperty("index")&&!r.hasOwnProperty("uniqueId")){return}this.toggleRow(r.index,r.uniqueId,false)};e.prototype.getRowsHidden=function(r){var t=j(this.$body[0]).children().filter(":hidden"),s=0;if(r){for(;str"),r;if(this.options.detailView&&!this.options.cardView){t+=1}r=x.eq(y).find(">td").eq(t);if(y<0||t<0||y>=this.data.length){return}for(w=y;wtd").eq(v).hide()}}r.attr("rowspan",u).attr("colspan",s).show()};e.prototype.updateCell=function(r){if(!r.hasOwnProperty("index")||!r.hasOwnProperty("field")||!r.hasOwnProperty("value")){return}this.data[r.index][r.field]=r.value;if(r.reinit===false){return}this.initSort();this.initBody(true)};e.prototype.getOptions=function(){return this.options};e.prototype.getSelections=function(){var r=this;return j.grep(this.options.data,function(s){return s[r.header.stateField]})};e.prototype.getAllSelections=function(){var r=this;return j.grep(this.options.data,function(s){return s[r.header.stateField]})};e.prototype.checkAll=function(){this.checkAll_(true)};e.prototype.uncheckAll=function(){this.checkAll_(false)};e.prototype.checkInvert=function(){var s=this;var t=s.$selectItem.filter(":enabled");var r=t.filter(":checked");t.each(function(){j(this).prop("checked",!j(this).prop("checked"))});s.updateRows();s.updateSelected();s.trigger("uncheck-some",r);r=s.getSelections();s.trigger("check-some",r)};e.prototype.checkAll_=function(r){var s;if(!r){s=this.getSelections()}this.$selectAll.add(this.$selectAll_).prop("checked",r);this.$selectItem.filter(":enabled").prop("checked",r);this.updateRows();if(r){s=this.getSelections()}this.trigger(r?"check-all":"uncheck-all",s)};e.prototype.check=function(r){this.check_(true,r)};e.prototype.uncheck=function(r){this.check_(false,r)};e.prototype.check_=function(t,r){var s=this.$selectItem.filter(m('[data-index="%s"]',r)).prop("checked",t); this.data[r][this.header.stateField]=t;this.updateSelected();this.trigger(t?"check":"uncheck",this.data[r],s)};e.prototype.checkBy=function(r){this.checkBy_(true,r)};e.prototype.uncheckBy=function(r){this.checkBy_(false,r)};e.prototype.checkBy_=function(s,u){if(!u.hasOwnProperty("field")||!u.hasOwnProperty("values")){return}var r=this,t=[];j.each(this.options.data,function(v,x){if(!x.hasOwnProperty(u.field)){return false}if(j.inArray(x[u.field],u.values)!==-1){var w=r.$selectItem.filter(":enabled").filter(m('[data-index="%s"]',v)).prop("checked",s);x[r.header.stateField]=s;t.push(x);r.trigger(s?"check":"uncheck",x,w)}});this.updateSelected();this.trigger(s?"check-some":"uncheck-some",t)};e.prototype.destroy=function(){this.$el.insertBefore(this.$container);j(this.options.toolbar).insertBefore(this.$el);this.$container.next().remove();this.$container.remove();this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")};e.prototype.showLoading=function(){this.$tableLoading.show()};e.prototype.hideLoading=function(){this.$tableLoading.hide()};e.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var r=this.$toolbar.find('button[name="paginationSwitch"] i');if(this.options.pagination){r.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown)}else{r.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp)}this.updatePagination()};e.prototype.refresh=function(r){if(r&&r.url){this.options.pageNumber=1}if(selectionIds.length>0){selectionIds=[]}this.initServer(r&&r.silent,r&&r.query,r&&r.url);this.trigger("refresh",r)};e.prototype.resetWidth=function(){if(this.options.showHeader&&this.options.height){this.fitHeader()}if(this.options.showFooter){this.fitFooter()}};e.prototype.showColumn=function(r){this.toggleColumn(i(this.columns,r),true,true)};e.prototype.hideColumn=function(r){this.toggleColumn(i(this.columns,r),false,true)};e.prototype.getHiddenColumns=function(){return j.grep(this.columns,function(r){return !r.visible})};e.prototype.getVisibleColumns=function(){return j.grep(this.columns,function(r){return r.visible})};e.prototype.toggleAllColumns=function(r){j.each(this.columns,function(t,u){this.columns[t].visible=r});this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var s=this.$toolbar.find(".keep-open input").prop("disabled",false);if(s.filter(":checked").length<=this.options.minimumCountColumns){s.filter(":checked").prop("disabled",true)}}};e.prototype.showAllColumns=function(){this.toggleAllColumns(true)};e.prototype.hideAllColumns=function(){this.toggleAllColumns(false)};e.prototype.filterBy=function(r){this.filterColumns=j.isEmptyObject(r)?{}:r;this.options.pageNumber=1;this.initSearch();this.updatePagination()};e.prototype.scrollTo=function(r){if(typeof r==="string"){r=r==="bottom"?this.$tableBody[0].scrollHeight:0}if(typeof r==="number"){this.$tableBody.scrollTop(r)}if(typeof r==="undefined"){return this.$tableBody.scrollTop()}};e.prototype.getScrollPosition=function(){return this.scrollTo()};e.prototype.selectPage=function(r){if(r>0&&r<=this.options.totalPages){this.options.pageNumber=r;this.updatePagination()}};e.prototype.prevPage=function(){if(this.options.pageNumber>1){this.options.pageNumber--;this.updatePagination()}};e.prototype.nextPage=function(){if(this.options.pageNumber tr[data-index="%s"]',r));if(t.next().is("tr.detail-view")===(s?false:true)){t.find("> td > .detail-icon").click()}};e.prototype.expandRow=function(r){this.expandRow_(true,r)};e.prototype.collapseRow=function(r){this.expandRow_(false,r)};e.prototype.expandAllRows=function(r){if(r){var w=this.$body.find(m('> tr[data-index="%s"]',0)),x=this,u=null,v=false,s=-1;if(!w.next().is("tr.detail-view")){w.find("> td > .detail-icon").click();v=true}else{if(!w.next().next().is("tr.detail-view")){w.next().find(".detail-icon").click();v=true}}if(v){try{s=setInterval(function(){u=x.$body.find("tr.detail-view").last().find(".detail-icon");if(u.length>0){u.click()}else{clearInterval(s)}},1)}catch(z){clearInterval(s)}}}else{var y=this.$body.children();for(var t=0;t - * extensions: https://github.com/vitalets/x-editable - */ - -(function($) { - - 'use strict'; - - $.extend($.fn.bootstrapTable.defaults, { - editable: true, - onEditableInit: function() { - return false; - }, - onEditableSave: function(field, row, oldValue, $el) { - return false; - }, - onEditableShown: function(field, row, $el, editable) { - return false; - }, - onEditableHidden: function(field, row, $el, reason) { - return false; - } - }); - - $.extend($.fn.bootstrapTable.Constructor.EVENTS, { - 'editable-init.bs.table': 'onEditableInit', - 'editable-save.bs.table': 'onEditableSave', - 'editable-shown.bs.table': 'onEditableShown', - 'editable-hidden.bs.table': 'onEditableHidden' - }); - - var BootstrapTable = $.fn.bootstrapTable.Constructor, - _initTable = BootstrapTable.prototype.initTable, - _initBody = BootstrapTable.prototype.initBody; - - BootstrapTable.prototype.initTable = function() { - var that = this; - _initTable.apply(this, Array.prototype.slice.apply(arguments)); - - if (!this.options.editable) { - return; - } - - $.each(this.columns, function(i, column) { - if (!column.editable) { - return; - } - - var editableOptions = {}, - editableDataMarkup = [], - editableDataPrefix = 'editable-'; - - var processDataOptions = function(key, value) { - // Replace camel case with dashes. - var dashKey = key.replace(/([A-Z])/g, function($1) { - return "-" + $1.toLowerCase(); - }); - if (dashKey.slice(0, editableDataPrefix.length) == editableDataPrefix) { - var dataKey = dashKey.replace(editableDataPrefix, 'data-'); - editableOptions[dataKey] = value; - } - }; - - $.each(that.options, processDataOptions); - - column.formatter = column.formatter || function(value, row, index) { - return value; - }; - column._formatter = column._formatter ? column._formatter : column.formatter; - column.formatter = function(value, row, index) { - var result = column._formatter ? column._formatter(value, row, index) : value; - - $.each(column, processDataOptions); - - $.each(editableOptions, function(key, value) { - editableDataMarkup.push(' ' + key + '="' + value + '"'); - }); - - var _dont_edit_formatter = false; - if (column.editable.hasOwnProperty('noeditFormatter')) { - _dont_edit_formatter = column.editable.noeditFormatter(value, row, index); - } - - if (_dont_edit_formatter === false) { - return ['' + '' - ].join(''); - } else { - return _dont_edit_formatter; - } - - }; - }); - }; - - BootstrapTable.prototype.initBody = function() { - var that = this; - _initBody.apply(this, Array.prototype.slice.apply(arguments)); - - if (!this.options.editable) { - return; - } - - $.each(this.columns, function(i, column) { - if (!column.editable) { - return; - } - - that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable) - .off('save').on('save', function(e, params) { - var data = that.getData(), - index = $(this).parents('tr[data-index]').data('index'), - row = data[index], - oldValue = row[column.field]; - - $(this).data('value', params.submitValue); - row[column.field] = params.submitValue; - that.trigger('editable-save', column.field, row, oldValue, $(this)); - that.resetFooter(); - }); - that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable) - .off('shown').on('shown', function(e, editable) { - var data = that.getData(), - index = $(this).parents('tr[data-index]').data('index'), - row = data[index]; - - that.trigger('editable-shown', column.field, row, $(this), editable); - }); - that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable) - .off('hidden').on('hidden', function(e, reason) { - var data = that.getData(), - index = $(this).parents('tr[data-index]').data('index'), - row = data[index]; - - that.trigger('editable-hidden', column.field, row, $(this), reason); - }); - }); - this.trigger('editable-init'); - }; - +/** + * @author zhixin wen + * extensions: https://github.com/vitalets/x-editable + */ + +(function($) { + + 'use strict'; + + $.extend($.fn.bootstrapTable.defaults, { + editable: true, + onEditableInit: function() { + return false; + }, + onEditableSave: function(field, row, oldValue, $el) { + return false; + }, + onEditableShown: function(field, row, $el, editable) { + return false; + }, + onEditableHidden: function(field, row, $el, reason) { + return false; + } + }); + + $.extend($.fn.bootstrapTable.Constructor.EVENTS, { + 'editable-init.bs.table': 'onEditableInit', + 'editable-save.bs.table': 'onEditableSave', + 'editable-shown.bs.table': 'onEditableShown', + 'editable-hidden.bs.table': 'onEditableHidden' + }); + + var BootstrapTable = $.fn.bootstrapTable.Constructor, + _initTable = BootstrapTable.prototype.initTable, + _initBody = BootstrapTable.prototype.initBody; + + BootstrapTable.prototype.initTable = function() { + var that = this; + _initTable.apply(this, Array.prototype.slice.apply(arguments)); + + if (!this.options.editable) { + return; + } + + $.each(this.columns, function(i, column) { + if (!column.editable) { + return; + } + + var editableOptions = {}, + editableDataMarkup = [], + editableDataPrefix = 'editable-'; + + var processDataOptions = function(key, value) { + // Replace camel case with dashes. + var dashKey = key.replace(/([A-Z])/g, function($1) { + return "-" + $1.toLowerCase(); + }); + if (dashKey.slice(0, editableDataPrefix.length) == editableDataPrefix) { + var dataKey = dashKey.replace(editableDataPrefix, 'data-'); + editableOptions[dataKey] = value; + } + }; + + $.each(that.options, processDataOptions); + + column.formatter = column.formatter || function(value, row, index) { + return value; + }; + column._formatter = column._formatter ? column._formatter : column.formatter; + column.formatter = function(value, row, index) { + var result = column._formatter ? column._formatter(value, row, index) : value; + + $.each(column, processDataOptions); + + $.each(editableOptions, function(key, value) { + editableDataMarkup.push(' ' + key + '="' + value + '"'); + }); + + var _dont_edit_formatter = false; + if (column.editable.hasOwnProperty('noeditFormatter')) { + _dont_edit_formatter = column.editable.noeditFormatter(value, row, index); + } + + if (_dont_edit_formatter === false) { + return ['' + '' + ].join(''); + } else { + return _dont_edit_formatter; + } + + }; + }); + }; + + BootstrapTable.prototype.initBody = function() { + var that = this; + _initBody.apply(this, Array.prototype.slice.apply(arguments)); + + if (!this.options.editable) { + return; + } + + $.each(this.columns, function(i, column) { + if (!column.editable) { + return; + } + + that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable) + .off('save').on('save', function(e, params) { + var data = that.getData(), + index = $(this).parents('tr[data-index]').data('index'), + row = data[index], + oldValue = row[column.field]; + + $(this).data('value', params.submitValue); + row[column.field] = params.submitValue; + that.trigger('editable-save', column.field, row, oldValue, $(this)); + that.resetFooter(); + }); + that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable) + .off('shown').on('shown', function(e, editable) { + var data = that.getData(), + index = $(this).parents('tr[data-index]').data('index'), + row = data[index]; + + that.trigger('editable-shown', column.field, row, $(this), editable); + }); + that.$body.find('a[data-name="' + column.field + '"]').editable(column.editable) + .off('hidden').on('hidden', function(e, reason) { + var data = that.getData(), + index = $(this).parents('tr[data-index]').data('index'), + row = data[index]; + + that.trigger('editable-hidden', column.field, row, $(this), reason); + }); + }); + this.trigger('editable-init'); + }; + })(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js index 53f276641..c25643e3e 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js @@ -1,7 +1,7 @@ -/* -* bootstrap-table - v1.11.0 - 2016-07-02 -* https://github.com/wenzhixin/bootstrap-table -* Copyright (c) 2016 zhixin wen -* Licensed MIT License -*/ +/* +* bootstrap-table - v1.11.0 - 2016-07-02 +* https://github.com/wenzhixin/bootstrap-table +* Copyright (c) 2016 zhixin wen +* Licensed MIT License +*/ !function(a){"use strict";a.extend(a.fn.bootstrapTable.defaults,{editable:!0,onEditableInit:function(){return!1},onEditableSave:function(){return!1},onEditableShown:function(){return!1},onEditableHidden:function(){return!1}}),a.extend(a.fn.bootstrapTable.Constructor.EVENTS,{"editable-init.bs.table":"onEditableInit","editable-save.bs.table":"onEditableSave","editable-shown.bs.table":"onEditableShown","editable-hidden.bs.table":"onEditableHidden"});var b=a.fn.bootstrapTable.Constructor,c=b.prototype.initTable,d=b.prototype.initBody;b.prototype.initTable=function(){var b=this;c.apply(this,Array.prototype.slice.apply(arguments)),this.options.editable&&a.each(this.columns,function(c,d){if(d.editable){var e={},f=[],g="editable-",h=function(a,b){var c=a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()});if(c.slice(0,g.length)==g){var d=c.replace(g,"data-");e[d]=b}};a.each(b.options,h),d.formatter=d.formatter||function(a){return a},d._formatter=d._formatter?d._formatter:d.formatter,d.formatter=function(c,g,i){var j=d._formatter?d._formatter(c,g,i):c;a.each(d,h),a.each(e,function(a,b){f.push(" "+a+'="'+b+'"')});var k=!1;return d.editable.hasOwnProperty("noeditFormatter")&&(k=d.editable.noeditFormatter(c,g,i)),k===!1?['"].join(""):k}}})},b.prototype.initBody=function(){var b=this;d.apply(this,Array.prototype.slice.apply(arguments)),this.options.editable&&(a.each(this.columns,function(c,d){d.editable&&(b.$body.find('a[data-name="'+d.field+'"]').editable(d.editable).off("save").on("save",function(c,e){var f=b.getData(),g=a(this).parents("tr[data-index]").data("index"),h=f[g],i=h[d.field];a(this).data("value",e.submitValue),h[d.field]=e.submitValue,b.trigger("editable-save",d.field,h,i,a(this)),b.resetFooter()}),b.$body.find('a[data-name="'+d.field+'"]').editable(d.editable).off("shown").on("shown",function(c,e){var f=b.getData(),g=a(this).parents("tr[data-index]").data("index"),h=f[g];b.trigger("editable-shown",d.field,h,a(this),e)}),b.$body.find('a[data-name="'+d.field+'"]').editable(d.editable).off("hidden").on("hidden",function(c,e){var f=b.getData(),g=a(this).parents("tr[data-index]").data("index"),h=f[g];b.trigger("editable-hidden",d.field,h,a(this),e)}))}),this.trigger("editable-init"))}}(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js index f3d9bc4e8..f897fbc7f 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js @@ -1,119 +1,119 @@ -/** - * @author zhixin wen - * extensions: https://github.com/kayalshri/tableExport.jquery.plugin - */ - -(function ($) { - 'use strict'; - var sprintf = $.fn.bootstrapTable.utils.sprintf; - - var TYPE_NAME = { - csv: 'CSV', - txt: 'TXT', - doc: 'Word', - excel: 'Excel' - }; - - $.extend($.fn.bootstrapTable.defaults, { - showExport: false, - exportDataType: 'all', // basic, all, selected - exportTypes: ['csv', 'txt', 'doc', 'excel'], - exportOptions: { - ignoreColumn: [0] //忽略列索引 - } - }); - - $.extend($.fn.bootstrapTable.defaults.icons, { - export: 'glyphicon glyphicon-save' - }); - - $.extend($.fn.bootstrapTable.locales, { - formatExport: function () { - return 'Export data'; - } - }); - $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); - - var BootstrapTable = $.fn.bootstrapTable.Constructor, - _initToolbar = BootstrapTable.prototype.initToolbar; - - BootstrapTable.prototype.initToolbar = function () { - this.showToolbar = this.options.showExport; - - _initToolbar.apply(this, Array.prototype.slice.apply(arguments)); - - if (this.options.showExport) { - var that = this, - $btnGroup = this.$toolbar.find('>.btn-group'), - $export = $btnGroup.find('div.export'); - - if (!$export.length) { - $export = $([ - '
    ', - '', - '', - '
    '].join('')).appendTo($btnGroup); - - var $menu = $export.find('.dropdown-menu'), - exportTypes = this.options.exportTypes; - - if (typeof this.options.exportTypes === 'string') { - var types = this.options.exportTypes.slice(1, -1).replace(/ /g, '').split(','); - - exportTypes = []; - $.each(types, function (i, value) { - exportTypes.push(value.slice(1, -1)); - }); - } - $.each(exportTypes, function (i, type) { - if (TYPE_NAME.hasOwnProperty(type)) { - $menu.append(['
  • ', - '', - TYPE_NAME[type], - '', - '
  • '].join('')); - } - }); - - $menu.find('li').click(function () { - var type = $(this).data('type'), - doExport = function () { - that.$el.tableExport($.extend({}, that.options.exportOptions, { - type: type, - escape: false - })); - }; - - if (that.options.exportDataType === 'all' && that.options.pagination) { - that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () { - doExport(); - that.togglePagination(); - }); - that.togglePagination(); - } else if (that.options.exportDataType === 'selected') { - //修改sidePagination属性为server无法导出选中数据 - var trs = that.$body.children(); - for (var i = 0; i < trs.length; i++) { - var $this = $(trs[i]); - if(!$this.find(sprintf('[name="%s"]',that.options.selectItemName)).prop('checked')){ - $this['hide'](); - }} - doExport(); - that.getRowsHidden(true); - } else { - doExport(); - } - }); - } - } - }; -})(jQuery); +/** + * @author zhixin wen + * extensions: https://github.com/kayalshri/tableExport.jquery.plugin + */ + +(function ($) { + 'use strict'; + var sprintf = $.fn.bootstrapTable.utils.sprintf; + + var TYPE_NAME = { + csv: 'CSV', + txt: 'TXT', + doc: 'Word', + excel: 'Excel' + }; + + $.extend($.fn.bootstrapTable.defaults, { + showExport: false, + exportDataType: 'all', // basic, all, selected + exportTypes: ['csv', 'txt', 'doc', 'excel'], + exportOptions: { + ignoreColumn: [0] //忽略列索引 + } + }); + + $.extend($.fn.bootstrapTable.defaults.icons, { + export: 'glyphicon glyphicon-save' + }); + + $.extend($.fn.bootstrapTable.locales, { + formatExport: function () { + return 'Export data'; + } + }); + $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); + + var BootstrapTable = $.fn.bootstrapTable.Constructor, + _initToolbar = BootstrapTable.prototype.initToolbar; + + BootstrapTable.prototype.initToolbar = function () { + this.showToolbar = this.options.showExport; + + _initToolbar.apply(this, Array.prototype.slice.apply(arguments)); + + if (this.options.showExport) { + var that = this, + $btnGroup = this.$toolbar.find('>.btn-group'), + $export = $btnGroup.find('div.export'); + + if (!$export.length) { + $export = $([ + '
    ', + '', + '', + '
    '].join('')).appendTo($btnGroup); + + var $menu = $export.find('.dropdown-menu'), + exportTypes = this.options.exportTypes; + + if (typeof this.options.exportTypes === 'string') { + var types = this.options.exportTypes.slice(1, -1).replace(/ /g, '').split(','); + + exportTypes = []; + $.each(types, function (i, value) { + exportTypes.push(value.slice(1, -1)); + }); + } + $.each(exportTypes, function (i, type) { + if (TYPE_NAME.hasOwnProperty(type)) { + $menu.append(['
  • ', + '', + TYPE_NAME[type], + '', + '
  • '].join('')); + } + }); + + $menu.find('li').click(function () { + var type = $(this).data('type'), + doExport = function () { + that.$el.tableExport($.extend({}, that.options.exportOptions, { + type: type, + escape: false + })); + }; + + if (that.options.exportDataType === 'all' && that.options.pagination) { + that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () { + doExport(); + that.togglePagination(); + }); + that.togglePagination(); + } else if (that.options.exportDataType === 'selected') { + //修改sidePagination属性为server无法导出选中数据 + var trs = that.$body.children(); + for (var i = 0; i < trs.length; i++) { + var $this = $(trs[i]); + if(!$this.find(sprintf('[name="%s"]',that.options.selectItemName)).prop('checked')){ + $this['hide'](); + }} + doExport(); + that.getRowsHidden(true); + } else { + doExport(); + } + }); + } + } + }; +})(jQuery); diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js index b37f6b050..5e717f2f1 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js @@ -1,2257 +1,2257 @@ -/** - * @preserve tableExport.jquery.plugin - * - * Version 1.9.8 - * - * Copyright (c) 2015-2017 hhurz, https://github.com/hhurz - * - * Original Work Copyright (c) 2014 Giri Raj - * - * Licensed under the MIT License - **/ - -(function ($) { - $.fn.tableExport = function (options) { - var defaults = { - consoleLog: false, - csvEnclosure: '"', - csvSeparator: ',', - csvUseBOM: true, - displayTableName: false, - escape: false, - excelFileFormat: 'xlshtml', // xmlss = XML Spreadsheet 2003 file format (XMLSS), xlshtml = Excel 2000 html format - excelRTL: false, // true = Set Excel option 'DisplayRightToLeft' - excelstyles: [], // e.g. ['border-bottom', 'border-top', 'border-left', 'border-right'] - exportHiddenCells: false, // true = speed up export of large tables with hidden cells (hidden cells will be exported !) - fileName: 'export', - htmlContent: false, - ignoreColumn: [], - ignoreRow: [], - jsonScope: 'all', // head, data, all - jspdf: { - orientation: 'p', - unit: 'pt', - format: 'a4', // jspdf page format or 'bestfit' for autmatic paper format selection - margins: {left: 20, right: 10, top: 10, bottom: 10}, - onDocCreated: null, - autotable: { - styles: { - cellPadding: 2, - rowHeight: 12, - fontSize: 8, - fillColor: 255, // color value or 'inherit' to use css background-color from html table - textColor: 50, // color value or 'inherit' to use css color from html table - fontStyle: 'normal', // normal, bold, italic, bolditalic or 'inherit' to use css font-weight and fonst-style from html table - overflow: 'ellipsize', // visible, hidden, ellipsize or linebreak - halign: 'left', // left, center, right - valign: 'middle' // top, middle, bottom - }, - headerStyles: { - fillColor: [52, 73, 94], - textColor: 255, - fontStyle: 'bold', - halign: 'center' - }, - alternateRowStyles: { - fillColor: 245 - }, - tableExport: { - doc: null, // jsPDF doc object. If set, an already created doc will be used to export to - onAfterAutotable: null, - onBeforeAutotable: null, - onAutotableText: null, - onTable: null, - outputImages: true - } - } - }, - numbers: { - html: { - decimalMark: '.', - thousandsSeparator: ',' - }, - output: { // set output: false to keep number format in exported output - decimalMark: '.', - thousandsSeparator: ',' - } - }, - onCellData: null, - onCellHtmlData: null, - onIgnoreRow: null, // onIgnoreRow($tr, rowIndex): function should return true to not export a row - onMsoNumberFormat: null, // Excel 2000 html format only. See readme.md for more information about msonumberformat - outputMode: 'file', // 'file', 'string', 'base64' or 'window' (experimental) - pdfmake: { - enabled: false, // true: use pdfmake instead of jspdf and jspdf-autotable (experimental) - docDefinition: { - pageOrientation: 'portrait', // 'portrait' or 'landscape' - defaultStyle: { - font: 'Roboto' // default is 'Roboto', for arabic font set this option to 'Mirza' and include mirza_fonts.js - } - }, - fonts: {} - }, - tbodySelector: 'tr', - tfootSelector: 'tr', // set empty ('') to prevent export of tfoot rows - theadSelector: 'tr', - tableName: 'Table', - type: 'csv', // 'csv', 'tsv', 'txt', 'sql', 'json', 'xml', 'excel', 'doc', 'png' or 'pdf' - worksheetName: '' - }; - - var FONT_ROW_RATIO = 1.15; - var el = this; - var DownloadEvt = null; - var $hrows = []; - var $rows = []; - var rowIndex = 0; - var trData = ''; - var colNames = []; - var ranges = []; - var blob; - var $hiddenTableElements = []; - var checkCellVisibilty = false; - - $.extend(true, defaults, options); - - colNames = GetColumnNames(el); - - if ( defaults.type == 'csv' || defaults.type == 'tsv' || defaults.type == 'txt' ) { - - var csvData = ""; - var rowlength = 0; - ranges = []; - rowIndex = 0; - - function csvString (cell, rowIndex, colIndex) { - var result = ''; - - if ( cell !== null ) { - var dataString = parseString(cell, rowIndex, colIndex); - - var csvValue = (dataString === null || dataString === '') ? '' : dataString.toString(); - - if ( defaults.type == 'tsv' ) { - if ( dataString instanceof Date ) - dataString.toLocaleString(); - - // According to http://www.iana.org/assignments/media-types/text/tab-separated-values - // are fields that contain tabs not allowable in tsv encoding - result = replaceAll(csvValue, '\t', ' '); - } - else { - // Takes a string and encapsulates it (by default in double-quotes) if it - // contains the csv field separator, spaces, or linebreaks. - if ( dataString instanceof Date ) - result = defaults.csvEnclosure + dataString.toLocaleString() + defaults.csvEnclosure; - else { - result = replaceAll(csvValue, defaults.csvEnclosure, defaults.csvEnclosure + defaults.csvEnclosure); - - if ( result.indexOf(defaults.csvSeparator) >= 0 || /[\r\n ]/g.test(result) ) - result = defaults.csvEnclosure + result + defaults.csvEnclosure; - } - } - } - - return result; - } - - var CollectCsvData = function ($rows, rowselector, length) { - - $rows.each(function () { - trData = ""; - ForEachVisibleCell(this, rowselector, rowIndex, length + $rows.length, - function (cell, row, col) { - trData += csvString(cell, row, col) + (defaults.type == 'tsv' ? '\t' : defaults.csvSeparator); - }); - trData = $.trim(trData).substring(0, trData.length - 1); - if ( trData.length > 0 ) { - - if ( csvData.length > 0 ) - csvData += "\n"; - - csvData += trData; - } - rowIndex++; - }); - - return $rows.length; - }; - - rowlength += CollectCsvData($(el).find('thead').first().find(defaults.theadSelector), 'th,td', rowlength); - findTablePart($(el),'tbody').each(function () { - rowlength += CollectCsvData(findRows($(this), defaults.tbodySelector), 'td,th', rowlength); - }); - if ( defaults.tfootSelector.length ) - CollectCsvData($(el).find('tfoot').first().find(defaults.tfootSelector), 'td,th', rowlength); - - csvData += "\n"; - - //output - if ( defaults.consoleLog === true ) - console.log(csvData); - - if ( defaults.outputMode === 'string' ) - return csvData; - - if ( defaults.outputMode === 'base64' ) - return base64encode(csvData); - - if ( defaults.outputMode === 'window' ) { - downloadFile(false, 'data:text/' + (defaults.type == 'csv' ? 'csv' : 'plain') + ';charset=utf-8,', csvData); - return; - } - - try { - blob = new Blob([csvData], {type: "text/" + (defaults.type == 'csv' ? 'csv' : 'plain') + ";charset=utf-8"}); - saveAs(blob, defaults.fileName + '.' + defaults.type, (defaults.type != 'csv' || defaults.csvUseBOM === false)); - } - catch (e) { - downloadFile(defaults.fileName + '.' + defaults.type, - 'data:text/' + (defaults.type == 'csv' ? 'csv' : 'plain') + ';charset=utf-8,' + ((defaults.type == 'csv' && defaults.csvUseBOM) ? '\ufeff' : ''), - csvData); - } - - } else if ( defaults.type == 'sql' ) { - - // Header - rowIndex = 0; - ranges = []; - var tdData = "INSERT INTO `" + defaults.tableName + "` ("; - $hrows = $(el).find('thead').first().find(defaults.theadSelector); - $hrows.each(function () { - ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, - function (cell, row, col) { - tdData += "'" + parseString(cell, row, col) + "',"; - }); - rowIndex++; - tdData = $.trim(tdData).substring(0, tdData.length - 1); - }); - tdData += ") VALUES "; - - // Data - $rows = collectRows ($(el)); - $($rows).each(function () { - trData = ""; - ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, - function (cell, row, col) { - trData += "'" + parseString(cell, row, col) + "',"; - }); - if ( trData.length > 3 ) { - tdData += "(" + trData; - tdData = $.trim(tdData).substring(0, tdData.length - 1); - tdData += "),"; - } - rowIndex++; - }); - - tdData = $.trim(tdData).substring(0, tdData.length - 1); - tdData += ";"; - - // Output - if ( defaults.consoleLog === true ) - console.log(tdData); - - if ( defaults.outputMode === 'string' ) - return tdData; - - if ( defaults.outputMode === 'base64' ) - return base64encode(tdData); - - try { - blob = new Blob([tdData], {type: "text/plain;charset=utf-8"}); - saveAs(blob, defaults.fileName + '.sql'); - } - catch (e) { - downloadFile(defaults.fileName + '.sql', - 'data:application/sql;charset=utf-8,', - tdData); - } - - } else if ( defaults.type == 'json' ) { - var jsonHeaderArray = []; - ranges = []; - $hrows = $(el).find('thead').first().find(defaults.theadSelector); - $hrows.each(function () { - var jsonArrayTd = []; - - ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, - function (cell, row, col) { - jsonArrayTd.push(parseString(cell, row, col)); - }); - jsonHeaderArray.push(jsonArrayTd); - }); - - // Data - var jsonArray = []; - - $rows = collectRows ($(el)); - $($rows).each(function () { - var jsonObjectTd = {}; - var colIndex = 0; - - ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, - function (cell, row, col) { - if ( jsonHeaderArray.length ) { - jsonObjectTd[jsonHeaderArray[jsonHeaderArray.length - 1][colIndex]] = parseString(cell, row, col); - } else { - jsonObjectTd[colIndex] = parseString(cell, row, col); - } - colIndex++; - }); - if ( $.isEmptyObject(jsonObjectTd) === false ) - jsonArray.push(jsonObjectTd); - - rowIndex++; - }); - - var sdata = ""; - - if ( defaults.jsonScope == 'head' ) - sdata = JSON.stringify(jsonHeaderArray); - else if ( defaults.jsonScope == 'data' ) - sdata = JSON.stringify(jsonArray); - else // all - sdata = JSON.stringify({header: jsonHeaderArray, data: jsonArray}); - - if ( defaults.consoleLog === true ) - console.log(sdata); - - if ( defaults.outputMode === 'string' ) - return sdata; - - if ( defaults.outputMode === 'base64' ) - return base64encode(sdata); - - try { - blob = new Blob([sdata], {type: "application/json;charset=utf-8"}); - saveAs(blob, defaults.fileName + '.json'); - } - catch (e) { - downloadFile(defaults.fileName + '.json', - 'data:application/json;charset=utf-8;base64,', - sdata); - } - - } else if ( defaults.type === 'xml' ) { - rowIndex = 0; - ranges = []; - var xml = ''; - xml += ''; - - // Header - $hrows = $(el).find('thead').first().find(defaults.theadSelector); - $hrows.each(function () { - - ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, - function (cell, row, col) { - xml += "" + parseString(cell, row, col) + ""; - }); - rowIndex++; - }); - xml += ''; - - // Data - var rowCount = 1; - - $rows = collectRows ($(el)); - $($rows).each(function () { - var colCount = 1; - trData = ""; - ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, - function (cell, row, col) { - trData += "" + parseString(cell, row, col) + ""; - colCount++; - }); - if ( trData.length > 0 && trData != "" ) { - xml += '' + trData + ''; - rowCount++; - } - - rowIndex++; - }); - xml += ''; - - // Output - if ( defaults.consoleLog === true ) - console.log(xml); - - if ( defaults.outputMode === 'string' ) - return xml; - - if ( defaults.outputMode === 'base64' ) - return base64encode(xml); - - try { - blob = new Blob([xml], {type: "application/xml;charset=utf-8"}); - saveAs(blob, defaults.fileName + '.xml'); - } - catch (e) { - downloadFile(defaults.fileName + '.xml', - 'data:application/xml;charset=utf-8;base64,', - xml); - } - } - else if ( defaults.type === 'excel' && defaults.excelFileFormat === 'xmlss' ) { - var docDatas = []; - var docNames = []; - - $(el).filter(function () { - return isVisible($(this)); - }).each(function () { - var $table = $(this); - - var ssName = ''; - if ( typeof defaults.worksheetName === 'string' && defaults.worksheetName.length ) - ssName = defaults.worksheetName + ' ' + (docNames.length + 1); - else if ( typeof defaults.worksheetName[docNames.length] !== 'undefined' ) - ssName = defaults.worksheetName[docNames.length]; - if ( ! ssName.length ) - ssName = $table.find('caption').text() || ''; - if ( ! ssName.length ) - ssName = 'Table ' + (docNames.length + 1); - ssName = $.trim(ssName.replace(/[\\\/[\]*:?'"]/g,'').substring(0,31)); - - docNames.push($('
    ').text(ssName).html()); - - if ( defaults.exportHiddenCells === false ) { - $hiddenTableElements = $table.find("tr, th, td").filter(":hidden"); - checkCellVisibilty = $hiddenTableElements.length > 0; - } - - rowIndex = 0; - colNames = GetColumnNames(this); - docData = '\r'; - - function CollectXmlssData ($rows, rowselector, length) { - var spans = []; - - $($rows).each(function () { - var ssIndex = 0; - var nCols = 0; - trData = ""; - - ForEachVisibleCell(this, 'td,th', rowIndex, length + $rows.length, - function (cell, row, col) { - if ( cell !== null ) { - var style = ""; - var data = parseString(cell, row, col); - var type = "String"; - - if ( jQuery.isNumeric(data) !== false ) { - type = "Number"; - } - else { - var number = parsePercent(data); - if ( number !== false ) { - data = number; - type = "Number"; - style += ' ss:StyleID="pct1"'; - } - } - - if ( type !== "Number" ) - data = data.replace(/\n/g, '
    '); - - var colspan = parseInt(cell.getAttribute('colspan')); - var rowspan = parseInt(cell.getAttribute('rowspan')); - - // Skip spans - $.each(spans, function () { - var range = this; - if ( rowIndex >= range.s.r && rowIndex <= range.e.r && nCols >= range.s.c && nCols <= range.e.c ) { - for ( var i = 0; i <= range.e.c - range.s.c; ++i ) { - nCols++; - ssIndex++; - } - } - }); - - // Handle Row Span - if ( rowspan || colspan ) { - rowspan = rowspan || 1; - colspan = colspan || 1; - spans.push({ - s: {r: rowIndex, c: nCols}, - e: {r: rowIndex + rowspan - 1, c: nCols + colspan - 1} - }); - } - - // Handle Colspan - if ( colspan > 1 ) { - style += ' ss:MergeAcross="' + (colspan-1) + '"'; - nCols += (colspan - 1); - } - - if ( rowspan > 1 ) { - style += ' ss:MergeDown="' + (rowspan-1) + '" ss:StyleID="rsp1"'; - } - - if ( ssIndex > 0 ) { - style += ' ss:Index="' + (nCols+1) + '"'; - ssIndex = 0; - } - - trData += '' + - $('
    ').text(data).html() + - '\r'; - nCols++; - } - }); - if ( trData.length > 0 ) - docData += '\r' + trData + '\r'; - rowIndex++; - }); - - return $rows.length; - } - - var rowLength = 0; - rowLength += CollectXmlssData ($table.find('thead').first().find(defaults.theadSelector), 'th,td', rowLength); - CollectXmlssData (collectRows ($table), 'td,th', rowLength); - - docData += '
    \r'; - docDatas.push(docData); - - if ( defaults.consoleLog === true ) - console.log(docData); - }); - - var count = {}; - var firstOccurences = {}; - var item, itemCount; - for (var n = 0, c = docNames.length; n < c; n++) - { - item = docNames[n]; - itemCount = count[item]; - itemCount = count[item] = (itemCount == null ? 1 : itemCount + 1); - - if( itemCount == 2 ) - docNames[firstOccurences[item]] = docNames[firstOccurences[item]].substring(0,29) + "-1"; - if( count[ item ] > 1 ) - docNames[n] = docNames[n].substring(0,29) + "-" + count[item]; - else - firstOccurences[item] = n; - } - - var CreationDate = new Date().toISOString(); - var xmlssDocFile = '\r' + - '\r' + - '\r' + - '\r' + - ' ' + CreationDate + '\r' + - '\r' + - '\r' + - ' \r' + - '\r' + - '\r' + - ' 9000\r' + - ' 13860\r' + - ' 0\r' + - ' 0\r' + - ' False\r' + - ' False\r' + - '\r' + - '\r' + - ' \r' + - ' \r' + - ' \r' + - '\r'; - - for ( var j = 0; j < docDatas.length; j++ ) { - xmlssDocFile += '\r' + - docDatas[j]; - if (defaults.excelRTL) { - xmlssDocFile += '\r' + - '\r' + - '\r'; - } - else - xmlssDocFile += '\r'; - xmlssDocFile += '\r'; - } - - xmlssDocFile += '\r'; - - if ( defaults.consoleLog === true ) - console.log(xmlssDocFile); - - if ( defaults.outputMode === 'string' ) - return xmlssDocFile; - - if ( defaults.outputMode === 'base64' ) - return base64encode(xmlssDocFile); - - try { - blob = new Blob([xmlssDocFile], {type: "application/xml;charset=utf-8"}); - saveAs(blob, defaults.fileName + '.xml'); - } - catch (e) { - downloadFile(defaults.fileName + '.xml', - 'data:application/xml;charset=utf-8;base64,', - xmlssDocFile); - } - } - else if ( defaults.type == 'excel' || defaults.type == 'xls' || defaults.type == 'word' || defaults.type == 'doc' ) { - - var MSDocType = (defaults.type == 'excel' || defaults.type == 'xls') ? 'excel' : 'word'; - var MSDocExt = (MSDocType == 'excel') ? 'xls' : 'doc'; - var MSDocSchema = 'xmlns:x="urn:schemas-microsoft-com:office:' + MSDocType + '"'; - var docData = ''; - var docName = ''; - - $(el).filter(function () { - return isVisible($(this)); - }).each(function () { - var $table = $(this); - - if (docName === '') { - docName = defaults.worksheetName || $table.find('caption').text() || 'Table'; - docName = $.trim(docName.replace(/[\\\/[\]*:?'"]/g, '').substring(0, 31)); - } - - if ( defaults.exportHiddenCells === false ) { - $hiddenTableElements = $table.find("tr, th, td").filter(":hidden"); - checkCellVisibilty = $hiddenTableElements.length > 0; - } - - rowIndex = 0; - ranges = []; - colNames = GetColumnNames(this); - - // Header - docData += ''; - $hrows = $table.find('thead').first().find(defaults.theadSelector); - $hrows.each(function () { - trData = ""; - ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, - function (cell, row, col) { - if ( cell !== null ) { - var thstyle = ''; - trData += ''; - } - }); - if ( trData.length > 0 ) - docData += '' + trData + ''; - rowIndex++; - }); - docData += ''; - - // Data - $rows = collectRows ($table); - $($rows).each(function () { - var $row = $(this); - trData = ""; - ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, - function (cell, row, col) { - if ( cell !== null ) { - var tdvalue = parseString(cell, row, col); - var tdstyle = ''; - var tdcss = $(cell).data("tableexport-msonumberformat"); - - if ( typeof tdcss == 'undefined' && typeof defaults.onMsoNumberFormat === 'function' ) - tdcss = defaults.onMsoNumberFormat(cell, row, col); - - if ( typeof tdcss != 'undefined' && tdcss !== '' ) - tdstyle = 'style="mso-number-format:\'' + tdcss + '\''; - - for ( var cssStyle in defaults.excelstyles ) { - if ( defaults.excelstyles.hasOwnProperty(cssStyle) ) { - tdcss = $(cell).css(defaults.excelstyles[cssStyle]); - if ( tdcss === '' ) - tdcss = $row.css(defaults.excelstyles[cssStyle]); - - if ( tdcss !== '' && tdcss != '0px none rgb(0, 0, 0)' && tdcss != 'rgba(0, 0, 0, 0)' ) { - tdstyle += (tdstyle === '') ? 'style="' : ';'; - tdstyle += defaults.excelstyles[cssStyle] + ':' + tdcss; - } - } - } - trData += ''); - - trData += '>' + tdvalue + ''; - } - }); - if ( trData.length > 0 ) - docData += '' + trData + ''; - rowIndex++; - }); - - if ( defaults.displayTableName ) - docData += ''; - - docData += '
    ' + parseString($('

    ' + defaults.tableName + '

    ')) + '
    '; - - if ( defaults.consoleLog === true ) - console.log(docData); - }); - - //noinspection XmlUnusedNamespaceDeclaration - var docFile = ''; - docFile += ''; - docFile += ""; - if (MSDocType === 'excel') { - docFile += ""; - } - docFile += ""; - docFile += ""; - docFile += ""; - docFile += docData; - docFile += ""; - docFile += ""; - - if ( defaults.consoleLog === true ) - console.log(docFile); - - if ( defaults.outputMode === 'string' ) - return docFile; - - if ( defaults.outputMode === 'base64' ) - return base64encode(docFile); - - try { - blob = new Blob([docFile], {type: 'application/vnd.ms-' + defaults.type}); - saveAs(blob, defaults.fileName + '.' + MSDocExt); - } - catch (e) { - downloadFile(defaults.fileName + '.' + MSDocExt, - 'data:application/vnd.ms-' + MSDocType + ';base64,', - docFile); - } - - } else if ( defaults.type == 'xlsx' ) { - - var data = []; - var spans = []; - rowIndex = 0; - - $rows = $(el).find('thead').first().find(defaults.theadSelector).toArray(); - $rows.push.apply($rows, collectRows ($(el))); - - $($rows).each(function () { - var cols = []; - ForEachVisibleCell(this, 'th,td', rowIndex, $rows.length, - function (cell, row, col) { - if ( typeof cell !== 'undefined' && cell !== null ) { - - var cellValue = parseString(cell, row, col); - - var colspan = parseInt(cell.getAttribute('colspan')); - var rowspan = parseInt(cell.getAttribute('rowspan')); - - // Skip span ranges - $.each(spans, function () { - var range = this; - if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cols.length >= range.s.c && cols.length <= range.e.c ) { - for ( var i = 0; i <= range.e.c - range.s.c; ++i ) - cols.push(null); - } - }); - - // Handle Row Span - if ( rowspan || colspan ) { - rowspan = rowspan || 1; - colspan = colspan || 1; - spans.push({ - s: {r: rowIndex, c: cols.length}, - e: {r: rowIndex + rowspan - 1, c: cols.length + colspan - 1} - }); - } - - // Handle Value - if ( typeof defaults.onCellData !== 'function' ) { - - // Type conversion - if ( cellValue !== "" && cellValue == +cellValue ) - cellValue = +cellValue; - } - cols.push(cellValue !== "" ? cellValue : null); - - // Handle Colspan - if ( colspan ) - for ( var k = 0; k < colspan - 1; ++k ) - cols.push(null); - } - }); - data.push(cols); - rowIndex++; - }); - - //noinspection JSPotentiallyInvalidConstructorUsage - var wb = new jx_Workbook(), - ws = jx_createSheet(data); - - // add span ranges to worksheet - ws['!merges'] = spans; - - // add worksheet to workbook - wb.SheetNames.push(defaults.worksheetName); - wb.Sheets[defaults.worksheetName] = ws; - - var wbout = XLSX.write(wb, {bookType: defaults.type, bookSST: false, type: 'binary'}); - - try { - blob = new Blob([jx_s2ab(wbout)], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'}); - saveAs(blob, defaults.fileName + '.' + defaults.type); - } - catch (e) { - downloadFile(defaults.fileName + '.' + defaults.type, - 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8,', - jx_s2ab(wbout)); - } - - } else if ( defaults.type == 'png' ) { - //html2canvas($(el)[0], { - // onrendered: function (canvas) { - html2canvas($(el)[0]).then( - function (canvas) { - - var image = canvas.toDataURL(); - var byteString = atob(image.substring(22)); // remove data stuff - var buffer = new ArrayBuffer(byteString.length); - var intArray = new Uint8Array(buffer); - - for ( var i = 0; i < byteString.length; i++ ) - intArray[i] = byteString.charCodeAt(i); - - if ( defaults.consoleLog === true ) - console.log(byteString); - - if ( defaults.outputMode === 'string' ) - return byteString; - - if ( defaults.outputMode === 'base64' ) - return base64encode(image); - - if ( defaults.outputMode === 'window' ) { - window.open(image); - return; - } - - try { - blob = new Blob([buffer], {type: "image/png"}); - saveAs(blob, defaults.fileName + '.png'); - } - catch (e) { - downloadFile(defaults.fileName + '.png', 'data:image/png,', blob); - } - //} - }); - - } else if ( defaults.type == 'pdf' ) { - - if ( defaults.pdfmake.enabled === true ) { - // pdf output using pdfmake - // https://github.com/bpampuch/pdfmake - - var widths = []; - var body = []; - rowIndex = 0; - ranges = []; - - var CollectPdfmakeData = function ($rows, colselector, length) { - var rlength = 0; - - $($rows).each(function () { - var r = []; - - ForEachVisibleCell(this, colselector, rowIndex, length, - function (cell, row, col) { - if ( typeof cell !== 'undefined' && cell !== null ) { - - var colspan = parseInt(cell.getAttribute('colspan')); - var rowspan = parseInt(cell.getAttribute('rowspan')); - - var cellValue = parseString(cell, row, col) || " "; - - if ( colspan > 1 || rowspan > 1 ) { - colspan = colspan || 1; - rowspan = rowspan || 1; - r.push({colSpan: colspan, rowSpan: rowspan, text: cellValue}); - } - else - r.push(cellValue); - } - else - r.push(" "); - }); - - if ( r.length ) - body.push(r); - - if ( rlength < r.length ) - rlength = r.length; - - rowIndex++; - }); - - return rlength; - }; - - $hrows = $(this).find('thead').first().find(defaults.theadSelector); - - var colcount = CollectPdfmakeData($hrows, 'th,td', $hrows.length); - - for ( var i = widths.length; i < colcount; i++ ) - widths.push("*"); - - // Data - $rows = collectRows ($(this)); - - CollectPdfmakeData($rows, 'th,td', $hrows.length + $rows.length); - - var docDefinition = { - content: [{ - table: { - headerRows: $hrows.length, - widths: widths, - body: body - } - }] - }; - - $.extend(true, docDefinition, defaults.pdfmake.docDefinition); - - pdfMake.fonts = { - Roboto: { - normal: 'Roboto-Regular.ttf', - bold: 'Roboto-Medium.ttf', - italics: 'Roboto-Italic.ttf', - bolditalics: 'Roboto-MediumItalic.ttf' - } - }; - - $.extend(true, pdfMake.fonts, defaults.pdfmake.fonts); - - pdfMake.createPdf(docDefinition).getBuffer(function (buffer) { - - try { - var blob = new Blob([buffer], {type: "application/pdf"}); - saveAs(blob, defaults.fileName + '.pdf'); - } - catch (e) { - downloadFile(defaults.fileName + '.pdf', - 'data:application/pdf;base64,', - buffer); - } - }); - - } - else if ( defaults.jspdf.autotable === false ) { - // pdf output using jsPDF's core html support - - var addHtmlOptions = { - dim: { - w: getPropertyUnitValue($(el).first().get(0), 'width', 'mm'), - h: getPropertyUnitValue($(el).first().get(0), 'height', 'mm') - }, - pagesplit: false - }; - - var doc = new jsPDF(defaults.jspdf.orientation, defaults.jspdf.unit, defaults.jspdf.format); - doc.addHTML($(el).first(), - defaults.jspdf.margins.left, - defaults.jspdf.margins.top, - addHtmlOptions, - function () { - jsPdfOutput(doc, false); - }); - //delete doc; - } - else { - // pdf output using jsPDF AutoTable plugin - // https://github.com/simonbengtsson/jsPDF-AutoTable - - var teOptions = defaults.jspdf.autotable.tableExport; - - // When setting jspdf.format to 'bestfit' tableExport tries to choose - // the minimum required paper format and orientation in which the table - // (or tables in multitable mode) completely fits without column adjustment - if ( typeof defaults.jspdf.format === 'string' && defaults.jspdf.format.toLowerCase() === 'bestfit' ) { - var pageFormats = { - 'a0': [2383.94, 3370.39], 'a1': [1683.78, 2383.94], - 'a2': [1190.55, 1683.78], 'a3': [841.89, 1190.55], - 'a4': [595.28, 841.89] - }; - var rk = '', ro = ''; - var mw = 0; - - $(el).each(function () { - if ( isVisible($(this)) ) { - var w = getPropertyUnitValue($(this).get(0), 'width', 'pt'); - - if ( w > mw ) { - if ( w > pageFormats.a0[0] ) { - rk = 'a0'; - ro = 'l'; - } - for ( var key in pageFormats ) { - if ( pageFormats.hasOwnProperty(key) ) { - if ( pageFormats[key][1] > w ) { - rk = key; - ro = 'l'; - if ( pageFormats[key][0] > w ) - ro = 'p'; - } - } - } - mw = w; - } - } - }); - defaults.jspdf.format = (rk === '' ? 'a4' : rk); - defaults.jspdf.orientation = (ro === '' ? 'w' : ro); - } - - // The jsPDF doc object is stored in defaults.jspdf.autotable.tableExport, - // thus it can be accessed from any callback function - if ( teOptions.doc == null ) { - teOptions.doc = new jsPDF(defaults.jspdf.orientation, - defaults.jspdf.unit, - defaults.jspdf.format); - - if ( typeof defaults.jspdf.onDocCreated === 'function' ) - defaults.jspdf.onDocCreated(teOptions.doc); - } - - if ( teOptions.outputImages === true ) - teOptions.images = {}; - - if ( typeof teOptions.images != 'undefined' ) { - $(el).filter(function () { - return isVisible($(this)); - }).each(function () { - var rowCount = 0; - ranges = []; - - if ( defaults.exportHiddenCells === false ) { - $hiddenTableElements = $(this).find("tr, th, td").filter(":hidden"); - checkCellVisibilty = $hiddenTableElements.length > 0; - } - - $hrows = $(this).find('thead').find(defaults.theadSelector); - $rows = collectRows ($(this)); - - $($rows).each(function () { - ForEachVisibleCell(this, 'td,th', $hrows.length + rowCount, $hrows.length + $rows.length, - function (cell) { - if ( typeof cell !== 'undefined' && cell !== null ) { - var kids = $(cell).children(); - if ( typeof kids != 'undefined' && kids.length > 0 ) - collectImages(cell, kids, teOptions); - } - }); - rowCount++; - }); - }); - - $hrows = []; - $rows = []; - } - - loadImages(teOptions, function () { - $(el).filter(function () { - return isVisible($(this)); - }).each(function () { - var colKey; - rowIndex = 0; - ranges = []; - - if ( defaults.exportHiddenCells === false ) { - $hiddenTableElements = $(this).find("tr, th, td").filter(":hidden"); - checkCellVisibilty = $hiddenTableElements.length > 0; - } - - colNames = GetColumnNames(this); - - teOptions.columns = []; - teOptions.rows = []; - teOptions.rowoptions = {}; - - // onTable: optional callback function for every matching table that can be used - // to modify the tableExport options or to skip the output of a particular table - // if the table selector targets multiple tables - if ( typeof teOptions.onTable === 'function' ) - if ( teOptions.onTable($(this), defaults) === false ) - return true; // continue to next iteration step (table) - - // each table works with an own copy of AutoTable options - defaults.jspdf.autotable.tableExport = null; // avoid deep recursion error - var atOptions = $.extend(true, {}, defaults.jspdf.autotable); - defaults.jspdf.autotable.tableExport = teOptions; - - atOptions.margin = {}; - $.extend(true, atOptions.margin, defaults.jspdf.margins); - atOptions.tableExport = teOptions; - - // Fix jsPDF Autotable's row height calculation - if ( typeof atOptions.beforePageContent !== 'function' ) { - atOptions.beforePageContent = function (data) { - if ( data.pageCount == 1 ) { - var all = data.table.rows.concat(data.table.headerRow); - $.each(all, function () { - var row = this; - if ( row.height > 0 ) { - row.height += (2 - FONT_ROW_RATIO) / 2 * row.styles.fontSize; - data.table.height += (2 - FONT_ROW_RATIO) / 2 * row.styles.fontSize; - } - }); - } - }; - } - - if ( typeof atOptions.createdHeaderCell !== 'function' ) { - // apply some original css styles to pdf header cells - atOptions.createdHeaderCell = function (cell, data) { - - // jsPDF AutoTable plugin v2.0.14 fix: each cell needs its own styles object - cell.styles = $.extend({}, data.row.styles); - - if ( typeof teOptions.columns [data.column.dataKey] != 'undefined' ) { - var col = teOptions.columns [data.column.dataKey]; - - if ( typeof col.rect != 'undefined' ) { - var rh; - - cell.contentWidth = col.rect.width; - - if ( typeof teOptions.heightRatio == 'undefined' || teOptions.heightRatio === 0 ) { - if ( data.row.raw [data.column.dataKey].rowspan ) - rh = data.row.raw [data.column.dataKey].rect.height / data.row.raw [data.column.dataKey].rowspan; - else - rh = data.row.raw [data.column.dataKey].rect.height; - - teOptions.heightRatio = cell.styles.rowHeight / rh; - } - - rh = data.row.raw [data.column.dataKey].rect.height * teOptions.heightRatio; - if ( rh > cell.styles.rowHeight ) - cell.styles.rowHeight = rh; - } - - if ( typeof col.style != 'undefined' && col.style.hidden !== true ) { - cell.styles.halign = col.style.align; - if ( atOptions.styles.fillColor === 'inherit' ) - cell.styles.fillColor = col.style.bcolor; - if ( atOptions.styles.textColor === 'inherit' ) - cell.styles.textColor = col.style.color; - if ( atOptions.styles.fontStyle === 'inherit' ) - cell.styles.fontStyle = col.style.fstyle; - } - } - }; - } - - if ( typeof atOptions.createdCell !== 'function' ) { - // apply some original css styles to pdf table cells - atOptions.createdCell = function (cell, data) { - var rowopt = teOptions.rowoptions [data.row.index + ":" + data.column.dataKey]; - - if ( typeof rowopt != 'undefined' && - typeof rowopt.style != 'undefined' && - rowopt.style.hidden !== true ) { - cell.styles.halign = rowopt.style.align; - if ( atOptions.styles.fillColor === 'inherit' ) - cell.styles.fillColor = rowopt.style.bcolor; - if ( atOptions.styles.textColor === 'inherit' ) - cell.styles.textColor = rowopt.style.color; - if ( atOptions.styles.fontStyle === 'inherit' ) - cell.styles.fontStyle = rowopt.style.fstyle; - } - }; - } - - if ( typeof atOptions.drawHeaderCell !== 'function' ) { - atOptions.drawHeaderCell = function (cell, data) { - var colopt = teOptions.columns [data.column.dataKey]; - - if ( (colopt.style.hasOwnProperty("hidden") !== true || colopt.style.hidden !== true) && - colopt.rowIndex >= 0 ) - return prepareAutoTableText(cell, data, colopt); - else - return false; // cell is hidden - }; - } - - if ( typeof atOptions.drawCell !== 'function' ) { - atOptions.drawCell = function (cell, data) { - var rowopt = teOptions.rowoptions [data.row.index + ":" + data.column.dataKey]; - if ( prepareAutoTableText(cell, data, rowopt) ) { - - teOptions.doc.rect(cell.x, cell.y, cell.width, cell.height, cell.styles.fillStyle); - - if ( typeof rowopt != 'undefined' && typeof rowopt.kids != 'undefined' && rowopt.kids.length > 0 ) { - - var dh = cell.height / rowopt.rect.height; - if ( dh > teOptions.dh || typeof teOptions.dh == 'undefined' ) - teOptions.dh = dh; - teOptions.dw = cell.width / rowopt.rect.width; - - var y = cell.textPos.y; - drawAutotableElements(cell, rowopt.kids, teOptions); - cell.textPos.y = y; - drawAutotableText(cell, rowopt.kids, teOptions); - } - else - drawAutotableText(cell, {}, teOptions); - } - return false; - }; - } - - // collect header and data rows - teOptions.headerrows = []; - $hrows = $(this).find('thead').find(defaults.theadSelector); - $hrows.each(function () { - colKey = 0; - teOptions.headerrows[rowIndex] = []; - - ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, - function (cell, row, col) { - var obj = getCellStyles(cell); - obj.title = parseString(cell, row, col); - obj.key = colKey++; - obj.rowIndex = rowIndex; - teOptions.headerrows[rowIndex].push(obj); - }); - rowIndex++; - }); - - if ( rowIndex > 0 ) { - // iterate through last row - var lastrow = rowIndex - 1; - while ( lastrow >= 0 ) { - $.each(teOptions.headerrows[lastrow], function () { - var obj = this; - - if ( lastrow > 0 && this.rect === null ) - obj = teOptions.headerrows[lastrow - 1][this.key]; - - if ( obj !== null && obj.rowIndex >= 0 && - (obj.style.hasOwnProperty("hidden") !== true || obj.style.hidden !== true) ) - teOptions.columns.push(obj); - }); - - lastrow = (teOptions.columns.length > 0) ? -1 : lastrow - 1; - } - } - - var rowCount = 0; - $rows = []; - $rows = collectRows ($(this)); - $($rows).each(function () { - var rowData = []; - colKey = 0; - - ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, - function (cell, row, col) { - var obj; - - if ( typeof teOptions.columns[colKey] === 'undefined' ) { - // jsPDF-Autotable needs columns. Thus define hidden ones for tables without thead - obj = { - title: '', - key: colKey, - style: { - hidden: true - } - }; - teOptions.columns.push(obj); - } - if ( typeof cell !== 'undefined' && cell !== null ) { - obj = getCellStyles(cell); - obj.kids = $(cell).children(); - teOptions.rowoptions [rowCount + ":" + colKey++] = obj; - } - else { - obj = $.extend(true, {}, teOptions.rowoptions [rowCount + ":" + (colKey - 1)]); - obj.colspan = -1; - teOptions.rowoptions [rowCount + ":" + colKey++] = obj; - } - - rowData.push(parseString(cell, row, col)); - }); - if ( rowData.length ) { - teOptions.rows.push(rowData); - rowCount++; - } - rowIndex++; - }); - - // onBeforeAutotable: optional callback function before calling - // jsPDF AutoTable that can be used to modify the AutoTable options - if ( typeof teOptions.onBeforeAutotable === 'function' ) - teOptions.onBeforeAutotable($(this), teOptions.columns, teOptions.rows, atOptions); - - teOptions.doc.autoTable(teOptions.columns, teOptions.rows, atOptions); - - // onAfterAutotable: optional callback function after returning - // from jsPDF AutoTable that can be used to modify the AutoTable options - if ( typeof teOptions.onAfterAutotable === 'function' ) - teOptions.onAfterAutotable($(this), atOptions); - - // set the start position for the next table (in case there is one) - defaults.jspdf.autotable.startY = teOptions.doc.autoTableEndPosY() + atOptions.margin.top; - - }); - - jsPdfOutput(teOptions.doc, (typeof teOptions.images != 'undefined' && jQuery.isEmptyObject(teOptions.images) === false)); - - if ( typeof teOptions.headerrows != 'undefined' ) - teOptions.headerrows.length = 0; - if ( typeof teOptions.columns != 'undefined' ) - teOptions.columns.length = 0; - if ( typeof teOptions.rows != 'undefined' ) - teOptions.rows.length = 0; - delete teOptions.doc; - teOptions.doc = null; - }); - } - } - - /* - function FindColObject (objects, colIndex, rowIndex) { - var result = null; - $.each(objects, function () { - if ( this.rowIndex == rowIndex && this.key == colIndex ) { - result = this; - return false; - } - }); - return result; - } - */ - function collectRows ($table) { - var result = []; - findTablePart($table,'tbody').each(function () { - result.push.apply(result, findRows($(this), defaults.tbodySelector).toArray()); - }); - if ( defaults.tfootSelector.length ) { - findTablePart($table,'tfoot').each(function () { - result.push.apply(result, findRows($(this), defaults.tfootSelector).toArray()); - }); - } - return result; - } - - function findTablePart ($table, type) { - var tl = $table.parents('table').length; - return $table.find(type).filter (function () { - return $(this).closest('table').parents('table').length === tl; - }); - } - - function findRows ($tpart, rowSelector) { - return $tpart.find(rowSelector).filter (function () { - return $(this).find('table').length === 0 && $(this).parents('table').length === 1; - }); - } - - function GetColumnNames (table) { - var result = []; - $(table).find('thead').first().find('th').each(function (index, el) { - if ( $(el).attr("data-field") !== undefined ) - result[index] = $(el).attr("data-field"); - else - result[index] = index.toString(); - }); - return result; - } - - function isVisible ($element) { - var isCell = typeof $element[0].cellIndex !== 'undefined'; - var isRow = typeof $element[0].rowIndex !== 'undefined'; - var isElementVisible = (isCell || isRow) ? isTableElementVisible($element) : $element.is(':visible'); - var tableexportDisplay = $element.data("tableexport-display"); - - if (isCell && tableexportDisplay != 'none' && tableexportDisplay != 'always') { - $element = $($element[0].parentNode); - isRow = typeof $element[0].rowIndex !== 'undefined'; - tableexportDisplay = $element.data("tableexport-display"); - } - if (isRow && tableexportDisplay != 'none' && tableexportDisplay != 'always') { - tableexportDisplay = $element.closest('table').data("tableexport-display"); - } - - return tableexportDisplay !== 'none' && (isElementVisible == true || tableexportDisplay == 'always'); - } - - function isTableElementVisible ($element) { - var hiddenEls = []; - - if ( checkCellVisibilty ) { - hiddenEls = $hiddenTableElements.filter (function () { - var found = false; - - if (this.nodeType == $element[0].nodeType) { - if (typeof this.rowIndex !== 'undefined' && this.rowIndex == $element[0].rowIndex) - found = true; - else if (typeof this.cellIndex !== 'undefined' && this.cellIndex == $element[0].cellIndex && - typeof this.parentNode.rowIndex !== 'undefined' && - typeof $element[0].parentNode.rowIndex !== 'undefined' && - this.parentNode.rowIndex == $element[0].parentNode.rowIndex) - found = true; - } - return found; - }); - } - return (checkCellVisibilty == false || hiddenEls.length == 0); - } - - function isColumnIgnored ($cell, rowLength, colIndex) { - var result = false; - - if (isVisible($cell)) { - if ( defaults.ignoreColumn.length > 0 ) { - if ( $.inArray(colIndex, defaults.ignoreColumn) != -1 || - $.inArray(colIndex - rowLength, defaults.ignoreColumn) != -1 || - (colNames.length > colIndex && typeof colNames[colIndex] != 'undefined' && - $.inArray(colNames[colIndex], defaults.ignoreColumn) != -1) ) - result = true; - } - } - else - result = true; - - return result; - } - - function ForEachVisibleCell (tableRow, selector, rowIndex, rowCount, cellcallback) { - if ( typeof (cellcallback) === 'function' ) { - var ignoreRow = false; - - if (typeof defaults.onIgnoreRow === 'function') - ignoreRow = defaults.onIgnoreRow($(tableRow), rowIndex); - - if (ignoreRow === false && - $.inArray(rowIndex, defaults.ignoreRow) == -1 && - $.inArray(rowIndex - rowCount, defaults.ignoreRow) == -1 && - isVisible($(tableRow))) { - - var $cells = $(tableRow).find(selector); - var cellCount = 0; - - $cells.each(function (colIndex) { - var $cell = $(this); - var c; - var colspan = parseInt(this.getAttribute('colspan')); - var rowspan = parseInt(this.getAttribute('rowspan')); - - // Skip ranges - $.each(ranges, function () { - var range = this; - if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cellCount >= range.s.c && cellCount <= range.e.c ) { - for ( c = 0; c <= range.e.c - range.s.c; ++c ) - cellcallback(null, rowIndex, cellCount++); - } - }); - - if ( isColumnIgnored($cell, $cells.length, colIndex) === false ) { - // Handle Row Span - if ( rowspan || colspan ) { - rowspan = rowspan || 1; - colspan = colspan || 1; - ranges.push({ - s: {r: rowIndex, c: cellCount}, - e: {r: rowIndex + rowspan - 1, c: cellCount + colspan - 1} - }); - } - - // Handle Value - cellcallback(this, rowIndex, cellCount++); - } - - // Handle Colspan - if ( colspan ) - for ( c = 0; c < colspan - 1; ++c ) - cellcallback(null, rowIndex, cellCount++); - }); - - // Skip ranges - $.each(ranges, function () { - var range = this; - if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cellCount >= range.s.c && cellCount <= range.e.c ) { - for ( c = 0; c <= range.e.c - range.s.c; ++c ) - cellcallback(null, rowIndex, cellCount++); - } - }); - } - } - } - - function jsPdfOutput (doc, hasimages) { - if ( defaults.consoleLog === true ) - console.log(doc.output()); - - if ( defaults.outputMode === 'string' ) - return doc.output(); - - if ( defaults.outputMode === 'base64' ) - return base64encode(doc.output()); - - if ( defaults.outputMode === 'window' ) { - window.URL = window.URL || window.webkitURL; - window.open(window.URL.createObjectURL(doc.output("blob"))); - return; - } - - try { - var blob = doc.output('blob'); - saveAs(blob, defaults.fileName + '.pdf'); - } - catch (e) { - downloadFile(defaults.fileName + '.pdf', - 'data:application/pdf' + (hasimages ? '' : ';base64') + ',', - hasimages ? doc.output('blob') : doc.output()); - } - } - - function prepareAutoTableText (cell, data, cellopt) { - var cs = 0; - if ( typeof cellopt !== 'undefined' ) - cs = cellopt.colspan; - - if ( cs >= 0 ) { - // colspan handling - var cellWidth = cell.width; - var textPosX = cell.textPos.x; - var i = data.table.columns.indexOf(data.column); - - for ( var c = 1; c < cs; c++ ) { - var column = data.table.columns[i + c]; - cellWidth += column.width; - } - - if ( cs > 1 ) { - if ( cell.styles.halign === 'right' ) - textPosX = cell.textPos.x + cellWidth - cell.width; - else if ( cell.styles.halign === 'center' ) - textPosX = cell.textPos.x + (cellWidth - cell.width) / 2; - } - - cell.width = cellWidth; - cell.textPos.x = textPosX; - - if ( typeof cellopt !== 'undefined' && cellopt.rowspan > 1 ) - cell.height = cell.height * cellopt.rowspan; - - // fix jsPDF's calculation of text position - if ( cell.styles.valign === 'middle' || cell.styles.valign === 'bottom' ) { - var splittedText = typeof cell.text === 'string' ? cell.text.split(/\r\n|\r|\n/g) : cell.text; - var lineCount = splittedText.length || 1; - if ( lineCount > 2 ) - cell.textPos.y -= ((2 - FONT_ROW_RATIO) / 2 * data.row.styles.fontSize) * (lineCount - 2) / 3; - } - return true; - } - else - return false; // cell is hidden (colspan = -1), don't draw it - } - - function collectImages (cell, elements, teOptions) { - if ( typeof teOptions.images != 'undefined' ) { - elements.each(function () { - var kids = $(this).children(); - - if ( $(this).is("img") ) { - var hash = strHashCode(this.src); - - teOptions.images[hash] = { - url: this.src, - src: this.src - }; - } - - if ( typeof kids != 'undefined' && kids.length > 0 ) - collectImages(cell, kids, teOptions); - }); - } - } - - function loadImages (teOptions, callback) { - var i; - var imageCount = 0; - var x = 0; - - function done () { - callback(imageCount); - } - - function loadImage (image) { - if ( !image.url ) - return; - var img = new Image(); - imageCount = ++x; - img.crossOrigin = 'Anonymous'; - img.onerror = img.onload = function () { - if ( img.complete ) { - - if ( img.src.indexOf('data:image/') === 0 ) { - img.width = image.width || img.width || 0; - img.height = image.height || img.height || 0; - } - - if ( img.width + img.height ) { - var canvas = document.createElement("canvas"); - var ctx = canvas.getContext("2d"); - - canvas.width = img.width; - canvas.height = img.height; - ctx.drawImage(img, 0, 0); - - image.src = canvas.toDataURL("image/jpeg"); - } - } - if ( !--x ) - done(); - }; - img.src = image.url; - } - - if ( typeof teOptions.images != 'undefined' ) { - for ( i in teOptions.images ) - if ( teOptions.images.hasOwnProperty(i) ) - loadImage(teOptions.images[i]); - } - - return x || done(); - } - - function drawAutotableElements (cell, elements, teOptions) { - elements.each(function () { - var kids = $(this).children(); - var uy = 0; - - if ( $(this).is("div") ) { - var bcolor = rgb2array(getStyle(this, 'background-color'), [255, 255, 255]); - var lcolor = rgb2array(getStyle(this, 'border-top-color'), [0, 0, 0]); - var lwidth = getPropertyUnitValue(this, 'border-top-width', defaults.jspdf.unit); - - var r = this.getBoundingClientRect(); - var ux = this.offsetLeft * teOptions.dw; - uy = this.offsetTop * teOptions.dh; - var uw = r.width * teOptions.dw; - var uh = r.height * teOptions.dh; - - teOptions.doc.setDrawColor.apply(undefined, lcolor); - teOptions.doc.setFillColor.apply(undefined, bcolor); - teOptions.doc.setLineWidth(lwidth); - teOptions.doc.rect(cell.x + ux, cell.y + uy, uw, uh, lwidth ? "FD" : "F"); - } - else if ( $(this).is("img") ) { - if ( typeof teOptions.images != 'undefined' ) { - var hash = strHashCode(this.src); - var image = teOptions.images[hash]; - - if ( typeof image != 'undefined' ) { - - var arCell = cell.width / cell.height; - var arImg = this.width / this.height; - var imgWidth = cell.width; - var imgHeight = cell.height; - var px2pt = 0.264583 * 72 / 25.4; - - if ( arImg <= arCell ) { - imgHeight = Math.min(cell.height, this.height); - imgWidth = this.width * imgHeight / this.height; - } - else if ( arImg > arCell ) { - imgWidth = Math.min(cell.width, this.width); - imgHeight = this.height * imgWidth / this.width; - } - - imgWidth *= px2pt; - imgHeight *= px2pt; - - if ( imgHeight < cell.height ) - uy = (cell.height - imgHeight) / 2; - - try { - teOptions.doc.addImage(image.src, cell.textPos.x, cell.y + uy, imgWidth, imgHeight); - } - catch (e) { - // TODO: IE -> convert png to jpeg - } - cell.textPos.x += imgWidth; - } - } - } - - if ( typeof kids != 'undefined' && kids.length > 0 ) - drawAutotableElements(cell, kids, teOptions); - }); - } - - function drawAutotableText (cell, texttags, teOptions) { - if ( typeof teOptions.onAutotableText === 'function' ) { - teOptions.onAutotableText(teOptions.doc, cell, texttags); - } - else { - var x = cell.textPos.x; - var y = cell.textPos.y; - var style = {halign: cell.styles.halign, valign: cell.styles.valign}; - - if ( texttags.length ) { - var tag = texttags[0]; - while ( tag.previousSibling ) - tag = tag.previousSibling; - - var b = false, i = false; - - while ( tag ) { - var txt = tag.innerText || tag.textContent || ""; - - txt = ((txt.length && txt[0] == " ") ? " " : "") + - $.trim(txt) + - ((txt.length > 1 && txt[txt.length - 1] == " ") ? " " : ""); - - if ( $(tag).is("br") ) { - x = cell.textPos.x; - y += teOptions.doc.internal.getFontSize(); - } - - if ( $(tag).is("b") ) - b = true; - else if ( $(tag).is("i") ) - i = true; - - if ( b || i ) - teOptions.doc.setFontType((b && i) ? "bolditalic" : b ? "bold" : "italic"); - - var w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); - - if ( w ) { - if ( cell.styles.overflow === 'linebreak' && - x > cell.textPos.x && (x + w) > (cell.textPos.x + cell.width) ) { - var chars = ".,!%*;:=-"; - if ( chars.indexOf(txt.charAt(0)) >= 0 ) { - var s = txt.charAt(0); - w = teOptions.doc.getStringUnitWidth(s) * teOptions.doc.internal.getFontSize(); - if ( (x + w) <= (cell.textPos.x + cell.width) ) { - teOptions.doc.autoTableText(s, x, y, style); - txt = txt.substring(1, txt.length); - } - w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); - } - x = cell.textPos.x; - y += teOptions.doc.internal.getFontSize(); - } - - while ( txt.length && (x + w) > (cell.textPos.x + cell.width) ) { - txt = txt.substring(0, txt.length - 1); - w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); - } - - teOptions.doc.autoTableText(txt, x, y, style); - x += w; - } - - if ( b || i ) { - if ( $(tag).is("b") ) - b = false; - else if ( $(tag).is("i") ) - i = false; - - teOptions.doc.setFontType((!b && !i) ? "normal" : b ? "bold" : "italic"); - } - - tag = tag.nextSibling; - } - cell.textPos.x = x; - cell.textPos.y = y; - } - else { - teOptions.doc.autoTableText(cell.text, cell.textPos.x, cell.textPos.y, style); - } - } - } - - function escapeRegExp (string) { - return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); - } - - function replaceAll (string, find, replace) { - return string.replace(new RegExp(escapeRegExp(find), 'g'), replace); - } - - function parseNumber (value) { - value = value || "0"; - value = replaceAll(value, defaults.numbers.html.thousandsSeparator, ''); - value = replaceAll(value, defaults.numbers.html.decimalMark, '.'); - - return typeof value === "number" || jQuery.isNumeric(value) !== false ? value : false; - } - - function parsePercent (value) { - if ( value.indexOf("%") > -1 ) { - value = parseNumber(value.replace(/%/g, "")); - if ( value !== false ) - value = value / 100; - } - else - value = false; - return value; - } - - function parseString (cell, rowIndex, colIndex) { - var result = ''; - - if ( cell !== null ) { - var $cell = $(cell); - var htmlData; - - if ( $cell[0].hasAttribute("data-tableexport-value") ) { - htmlData = $cell.data("tableexport-value"); - htmlData = htmlData ? htmlData + '' : '' - } - else { - htmlData = $cell.html(); - - if ( typeof defaults.onCellHtmlData === 'function' ) - htmlData = defaults.onCellHtmlData($cell, rowIndex, colIndex, htmlData); - else if ( htmlData != '' ) { - var html = $.parseHTML(htmlData); - var inputidx = 0; - var selectidx = 0; - - htmlData = ''; - $.each(html, function () { - if ( $(this).is("input") ) - htmlData += $cell.find('input').eq(inputidx++).val(); - else if ( $(this).is("select") ) - htmlData += $cell.find('select option:selected').eq(selectidx++).text(); - else { - if ( typeof $(this).html() === 'undefined' ) - htmlData += $(this).text(); - else if ( jQuery().bootstrapTable === undefined || - ($(this).hasClass('filterControl') !== true && - $(cell).parents('.detail-view').length === 0) ) - htmlData += $(this).html(); - } - }); - } - } - - if ( defaults.htmlContent === true ) { - result = $.trim(htmlData); - } - else if ( htmlData && htmlData != '' ) { - var cellFormat = $(cell).data("tableexport-cellformat"); - - if ( cellFormat != '' ) { - var text = htmlData.replace(/\n/g, '\u2028').replace(//gi, '\u2060'); - var obj = $('
    ').html(text).contents(); - var number = false; - text = ''; - $.each(obj.text().split("\u2028"), function (i, v) { - if ( i > 0 ) - text += " "; - text += $.trim(v); - }); - - $.each(text.split("\u2060"), function (i, v) { - if ( i > 0 ) - result += "\n"; - result += $.trim(v).replace(/\u00AD/g, ""); // remove soft hyphens - }); - - if ( defaults.type == 'json' || - (defaults.type === 'excel' && defaults.excelFileFormat === 'xmlss') || - defaults.numbers.output === false ) { - number = parseNumber(result); - - if ( number !== false ) - result = Number(number); - } - else if ( defaults.numbers.html.decimalMark != defaults.numbers.output.decimalMark || - defaults.numbers.html.thousandsSeparator != defaults.numbers.output.thousandsSeparator ) { - number = parseNumber(result); - - if ( number !== false ) { - var frac = ("" + number.substr(number < 0 ? 1 : 0)).split('.'); - if ( frac.length == 1 ) - frac[1] = ""; - var mod = frac[0].length > 3 ? frac[0].length % 3 : 0; - - result = (number < 0 ? "-" : "") + - (defaults.numbers.output.thousandsSeparator ? ((mod ? frac[0].substr(0, mod) + defaults.numbers.output.thousandsSeparator : "") + frac[0].substr(mod).replace(/(\d{3})(?=\d)/g, "$1" + defaults.numbers.output.thousandsSeparator)) : frac[0]) + - (frac[1].length ? defaults.numbers.output.decimalMark + frac[1] : ""); - } - } - } - else - result = htmlData; - } - - if ( defaults.escape === true ) { - //noinspection JSDeprecatedSymbols - result = escape(result); - } - - if ( typeof defaults.onCellData === 'function' ) { - result = defaults.onCellData($cell, rowIndex, colIndex, result); - } - } - - return result; - } - - //noinspection JSUnusedLocalSymbols - function hyphenate (a, b, c) { - return b + "-" + c.toLowerCase(); - } - - function rgb2array (rgb_string, default_result) { - var re = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/; - var bits = re.exec(rgb_string); - var result = default_result; - if ( bits ) - result = [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])]; - return result; - } - - function getCellStyles (cell) { - var a = getStyle(cell, 'text-align'); - var fw = getStyle(cell, 'font-weight'); - var fs = getStyle(cell, 'font-style'); - var f = ''; - if ( a == 'start' ) - a = getStyle(cell, 'direction') == 'rtl' ? 'right' : 'left'; - if ( fw >= 700 ) - f = 'bold'; - if ( fs == 'italic' ) - f += fs; - if ( f === '' ) - f = 'normal'; - - var result = { - style: { - align: a, - bcolor: rgb2array(getStyle(cell, 'background-color'), [255, 255, 255]), - color: rgb2array(getStyle(cell, 'color'), [0, 0, 0]), - fstyle: f - }, - colspan: (parseInt($(cell).attr('colspan')) || 0), - rowspan: (parseInt($(cell).attr('rowspan')) || 0) - }; - - if ( cell !== null ) { - var r = cell.getBoundingClientRect(); - result.rect = { - width: r.width, - height: r.height - }; - } - - return result; - } - - // get computed style property - function getStyle (target, prop) { - try { - if ( window.getComputedStyle ) { // gecko and webkit - prop = prop.replace(/([a-z])([A-Z])/, hyphenate); // requires hyphenated, not camel - return window.getComputedStyle(target, null).getPropertyValue(prop); - } - if ( target.currentStyle ) { // ie - return target.currentStyle[prop]; - } - return target.style[prop]; - } - catch (e) { - } - return ""; - } - - function getUnitValue (parent, value, unit) { - var baseline = 100; // any number serves - - var temp = document.createElement("div"); // create temporary element - temp.style.overflow = "hidden"; // in case baseline is set too low - temp.style.visibility = "hidden"; // no need to show it - - parent.appendChild(temp); // insert it into the parent for em, ex and % - - temp.style.width = baseline + unit; - var factor = baseline / temp.offsetWidth; - - parent.removeChild(temp); // clean up - - return (value * factor); - } - - function getPropertyUnitValue (target, prop, unit) { - var value = getStyle(target, prop); // get the computed style value - - var numeric = value.match(/\d+/); // get the numeric component - if ( numeric !== null ) { - numeric = numeric[0]; // get the string - - return getUnitValue(target.parentElement, numeric, unit); - } - return 0; - } - - function jx_Workbook () { - if ( !(this instanceof jx_Workbook) ) { - //noinspection JSPotentiallyInvalidConstructorUsage - return new jx_Workbook(); - } - this.SheetNames = []; - this.Sheets = {}; - } - - function jx_s2ab (s) { - var buf = new ArrayBuffer(s.length); - var view = new Uint8Array(buf); - for ( var i = 0; i != s.length; ++i ) view[i] = s.charCodeAt(i) & 0xFF; - return buf; - } - - function jx_datenum (v, date1904) { - if ( date1904 ) v += 1462; - var epoch = Date.parse(v); - return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000); - } - - function jx_createSheet (data) { - var ws = {}; - var range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}}; - for ( var R = 0; R != data.length; ++R ) { - for ( var C = 0; C != data[R].length; ++C ) { - if ( range.s.r > R ) range.s.r = R; - if ( range.s.c > C ) range.s.c = C; - if ( range.e.r < R ) range.e.r = R; - if ( range.e.c < C ) range.e.c = C; - var cell = {v: data[R][C]}; - if ( cell.v === null ) continue; - var cell_ref = XLSX.utils.encode_cell({c: C, r: R}); - - if ( typeof cell.v === 'number' ) cell.t = 'n'; - else if ( typeof cell.v === 'boolean' ) cell.t = 'b'; - else if ( cell.v instanceof Date ) { - cell.t = 'n'; - cell.z = XLSX.SSF._table[14]; - cell.v = jx_datenum(cell.v); - } - else cell.t = 's'; - ws[cell_ref] = cell; - } - } - - if ( range.s.c < 10000000 ) ws['!ref'] = XLSX.utils.encode_range(range); - return ws; - } - - function strHashCode (str) { - var hash = 0, i, chr, len; - if ( str.length === 0 ) return hash; - for ( i = 0, len = str.length; i < len; i++ ) { - chr = str.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; - hash |= 0; // Convert to 32bit integer - } - return hash; - } - - function downloadFile (filename, header, data) { - var ua = window.navigator.userAgent; - if ( filename !== false && window.navigator.msSaveOrOpenBlob ) { - //noinspection JSUnresolvedFunction - window.navigator.msSaveOrOpenBlob(new Blob([data]), filename); - } - else if ( filename !== false && (ua.indexOf("MSIE ") > 0 || !!ua.match(/Trident.*rv\:11\./)) ) { - // Internet Explorer (<= 9) workaround by Darryl (https://github.com/dawiong/tableExport.jquery.plugin) - // based on sampopes answer on http://stackoverflow.com/questions/22317951 - // ! Not working for json and pdf format ! - var frame = document.createElement("iframe"); - - if ( frame ) { - document.body.appendChild(frame); - frame.setAttribute("style", "display:none"); - frame.contentDocument.open("txt/plain", "replace"); - frame.contentDocument.write(data); - frame.contentDocument.close(); - frame.contentDocument.focus(); - - var extension = filename.substr((filename.lastIndexOf('.') +1)); - switch(extension) { - case 'doc': case 'json': case 'png': case 'pdf': case 'xls': case 'xlsx': - filename += ".txt"; - break; - } - frame.contentDocument.execCommand("SaveAs", true, filename); - document.body.removeChild(frame); - } - } - else { - var DownloadLink = document.createElement('a'); - - if ( DownloadLink ) { - var blobUrl = null; - - DownloadLink.style.display = 'none'; - if ( filename !== false ) - DownloadLink.download = filename; - else - DownloadLink.target = '_blank'; - - if ( typeof data == 'object' ) { - window.URL = window.URL || window.webkitURL; - blobUrl = window.URL.createObjectURL(data); - DownloadLink.href = blobUrl; - } - else if ( header.toLowerCase().indexOf("base64,") >= 0 ) - DownloadLink.href = header + base64encode(data); - else - DownloadLink.href = header + encodeURIComponent(data); - - document.body.appendChild(DownloadLink); - - if ( document.createEvent ) { - if ( DownloadEvt === null ) - DownloadEvt = document.createEvent('MouseEvents'); - - DownloadEvt.initEvent('click', true, false); - DownloadLink.dispatchEvent(DownloadEvt); - } - else if ( document.createEventObject ) - DownloadLink.fireEvent('onclick'); - else if ( typeof DownloadLink.onclick == 'function' ) - DownloadLink.onclick(); - - setTimeout(function(){ - if ( blobUrl ) - window.URL.revokeObjectURL(blobUrl); - document.body.removeChild(DownloadLink); - }, 100); - } - } - } - - function utf8Encode (text) { - if (typeof text === 'string') { - text = text.replace(/\x0d\x0a/g, "\x0a"); - var utftext = ""; - for ( var n = 0; n < text.length; n++ ) { - var c = text.charCodeAt(n); - if ( c < 128 ) { - utftext += String.fromCharCode(c); - } - else if ( (c > 127) && (c < 2048) ) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - } - return utftext; - } - return text; - } - - function base64encode (input) { - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var output = ""; - var i = 0; - input = utf8Encode(input); - while ( i < input.length ) { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - if ( isNaN(chr2) ) { - enc3 = enc4 = 64; - } else if ( isNaN(chr3) ) { - enc4 = 64; - } - output = output + - keyStr.charAt(enc1) + keyStr.charAt(enc2) + - keyStr.charAt(enc3) + keyStr.charAt(enc4); - } - return output; - } - - return this; - } -})(jQuery); +/** + * @preserve tableExport.jquery.plugin + * + * Version 1.9.8 + * + * Copyright (c) 2015-2017 hhurz, https://github.com/hhurz + * + * Original Work Copyright (c) 2014 Giri Raj + * + * Licensed under the MIT License + **/ + +(function ($) { + $.fn.tableExport = function (options) { + var defaults = { + consoleLog: false, + csvEnclosure: '"', + csvSeparator: ',', + csvUseBOM: true, + displayTableName: false, + escape: false, + excelFileFormat: 'xlshtml', // xmlss = XML Spreadsheet 2003 file format (XMLSS), xlshtml = Excel 2000 html format + excelRTL: false, // true = Set Excel option 'DisplayRightToLeft' + excelstyles: [], // e.g. ['border-bottom', 'border-top', 'border-left', 'border-right'] + exportHiddenCells: false, // true = speed up export of large tables with hidden cells (hidden cells will be exported !) + fileName: 'export', + htmlContent: false, + ignoreColumn: [], + ignoreRow: [], + jsonScope: 'all', // head, data, all + jspdf: { + orientation: 'p', + unit: 'pt', + format: 'a4', // jspdf page format or 'bestfit' for autmatic paper format selection + margins: {left: 20, right: 10, top: 10, bottom: 10}, + onDocCreated: null, + autotable: { + styles: { + cellPadding: 2, + rowHeight: 12, + fontSize: 8, + fillColor: 255, // color value or 'inherit' to use css background-color from html table + textColor: 50, // color value or 'inherit' to use css color from html table + fontStyle: 'normal', // normal, bold, italic, bolditalic or 'inherit' to use css font-weight and fonst-style from html table + overflow: 'ellipsize', // visible, hidden, ellipsize or linebreak + halign: 'left', // left, center, right + valign: 'middle' // top, middle, bottom + }, + headerStyles: { + fillColor: [52, 73, 94], + textColor: 255, + fontStyle: 'bold', + halign: 'center' + }, + alternateRowStyles: { + fillColor: 245 + }, + tableExport: { + doc: null, // jsPDF doc object. If set, an already created doc will be used to export to + onAfterAutotable: null, + onBeforeAutotable: null, + onAutotableText: null, + onTable: null, + outputImages: true + } + } + }, + numbers: { + html: { + decimalMark: '.', + thousandsSeparator: ',' + }, + output: { // set output: false to keep number format in exported output + decimalMark: '.', + thousandsSeparator: ',' + } + }, + onCellData: null, + onCellHtmlData: null, + onIgnoreRow: null, // onIgnoreRow($tr, rowIndex): function should return true to not export a row + onMsoNumberFormat: null, // Excel 2000 html format only. See readme.md for more information about msonumberformat + outputMode: 'file', // 'file', 'string', 'base64' or 'window' (experimental) + pdfmake: { + enabled: false, // true: use pdfmake instead of jspdf and jspdf-autotable (experimental) + docDefinition: { + pageOrientation: 'portrait', // 'portrait' or 'landscape' + defaultStyle: { + font: 'Roboto' // default is 'Roboto', for arabic font set this option to 'Mirza' and include mirza_fonts.js + } + }, + fonts: {} + }, + tbodySelector: 'tr', + tfootSelector: 'tr', // set empty ('') to prevent export of tfoot rows + theadSelector: 'tr', + tableName: 'Table', + type: 'csv', // 'csv', 'tsv', 'txt', 'sql', 'json', 'xml', 'excel', 'doc', 'png' or 'pdf' + worksheetName: '' + }; + + var FONT_ROW_RATIO = 1.15; + var el = this; + var DownloadEvt = null; + var $hrows = []; + var $rows = []; + var rowIndex = 0; + var trData = ''; + var colNames = []; + var ranges = []; + var blob; + var $hiddenTableElements = []; + var checkCellVisibilty = false; + + $.extend(true, defaults, options); + + colNames = GetColumnNames(el); + + if ( defaults.type == 'csv' || defaults.type == 'tsv' || defaults.type == 'txt' ) { + + var csvData = ""; + var rowlength = 0; + ranges = []; + rowIndex = 0; + + function csvString (cell, rowIndex, colIndex) { + var result = ''; + + if ( cell !== null ) { + var dataString = parseString(cell, rowIndex, colIndex); + + var csvValue = (dataString === null || dataString === '') ? '' : dataString.toString(); + + if ( defaults.type == 'tsv' ) { + if ( dataString instanceof Date ) + dataString.toLocaleString(); + + // According to http://www.iana.org/assignments/media-types/text/tab-separated-values + // are fields that contain tabs not allowable in tsv encoding + result = replaceAll(csvValue, '\t', ' '); + } + else { + // Takes a string and encapsulates it (by default in double-quotes) if it + // contains the csv field separator, spaces, or linebreaks. + if ( dataString instanceof Date ) + result = defaults.csvEnclosure + dataString.toLocaleString() + defaults.csvEnclosure; + else { + result = replaceAll(csvValue, defaults.csvEnclosure, defaults.csvEnclosure + defaults.csvEnclosure); + + if ( result.indexOf(defaults.csvSeparator) >= 0 || /[\r\n ]/g.test(result) ) + result = defaults.csvEnclosure + result + defaults.csvEnclosure; + } + } + } + + return result; + } + + var CollectCsvData = function ($rows, rowselector, length) { + + $rows.each(function () { + trData = ""; + ForEachVisibleCell(this, rowselector, rowIndex, length + $rows.length, + function (cell, row, col) { + trData += csvString(cell, row, col) + (defaults.type == 'tsv' ? '\t' : defaults.csvSeparator); + }); + trData = $.trim(trData).substring(0, trData.length - 1); + if ( trData.length > 0 ) { + + if ( csvData.length > 0 ) + csvData += "\n"; + + csvData += trData; + } + rowIndex++; + }); + + return $rows.length; + }; + + rowlength += CollectCsvData($(el).find('thead').first().find(defaults.theadSelector), 'th,td', rowlength); + findTablePart($(el),'tbody').each(function () { + rowlength += CollectCsvData(findRows($(this), defaults.tbodySelector), 'td,th', rowlength); + }); + if ( defaults.tfootSelector.length ) + CollectCsvData($(el).find('tfoot').first().find(defaults.tfootSelector), 'td,th', rowlength); + + csvData += "\n"; + + //output + if ( defaults.consoleLog === true ) + console.log(csvData); + + if ( defaults.outputMode === 'string' ) + return csvData; + + if ( defaults.outputMode === 'base64' ) + return base64encode(csvData); + + if ( defaults.outputMode === 'window' ) { + downloadFile(false, 'data:text/' + (defaults.type == 'csv' ? 'csv' : 'plain') + ';charset=utf-8,', csvData); + return; + } + + try { + blob = new Blob([csvData], {type: "text/" + (defaults.type == 'csv' ? 'csv' : 'plain') + ";charset=utf-8"}); + saveAs(blob, defaults.fileName + '.' + defaults.type, (defaults.type != 'csv' || defaults.csvUseBOM === false)); + } + catch (e) { + downloadFile(defaults.fileName + '.' + defaults.type, + 'data:text/' + (defaults.type == 'csv' ? 'csv' : 'plain') + ';charset=utf-8,' + ((defaults.type == 'csv' && defaults.csvUseBOM) ? '\ufeff' : ''), + csvData); + } + + } else if ( defaults.type == 'sql' ) { + + // Header + rowIndex = 0; + ranges = []; + var tdData = "INSERT INTO `" + defaults.tableName + "` ("; + $hrows = $(el).find('thead').first().find(defaults.theadSelector); + $hrows.each(function () { + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + tdData += "'" + parseString(cell, row, col) + "',"; + }); + rowIndex++; + tdData = $.trim(tdData).substring(0, tdData.length - 1); + }); + tdData += ") VALUES "; + + // Data + $rows = collectRows ($(el)); + $($rows).each(function () { + trData = ""; + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + trData += "'" + parseString(cell, row, col) + "',"; + }); + if ( trData.length > 3 ) { + tdData += "(" + trData; + tdData = $.trim(tdData).substring(0, tdData.length - 1); + tdData += "),"; + } + rowIndex++; + }); + + tdData = $.trim(tdData).substring(0, tdData.length - 1); + tdData += ";"; + + // Output + if ( defaults.consoleLog === true ) + console.log(tdData); + + if ( defaults.outputMode === 'string' ) + return tdData; + + if ( defaults.outputMode === 'base64' ) + return base64encode(tdData); + + try { + blob = new Blob([tdData], {type: "text/plain;charset=utf-8"}); + saveAs(blob, defaults.fileName + '.sql'); + } + catch (e) { + downloadFile(defaults.fileName + '.sql', + 'data:application/sql;charset=utf-8,', + tdData); + } + + } else if ( defaults.type == 'json' ) { + var jsonHeaderArray = []; + ranges = []; + $hrows = $(el).find('thead').first().find(defaults.theadSelector); + $hrows.each(function () { + var jsonArrayTd = []; + + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + jsonArrayTd.push(parseString(cell, row, col)); + }); + jsonHeaderArray.push(jsonArrayTd); + }); + + // Data + var jsonArray = []; + + $rows = collectRows ($(el)); + $($rows).each(function () { + var jsonObjectTd = {}; + var colIndex = 0; + + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + if ( jsonHeaderArray.length ) { + jsonObjectTd[jsonHeaderArray[jsonHeaderArray.length - 1][colIndex]] = parseString(cell, row, col); + } else { + jsonObjectTd[colIndex] = parseString(cell, row, col); + } + colIndex++; + }); + if ( $.isEmptyObject(jsonObjectTd) === false ) + jsonArray.push(jsonObjectTd); + + rowIndex++; + }); + + var sdata = ""; + + if ( defaults.jsonScope == 'head' ) + sdata = JSON.stringify(jsonHeaderArray); + else if ( defaults.jsonScope == 'data' ) + sdata = JSON.stringify(jsonArray); + else // all + sdata = JSON.stringify({header: jsonHeaderArray, data: jsonArray}); + + if ( defaults.consoleLog === true ) + console.log(sdata); + + if ( defaults.outputMode === 'string' ) + return sdata; + + if ( defaults.outputMode === 'base64' ) + return base64encode(sdata); + + try { + blob = new Blob([sdata], {type: "application/json;charset=utf-8"}); + saveAs(blob, defaults.fileName + '.json'); + } + catch (e) { + downloadFile(defaults.fileName + '.json', + 'data:application/json;charset=utf-8;base64,', + sdata); + } + + } else if ( defaults.type === 'xml' ) { + rowIndex = 0; + ranges = []; + var xml = ''; + xml += ''; + + // Header + $hrows = $(el).find('thead').first().find(defaults.theadSelector); + $hrows.each(function () { + + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + xml += "" + parseString(cell, row, col) + ""; + }); + rowIndex++; + }); + xml += ''; + + // Data + var rowCount = 1; + + $rows = collectRows ($(el)); + $($rows).each(function () { + var colCount = 1; + trData = ""; + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + trData += "" + parseString(cell, row, col) + ""; + colCount++; + }); + if ( trData.length > 0 && trData != "" ) { + xml += '' + trData + ''; + rowCount++; + } + + rowIndex++; + }); + xml += ''; + + // Output + if ( defaults.consoleLog === true ) + console.log(xml); + + if ( defaults.outputMode === 'string' ) + return xml; + + if ( defaults.outputMode === 'base64' ) + return base64encode(xml); + + try { + blob = new Blob([xml], {type: "application/xml;charset=utf-8"}); + saveAs(blob, defaults.fileName + '.xml'); + } + catch (e) { + downloadFile(defaults.fileName + '.xml', + 'data:application/xml;charset=utf-8;base64,', + xml); + } + } + else if ( defaults.type === 'excel' && defaults.excelFileFormat === 'xmlss' ) { + var docDatas = []; + var docNames = []; + + $(el).filter(function () { + return isVisible($(this)); + }).each(function () { + var $table = $(this); + + var ssName = ''; + if ( typeof defaults.worksheetName === 'string' && defaults.worksheetName.length ) + ssName = defaults.worksheetName + ' ' + (docNames.length + 1); + else if ( typeof defaults.worksheetName[docNames.length] !== 'undefined' ) + ssName = defaults.worksheetName[docNames.length]; + if ( ! ssName.length ) + ssName = $table.find('caption').text() || ''; + if ( ! ssName.length ) + ssName = 'Table ' + (docNames.length + 1); + ssName = $.trim(ssName.replace(/[\\\/[\]*:?'"]/g,'').substring(0,31)); + + docNames.push($('
    ').text(ssName).html()); + + if ( defaults.exportHiddenCells === false ) { + $hiddenTableElements = $table.find("tr, th, td").filter(":hidden"); + checkCellVisibilty = $hiddenTableElements.length > 0; + } + + rowIndex = 0; + colNames = GetColumnNames(this); + docData = '\r'; + + function CollectXmlssData ($rows, rowselector, length) { + var spans = []; + + $($rows).each(function () { + var ssIndex = 0; + var nCols = 0; + trData = ""; + + ForEachVisibleCell(this, 'td,th', rowIndex, length + $rows.length, + function (cell, row, col) { + if ( cell !== null ) { + var style = ""; + var data = parseString(cell, row, col); + var type = "String"; + + if ( jQuery.isNumeric(data) !== false ) { + type = "Number"; + } + else { + var number = parsePercent(data); + if ( number !== false ) { + data = number; + type = "Number"; + style += ' ss:StyleID="pct1"'; + } + } + + if ( type !== "Number" ) + data = data.replace(/\n/g, '
    '); + + var colspan = parseInt(cell.getAttribute('colspan')); + var rowspan = parseInt(cell.getAttribute('rowspan')); + + // Skip spans + $.each(spans, function () { + var range = this; + if ( rowIndex >= range.s.r && rowIndex <= range.e.r && nCols >= range.s.c && nCols <= range.e.c ) { + for ( var i = 0; i <= range.e.c - range.s.c; ++i ) { + nCols++; + ssIndex++; + } + } + }); + + // Handle Row Span + if ( rowspan || colspan ) { + rowspan = rowspan || 1; + colspan = colspan || 1; + spans.push({ + s: {r: rowIndex, c: nCols}, + e: {r: rowIndex + rowspan - 1, c: nCols + colspan - 1} + }); + } + + // Handle Colspan + if ( colspan > 1 ) { + style += ' ss:MergeAcross="' + (colspan-1) + '"'; + nCols += (colspan - 1); + } + + if ( rowspan > 1 ) { + style += ' ss:MergeDown="' + (rowspan-1) + '" ss:StyleID="rsp1"'; + } + + if ( ssIndex > 0 ) { + style += ' ss:Index="' + (nCols+1) + '"'; + ssIndex = 0; + } + + trData += '' + + $('
    ').text(data).html() + + '\r'; + nCols++; + } + }); + if ( trData.length > 0 ) + docData += '\r' + trData + '\r'; + rowIndex++; + }); + + return $rows.length; + } + + var rowLength = 0; + rowLength += CollectXmlssData ($table.find('thead').first().find(defaults.theadSelector), 'th,td', rowLength); + CollectXmlssData (collectRows ($table), 'td,th', rowLength); + + docData += '
    \r'; + docDatas.push(docData); + + if ( defaults.consoleLog === true ) + console.log(docData); + }); + + var count = {}; + var firstOccurences = {}; + var item, itemCount; + for (var n = 0, c = docNames.length; n < c; n++) + { + item = docNames[n]; + itemCount = count[item]; + itemCount = count[item] = (itemCount == null ? 1 : itemCount + 1); + + if( itemCount == 2 ) + docNames[firstOccurences[item]] = docNames[firstOccurences[item]].substring(0,29) + "-1"; + if( count[ item ] > 1 ) + docNames[n] = docNames[n].substring(0,29) + "-" + count[item]; + else + firstOccurences[item] = n; + } + + var CreationDate = new Date().toISOString(); + var xmlssDocFile = '\r' + + '\r' + + '\r' + + '\r' + + ' ' + CreationDate + '\r' + + '\r' + + '\r' + + ' \r' + + '\r' + + '\r' + + ' 9000\r' + + ' 13860\r' + + ' 0\r' + + ' 0\r' + + ' False\r' + + ' False\r' + + '\r' + + '\r' + + ' \r' + + ' \r' + + ' \r' + + '\r'; + + for ( var j = 0; j < docDatas.length; j++ ) { + xmlssDocFile += '\r' + + docDatas[j]; + if (defaults.excelRTL) { + xmlssDocFile += '\r' + + '\r' + + '\r'; + } + else + xmlssDocFile += '\r'; + xmlssDocFile += '\r'; + } + + xmlssDocFile += '\r'; + + if ( defaults.consoleLog === true ) + console.log(xmlssDocFile); + + if ( defaults.outputMode === 'string' ) + return xmlssDocFile; + + if ( defaults.outputMode === 'base64' ) + return base64encode(xmlssDocFile); + + try { + blob = new Blob([xmlssDocFile], {type: "application/xml;charset=utf-8"}); + saveAs(blob, defaults.fileName + '.xml'); + } + catch (e) { + downloadFile(defaults.fileName + '.xml', + 'data:application/xml;charset=utf-8;base64,', + xmlssDocFile); + } + } + else if ( defaults.type == 'excel' || defaults.type == 'xls' || defaults.type == 'word' || defaults.type == 'doc' ) { + + var MSDocType = (defaults.type == 'excel' || defaults.type == 'xls') ? 'excel' : 'word'; + var MSDocExt = (MSDocType == 'excel') ? 'xls' : 'doc'; + var MSDocSchema = 'xmlns:x="urn:schemas-microsoft-com:office:' + MSDocType + '"'; + var docData = ''; + var docName = ''; + + $(el).filter(function () { + return isVisible($(this)); + }).each(function () { + var $table = $(this); + + if (docName === '') { + docName = defaults.worksheetName || $table.find('caption').text() || 'Table'; + docName = $.trim(docName.replace(/[\\\/[\]*:?'"]/g, '').substring(0, 31)); + } + + if ( defaults.exportHiddenCells === false ) { + $hiddenTableElements = $table.find("tr, th, td").filter(":hidden"); + checkCellVisibilty = $hiddenTableElements.length > 0; + } + + rowIndex = 0; + ranges = []; + colNames = GetColumnNames(this); + + // Header + docData += ''; + $hrows = $table.find('thead').first().find(defaults.theadSelector); + $hrows.each(function () { + trData = ""; + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + if ( cell !== null ) { + var thstyle = ''; + trData += ''; + } + }); + if ( trData.length > 0 ) + docData += '' + trData + ''; + rowIndex++; + }); + docData += ''; + + // Data + $rows = collectRows ($table); + $($rows).each(function () { + var $row = $(this); + trData = ""; + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + if ( cell !== null ) { + var tdvalue = parseString(cell, row, col); + var tdstyle = ''; + var tdcss = $(cell).data("tableexport-msonumberformat"); + + if ( typeof tdcss == 'undefined' && typeof defaults.onMsoNumberFormat === 'function' ) + tdcss = defaults.onMsoNumberFormat(cell, row, col); + + if ( typeof tdcss != 'undefined' && tdcss !== '' ) + tdstyle = 'style="mso-number-format:\'' + tdcss + '\''; + + for ( var cssStyle in defaults.excelstyles ) { + if ( defaults.excelstyles.hasOwnProperty(cssStyle) ) { + tdcss = $(cell).css(defaults.excelstyles[cssStyle]); + if ( tdcss === '' ) + tdcss = $row.css(defaults.excelstyles[cssStyle]); + + if ( tdcss !== '' && tdcss != '0px none rgb(0, 0, 0)' && tdcss != 'rgba(0, 0, 0, 0)' ) { + tdstyle += (tdstyle === '') ? 'style="' : ';'; + tdstyle += defaults.excelstyles[cssStyle] + ':' + tdcss; + } + } + } + trData += ''); + + trData += '>' + tdvalue + ''; + } + }); + if ( trData.length > 0 ) + docData += '' + trData + ''; + rowIndex++; + }); + + if ( defaults.displayTableName ) + docData += ''; + + docData += '
    ' + parseString($('

    ' + defaults.tableName + '

    ')) + '
    '; + + if ( defaults.consoleLog === true ) + console.log(docData); + }); + + //noinspection XmlUnusedNamespaceDeclaration + var docFile = ''; + docFile += ''; + docFile += ""; + if (MSDocType === 'excel') { + docFile += ""; + } + docFile += ""; + docFile += ""; + docFile += ""; + docFile += docData; + docFile += ""; + docFile += ""; + + if ( defaults.consoleLog === true ) + console.log(docFile); + + if ( defaults.outputMode === 'string' ) + return docFile; + + if ( defaults.outputMode === 'base64' ) + return base64encode(docFile); + + try { + blob = new Blob([docFile], {type: 'application/vnd.ms-' + defaults.type}); + saveAs(blob, defaults.fileName + '.' + MSDocExt); + } + catch (e) { + downloadFile(defaults.fileName + '.' + MSDocExt, + 'data:application/vnd.ms-' + MSDocType + ';base64,', + docFile); + } + + } else if ( defaults.type == 'xlsx' ) { + + var data = []; + var spans = []; + rowIndex = 0; + + $rows = $(el).find('thead').first().find(defaults.theadSelector).toArray(); + $rows.push.apply($rows, collectRows ($(el))); + + $($rows).each(function () { + var cols = []; + ForEachVisibleCell(this, 'th,td', rowIndex, $rows.length, + function (cell, row, col) { + if ( typeof cell !== 'undefined' && cell !== null ) { + + var cellValue = parseString(cell, row, col); + + var colspan = parseInt(cell.getAttribute('colspan')); + var rowspan = parseInt(cell.getAttribute('rowspan')); + + // Skip span ranges + $.each(spans, function () { + var range = this; + if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cols.length >= range.s.c && cols.length <= range.e.c ) { + for ( var i = 0; i <= range.e.c - range.s.c; ++i ) + cols.push(null); + } + }); + + // Handle Row Span + if ( rowspan || colspan ) { + rowspan = rowspan || 1; + colspan = colspan || 1; + spans.push({ + s: {r: rowIndex, c: cols.length}, + e: {r: rowIndex + rowspan - 1, c: cols.length + colspan - 1} + }); + } + + // Handle Value + if ( typeof defaults.onCellData !== 'function' ) { + + // Type conversion + if ( cellValue !== "" && cellValue == +cellValue ) + cellValue = +cellValue; + } + cols.push(cellValue !== "" ? cellValue : null); + + // Handle Colspan + if ( colspan ) + for ( var k = 0; k < colspan - 1; ++k ) + cols.push(null); + } + }); + data.push(cols); + rowIndex++; + }); + + //noinspection JSPotentiallyInvalidConstructorUsage + var wb = new jx_Workbook(), + ws = jx_createSheet(data); + + // add span ranges to worksheet + ws['!merges'] = spans; + + // add worksheet to workbook + wb.SheetNames.push(defaults.worksheetName); + wb.Sheets[defaults.worksheetName] = ws; + + var wbout = XLSX.write(wb, {bookType: defaults.type, bookSST: false, type: 'binary'}); + + try { + blob = new Blob([jx_s2ab(wbout)], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'}); + saveAs(blob, defaults.fileName + '.' + defaults.type); + } + catch (e) { + downloadFile(defaults.fileName + '.' + defaults.type, + 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8,', + jx_s2ab(wbout)); + } + + } else if ( defaults.type == 'png' ) { + //html2canvas($(el)[0], { + // onrendered: function (canvas) { + html2canvas($(el)[0]).then( + function (canvas) { + + var image = canvas.toDataURL(); + var byteString = atob(image.substring(22)); // remove data stuff + var buffer = new ArrayBuffer(byteString.length); + var intArray = new Uint8Array(buffer); + + for ( var i = 0; i < byteString.length; i++ ) + intArray[i] = byteString.charCodeAt(i); + + if ( defaults.consoleLog === true ) + console.log(byteString); + + if ( defaults.outputMode === 'string' ) + return byteString; + + if ( defaults.outputMode === 'base64' ) + return base64encode(image); + + if ( defaults.outputMode === 'window' ) { + window.open(image); + return; + } + + try { + blob = new Blob([buffer], {type: "image/png"}); + saveAs(blob, defaults.fileName + '.png'); + } + catch (e) { + downloadFile(defaults.fileName + '.png', 'data:image/png,', blob); + } + //} + }); + + } else if ( defaults.type == 'pdf' ) { + + if ( defaults.pdfmake.enabled === true ) { + // pdf output using pdfmake + // https://github.com/bpampuch/pdfmake + + var widths = []; + var body = []; + rowIndex = 0; + ranges = []; + + var CollectPdfmakeData = function ($rows, colselector, length) { + var rlength = 0; + + $($rows).each(function () { + var r = []; + + ForEachVisibleCell(this, colselector, rowIndex, length, + function (cell, row, col) { + if ( typeof cell !== 'undefined' && cell !== null ) { + + var colspan = parseInt(cell.getAttribute('colspan')); + var rowspan = parseInt(cell.getAttribute('rowspan')); + + var cellValue = parseString(cell, row, col) || " "; + + if ( colspan > 1 || rowspan > 1 ) { + colspan = colspan || 1; + rowspan = rowspan || 1; + r.push({colSpan: colspan, rowSpan: rowspan, text: cellValue}); + } + else + r.push(cellValue); + } + else + r.push(" "); + }); + + if ( r.length ) + body.push(r); + + if ( rlength < r.length ) + rlength = r.length; + + rowIndex++; + }); + + return rlength; + }; + + $hrows = $(this).find('thead').first().find(defaults.theadSelector); + + var colcount = CollectPdfmakeData($hrows, 'th,td', $hrows.length); + + for ( var i = widths.length; i < colcount; i++ ) + widths.push("*"); + + // Data + $rows = collectRows ($(this)); + + CollectPdfmakeData($rows, 'th,td', $hrows.length + $rows.length); + + var docDefinition = { + content: [{ + table: { + headerRows: $hrows.length, + widths: widths, + body: body + } + }] + }; + + $.extend(true, docDefinition, defaults.pdfmake.docDefinition); + + pdfMake.fonts = { + Roboto: { + normal: 'Roboto-Regular.ttf', + bold: 'Roboto-Medium.ttf', + italics: 'Roboto-Italic.ttf', + bolditalics: 'Roboto-MediumItalic.ttf' + } + }; + + $.extend(true, pdfMake.fonts, defaults.pdfmake.fonts); + + pdfMake.createPdf(docDefinition).getBuffer(function (buffer) { + + try { + var blob = new Blob([buffer], {type: "application/pdf"}); + saveAs(blob, defaults.fileName + '.pdf'); + } + catch (e) { + downloadFile(defaults.fileName + '.pdf', + 'data:application/pdf;base64,', + buffer); + } + }); + + } + else if ( defaults.jspdf.autotable === false ) { + // pdf output using jsPDF's core html support + + var addHtmlOptions = { + dim: { + w: getPropertyUnitValue($(el).first().get(0), 'width', 'mm'), + h: getPropertyUnitValue($(el).first().get(0), 'height', 'mm') + }, + pagesplit: false + }; + + var doc = new jsPDF(defaults.jspdf.orientation, defaults.jspdf.unit, defaults.jspdf.format); + doc.addHTML($(el).first(), + defaults.jspdf.margins.left, + defaults.jspdf.margins.top, + addHtmlOptions, + function () { + jsPdfOutput(doc, false); + }); + //delete doc; + } + else { + // pdf output using jsPDF AutoTable plugin + // https://github.com/simonbengtsson/jsPDF-AutoTable + + var teOptions = defaults.jspdf.autotable.tableExport; + + // When setting jspdf.format to 'bestfit' tableExport tries to choose + // the minimum required paper format and orientation in which the table + // (or tables in multitable mode) completely fits without column adjustment + if ( typeof defaults.jspdf.format === 'string' && defaults.jspdf.format.toLowerCase() === 'bestfit' ) { + var pageFormats = { + 'a0': [2383.94, 3370.39], 'a1': [1683.78, 2383.94], + 'a2': [1190.55, 1683.78], 'a3': [841.89, 1190.55], + 'a4': [595.28, 841.89] + }; + var rk = '', ro = ''; + var mw = 0; + + $(el).each(function () { + if ( isVisible($(this)) ) { + var w = getPropertyUnitValue($(this).get(0), 'width', 'pt'); + + if ( w > mw ) { + if ( w > pageFormats.a0[0] ) { + rk = 'a0'; + ro = 'l'; + } + for ( var key in pageFormats ) { + if ( pageFormats.hasOwnProperty(key) ) { + if ( pageFormats[key][1] > w ) { + rk = key; + ro = 'l'; + if ( pageFormats[key][0] > w ) + ro = 'p'; + } + } + } + mw = w; + } + } + }); + defaults.jspdf.format = (rk === '' ? 'a4' : rk); + defaults.jspdf.orientation = (ro === '' ? 'w' : ro); + } + + // The jsPDF doc object is stored in defaults.jspdf.autotable.tableExport, + // thus it can be accessed from any callback function + if ( teOptions.doc == null ) { + teOptions.doc = new jsPDF(defaults.jspdf.orientation, + defaults.jspdf.unit, + defaults.jspdf.format); + + if ( typeof defaults.jspdf.onDocCreated === 'function' ) + defaults.jspdf.onDocCreated(teOptions.doc); + } + + if ( teOptions.outputImages === true ) + teOptions.images = {}; + + if ( typeof teOptions.images != 'undefined' ) { + $(el).filter(function () { + return isVisible($(this)); + }).each(function () { + var rowCount = 0; + ranges = []; + + if ( defaults.exportHiddenCells === false ) { + $hiddenTableElements = $(this).find("tr, th, td").filter(":hidden"); + checkCellVisibilty = $hiddenTableElements.length > 0; + } + + $hrows = $(this).find('thead').find(defaults.theadSelector); + $rows = collectRows ($(this)); + + $($rows).each(function () { + ForEachVisibleCell(this, 'td,th', $hrows.length + rowCount, $hrows.length + $rows.length, + function (cell) { + if ( typeof cell !== 'undefined' && cell !== null ) { + var kids = $(cell).children(); + if ( typeof kids != 'undefined' && kids.length > 0 ) + collectImages(cell, kids, teOptions); + } + }); + rowCount++; + }); + }); + + $hrows = []; + $rows = []; + } + + loadImages(teOptions, function () { + $(el).filter(function () { + return isVisible($(this)); + }).each(function () { + var colKey; + rowIndex = 0; + ranges = []; + + if ( defaults.exportHiddenCells === false ) { + $hiddenTableElements = $(this).find("tr, th, td").filter(":hidden"); + checkCellVisibilty = $hiddenTableElements.length > 0; + } + + colNames = GetColumnNames(this); + + teOptions.columns = []; + teOptions.rows = []; + teOptions.rowoptions = {}; + + // onTable: optional callback function for every matching table that can be used + // to modify the tableExport options or to skip the output of a particular table + // if the table selector targets multiple tables + if ( typeof teOptions.onTable === 'function' ) + if ( teOptions.onTable($(this), defaults) === false ) + return true; // continue to next iteration step (table) + + // each table works with an own copy of AutoTable options + defaults.jspdf.autotable.tableExport = null; // avoid deep recursion error + var atOptions = $.extend(true, {}, defaults.jspdf.autotable); + defaults.jspdf.autotable.tableExport = teOptions; + + atOptions.margin = {}; + $.extend(true, atOptions.margin, defaults.jspdf.margins); + atOptions.tableExport = teOptions; + + // Fix jsPDF Autotable's row height calculation + if ( typeof atOptions.beforePageContent !== 'function' ) { + atOptions.beforePageContent = function (data) { + if ( data.pageCount == 1 ) { + var all = data.table.rows.concat(data.table.headerRow); + $.each(all, function () { + var row = this; + if ( row.height > 0 ) { + row.height += (2 - FONT_ROW_RATIO) / 2 * row.styles.fontSize; + data.table.height += (2 - FONT_ROW_RATIO) / 2 * row.styles.fontSize; + } + }); + } + }; + } + + if ( typeof atOptions.createdHeaderCell !== 'function' ) { + // apply some original css styles to pdf header cells + atOptions.createdHeaderCell = function (cell, data) { + + // jsPDF AutoTable plugin v2.0.14 fix: each cell needs its own styles object + cell.styles = $.extend({}, data.row.styles); + + if ( typeof teOptions.columns [data.column.dataKey] != 'undefined' ) { + var col = teOptions.columns [data.column.dataKey]; + + if ( typeof col.rect != 'undefined' ) { + var rh; + + cell.contentWidth = col.rect.width; + + if ( typeof teOptions.heightRatio == 'undefined' || teOptions.heightRatio === 0 ) { + if ( data.row.raw [data.column.dataKey].rowspan ) + rh = data.row.raw [data.column.dataKey].rect.height / data.row.raw [data.column.dataKey].rowspan; + else + rh = data.row.raw [data.column.dataKey].rect.height; + + teOptions.heightRatio = cell.styles.rowHeight / rh; + } + + rh = data.row.raw [data.column.dataKey].rect.height * teOptions.heightRatio; + if ( rh > cell.styles.rowHeight ) + cell.styles.rowHeight = rh; + } + + if ( typeof col.style != 'undefined' && col.style.hidden !== true ) { + cell.styles.halign = col.style.align; + if ( atOptions.styles.fillColor === 'inherit' ) + cell.styles.fillColor = col.style.bcolor; + if ( atOptions.styles.textColor === 'inherit' ) + cell.styles.textColor = col.style.color; + if ( atOptions.styles.fontStyle === 'inherit' ) + cell.styles.fontStyle = col.style.fstyle; + } + } + }; + } + + if ( typeof atOptions.createdCell !== 'function' ) { + // apply some original css styles to pdf table cells + atOptions.createdCell = function (cell, data) { + var rowopt = teOptions.rowoptions [data.row.index + ":" + data.column.dataKey]; + + if ( typeof rowopt != 'undefined' && + typeof rowopt.style != 'undefined' && + rowopt.style.hidden !== true ) { + cell.styles.halign = rowopt.style.align; + if ( atOptions.styles.fillColor === 'inherit' ) + cell.styles.fillColor = rowopt.style.bcolor; + if ( atOptions.styles.textColor === 'inherit' ) + cell.styles.textColor = rowopt.style.color; + if ( atOptions.styles.fontStyle === 'inherit' ) + cell.styles.fontStyle = rowopt.style.fstyle; + } + }; + } + + if ( typeof atOptions.drawHeaderCell !== 'function' ) { + atOptions.drawHeaderCell = function (cell, data) { + var colopt = teOptions.columns [data.column.dataKey]; + + if ( (colopt.style.hasOwnProperty("hidden") !== true || colopt.style.hidden !== true) && + colopt.rowIndex >= 0 ) + return prepareAutoTableText(cell, data, colopt); + else + return false; // cell is hidden + }; + } + + if ( typeof atOptions.drawCell !== 'function' ) { + atOptions.drawCell = function (cell, data) { + var rowopt = teOptions.rowoptions [data.row.index + ":" + data.column.dataKey]; + if ( prepareAutoTableText(cell, data, rowopt) ) { + + teOptions.doc.rect(cell.x, cell.y, cell.width, cell.height, cell.styles.fillStyle); + + if ( typeof rowopt != 'undefined' && typeof rowopt.kids != 'undefined' && rowopt.kids.length > 0 ) { + + var dh = cell.height / rowopt.rect.height; + if ( dh > teOptions.dh || typeof teOptions.dh == 'undefined' ) + teOptions.dh = dh; + teOptions.dw = cell.width / rowopt.rect.width; + + var y = cell.textPos.y; + drawAutotableElements(cell, rowopt.kids, teOptions); + cell.textPos.y = y; + drawAutotableText(cell, rowopt.kids, teOptions); + } + else + drawAutotableText(cell, {}, teOptions); + } + return false; + }; + } + + // collect header and data rows + teOptions.headerrows = []; + $hrows = $(this).find('thead').find(defaults.theadSelector); + $hrows.each(function () { + colKey = 0; + teOptions.headerrows[rowIndex] = []; + + ForEachVisibleCell(this, 'th,td', rowIndex, $hrows.length, + function (cell, row, col) { + var obj = getCellStyles(cell); + obj.title = parseString(cell, row, col); + obj.key = colKey++; + obj.rowIndex = rowIndex; + teOptions.headerrows[rowIndex].push(obj); + }); + rowIndex++; + }); + + if ( rowIndex > 0 ) { + // iterate through last row + var lastrow = rowIndex - 1; + while ( lastrow >= 0 ) { + $.each(teOptions.headerrows[lastrow], function () { + var obj = this; + + if ( lastrow > 0 && this.rect === null ) + obj = teOptions.headerrows[lastrow - 1][this.key]; + + if ( obj !== null && obj.rowIndex >= 0 && + (obj.style.hasOwnProperty("hidden") !== true || obj.style.hidden !== true) ) + teOptions.columns.push(obj); + }); + + lastrow = (teOptions.columns.length > 0) ? -1 : lastrow - 1; + } + } + + var rowCount = 0; + $rows = []; + $rows = collectRows ($(this)); + $($rows).each(function () { + var rowData = []; + colKey = 0; + + ForEachVisibleCell(this, 'td,th', rowIndex, $hrows.length + $rows.length, + function (cell, row, col) { + var obj; + + if ( typeof teOptions.columns[colKey] === 'undefined' ) { + // jsPDF-Autotable needs columns. Thus define hidden ones for tables without thead + obj = { + title: '', + key: colKey, + style: { + hidden: true + } + }; + teOptions.columns.push(obj); + } + if ( typeof cell !== 'undefined' && cell !== null ) { + obj = getCellStyles(cell); + obj.kids = $(cell).children(); + teOptions.rowoptions [rowCount + ":" + colKey++] = obj; + } + else { + obj = $.extend(true, {}, teOptions.rowoptions [rowCount + ":" + (colKey - 1)]); + obj.colspan = -1; + teOptions.rowoptions [rowCount + ":" + colKey++] = obj; + } + + rowData.push(parseString(cell, row, col)); + }); + if ( rowData.length ) { + teOptions.rows.push(rowData); + rowCount++; + } + rowIndex++; + }); + + // onBeforeAutotable: optional callback function before calling + // jsPDF AutoTable that can be used to modify the AutoTable options + if ( typeof teOptions.onBeforeAutotable === 'function' ) + teOptions.onBeforeAutotable($(this), teOptions.columns, teOptions.rows, atOptions); + + teOptions.doc.autoTable(teOptions.columns, teOptions.rows, atOptions); + + // onAfterAutotable: optional callback function after returning + // from jsPDF AutoTable that can be used to modify the AutoTable options + if ( typeof teOptions.onAfterAutotable === 'function' ) + teOptions.onAfterAutotable($(this), atOptions); + + // set the start position for the next table (in case there is one) + defaults.jspdf.autotable.startY = teOptions.doc.autoTableEndPosY() + atOptions.margin.top; + + }); + + jsPdfOutput(teOptions.doc, (typeof teOptions.images != 'undefined' && jQuery.isEmptyObject(teOptions.images) === false)); + + if ( typeof teOptions.headerrows != 'undefined' ) + teOptions.headerrows.length = 0; + if ( typeof teOptions.columns != 'undefined' ) + teOptions.columns.length = 0; + if ( typeof teOptions.rows != 'undefined' ) + teOptions.rows.length = 0; + delete teOptions.doc; + teOptions.doc = null; + }); + } + } + + /* + function FindColObject (objects, colIndex, rowIndex) { + var result = null; + $.each(objects, function () { + if ( this.rowIndex == rowIndex && this.key == colIndex ) { + result = this; + return false; + } + }); + return result; + } + */ + function collectRows ($table) { + var result = []; + findTablePart($table,'tbody').each(function () { + result.push.apply(result, findRows($(this), defaults.tbodySelector).toArray()); + }); + if ( defaults.tfootSelector.length ) { + findTablePart($table,'tfoot').each(function () { + result.push.apply(result, findRows($(this), defaults.tfootSelector).toArray()); + }); + } + return result; + } + + function findTablePart ($table, type) { + var tl = $table.parents('table').length; + return $table.find(type).filter (function () { + return $(this).closest('table').parents('table').length === tl; + }); + } + + function findRows ($tpart, rowSelector) { + return $tpart.find(rowSelector).filter (function () { + return $(this).find('table').length === 0 && $(this).parents('table').length === 1; + }); + } + + function GetColumnNames (table) { + var result = []; + $(table).find('thead').first().find('th').each(function (index, el) { + if ( $(el).attr("data-field") !== undefined ) + result[index] = $(el).attr("data-field"); + else + result[index] = index.toString(); + }); + return result; + } + + function isVisible ($element) { + var isCell = typeof $element[0].cellIndex !== 'undefined'; + var isRow = typeof $element[0].rowIndex !== 'undefined'; + var isElementVisible = (isCell || isRow) ? isTableElementVisible($element) : $element.is(':visible'); + var tableexportDisplay = $element.data("tableexport-display"); + + if (isCell && tableexportDisplay != 'none' && tableexportDisplay != 'always') { + $element = $($element[0].parentNode); + isRow = typeof $element[0].rowIndex !== 'undefined'; + tableexportDisplay = $element.data("tableexport-display"); + } + if (isRow && tableexportDisplay != 'none' && tableexportDisplay != 'always') { + tableexportDisplay = $element.closest('table').data("tableexport-display"); + } + + return tableexportDisplay !== 'none' && (isElementVisible == true || tableexportDisplay == 'always'); + } + + function isTableElementVisible ($element) { + var hiddenEls = []; + + if ( checkCellVisibilty ) { + hiddenEls = $hiddenTableElements.filter (function () { + var found = false; + + if (this.nodeType == $element[0].nodeType) { + if (typeof this.rowIndex !== 'undefined' && this.rowIndex == $element[0].rowIndex) + found = true; + else if (typeof this.cellIndex !== 'undefined' && this.cellIndex == $element[0].cellIndex && + typeof this.parentNode.rowIndex !== 'undefined' && + typeof $element[0].parentNode.rowIndex !== 'undefined' && + this.parentNode.rowIndex == $element[0].parentNode.rowIndex) + found = true; + } + return found; + }); + } + return (checkCellVisibilty == false || hiddenEls.length == 0); + } + + function isColumnIgnored ($cell, rowLength, colIndex) { + var result = false; + + if (isVisible($cell)) { + if ( defaults.ignoreColumn.length > 0 ) { + if ( $.inArray(colIndex, defaults.ignoreColumn) != -1 || + $.inArray(colIndex - rowLength, defaults.ignoreColumn) != -1 || + (colNames.length > colIndex && typeof colNames[colIndex] != 'undefined' && + $.inArray(colNames[colIndex], defaults.ignoreColumn) != -1) ) + result = true; + } + } + else + result = true; + + return result; + } + + function ForEachVisibleCell (tableRow, selector, rowIndex, rowCount, cellcallback) { + if ( typeof (cellcallback) === 'function' ) { + var ignoreRow = false; + + if (typeof defaults.onIgnoreRow === 'function') + ignoreRow = defaults.onIgnoreRow($(tableRow), rowIndex); + + if (ignoreRow === false && + $.inArray(rowIndex, defaults.ignoreRow) == -1 && + $.inArray(rowIndex - rowCount, defaults.ignoreRow) == -1 && + isVisible($(tableRow))) { + + var $cells = $(tableRow).find(selector); + var cellCount = 0; + + $cells.each(function (colIndex) { + var $cell = $(this); + var c; + var colspan = parseInt(this.getAttribute('colspan')); + var rowspan = parseInt(this.getAttribute('rowspan')); + + // Skip ranges + $.each(ranges, function () { + var range = this; + if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cellCount >= range.s.c && cellCount <= range.e.c ) { + for ( c = 0; c <= range.e.c - range.s.c; ++c ) + cellcallback(null, rowIndex, cellCount++); + } + }); + + if ( isColumnIgnored($cell, $cells.length, colIndex) === false ) { + // Handle Row Span + if ( rowspan || colspan ) { + rowspan = rowspan || 1; + colspan = colspan || 1; + ranges.push({ + s: {r: rowIndex, c: cellCount}, + e: {r: rowIndex + rowspan - 1, c: cellCount + colspan - 1} + }); + } + + // Handle Value + cellcallback(this, rowIndex, cellCount++); + } + + // Handle Colspan + if ( colspan ) + for ( c = 0; c < colspan - 1; ++c ) + cellcallback(null, rowIndex, cellCount++); + }); + + // Skip ranges + $.each(ranges, function () { + var range = this; + if ( rowIndex >= range.s.r && rowIndex <= range.e.r && cellCount >= range.s.c && cellCount <= range.e.c ) { + for ( c = 0; c <= range.e.c - range.s.c; ++c ) + cellcallback(null, rowIndex, cellCount++); + } + }); + } + } + } + + function jsPdfOutput (doc, hasimages) { + if ( defaults.consoleLog === true ) + console.log(doc.output()); + + if ( defaults.outputMode === 'string' ) + return doc.output(); + + if ( defaults.outputMode === 'base64' ) + return base64encode(doc.output()); + + if ( defaults.outputMode === 'window' ) { + window.URL = window.URL || window.webkitURL; + window.open(window.URL.createObjectURL(doc.output("blob"))); + return; + } + + try { + var blob = doc.output('blob'); + saveAs(blob, defaults.fileName + '.pdf'); + } + catch (e) { + downloadFile(defaults.fileName + '.pdf', + 'data:application/pdf' + (hasimages ? '' : ';base64') + ',', + hasimages ? doc.output('blob') : doc.output()); + } + } + + function prepareAutoTableText (cell, data, cellopt) { + var cs = 0; + if ( typeof cellopt !== 'undefined' ) + cs = cellopt.colspan; + + if ( cs >= 0 ) { + // colspan handling + var cellWidth = cell.width; + var textPosX = cell.textPos.x; + var i = data.table.columns.indexOf(data.column); + + for ( var c = 1; c < cs; c++ ) { + var column = data.table.columns[i + c]; + cellWidth += column.width; + } + + if ( cs > 1 ) { + if ( cell.styles.halign === 'right' ) + textPosX = cell.textPos.x + cellWidth - cell.width; + else if ( cell.styles.halign === 'center' ) + textPosX = cell.textPos.x + (cellWidth - cell.width) / 2; + } + + cell.width = cellWidth; + cell.textPos.x = textPosX; + + if ( typeof cellopt !== 'undefined' && cellopt.rowspan > 1 ) + cell.height = cell.height * cellopt.rowspan; + + // fix jsPDF's calculation of text position + if ( cell.styles.valign === 'middle' || cell.styles.valign === 'bottom' ) { + var splittedText = typeof cell.text === 'string' ? cell.text.split(/\r\n|\r|\n/g) : cell.text; + var lineCount = splittedText.length || 1; + if ( lineCount > 2 ) + cell.textPos.y -= ((2 - FONT_ROW_RATIO) / 2 * data.row.styles.fontSize) * (lineCount - 2) / 3; + } + return true; + } + else + return false; // cell is hidden (colspan = -1), don't draw it + } + + function collectImages (cell, elements, teOptions) { + if ( typeof teOptions.images != 'undefined' ) { + elements.each(function () { + var kids = $(this).children(); + + if ( $(this).is("img") ) { + var hash = strHashCode(this.src); + + teOptions.images[hash] = { + url: this.src, + src: this.src + }; + } + + if ( typeof kids != 'undefined' && kids.length > 0 ) + collectImages(cell, kids, teOptions); + }); + } + } + + function loadImages (teOptions, callback) { + var i; + var imageCount = 0; + var x = 0; + + function done () { + callback(imageCount); + } + + function loadImage (image) { + if ( !image.url ) + return; + var img = new Image(); + imageCount = ++x; + img.crossOrigin = 'Anonymous'; + img.onerror = img.onload = function () { + if ( img.complete ) { + + if ( img.src.indexOf('data:image/') === 0 ) { + img.width = image.width || img.width || 0; + img.height = image.height || img.height || 0; + } + + if ( img.width + img.height ) { + var canvas = document.createElement("canvas"); + var ctx = canvas.getContext("2d"); + + canvas.width = img.width; + canvas.height = img.height; + ctx.drawImage(img, 0, 0); + + image.src = canvas.toDataURL("image/jpeg"); + } + } + if ( !--x ) + done(); + }; + img.src = image.url; + } + + if ( typeof teOptions.images != 'undefined' ) { + for ( i in teOptions.images ) + if ( teOptions.images.hasOwnProperty(i) ) + loadImage(teOptions.images[i]); + } + + return x || done(); + } + + function drawAutotableElements (cell, elements, teOptions) { + elements.each(function () { + var kids = $(this).children(); + var uy = 0; + + if ( $(this).is("div") ) { + var bcolor = rgb2array(getStyle(this, 'background-color'), [255, 255, 255]); + var lcolor = rgb2array(getStyle(this, 'border-top-color'), [0, 0, 0]); + var lwidth = getPropertyUnitValue(this, 'border-top-width', defaults.jspdf.unit); + + var r = this.getBoundingClientRect(); + var ux = this.offsetLeft * teOptions.dw; + uy = this.offsetTop * teOptions.dh; + var uw = r.width * teOptions.dw; + var uh = r.height * teOptions.dh; + + teOptions.doc.setDrawColor.apply(undefined, lcolor); + teOptions.doc.setFillColor.apply(undefined, bcolor); + teOptions.doc.setLineWidth(lwidth); + teOptions.doc.rect(cell.x + ux, cell.y + uy, uw, uh, lwidth ? "FD" : "F"); + } + else if ( $(this).is("img") ) { + if ( typeof teOptions.images != 'undefined' ) { + var hash = strHashCode(this.src); + var image = teOptions.images[hash]; + + if ( typeof image != 'undefined' ) { + + var arCell = cell.width / cell.height; + var arImg = this.width / this.height; + var imgWidth = cell.width; + var imgHeight = cell.height; + var px2pt = 0.264583 * 72 / 25.4; + + if ( arImg <= arCell ) { + imgHeight = Math.min(cell.height, this.height); + imgWidth = this.width * imgHeight / this.height; + } + else if ( arImg > arCell ) { + imgWidth = Math.min(cell.width, this.width); + imgHeight = this.height * imgWidth / this.width; + } + + imgWidth *= px2pt; + imgHeight *= px2pt; + + if ( imgHeight < cell.height ) + uy = (cell.height - imgHeight) / 2; + + try { + teOptions.doc.addImage(image.src, cell.textPos.x, cell.y + uy, imgWidth, imgHeight); + } + catch (e) { + // TODO: IE -> convert png to jpeg + } + cell.textPos.x += imgWidth; + } + } + } + + if ( typeof kids != 'undefined' && kids.length > 0 ) + drawAutotableElements(cell, kids, teOptions); + }); + } + + function drawAutotableText (cell, texttags, teOptions) { + if ( typeof teOptions.onAutotableText === 'function' ) { + teOptions.onAutotableText(teOptions.doc, cell, texttags); + } + else { + var x = cell.textPos.x; + var y = cell.textPos.y; + var style = {halign: cell.styles.halign, valign: cell.styles.valign}; + + if ( texttags.length ) { + var tag = texttags[0]; + while ( tag.previousSibling ) + tag = tag.previousSibling; + + var b = false, i = false; + + while ( tag ) { + var txt = tag.innerText || tag.textContent || ""; + + txt = ((txt.length && txt[0] == " ") ? " " : "") + + $.trim(txt) + + ((txt.length > 1 && txt[txt.length - 1] == " ") ? " " : ""); + + if ( $(tag).is("br") ) { + x = cell.textPos.x; + y += teOptions.doc.internal.getFontSize(); + } + + if ( $(tag).is("b") ) + b = true; + else if ( $(tag).is("i") ) + i = true; + + if ( b || i ) + teOptions.doc.setFontType((b && i) ? "bolditalic" : b ? "bold" : "italic"); + + var w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); + + if ( w ) { + if ( cell.styles.overflow === 'linebreak' && + x > cell.textPos.x && (x + w) > (cell.textPos.x + cell.width) ) { + var chars = ".,!%*;:=-"; + if ( chars.indexOf(txt.charAt(0)) >= 0 ) { + var s = txt.charAt(0); + w = teOptions.doc.getStringUnitWidth(s) * teOptions.doc.internal.getFontSize(); + if ( (x + w) <= (cell.textPos.x + cell.width) ) { + teOptions.doc.autoTableText(s, x, y, style); + txt = txt.substring(1, txt.length); + } + w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); + } + x = cell.textPos.x; + y += teOptions.doc.internal.getFontSize(); + } + + while ( txt.length && (x + w) > (cell.textPos.x + cell.width) ) { + txt = txt.substring(0, txt.length - 1); + w = teOptions.doc.getStringUnitWidth(txt) * teOptions.doc.internal.getFontSize(); + } + + teOptions.doc.autoTableText(txt, x, y, style); + x += w; + } + + if ( b || i ) { + if ( $(tag).is("b") ) + b = false; + else if ( $(tag).is("i") ) + i = false; + + teOptions.doc.setFontType((!b && !i) ? "normal" : b ? "bold" : "italic"); + } + + tag = tag.nextSibling; + } + cell.textPos.x = x; + cell.textPos.y = y; + } + else { + teOptions.doc.autoTableText(cell.text, cell.textPos.x, cell.textPos.y, style); + } + } + } + + function escapeRegExp (string) { + return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); + } + + function replaceAll (string, find, replace) { + return string.replace(new RegExp(escapeRegExp(find), 'g'), replace); + } + + function parseNumber (value) { + value = value || "0"; + value = replaceAll(value, defaults.numbers.html.thousandsSeparator, ''); + value = replaceAll(value, defaults.numbers.html.decimalMark, '.'); + + return typeof value === "number" || jQuery.isNumeric(value) !== false ? value : false; + } + + function parsePercent (value) { + if ( value.indexOf("%") > -1 ) { + value = parseNumber(value.replace(/%/g, "")); + if ( value !== false ) + value = value / 100; + } + else + value = false; + return value; + } + + function parseString (cell, rowIndex, colIndex) { + var result = ''; + + if ( cell !== null ) { + var $cell = $(cell); + var htmlData; + + if ( $cell[0].hasAttribute("data-tableexport-value") ) { + htmlData = $cell.data("tableexport-value"); + htmlData = htmlData ? htmlData + '' : '' + } + else { + htmlData = $cell.html(); + + if ( typeof defaults.onCellHtmlData === 'function' ) + htmlData = defaults.onCellHtmlData($cell, rowIndex, colIndex, htmlData); + else if ( htmlData != '' ) { + var html = $.parseHTML(htmlData); + var inputidx = 0; + var selectidx = 0; + + htmlData = ''; + $.each(html, function () { + if ( $(this).is("input") ) + htmlData += $cell.find('input').eq(inputidx++).val(); + else if ( $(this).is("select") ) + htmlData += $cell.find('select option:selected').eq(selectidx++).text(); + else { + if ( typeof $(this).html() === 'undefined' ) + htmlData += $(this).text(); + else if ( jQuery().bootstrapTable === undefined || + ($(this).hasClass('filterControl') !== true && + $(cell).parents('.detail-view').length === 0) ) + htmlData += $(this).html(); + } + }); + } + } + + if ( defaults.htmlContent === true ) { + result = $.trim(htmlData); + } + else if ( htmlData && htmlData != '' ) { + var cellFormat = $(cell).data("tableexport-cellformat"); + + if ( cellFormat != '' ) { + var text = htmlData.replace(/\n/g, '\u2028').replace(//gi, '\u2060'); + var obj = $('
    ').html(text).contents(); + var number = false; + text = ''; + $.each(obj.text().split("\u2028"), function (i, v) { + if ( i > 0 ) + text += " "; + text += $.trim(v); + }); + + $.each(text.split("\u2060"), function (i, v) { + if ( i > 0 ) + result += "\n"; + result += $.trim(v).replace(/\u00AD/g, ""); // remove soft hyphens + }); + + if ( defaults.type == 'json' || + (defaults.type === 'excel' && defaults.excelFileFormat === 'xmlss') || + defaults.numbers.output === false ) { + number = parseNumber(result); + + if ( number !== false ) + result = Number(number); + } + else if ( defaults.numbers.html.decimalMark != defaults.numbers.output.decimalMark || + defaults.numbers.html.thousandsSeparator != defaults.numbers.output.thousandsSeparator ) { + number = parseNumber(result); + + if ( number !== false ) { + var frac = ("" + number.substr(number < 0 ? 1 : 0)).split('.'); + if ( frac.length == 1 ) + frac[1] = ""; + var mod = frac[0].length > 3 ? frac[0].length % 3 : 0; + + result = (number < 0 ? "-" : "") + + (defaults.numbers.output.thousandsSeparator ? ((mod ? frac[0].substr(0, mod) + defaults.numbers.output.thousandsSeparator : "") + frac[0].substr(mod).replace(/(\d{3})(?=\d)/g, "$1" + defaults.numbers.output.thousandsSeparator)) : frac[0]) + + (frac[1].length ? defaults.numbers.output.decimalMark + frac[1] : ""); + } + } + } + else + result = htmlData; + } + + if ( defaults.escape === true ) { + //noinspection JSDeprecatedSymbols + result = escape(result); + } + + if ( typeof defaults.onCellData === 'function' ) { + result = defaults.onCellData($cell, rowIndex, colIndex, result); + } + } + + return result; + } + + //noinspection JSUnusedLocalSymbols + function hyphenate (a, b, c) { + return b + "-" + c.toLowerCase(); + } + + function rgb2array (rgb_string, default_result) { + var re = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/; + var bits = re.exec(rgb_string); + var result = default_result; + if ( bits ) + result = [parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3])]; + return result; + } + + function getCellStyles (cell) { + var a = getStyle(cell, 'text-align'); + var fw = getStyle(cell, 'font-weight'); + var fs = getStyle(cell, 'font-style'); + var f = ''; + if ( a == 'start' ) + a = getStyle(cell, 'direction') == 'rtl' ? 'right' : 'left'; + if ( fw >= 700 ) + f = 'bold'; + if ( fs == 'italic' ) + f += fs; + if ( f === '' ) + f = 'normal'; + + var result = { + style: { + align: a, + bcolor: rgb2array(getStyle(cell, 'background-color'), [255, 255, 255]), + color: rgb2array(getStyle(cell, 'color'), [0, 0, 0]), + fstyle: f + }, + colspan: (parseInt($(cell).attr('colspan')) || 0), + rowspan: (parseInt($(cell).attr('rowspan')) || 0) + }; + + if ( cell !== null ) { + var r = cell.getBoundingClientRect(); + result.rect = { + width: r.width, + height: r.height + }; + } + + return result; + } + + // get computed style property + function getStyle (target, prop) { + try { + if ( window.getComputedStyle ) { // gecko and webkit + prop = prop.replace(/([a-z])([A-Z])/, hyphenate); // requires hyphenated, not camel + return window.getComputedStyle(target, null).getPropertyValue(prop); + } + if ( target.currentStyle ) { // ie + return target.currentStyle[prop]; + } + return target.style[prop]; + } + catch (e) { + } + return ""; + } + + function getUnitValue (parent, value, unit) { + var baseline = 100; // any number serves + + var temp = document.createElement("div"); // create temporary element + temp.style.overflow = "hidden"; // in case baseline is set too low + temp.style.visibility = "hidden"; // no need to show it + + parent.appendChild(temp); // insert it into the parent for em, ex and % + + temp.style.width = baseline + unit; + var factor = baseline / temp.offsetWidth; + + parent.removeChild(temp); // clean up + + return (value * factor); + } + + function getPropertyUnitValue (target, prop, unit) { + var value = getStyle(target, prop); // get the computed style value + + var numeric = value.match(/\d+/); // get the numeric component + if ( numeric !== null ) { + numeric = numeric[0]; // get the string + + return getUnitValue(target.parentElement, numeric, unit); + } + return 0; + } + + function jx_Workbook () { + if ( !(this instanceof jx_Workbook) ) { + //noinspection JSPotentiallyInvalidConstructorUsage + return new jx_Workbook(); + } + this.SheetNames = []; + this.Sheets = {}; + } + + function jx_s2ab (s) { + var buf = new ArrayBuffer(s.length); + var view = new Uint8Array(buf); + for ( var i = 0; i != s.length; ++i ) view[i] = s.charCodeAt(i) & 0xFF; + return buf; + } + + function jx_datenum (v, date1904) { + if ( date1904 ) v += 1462; + var epoch = Date.parse(v); + return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000); + } + + function jx_createSheet (data) { + var ws = {}; + var range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}}; + for ( var R = 0; R != data.length; ++R ) { + for ( var C = 0; C != data[R].length; ++C ) { + if ( range.s.r > R ) range.s.r = R; + if ( range.s.c > C ) range.s.c = C; + if ( range.e.r < R ) range.e.r = R; + if ( range.e.c < C ) range.e.c = C; + var cell = {v: data[R][C]}; + if ( cell.v === null ) continue; + var cell_ref = XLSX.utils.encode_cell({c: C, r: R}); + + if ( typeof cell.v === 'number' ) cell.t = 'n'; + else if ( typeof cell.v === 'boolean' ) cell.t = 'b'; + else if ( cell.v instanceof Date ) { + cell.t = 'n'; + cell.z = XLSX.SSF._table[14]; + cell.v = jx_datenum(cell.v); + } + else cell.t = 's'; + ws[cell_ref] = cell; + } + } + + if ( range.s.c < 10000000 ) ws['!ref'] = XLSX.utils.encode_range(range); + return ws; + } + + function strHashCode (str) { + var hash = 0, i, chr, len; + if ( str.length === 0 ) return hash; + for ( i = 0, len = str.length; i < len; i++ ) { + chr = str.charCodeAt(i); + hash = ((hash << 5) - hash) + chr; + hash |= 0; // Convert to 32bit integer + } + return hash; + } + + function downloadFile (filename, header, data) { + var ua = window.navigator.userAgent; + if ( filename !== false && window.navigator.msSaveOrOpenBlob ) { + //noinspection JSUnresolvedFunction + window.navigator.msSaveOrOpenBlob(new Blob([data]), filename); + } + else if ( filename !== false && (ua.indexOf("MSIE ") > 0 || !!ua.match(/Trident.*rv\:11\./)) ) { + // Internet Explorer (<= 9) workaround by Darryl (https://github.com/dawiong/tableExport.jquery.plugin) + // based on sampopes answer on http://stackoverflow.com/questions/22317951 + // ! Not working for json and pdf format ! + var frame = document.createElement("iframe"); + + if ( frame ) { + document.body.appendChild(frame); + frame.setAttribute("style", "display:none"); + frame.contentDocument.open("txt/plain", "replace"); + frame.contentDocument.write(data); + frame.contentDocument.close(); + frame.contentDocument.focus(); + + var extension = filename.substr((filename.lastIndexOf('.') +1)); + switch(extension) { + case 'doc': case 'json': case 'png': case 'pdf': case 'xls': case 'xlsx': + filename += ".txt"; + break; + } + frame.contentDocument.execCommand("SaveAs", true, filename); + document.body.removeChild(frame); + } + } + else { + var DownloadLink = document.createElement('a'); + + if ( DownloadLink ) { + var blobUrl = null; + + DownloadLink.style.display = 'none'; + if ( filename !== false ) + DownloadLink.download = filename; + else + DownloadLink.target = '_blank'; + + if ( typeof data == 'object' ) { + window.URL = window.URL || window.webkitURL; + blobUrl = window.URL.createObjectURL(data); + DownloadLink.href = blobUrl; + } + else if ( header.toLowerCase().indexOf("base64,") >= 0 ) + DownloadLink.href = header + base64encode(data); + else + DownloadLink.href = header + encodeURIComponent(data); + + document.body.appendChild(DownloadLink); + + if ( document.createEvent ) { + if ( DownloadEvt === null ) + DownloadEvt = document.createEvent('MouseEvents'); + + DownloadEvt.initEvent('click', true, false); + DownloadLink.dispatchEvent(DownloadEvt); + } + else if ( document.createEventObject ) + DownloadLink.fireEvent('onclick'); + else if ( typeof DownloadLink.onclick == 'function' ) + DownloadLink.onclick(); + + setTimeout(function(){ + if ( blobUrl ) + window.URL.revokeObjectURL(blobUrl); + document.body.removeChild(DownloadLink); + }, 100); + } + } + } + + function utf8Encode (text) { + if (typeof text === 'string') { + text = text.replace(/\x0d\x0a/g, "\x0a"); + var utftext = ""; + for ( var n = 0; n < text.length; n++ ) { + var c = text.charCodeAt(n); + if ( c < 128 ) { + utftext += String.fromCharCode(c); + } + else if ( (c > 127) && (c < 2048) ) { + utftext += String.fromCharCode((c >> 6) | 192); + utftext += String.fromCharCode((c & 63) | 128); + } + else { + utftext += String.fromCharCode((c >> 12) | 224); + utftext += String.fromCharCode(((c >> 6) & 63) | 128); + utftext += String.fromCharCode((c & 63) | 128); + } + } + return utftext; + } + return text; + } + + function base64encode (input) { + var chr1, chr2, chr3, enc1, enc2, enc3, enc4; + var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + var output = ""; + var i = 0; + input = utf8Encode(input); + while ( i < input.length ) { + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + if ( isNaN(chr2) ) { + enc3 = enc4 = 64; + } else if ( isNaN(chr3) ) { + enc4 = 64; + } + output = output + + keyStr.charAt(enc1) + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + keyStr.charAt(enc4); + } + return output; + } + + return this; + } +})(jQuery); diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js similarity index 96% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js index ee98b198b..c4a362a52 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js @@ -1,92 +1,92 @@ -/** - * 基于bootstrap-table-mobile修改 - * 修正部分iPhone手机不显示卡片视图 - * Copyright (c) 2019 ruoyi - */ -!function ($) { - - 'use strict'; - - var resetView = function (that) { - if (that.options.height || that.options.showFooter) { - setTimeout(that.resetView(), 1); - } - }; - - // 判断是否 iphone - var isIPhone = function () { - var browserName = navigator.userAgent.toLowerCase(); - return /(iPhone|iPad|iPod|iOS)/i.test(browserName); - }; - - var changeView = function (that, width, height) { - if (that.options.minHeight) { - if (checkValuesLessEqual(width, that.options.minWidth) && checkValuesLessEqual(height, that.options.minHeight)) { - conditionCardView(that); - } else if (checkValuesGreater(width, that.options.minWidth) && checkValuesGreater(height, that.options.minHeight)) { - conditionFullView(that); - } - } else { - if (checkValuesLessEqual(width, that.options.minWidth) || isIPhone()) { - conditionCardView(that); - } else if (checkValuesGreater(width, that.options.minWidth)) { - conditionFullView(that); - } - } - - resetView(that); - }; - - var checkValuesLessEqual = function (currentValue, targetValue) { - return currentValue <= targetValue; - }; - - var checkValuesGreater = function (currentValue, targetValue) { - return currentValue > targetValue; - }; - - var conditionCardView = function (that) { - changeTableView(that, false); - }; - - var conditionFullView = function (that) { - changeTableView(that, true); - }; - - var changeTableView = function (that, cardViewState) { - that.options.cardView = cardViewState; - that.toggleView(); - }; - - $.extend($.fn.bootstrapTable.defaults, { - mobileResponsive: false, - minWidth: 562, - minHeight: undefined, - checkOnInit: true, - toggled: false - }); - - var BootstrapTable = $.fn.bootstrapTable.Constructor, - _init = BootstrapTable.prototype.init; - - BootstrapTable.prototype.init = function () { - _init.apply(this, Array.prototype.slice.apply(arguments)); - - if (!this.options.mobileResponsive) { - return; - } - - if (!this.options.minWidth) { - return; - } - - var that = this; - $(window).resize(function () { - changeView(that, $(this).width(), $(this).height()) - }); - - if (this.options.checkOnInit) { - changeView(this, $(window).width(), $(window).height()); - } - }; +/** + * 基于bootstrap-table-mobile修改 + * 修正部分iPhone手机不显示卡片视图 + * Copyright (c) 2019 ruoyi + */ +!function ($) { + + 'use strict'; + + var resetView = function (that) { + if (that.options.height || that.options.showFooter) { + setTimeout(that.resetView(), 1); + } + }; + + // 判断是否 iphone + var isIPhone = function () { + var browserName = navigator.userAgent.toLowerCase(); + return /(iPhone|iPad|iPod|iOS)/i.test(browserName); + }; + + var changeView = function (that, width, height) { + if (that.options.minHeight) { + if (checkValuesLessEqual(width, that.options.minWidth) && checkValuesLessEqual(height, that.options.minHeight)) { + conditionCardView(that); + } else if (checkValuesGreater(width, that.options.minWidth) && checkValuesGreater(height, that.options.minHeight)) { + conditionFullView(that); + } + } else { + if (checkValuesLessEqual(width, that.options.minWidth) || isIPhone()) { + conditionCardView(that); + } else if (checkValuesGreater(width, that.options.minWidth)) { + conditionFullView(that); + } + } + + resetView(that); + }; + + var checkValuesLessEqual = function (currentValue, targetValue) { + return currentValue <= targetValue; + }; + + var checkValuesGreater = function (currentValue, targetValue) { + return currentValue > targetValue; + }; + + var conditionCardView = function (that) { + changeTableView(that, false); + }; + + var conditionFullView = function (that) { + changeTableView(that, true); + }; + + var changeTableView = function (that, cardViewState) { + that.options.cardView = cardViewState; + that.toggleView(); + }; + + $.extend($.fn.bootstrapTable.defaults, { + mobileResponsive: false, + minWidth: 562, + minHeight: undefined, + checkOnInit: true, + toggled: false + }); + + var BootstrapTable = $.fn.bootstrapTable.Constructor, + _init = BootstrapTable.prototype.init; + + BootstrapTable.prototype.init = function () { + _init.apply(this, Array.prototype.slice.apply(arguments)); + + if (!this.options.mobileResponsive) { + return; + } + + if (!this.options.minWidth) { + return; + } + + var that = this; + $(window).resize(function () { + changeView(that, $(this).width(), $(this).height()) + }); + + if (this.options.checkOnInit) { + changeView(this, $(window).width(), $(window).height()); + } + }; }(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder/bootstrap-table-reorder.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder/bootstrap-table-reorder.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder/bootstrap-table-reorder.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder/bootstrap-table-reorder.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder/jquery.tablednd.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder/jquery.tablednd.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder/jquery.tablednd.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/reorder/jquery.tablednd.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js index 0a81b323f..c6dbae25e 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js @@ -1,211 +1,211 @@ -/** - * @author: aperez - * @version: v2.0.0 - * - * @update Dennis Hernández - */ - -!function($) { - 'use strict'; - - var firstLoad = false; - - var sprintf = $.fn.bootstrapTable.utils.sprintf; - - var showAvdSearch = function(pColumns, searchTitle, searchText, that) { - if (!$("#avdSearchModal" + "_" + that.options.idTable).hasClass("modal")) { - var vModal = sprintf("
    ", "_" + that.options.idTable); - vModal += "
    "; - vModal += "
    "; - vModal += "
    "; - vModal += " "; - vModal += sprintf("

    %s

    ", searchTitle); - vModal += "
    "; - vModal += "
    "; - vModal += sprintf("
    ", "_" + that.options.idTable); - vModal += "
    "; - vModal += "
    "; - vModal += "
    "; - vModal += "
    "; - vModal += "
    "; - - $("body").append($(vModal)); - - var vFormAvd = createFormAvd(pColumns, searchText, that), - timeoutId = 0;; - - $('#avdSearchModalContent' + "_" + that.options.idTable).append(vFormAvd.join('')); - - $('#' + that.options.idForm).off('keyup blur', 'input').on('keyup blur', 'input', function (event) { - clearTimeout(timeoutId); - timeoutId = setTimeout(function () { - that.onColumnAdvancedSearch(event); - }, that.options.searchTimeOut); - }); - - $("#btnCloseAvd" + "_" + that.options.idTable).click(function() { - $("#avdSearchModal" + "_" + that.options.idTable).modal('hide'); - }); - - $("#avdSearchModal" + "_" + that.options.idTable).modal(); - } else { - $("#avdSearchModal" + "_" + that.options.idTable).modal(); - } - }; - - var createFormAvd = function(pColumns, searchText, that) { - var htmlForm = []; - htmlForm.push(sprintf('
    ', that.options.idForm, that.options.actionForm)); - for (var i in pColumns) { - var vObjCol = pColumns[i]; - if (!vObjCol.checkbox && vObjCol.visible && vObjCol.searchable) { - htmlForm.push('
    '); - htmlForm.push(sprintf('', vObjCol.title)); - htmlForm.push('
    '); - htmlForm.push(sprintf('', vObjCol.field, vObjCol.title, vObjCol.field)); - htmlForm.push('
    '); - htmlForm.push('
    '); - } - } - - htmlForm.push('
    '); - htmlForm.push('
    '); - htmlForm.push(sprintf('', "_" + that.options.idTable, searchText)); - htmlForm.push('
    '); - htmlForm.push('
    '); - htmlForm.push('
    '); - - return htmlForm; - }; - - $.extend($.fn.bootstrapTable.defaults, { - advancedSearch: false, - idForm: 'advancedSearch', - actionForm: '', - idTable: undefined, - onColumnAdvancedSearch: function (field, text) { - return false; - } - }); - - $.extend($.fn.bootstrapTable.defaults.icons, { - advancedSearchIcon: 'glyphicon-chevron-down' - }); - - $.extend($.fn.bootstrapTable.Constructor.EVENTS, { - 'column-advanced-search.bs.table': 'onColumnAdvancedSearch' - }); - - $.extend($.fn.bootstrapTable.locales, { - formatAdvancedSearch: function() { - return 'Advanced search'; - }, - formatAdvancedCloseButton: function() { - return "Close"; - } - }); - - $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); - - var BootstrapTable = $.fn.bootstrapTable.Constructor, - _initToolbar = BootstrapTable.prototype.initToolbar, - _load = BootstrapTable.prototype.load, - _initSearch = BootstrapTable.prototype.initSearch; - - BootstrapTable.prototype.initToolbar = function() { - _initToolbar.apply(this, Array.prototype.slice.apply(arguments)); - - if (!this.options.search) { - return; - } - - if (!this.options.advancedSearch) { - return; - } - - if (!this.options.idTable) { - return; - } - - var that = this, - html = []; - - html.push(sprintf('
    ', this.options.buttonsAlign, this.options.buttonsAlign)); - html.push(sprintf('
    '); - - that.$toolbar.prepend(html.join('')); - - that.$toolbar.find('button[name="advancedSearch"]') - .off('click').on('click', function() { - showAvdSearch(that.columns, that.options.formatAdvancedSearch(), that.options.formatAdvancedCloseButton(), that); - }); - }; - - BootstrapTable.prototype.load = function(data) { - _load.apply(this, Array.prototype.slice.apply(arguments)); - - if (!this.options.advancedSearch) { - return; - } - - if (typeof this.options.idTable === 'undefined') { - return; - } else { - if (!firstLoad) { - var height = parseInt($(".bootstrap-table").height()); - height += 10; - $("#" + this.options.idTable).bootstrapTable("resetView", {height: height}); - firstLoad = true; - } - } - }; - - BootstrapTable.prototype.initSearch = function () { - _initSearch.apply(this, Array.prototype.slice.apply(arguments)); - - if (!this.options.advancedSearch) { - return; - } - - var that = this; - var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial; - - this.data = fp ? $.grep(this.data, function (item, i) { - for (var key in fp) { - var fval = fp[key].toLowerCase(); - var value = item[key]; - value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header, - that.header.formatters[$.inArray(key, that.header.fields)], - [value, item, i], value); - - if (!($.inArray(key, that.header.fields) !== -1 && - (typeof value === 'string' || typeof value === 'number') && - (value + '').toLowerCase().indexOf(fval) !== -1)) { - return false; - } - } - return true; - }) : this.data; - }; - - BootstrapTable.prototype.onColumnAdvancedSearch = function (event) { - var text = $.trim($(event.currentTarget).val()); - var $field = $(event.currentTarget)[0].id; - - if ($.isEmptyObject(this.filterColumnsPartial)) { - this.filterColumnsPartial = {}; - } - if (text) { - this.filterColumnsPartial[$field] = text; - } else { - delete this.filterColumnsPartial[$field]; - } - - this.options.pageNumber = 1; - this.onSearch(event); - this.updatePagination(); - this.trigger('column-advanced-search', $field, text); - }; +/** + * @author: aperez + * @version: v2.0.0 + * + * @update Dennis Hernández + */ + +!function($) { + 'use strict'; + + var firstLoad = false; + + var sprintf = $.fn.bootstrapTable.utils.sprintf; + + var showAvdSearch = function(pColumns, searchTitle, searchText, that) { + if (!$("#avdSearchModal" + "_" + that.options.idTable).hasClass("modal")) { + var vModal = sprintf("
    ", "_" + that.options.idTable); + vModal += "
    "; + vModal += "
    "; + vModal += "
    "; + vModal += " "; + vModal += sprintf("

    %s

    ", searchTitle); + vModal += "
    "; + vModal += "
    "; + vModal += sprintf("
    ", "_" + that.options.idTable); + vModal += "
    "; + vModal += "
    "; + vModal += "
    "; + vModal += "
    "; + vModal += "
    "; + + $("body").append($(vModal)); + + var vFormAvd = createFormAvd(pColumns, searchText, that), + timeoutId = 0;; + + $('#avdSearchModalContent' + "_" + that.options.idTable).append(vFormAvd.join('')); + + $('#' + that.options.idForm).off('keyup blur', 'input').on('keyup blur', 'input', function (event) { + clearTimeout(timeoutId); + timeoutId = setTimeout(function () { + that.onColumnAdvancedSearch(event); + }, that.options.searchTimeOut); + }); + + $("#btnCloseAvd" + "_" + that.options.idTable).click(function() { + $("#avdSearchModal" + "_" + that.options.idTable).modal('hide'); + }); + + $("#avdSearchModal" + "_" + that.options.idTable).modal(); + } else { + $("#avdSearchModal" + "_" + that.options.idTable).modal(); + } + }; + + var createFormAvd = function(pColumns, searchText, that) { + var htmlForm = []; + htmlForm.push(sprintf('
    ', that.options.idForm, that.options.actionForm)); + for (var i in pColumns) { + var vObjCol = pColumns[i]; + if (!vObjCol.checkbox && vObjCol.visible && vObjCol.searchable) { + htmlForm.push('
    '); + htmlForm.push(sprintf('', vObjCol.title)); + htmlForm.push('
    '); + htmlForm.push(sprintf('', vObjCol.field, vObjCol.title, vObjCol.field)); + htmlForm.push('
    '); + htmlForm.push('
    '); + } + } + + htmlForm.push('
    '); + htmlForm.push('
    '); + htmlForm.push(sprintf('', "_" + that.options.idTable, searchText)); + htmlForm.push('
    '); + htmlForm.push('
    '); + htmlForm.push('
    '); + + return htmlForm; + }; + + $.extend($.fn.bootstrapTable.defaults, { + advancedSearch: false, + idForm: 'advancedSearch', + actionForm: '', + idTable: undefined, + onColumnAdvancedSearch: function (field, text) { + return false; + } + }); + + $.extend($.fn.bootstrapTable.defaults.icons, { + advancedSearchIcon: 'glyphicon-chevron-down' + }); + + $.extend($.fn.bootstrapTable.Constructor.EVENTS, { + 'column-advanced-search.bs.table': 'onColumnAdvancedSearch' + }); + + $.extend($.fn.bootstrapTable.locales, { + formatAdvancedSearch: function() { + return 'Advanced search'; + }, + formatAdvancedCloseButton: function() { + return "Close"; + } + }); + + $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); + + var BootstrapTable = $.fn.bootstrapTable.Constructor, + _initToolbar = BootstrapTable.prototype.initToolbar, + _load = BootstrapTable.prototype.load, + _initSearch = BootstrapTable.prototype.initSearch; + + BootstrapTable.prototype.initToolbar = function() { + _initToolbar.apply(this, Array.prototype.slice.apply(arguments)); + + if (!this.options.search) { + return; + } + + if (!this.options.advancedSearch) { + return; + } + + if (!this.options.idTable) { + return; + } + + var that = this, + html = []; + + html.push(sprintf('
    ', this.options.buttonsAlign, this.options.buttonsAlign)); + html.push(sprintf('
    '); + + that.$toolbar.prepend(html.join('')); + + that.$toolbar.find('button[name="advancedSearch"]') + .off('click').on('click', function() { + showAvdSearch(that.columns, that.options.formatAdvancedSearch(), that.options.formatAdvancedCloseButton(), that); + }); + }; + + BootstrapTable.prototype.load = function(data) { + _load.apply(this, Array.prototype.slice.apply(arguments)); + + if (!this.options.advancedSearch) { + return; + } + + if (typeof this.options.idTable === 'undefined') { + return; + } else { + if (!firstLoad) { + var height = parseInt($(".bootstrap-table").height()); + height += 10; + $("#" + this.options.idTable).bootstrapTable("resetView", {height: height}); + firstLoad = true; + } + } + }; + + BootstrapTable.prototype.initSearch = function () { + _initSearch.apply(this, Array.prototype.slice.apply(arguments)); + + if (!this.options.advancedSearch) { + return; + } + + var that = this; + var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial; + + this.data = fp ? $.grep(this.data, function (item, i) { + for (var key in fp) { + var fval = fp[key].toLowerCase(); + var value = item[key]; + value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header, + that.header.formatters[$.inArray(key, that.header.fields)], + [value, item, i], value); + + if (!($.inArray(key, that.header.fields) !== -1 && + (typeof value === 'string' || typeof value === 'number') && + (value + '').toLowerCase().indexOf(fval) !== -1)) { + return false; + } + } + return true; + }) : this.data; + }; + + BootstrapTable.prototype.onColumnAdvancedSearch = function (event) { + var text = $.trim($(event.currentTarget).val()); + var $field = $(event.currentTarget)[0].id; + + if ($.isEmptyObject(this.filterColumnsPartial)) { + this.filterColumnsPartial = {}; + } + if (text) { + this.filterColumnsPartial[$field] = text; + } else { + delete this.filterColumnsPartial[$field]; + } + + this.options.pageNumber = 1; + this.onSearch(event); + this.updatePagination(); + this.trigger('column-advanced-search', $field, text); + }; }(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js index 7a9041fb1..bffb3cbfd 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js @@ -1,7 +1,7 @@ -/* -* bootstrap-table - v1.11.0 - 2016-07-02 -* https://github.com/wenzhixin/bootstrap-table -* Copyright (c) 2016 zhixin wen -* Licensed MIT License -*/ +/* +* bootstrap-table - v1.11.0 - 2016-07-02 +* https://github.com/wenzhixin/bootstrap-table +* Copyright (c) 2016 zhixin wen +* Licensed MIT License +*/ !function(a){"use strict";var b=!1,c=a.fn.bootstrapTable.utils.sprintf,d=function(b,d,f,g){if(a("#avdSearchModal_"+g.options.idTable).hasClass("modal"))a("#avdSearchModal_"+g.options.idTable).modal();else{var h=c('",a("body").append(a(h));var i=e(b,f,g),j=0;a("#avdSearchModalContent_"+g.options.idTable).append(i.join("")),a("#"+g.options.idForm).off("keyup blur","input").on("keyup blur","input",function(a){clearTimeout(j),j=setTimeout(function(){g.onColumnAdvancedSearch(a)},g.options.searchTimeOut)}),a("#btnCloseAvd_"+g.options.idTable).click(function(){a("#avdSearchModal_"+g.options.idTable).modal("hide")}),a("#avdSearchModal_"+g.options.idTable).modal()}},e=function(a,b,d){var e=[];e.push(c('
    ',d.options.idForm,d.options.actionForm));for(var f in a){var g=a[f];!g.checkbox&&g.visible&&g.searchable&&(e.push('
    '),e.push(c('',g.title)),e.push('
    '),e.push(c('',g.field,g.title,g.field)),e.push("
    "),e.push("
    "))}return e.push('
    '),e.push('
    '),e.push(c('',"_"+d.options.idTable,b)),e.push("
    "),e.push("
    "),e.push("
    "),e};a.extend(a.fn.bootstrapTable.defaults,{advancedSearch:!1,idForm:"advancedSearch",actionForm:"",idTable:void 0,onColumnAdvancedSearch:function(){return!1}}),a.extend(a.fn.bootstrapTable.defaults.icons,{advancedSearchIcon:"glyphicon-chevron-down"}),a.extend(a.fn.bootstrapTable.Constructor.EVENTS,{"column-advanced-search.bs.table":"onColumnAdvancedSearch"}),a.extend(a.fn.bootstrapTable.locales,{formatAdvancedSearch:function(){return"Advanced search"},formatAdvancedCloseButton:function(){return"Close"}}),a.extend(a.fn.bootstrapTable.defaults,a.fn.bootstrapTable.locales);var f=a.fn.bootstrapTable.Constructor,g=f.prototype.initToolbar,h=f.prototype.load,i=f.prototype.initSearch;f.prototype.initToolbar=function(){if(g.apply(this,Array.prototype.slice.apply(arguments)),this.options.search&&this.options.advancedSearch&&this.options.idTable){var a=this,b=[];b.push(c('
    ',this.options.buttonsAlign,this.options.buttonsAlign)),b.push(c('
    "),a.$toolbar.prepend(b.join("")),a.$toolbar.find('button[name="advancedSearch"]').off("click").on("click",function(){d(a.columns,a.options.formatAdvancedSearch(),a.options.formatAdvancedCloseButton(),a)})}},f.prototype.load=function(){if(h.apply(this,Array.prototype.slice.apply(arguments)),this.options.advancedSearch&&"undefined"!=typeof this.options.idTable&&!b){var c=parseInt(a(".bootstrap-table").height());c+=10,a("#"+this.options.idTable).bootstrapTable("resetView",{height:c}),b=!0}},f.prototype.initSearch=function(){if(i.apply(this,Array.prototype.slice.apply(arguments)),this.options.advancedSearch){var b=this,c=a.isEmptyObject(this.filterColumnsPartial)?null:this.filterColumnsPartial;this.data=c?a.grep(this.data,function(d,e){for(var f in c){var g=c[f].toLowerCase(),h=d[f];if(h=a.fn.bootstrapTable.utils.calculateObjectValue(b.header,b.header.formatters[a.inArray(f,b.header.fields)],[h,d,e],h),-1===a.inArray(f,b.header.fields)||"string"!=typeof h&&"number"!=typeof h||-1===(h+"").toLowerCase().indexOf(g))return!1}return!0}):this.data}},f.prototype.onColumnAdvancedSearch=function(b){var c=a.trim(a(b.currentTarget).val()),d=a(b.currentTarget)[0].id;a.isEmptyObject(this.filterColumnsPartial)&&(this.filterColumnsPartial={}),c?this.filterColumnsPartial[d]=c:delete this.filterColumnsPartial[d],this.options.pageNumber=1,this.onSearch(b),this.updatePagination(),this.trigger("column-advanced-search",d,c)}}(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.js similarity index 96% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.js index d0aeb94d2..7e9262dbf 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.js @@ -1,42 +1,42 @@ -(function ($) { - 'use strict'; - - $.fn.bootstrapTable.locales['zh-CN'] = { - formatLoadingMessage: function () { - return '正在努力地加载数据中,请稍候……'; - }, - formatRecordsPerPage: function (pageNumber) { - return pageNumber + ' 条记录每页'; - }, - formatShowingRows: function (pageFrom, pageTo, totalRows) { - return '第 ' + pageFrom + ' 到 ' + pageTo + ' 条,共 ' + totalRows + ' 条记录。'; - }, - formatSearch: function () { - return '搜索'; - }, - formatNoMatches: function () { - return '没有找到匹配的记录'; - }, - formatPaginationSwitch: function () { - return '隐藏/显示分页'; - }, - formatRefresh: function () { - return '刷新'; - }, - formatToggle: function () { - return '切换'; - }, - formatColumns: function () { - return '列'; - }, - formatExport: function () { - return '导出数据'; - }, - formatClearFilters: function () { - return '清空过滤'; - } - }; - - $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']); - -})(jQuery); +(function ($) { + 'use strict'; + + $.fn.bootstrapTable.locales['zh-CN'] = { + formatLoadingMessage: function () { + return '正在努力地加载数据中,请稍候……'; + }, + formatRecordsPerPage: function (pageNumber) { + return pageNumber + ' 条记录每页'; + }, + formatShowingRows: function (pageFrom, pageTo, totalRows) { + return '第 ' + pageFrom + ' 到 ' + pageTo + ' 条,共 ' + totalRows + ' 条记录。'; + }, + formatSearch: function () { + return '搜索'; + }, + formatNoMatches: function () { + return '没有找到匹配的记录'; + }, + formatPaginationSwitch: function () { + return '隐藏/显示分页'; + }, + formatRefresh: function () { + return '刷新'; + }, + formatToggle: function () { + return '切换'; + }, + formatColumns: function () { + return '列'; + }, + formatExport: function () { + return '导出数据'; + }, + formatClearFilters: function () { + return '清空过滤'; + } + }; + + $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']); + +})(jQuery); diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js rename to bmw-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js index 70842ca70..6bac7408c 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js @@ -1,706 +1,706 @@ -/** - * 基于bootstrapTreeTable/bootstrap-table-treegrid修改 - * Copyright (c) 2019 ruoyi - */ -(function($) { - "use strict"; - - $.fn.bootstrapTreeTable = function(options, param) { - var target = $(this).data('bootstrap.tree.table'); - target = target ? target : $(this); - // 如果是调用方法 - if (typeof options == 'string') { - return $.fn.bootstrapTreeTable.methods[options](target, param); - } - // 如果是初始化组件 - options = $.extend({}, $.fn.bootstrapTreeTable.defaults, options || {}); - target.hasSelectItem = false;// 是否有radio或checkbox - target.data_list = null; //用于缓存格式化后的数据-按父分组 - target.data_obj = null; //用于缓存格式化后的数据-按id存对象 - target.hiddenColumns = []; //用于存放被隐藏列的field - target.lastAjaxParams; //用户最后一次请求的参数 - target.isFixWidth=false; //是否有固定宽度 - // 初始化 - var init = function() { - // 初始化容器 - initContainer(); - // 初始化工具栏 - initToolbar(); - // 初始化表头 - initHeader(); - // 初始化表体 - initBody(); - // 初始化数据服务 - initServer(); - // 动态设置表头宽度 - autoTheadWidth(true); - // 缓存target对象 - target.data('bootstrap.tree.table', target); - } - // 初始化容器 - var initContainer = function() { - // 在外层包装一下div,样式用的bootstrap-table的 - var $main_div = $("
    "); - var $treetable = $("
    "); - target.before($main_div); - $main_div.append($treetable); - $treetable.append(target); - target.addClass("table"); - if (options.striped) { - target.addClass('table-striped'); - } - if (options.bordered) { - target.addClass('table-bordered'); - } - if (options.hover) { - target.addClass('table-hover'); - } - if (options.condensed) { - target.addClass('table-condensed'); - } - target.html(""); - } - // 初始化工具栏 - var initToolbar = function() { - var $toolbar = $("
    "); - if (options.toolbar) { - $(options.toolbar).addClass('tool-left'); - $toolbar.append($(options.toolbar)); - } - var $rightToolbar = $('
    '); - $toolbar.append($rightToolbar); - target.parent().before($toolbar); - // ruoyi 是否显示检索信息 - if (options.showSearch) { - var $searchBtn = $(''); - $rightToolbar.append($searchBtn); - registerSearchBtnClickEvent($searchBtn); - } - // 是否显示刷新按钮 - if (options.showRefresh) { - var $refreshBtn = $(''); - $rightToolbar.append($refreshBtn); - registerRefreshBtnClickEvent($refreshBtn); - } - // 是否显示列选项 - if (options.showColumns) { - var $columns_div = $('
    '); - var $columns_ul = $(''); - $.each(options.columns, function(i, column) { - if (column.field != 'selectItem') { - var _li = null; - if(typeof column.visible == "undefined"||column.visible==true){ - _li = $('
  • '); - }else{ - _li = $('
  • '); - target.hiddenColumns.push(column.field); - } - $columns_ul.append(_li); - } - }); - $columns_div.append($columns_ul); - $rightToolbar.append($columns_div); - // 注册列选项事件 - registerColumnClickEvent(); - }else{ - $.each(options.columns, function(i, column) { - if (column.field != 'selectItem') { - if(!(typeof column.visible == "undefined"||column.visible==true)){ - target.hiddenColumns.push(column.field); - } - } - }); - } - } - // 初始化隐藏列 - var initHiddenColumns = function(){ - $.each(target.hiddenColumns, function(i, field) { - target.find("."+field+"_cls").hide(); - }); - } - // 初始化表头 - var initHeader = function() { - var $thr = $(''); - $.each(options.columns, function(i, column) { - var $th = null; - // 判断有没有选择列 - if (i == 0 && column.field == 'selectItem') { - target.hasSelectItem = true; - $th = $(''); - } else { - $th = $(''); - } - if((!target.isFixWidth)&& column.width){ - target.isFixWidth = column.width.indexOf("px")>-1?true:false; - } - $th.text(column.title); - $thr.append($th); - }); - var $thead = $(''); - $thead.append($thr); - target.append($thead); - } - // 初始化表体 - var initBody = function() { - var $tbody = $(''); - target.append($tbody); - // 默认高度 - if (options.height) { - $tbody.css("height", options.height); - } - } - // 初始化数据服务 - var initServer = function(parms) { - // 加载数据前先清空 - target.data_list = {}; - target.data_obj = {}; - var $tbody = target.find("tbody"); - // 添加加载loading - var $loading = '
    正在努力地加载数据中,请稍候……
    ' - $tbody.html($loading); - if (options.url) { - $.ajax({ - type: options.type, - url: options.url, - data: parms ? parms : options.ajaxParams, - dataType: "JSON", - success: function(data, textStatus, jqXHR) { - renderTable(data); - }, - error: function(xhr, textStatus) { - var _errorMsg = '
    ' + xhr.responseText + '
    ' - $tbody.html(_errorMsg); - }, - }); - } else { - renderTable(options.data); - } - } - // 加载完数据后渲染表格 - var renderTable = function(data) { - var $tbody = target.find("tbody"); - // 先清空 - $tbody.html(""); - if (!data || data.length <= 0) { - var _empty = '
    没有找到匹配的记录
    ' - $tbody.html(_empty); - return; - } - // 缓存并格式化数据 - formatData(data); - // 获取所有根节点 - var rootNode = target.data_list["_root_"]; - // 开始绘制 - if (rootNode) { - $.each(rootNode, function(i, item) { - var _child_row_id = "row_id_" + i - recursionNode(item, 1, _child_row_id, "row_root"); - }); - } - // 下边的操作主要是为了查询时让一些没有根节点的节点显示 - $.each(data, function(i, item) { - if (!item.isShow) { - var tr = renderRow(item, false, 1, "", ""); - $tbody.append(tr); - } - }); - target.append($tbody); - registerExpanderEvent(); - registerRowClickEvent(); - initHiddenColumns(); - // 动态设置表头宽度 - autoTheadWidth() - } - // 动态设置表头宽度 - var autoTheadWidth = function(initFlag) { - if(options.height>0){ - var $thead = target.find("thead"); - var $tbody = target.find("tbody"); - var borderWidth = parseInt(target.css("border-left-width")) + parseInt(target.css("border-right-width")) - - $thead.css("width", $tbody.children(":first").width()); - if(initFlag){ - var resizeWaiter = false; - $(window).resize(function() { - if(!resizeWaiter){ - resizeWaiter = true; - setTimeout(function(){ - if(!target.isFixWidth){ - $tbody.css("width", target.parent().width()-borderWidth); - } - $thead.css("width", $tbody.children(":first").width()); - resizeWaiter = false; - }, 300); - } - }); - } - } - - } - // 缓存并格式化数据 - var formatData = function(data) { - var _root = options.rootIdValue ? options.rootIdValue : null; - var firstCode = data[0][options.parentCode]; - $.each(data, function(index, item) { - // 添加一个默认属性,用来判断当前节点有没有被显示 - item.isShow = false; - // 这里兼容几种常见Root节点写法 - // 默认的几种判断 - var _defaultRootFlag = item[options.parentCode] == '0' || - item[options.parentCode] == 0 || - item[options.parentCode] == null || - item[options.parentCode] == firstCode || - item[options.parentCode] == ''; - if (!item[options.parentCode] || (_root ? (item[options.parentCode] == options.rootIdValue) : _defaultRootFlag)) { - if (!target.data_list["_root_"]) { - target.data_list["_root_"] = []; - } - if (!target.data_obj["id_" + item[options.code]]) { - target.data_list["_root_"].push(item); - } - } else { - if (!target.data_list["_n_" + item[options.parentCode]]) { - target.data_list["_n_" + item[options.parentCode]] = []; - } - if (!target.data_obj["id_" + item[options.code]]) { - target.data_list["_n_" + item[options.parentCode]].push(item); - } - } - target.data_obj["id_" + item[options.code]] = item; - }); - } - // 递归获取子节点并且设置子节点 - var recursionNode = function(parentNode, lv, row_id, p_id) { - var $tbody = target.find("tbody"); - var _ls = target.data_list["_n_" + parentNode[options.code]]; - var $tr = renderRow(parentNode, _ls ? true : false, lv, row_id, p_id); - $tbody.append($tr); - if (_ls) { - $.each(_ls, function(i, item) { - var _child_row_id = row_id + "_" + i - recursionNode(item, (lv + 1), _child_row_id, row_id) - }); - } - }; - // 绘制行 - var renderRow = function(item, isP, lv, row_id, p_id) { - // 标记已显示 - item.isShow = true; - item.row_id = row_id; - item.p_id = p_id; - item.lv = lv; - var $tr = $(''); - var _icon = options.expanderCollapsedClass; - if (options.expandAll) { - $tr.css("display", "table"); - _icon = options.expanderExpandedClass; - } else if (lv == 1) { - $tr.css("display", "table"); - _icon = (options.expandFirst) ? options.expanderExpandedClass : options.expanderCollapsedClass; - } else if (lv == 2) { - if (options.expandFirst) { - $tr.css("display", "table"); - } else { - $tr.css("display", "none"); - } - _icon = options.expanderCollapsedClass; - } else { - $tr.css("display", "none"); - _icon = options.expanderCollapsedClass; - } - $.each(options.columns, function(index, column) { - // 判断有没有选择列 - if (column.field == 'selectItem') { - target.hasSelectItem = true; - var $td = $(''); - if (column.radio) { - var _ipt = $(''); - $td.append(_ipt); - } - if (column.checkbox) { - var _ipt = $(''); - $td.append(_ipt); - } - $tr.append($td); - } else { - var $td = $(''); - if(column.width){ - $td.css("width",column.width); - } - if(column.align){ - $td.css("text-align",column.align); - } - if(options.expandColumn == index){ - $td.css("text-align","left"); - } - if(column.valign){ - $td.css("vertical-align",column.valign); - } - if(options.showTitle){ - $td.addClass("ellipsis"); - } - // 增加formatter渲染 - if (column.formatter) { - $td.html(column.formatter.call(this, getItemField(item, column.field), item, index)); - } else { - if(options.showTitle){ - // 只在字段没有formatter时才添加title属性 - $td.attr("title",item[column.field]); - } - $td.text(getItemField(item, column.field)); - } - if (options.expandColumn == index) { - if (!isP) { - $td.prepend('') - } else { - $td.prepend('') - } - for (var int = 0; int < (lv - 1); int++) { - $td.prepend('') - } - } - $tr.append($td); - } - }); - return $tr; - } - // 检索信息按钮点击事件 - var registerSearchBtnClickEvent = function(btn) { - $(btn).off('click').on('click', function () { - $(".search-collapse").slideToggle(); - }); - } - // 注册刷新按钮点击事件 - var registerRefreshBtnClickEvent = function(btn) { - $(btn).off('click').on('click', function () { - target.refresh(); - }); - } - // 注册列选项事件 - var registerColumnClickEvent = function() { - $(".bootstrap-tree-table .treetable-bars .columns label input").off('click').on('click', function () { - var $this = $(this); - if($this.prop('checked')){ - target.showColumn($(this).val()); - }else{ - target.hideColumn($(this).val()); - } - }); - } - // 注册行点击选中事件 - var registerRowClickEvent = function() { - target.find("tbody").find("tr").unbind(); - target.find("tbody").find("tr").click(function() { - if (target.hasSelectItem) { - var _ipt = $(this).find("input[name='select_item']"); - if (_ipt.attr("type") == "radio") { - _ipt.prop('checked', true); - target.find("tbody").find("tr").removeClass("treetable-selected"); - $(this).addClass("treetable-selected"); - } else if (_ipt.attr("type") == "checkbox") { - if (_ipt.prop('checked')) { - _ipt.prop('checked', true); - target.find("tbody").find("tr").removeClass("treetable-selected"); - $(this).addClass("treetable-selected"); - } else { - _ipt.prop('checked', false); - target.find("tbody").find("tr").removeClass("treetable-selected"); - } - } else { - if (_ipt.prop('checked')) { - _ipt.prop('checked', false); - $(this).removeClass("treetable-selected"); - } else { - _ipt.prop('checked', true); - $(this).addClass("treetable-selected"); - } - } - } - }); - } - // 注册小图标点击事件--展开缩起 - var registerExpanderEvent = function() { - target.find("tbody").find("tr").find(".treetable-expander").unbind(); - target.find("tbody").find("tr").find(".treetable-expander").click(function() { - var _isExpanded = $(this).hasClass(options.expanderExpandedClass); - var _isCollapsed = $(this).hasClass(options.expanderCollapsedClass); - if (_isExpanded || _isCollapsed) { - var tr = $(this).parent().parent(); - var row_id = tr.attr("id"); - var _ls = target.find("tbody").find("tr[id^='" + row_id + "_']"); //下所有 - if (_isExpanded) { - $(this).removeClass(options.expanderExpandedClass); - $(this).addClass(options.expanderCollapsedClass); - if (_ls && _ls.length > 0) { - $.each(_ls, function(index, item) { - $(item).css("display", "none"); - }); - } - } else { - $(this).removeClass(options.expanderCollapsedClass); - $(this).addClass(options.expanderExpandedClass); - if (_ls && _ls.length > 0) { - $.each(_ls, function(index, item) { - // 父icon - var _p_icon = $("#" + $(item).attr("pid")).children().eq(options.expandColumn).find(".treetable-expander"); - if (_p_icon.hasClass(options.expanderExpandedClass)) { - $(item).css("display", "table"); - } - }); - } - } - } - }); - } - // 刷新数据 - target.refresh = function(parms) { - if(parms){ - target.lastAjaxParams=parms; - } - initServer(target.lastAjaxParams); - } - // 添加数据刷新表格 - target.appendData = function(data) { - // 下边的操作主要是为了查询时让一些没有根节点的节点显示 - $.each(data, function(i, item) { - var _data = target.data_obj["id_" + item[options.code]]; - var _p_data = target.data_obj["id_" + item[options.parentCode]]; - var _c_list = target.data_list["_n_" + item[options.parentCode]]; - var row_id = ""; //行id - var p_id = ""; //父行id - var _lv = 1; //如果没有父就是1默认显示 - var tr; //要添加行的对象 - if (_data && _data.row_id && _data.row_id != "") { - row_id = _data.row_id; // 如果已经存在了,就直接引用原来的 - } - if (_p_data) { - p_id = _p_data.row_id; - if (row_id == "") { - var _tmp = 0 - if (_c_list && _c_list.length > 0) { - _tmp = _c_list.length; - } - row_id = _p_data.row_id + "_" + _tmp; - } - _lv = _p_data.lv + 1; //如果有父 - // 绘制行 - tr = renderRow(item, false, _lv, row_id, p_id); - - var _p_icon = $("#" + _p_data.row_id).children().eq(options.expandColumn).find(".treetable-expander"); - var _isExpanded = _p_icon.hasClass(options.expanderExpandedClass); - var _isCollapsed = _p_icon.hasClass(options.expanderCollapsedClass); - // 父节点有没有展开收缩按钮 - if (_isExpanded || _isCollapsed) { - // 父节点展开状态显示新加行 - if (_isExpanded) { - tr.css("display", "table"); - } - } else { - // 父节点没有展开收缩按钮则添加 - _p_icon.addClass(options.expanderCollapsedClass); - } - - if (_data) { - $("#" + _data.row_id).before(tr); - $("#" + _data.row_id).remove(); - } else { - // 计算父的同级下一行 - var _tmp_ls = _p_data.row_id.split("_"); - var _p_next = _p_data.row_id.substring(0, _p_data.row_id.length - 1) + (parseInt(_tmp_ls[_tmp_ls.length - 1]) + 1); - // 画上 - $("#" + _p_next).before(tr); - } - } else { - tr = renderRow(item, false, _lv, row_id, p_id); - if (_data) { - $("#" + _data.row_id).before(tr); - $("#" + _data.row_id).remove(); - } else { - // 画上 - var tbody = target.find("tbody"); - tbody.append(tr); - } - } - item.isShow = true; - // 缓存并格式化数据 - formatData([item]); - }); - registerExpanderEvent(); - registerRowClickEvent(); - initHiddenColumns(); - } - - // 展开/折叠指定的行 - target.toggleRow=function(id) { - var _rowData = target.data_obj["id_" + id]; - var $row_expander = $("#"+_rowData.row_id).find(".treetable-expander"); - $row_expander.trigger("click"); - } - // 展开指定的行 - target.expandRow=function(id) { - var _rowData = target.data_obj["id_" + id]; - var $row_expander = $("#"+_rowData.row_id).find(".treetable-expander"); - var _isCollapsed = $row_expander.hasClass(target.options.expanderCollapsedClass); - if (_isCollapsed) { - $row_expander.trigger("click"); - } - } - // 折叠 指定的行 - target.collapseRow=function(id) { - var _rowData = target.data_obj["id_" + id]; - var $row_expander = $("#"+_rowData.row_id).find(".treetable-expander"); - var _isExpanded = $row_expander.hasClass(target.options.expanderExpandedClass); - if (_isExpanded) { - $row_expander.trigger("click"); - } - } - // 展开所有的行 - target.expandAll=function() { - target.find("tbody").find("tr").find(".treetable-expander").each(function(i,n){ - var _isCollapsed = $(n).hasClass(options.expanderCollapsedClass); - if (_isCollapsed) { - $(n).trigger("click"); - } - }) - } - // 折叠所有的行 - target.collapseAll=function() { - target.find("tbody").find("tr").find(".treetable-expander").each(function(i,n){ - var _isExpanded = $(n).hasClass(options.expanderExpandedClass); - if (_isExpanded) { - $(n).trigger("click"); - } - }) - } - // 显示指定列 - target.showColumn=function(field,flag) { - var _index = $.inArray(field, target.hiddenColumns); - if (_index > -1) { - target.hiddenColumns.splice(_index, 1); - } - target.find("."+field+"_cls").show(); - //是否更新列选项状态 - if(flag&&options.showColumns){ - var $input = $(".bootstrap-tree-table .treetable-bars .columns label").find("input[value='"+field+"']") - $input.prop("checked", 'checked'); - } - } - // 隐藏指定列 - target.hideColumn=function(field,flag) { - target.hiddenColumns.push(field); - target.find("."+field+"_cls").hide(); - //是否更新列选项状态 - if(flag&&options.showColumns){ - var $input = $(".bootstrap-tree-table .treetable-bars .columns label").find("input[value='"+field+"']") - $input.prop("checked", ''); - } - } - // ruoyi 解析数据,支持多层级访问 - var getItemField = function (item, field) { - var value = item; - - if (typeof field !== 'string' || item.hasOwnProperty(field)) { - return item[field]; - } - var props = field.split('.'); - for (var p in props) { - value = value && value[props[p]]; - } - return value; - }; - // 初始化 - init(); - return target; - }; - - // 组件方法封装........ - $.fn.bootstrapTreeTable.methods = { - // 为了兼容bootstrap-table的写法,统一返回数组,这里返回了表格显示列的数据 - getSelections: function(target, data) { - // 所有被选中的记录input - var _ipt = target.find("tbody").find("tr").find("input[name='select_item']:checked"); - var chk_value = []; - // 如果是radio - if (_ipt.attr("type") == "radio") { - var _data = target.data_obj["id_" + _ipt.val()]; - chk_value.push(_data); - } else { - _ipt.each(function(_i, _item) { - var _data = target.data_obj["id_" + $(_item).val()]; - chk_value.push(_data); - }); - } - return chk_value; - }, - // 刷新记录 - refresh: function(target, parms) { - if (parms) { - target.refresh(parms); - } else { - target.refresh(); - } - }, - // 添加数据到表格 - appendData: function(target, data) { - if (data) { - target.appendData(data); - } - }, - // 展开/折叠指定的行 - toggleRow: function(target, id) { - target.toggleRow(id); - }, - // 展开指定的行 - expandRow: function(target, id) { - target.expandRow(id); - }, - // 折叠 指定的行 - collapseRow: function(target, id) { - target.collapseRow(id); - }, - // 展开所有的行 - expandAll: function(target) { - target.expandAll(); - }, - // 折叠所有的行 - collapseAll: function(target) { - target.collapseAll(); - }, - // 显示指定列 - showColumn: function(target,field) { - target.showColumn(field,true); - }, - // 隐藏指定列 - hideColumn: function(target,field) { - target.hideColumn(field,true); - } - // 组件的其他方法也可以进行类似封装........ - }; - - $.fn.bootstrapTreeTable.defaults = { - code: 'code', // 选取记录返回的值,用于设置父子关系 - parentCode: 'parentCode', // 用于设置父子关系 - rootIdValue: null, // 设置根节点id值----可指定根节点,默认为null,"",0,"0" - data: null, // 构造table的数据集合 - type: "GET", // 请求数据的ajax类型 - url: null, // 请求数据的ajax的url - ajaxParams: {}, // 请求数据的ajax的data属性 - expandColumn: 0, // 在哪一列上面显示展开按钮 - expandAll: false, // 是否全部展开 - expandFirst: true, // 是否默认第一级展开--expandAll为false时生效 - striped: false, // 是否各行渐变色 - bordered: true, // 是否显示边框 - hover: true, // 是否鼠标悬停 - condensed: false, // 是否紧缩表格 - columns: [], // 列 - toolbar: null, // 顶部工具条 - height: 0, // 表格高度 - showTitle: true, // 是否采用title属性显示字段内容(被formatter格式化的字段不会显示) - showSearch: true, // 是否显示检索信息 - showColumns: true, // 是否显示内容列下拉框 - showRefresh: true, // 是否显示刷新按钮 - expanderExpandedClass: 'glyphicon glyphicon-chevron-down', // 展开的按钮的图标 - expanderCollapsedClass: 'glyphicon glyphicon-chevron-right' // 缩起的按钮的图标 - - }; +/** + * 基于bootstrapTreeTable/bootstrap-table-treegrid修改 + * Copyright (c) 2019 ruoyi + */ +(function($) { + "use strict"; + + $.fn.bootstrapTreeTable = function(options, param) { + var target = $(this).data('bootstrap.tree.table'); + target = target ? target : $(this); + // 如果是调用方法 + if (typeof options == 'string') { + return $.fn.bootstrapTreeTable.methods[options](target, param); + } + // 如果是初始化组件 + options = $.extend({}, $.fn.bootstrapTreeTable.defaults, options || {}); + target.hasSelectItem = false;// 是否有radio或checkbox + target.data_list = null; //用于缓存格式化后的数据-按父分组 + target.data_obj = null; //用于缓存格式化后的数据-按id存对象 + target.hiddenColumns = []; //用于存放被隐藏列的field + target.lastAjaxParams; //用户最后一次请求的参数 + target.isFixWidth=false; //是否有固定宽度 + // 初始化 + var init = function() { + // 初始化容器 + initContainer(); + // 初始化工具栏 + initToolbar(); + // 初始化表头 + initHeader(); + // 初始化表体 + initBody(); + // 初始化数据服务 + initServer(); + // 动态设置表头宽度 + autoTheadWidth(true); + // 缓存target对象 + target.data('bootstrap.tree.table', target); + } + // 初始化容器 + var initContainer = function() { + // 在外层包装一下div,样式用的bootstrap-table的 + var $main_div = $("
    "); + var $treetable = $("
    "); + target.before($main_div); + $main_div.append($treetable); + $treetable.append(target); + target.addClass("table"); + if (options.striped) { + target.addClass('table-striped'); + } + if (options.bordered) { + target.addClass('table-bordered'); + } + if (options.hover) { + target.addClass('table-hover'); + } + if (options.condensed) { + target.addClass('table-condensed'); + } + target.html(""); + } + // 初始化工具栏 + var initToolbar = function() { + var $toolbar = $("
    "); + if (options.toolbar) { + $(options.toolbar).addClass('tool-left'); + $toolbar.append($(options.toolbar)); + } + var $rightToolbar = $('
    '); + $toolbar.append($rightToolbar); + target.parent().before($toolbar); + // ruoyi 是否显示检索信息 + if (options.showSearch) { + var $searchBtn = $(''); + $rightToolbar.append($searchBtn); + registerSearchBtnClickEvent($searchBtn); + } + // 是否显示刷新按钮 + if (options.showRefresh) { + var $refreshBtn = $(''); + $rightToolbar.append($refreshBtn); + registerRefreshBtnClickEvent($refreshBtn); + } + // 是否显示列选项 + if (options.showColumns) { + var $columns_div = $('
    '); + var $columns_ul = $(''); + $.each(options.columns, function(i, column) { + if (column.field != 'selectItem') { + var _li = null; + if(typeof column.visible == "undefined"||column.visible==true){ + _li = $('
  • '); + }else{ + _li = $('
  • '); + target.hiddenColumns.push(column.field); + } + $columns_ul.append(_li); + } + }); + $columns_div.append($columns_ul); + $rightToolbar.append($columns_div); + // 注册列选项事件 + registerColumnClickEvent(); + }else{ + $.each(options.columns, function(i, column) { + if (column.field != 'selectItem') { + if(!(typeof column.visible == "undefined"||column.visible==true)){ + target.hiddenColumns.push(column.field); + } + } + }); + } + } + // 初始化隐藏列 + var initHiddenColumns = function(){ + $.each(target.hiddenColumns, function(i, field) { + target.find("."+field+"_cls").hide(); + }); + } + // 初始化表头 + var initHeader = function() { + var $thr = $(''); + $.each(options.columns, function(i, column) { + var $th = null; + // 判断有没有选择列 + if (i == 0 && column.field == 'selectItem') { + target.hasSelectItem = true; + $th = $(''); + } else { + $th = $(''); + } + if((!target.isFixWidth)&& column.width){ + target.isFixWidth = column.width.indexOf("px")>-1?true:false; + } + $th.text(column.title); + $thr.append($th); + }); + var $thead = $(''); + $thead.append($thr); + target.append($thead); + } + // 初始化表体 + var initBody = function() { + var $tbody = $(''); + target.append($tbody); + // 默认高度 + if (options.height) { + $tbody.css("height", options.height); + } + } + // 初始化数据服务 + var initServer = function(parms) { + // 加载数据前先清空 + target.data_list = {}; + target.data_obj = {}; + var $tbody = target.find("tbody"); + // 添加加载loading + var $loading = '
    正在努力地加载数据中,请稍候……
    ' + $tbody.html($loading); + if (options.url) { + $.ajax({ + type: options.type, + url: options.url, + data: parms ? parms : options.ajaxParams, + dataType: "JSON", + success: function(data, textStatus, jqXHR) { + renderTable(data); + }, + error: function(xhr, textStatus) { + var _errorMsg = '
    ' + xhr.responseText + '
    ' + $tbody.html(_errorMsg); + }, + }); + } else { + renderTable(options.data); + } + } + // 加载完数据后渲染表格 + var renderTable = function(data) { + var $tbody = target.find("tbody"); + // 先清空 + $tbody.html(""); + if (!data || data.length <= 0) { + var _empty = '
    没有找到匹配的记录
    ' + $tbody.html(_empty); + return; + } + // 缓存并格式化数据 + formatData(data); + // 获取所有根节点 + var rootNode = target.data_list["_root_"]; + // 开始绘制 + if (rootNode) { + $.each(rootNode, function(i, item) { + var _child_row_id = "row_id_" + i + recursionNode(item, 1, _child_row_id, "row_root"); + }); + } + // 下边的操作主要是为了查询时让一些没有根节点的节点显示 + $.each(data, function(i, item) { + if (!item.isShow) { + var tr = renderRow(item, false, 1, "", ""); + $tbody.append(tr); + } + }); + target.append($tbody); + registerExpanderEvent(); + registerRowClickEvent(); + initHiddenColumns(); + // 动态设置表头宽度 + autoTheadWidth() + } + // 动态设置表头宽度 + var autoTheadWidth = function(initFlag) { + if(options.height>0){ + var $thead = target.find("thead"); + var $tbody = target.find("tbody"); + var borderWidth = parseInt(target.css("border-left-width")) + parseInt(target.css("border-right-width")) + + $thead.css("width", $tbody.children(":first").width()); + if(initFlag){ + var resizeWaiter = false; + $(window).resize(function() { + if(!resizeWaiter){ + resizeWaiter = true; + setTimeout(function(){ + if(!target.isFixWidth){ + $tbody.css("width", target.parent().width()-borderWidth); + } + $thead.css("width", $tbody.children(":first").width()); + resizeWaiter = false; + }, 300); + } + }); + } + } + + } + // 缓存并格式化数据 + var formatData = function(data) { + var _root = options.rootIdValue ? options.rootIdValue : null; + var firstCode = data[0][options.parentCode]; + $.each(data, function(index, item) { + // 添加一个默认属性,用来判断当前节点有没有被显示 + item.isShow = false; + // 这里兼容几种常见Root节点写法 + // 默认的几种判断 + var _defaultRootFlag = item[options.parentCode] == '0' || + item[options.parentCode] == 0 || + item[options.parentCode] == null || + item[options.parentCode] == firstCode || + item[options.parentCode] == ''; + if (!item[options.parentCode] || (_root ? (item[options.parentCode] == options.rootIdValue) : _defaultRootFlag)) { + if (!target.data_list["_root_"]) { + target.data_list["_root_"] = []; + } + if (!target.data_obj["id_" + item[options.code]]) { + target.data_list["_root_"].push(item); + } + } else { + if (!target.data_list["_n_" + item[options.parentCode]]) { + target.data_list["_n_" + item[options.parentCode]] = []; + } + if (!target.data_obj["id_" + item[options.code]]) { + target.data_list["_n_" + item[options.parentCode]].push(item); + } + } + target.data_obj["id_" + item[options.code]] = item; + }); + } + // 递归获取子节点并且设置子节点 + var recursionNode = function(parentNode, lv, row_id, p_id) { + var $tbody = target.find("tbody"); + var _ls = target.data_list["_n_" + parentNode[options.code]]; + var $tr = renderRow(parentNode, _ls ? true : false, lv, row_id, p_id); + $tbody.append($tr); + if (_ls) { + $.each(_ls, function(i, item) { + var _child_row_id = row_id + "_" + i + recursionNode(item, (lv + 1), _child_row_id, row_id) + }); + } + }; + // 绘制行 + var renderRow = function(item, isP, lv, row_id, p_id) { + // 标记已显示 + item.isShow = true; + item.row_id = row_id; + item.p_id = p_id; + item.lv = lv; + var $tr = $(''); + var _icon = options.expanderCollapsedClass; + if (options.expandAll) { + $tr.css("display", "table"); + _icon = options.expanderExpandedClass; + } else if (lv == 1) { + $tr.css("display", "table"); + _icon = (options.expandFirst) ? options.expanderExpandedClass : options.expanderCollapsedClass; + } else if (lv == 2) { + if (options.expandFirst) { + $tr.css("display", "table"); + } else { + $tr.css("display", "none"); + } + _icon = options.expanderCollapsedClass; + } else { + $tr.css("display", "none"); + _icon = options.expanderCollapsedClass; + } + $.each(options.columns, function(index, column) { + // 判断有没有选择列 + if (column.field == 'selectItem') { + target.hasSelectItem = true; + var $td = $(''); + if (column.radio) { + var _ipt = $(''); + $td.append(_ipt); + } + if (column.checkbox) { + var _ipt = $(''); + $td.append(_ipt); + } + $tr.append($td); + } else { + var $td = $(''); + if(column.width){ + $td.css("width",column.width); + } + if(column.align){ + $td.css("text-align",column.align); + } + if(options.expandColumn == index){ + $td.css("text-align","left"); + } + if(column.valign){ + $td.css("vertical-align",column.valign); + } + if(options.showTitle){ + $td.addClass("ellipsis"); + } + // 增加formatter渲染 + if (column.formatter) { + $td.html(column.formatter.call(this, getItemField(item, column.field), item, index)); + } else { + if(options.showTitle){ + // 只在字段没有formatter时才添加title属性 + $td.attr("title",item[column.field]); + } + $td.text(getItemField(item, column.field)); + } + if (options.expandColumn == index) { + if (!isP) { + $td.prepend('') + } else { + $td.prepend('') + } + for (var int = 0; int < (lv - 1); int++) { + $td.prepend('') + } + } + $tr.append($td); + } + }); + return $tr; + } + // 检索信息按钮点击事件 + var registerSearchBtnClickEvent = function(btn) { + $(btn).off('click').on('click', function () { + $(".search-collapse").slideToggle(); + }); + } + // 注册刷新按钮点击事件 + var registerRefreshBtnClickEvent = function(btn) { + $(btn).off('click').on('click', function () { + target.refresh(); + }); + } + // 注册列选项事件 + var registerColumnClickEvent = function() { + $(".bootstrap-tree-table .treetable-bars .columns label input").off('click').on('click', function () { + var $this = $(this); + if($this.prop('checked')){ + target.showColumn($(this).val()); + }else{ + target.hideColumn($(this).val()); + } + }); + } + // 注册行点击选中事件 + var registerRowClickEvent = function() { + target.find("tbody").find("tr").unbind(); + target.find("tbody").find("tr").click(function() { + if (target.hasSelectItem) { + var _ipt = $(this).find("input[name='select_item']"); + if (_ipt.attr("type") == "radio") { + _ipt.prop('checked', true); + target.find("tbody").find("tr").removeClass("treetable-selected"); + $(this).addClass("treetable-selected"); + } else if (_ipt.attr("type") == "checkbox") { + if (_ipt.prop('checked')) { + _ipt.prop('checked', true); + target.find("tbody").find("tr").removeClass("treetable-selected"); + $(this).addClass("treetable-selected"); + } else { + _ipt.prop('checked', false); + target.find("tbody").find("tr").removeClass("treetable-selected"); + } + } else { + if (_ipt.prop('checked')) { + _ipt.prop('checked', false); + $(this).removeClass("treetable-selected"); + } else { + _ipt.prop('checked', true); + $(this).addClass("treetable-selected"); + } + } + } + }); + } + // 注册小图标点击事件--展开缩起 + var registerExpanderEvent = function() { + target.find("tbody").find("tr").find(".treetable-expander").unbind(); + target.find("tbody").find("tr").find(".treetable-expander").click(function() { + var _isExpanded = $(this).hasClass(options.expanderExpandedClass); + var _isCollapsed = $(this).hasClass(options.expanderCollapsedClass); + if (_isExpanded || _isCollapsed) { + var tr = $(this).parent().parent(); + var row_id = tr.attr("id"); + var _ls = target.find("tbody").find("tr[id^='" + row_id + "_']"); //下所有 + if (_isExpanded) { + $(this).removeClass(options.expanderExpandedClass); + $(this).addClass(options.expanderCollapsedClass); + if (_ls && _ls.length > 0) { + $.each(_ls, function(index, item) { + $(item).css("display", "none"); + }); + } + } else { + $(this).removeClass(options.expanderCollapsedClass); + $(this).addClass(options.expanderExpandedClass); + if (_ls && _ls.length > 0) { + $.each(_ls, function(index, item) { + // 父icon + var _p_icon = $("#" + $(item).attr("pid")).children().eq(options.expandColumn).find(".treetable-expander"); + if (_p_icon.hasClass(options.expanderExpandedClass)) { + $(item).css("display", "table"); + } + }); + } + } + } + }); + } + // 刷新数据 + target.refresh = function(parms) { + if(parms){ + target.lastAjaxParams=parms; + } + initServer(target.lastAjaxParams); + } + // 添加数据刷新表格 + target.appendData = function(data) { + // 下边的操作主要是为了查询时让一些没有根节点的节点显示 + $.each(data, function(i, item) { + var _data = target.data_obj["id_" + item[options.code]]; + var _p_data = target.data_obj["id_" + item[options.parentCode]]; + var _c_list = target.data_list["_n_" + item[options.parentCode]]; + var row_id = ""; //行id + var p_id = ""; //父行id + var _lv = 1; //如果没有父就是1默认显示 + var tr; //要添加行的对象 + if (_data && _data.row_id && _data.row_id != "") { + row_id = _data.row_id; // 如果已经存在了,就直接引用原来的 + } + if (_p_data) { + p_id = _p_data.row_id; + if (row_id == "") { + var _tmp = 0 + if (_c_list && _c_list.length > 0) { + _tmp = _c_list.length; + } + row_id = _p_data.row_id + "_" + _tmp; + } + _lv = _p_data.lv + 1; //如果有父 + // 绘制行 + tr = renderRow(item, false, _lv, row_id, p_id); + + var _p_icon = $("#" + _p_data.row_id).children().eq(options.expandColumn).find(".treetable-expander"); + var _isExpanded = _p_icon.hasClass(options.expanderExpandedClass); + var _isCollapsed = _p_icon.hasClass(options.expanderCollapsedClass); + // 父节点有没有展开收缩按钮 + if (_isExpanded || _isCollapsed) { + // 父节点展开状态显示新加行 + if (_isExpanded) { + tr.css("display", "table"); + } + } else { + // 父节点没有展开收缩按钮则添加 + _p_icon.addClass(options.expanderCollapsedClass); + } + + if (_data) { + $("#" + _data.row_id).before(tr); + $("#" + _data.row_id).remove(); + } else { + // 计算父的同级下一行 + var _tmp_ls = _p_data.row_id.split("_"); + var _p_next = _p_data.row_id.substring(0, _p_data.row_id.length - 1) + (parseInt(_tmp_ls[_tmp_ls.length - 1]) + 1); + // 画上 + $("#" + _p_next).before(tr); + } + } else { + tr = renderRow(item, false, _lv, row_id, p_id); + if (_data) { + $("#" + _data.row_id).before(tr); + $("#" + _data.row_id).remove(); + } else { + // 画上 + var tbody = target.find("tbody"); + tbody.append(tr); + } + } + item.isShow = true; + // 缓存并格式化数据 + formatData([item]); + }); + registerExpanderEvent(); + registerRowClickEvent(); + initHiddenColumns(); + } + + // 展开/折叠指定的行 + target.toggleRow=function(id) { + var _rowData = target.data_obj["id_" + id]; + var $row_expander = $("#"+_rowData.row_id).find(".treetable-expander"); + $row_expander.trigger("click"); + } + // 展开指定的行 + target.expandRow=function(id) { + var _rowData = target.data_obj["id_" + id]; + var $row_expander = $("#"+_rowData.row_id).find(".treetable-expander"); + var _isCollapsed = $row_expander.hasClass(target.options.expanderCollapsedClass); + if (_isCollapsed) { + $row_expander.trigger("click"); + } + } + // 折叠 指定的行 + target.collapseRow=function(id) { + var _rowData = target.data_obj["id_" + id]; + var $row_expander = $("#"+_rowData.row_id).find(".treetable-expander"); + var _isExpanded = $row_expander.hasClass(target.options.expanderExpandedClass); + if (_isExpanded) { + $row_expander.trigger("click"); + } + } + // 展开所有的行 + target.expandAll=function() { + target.find("tbody").find("tr").find(".treetable-expander").each(function(i,n){ + var _isCollapsed = $(n).hasClass(options.expanderCollapsedClass); + if (_isCollapsed) { + $(n).trigger("click"); + } + }) + } + // 折叠所有的行 + target.collapseAll=function() { + target.find("tbody").find("tr").find(".treetable-expander").each(function(i,n){ + var _isExpanded = $(n).hasClass(options.expanderExpandedClass); + if (_isExpanded) { + $(n).trigger("click"); + } + }) + } + // 显示指定列 + target.showColumn=function(field,flag) { + var _index = $.inArray(field, target.hiddenColumns); + if (_index > -1) { + target.hiddenColumns.splice(_index, 1); + } + target.find("."+field+"_cls").show(); + //是否更新列选项状态 + if(flag&&options.showColumns){ + var $input = $(".bootstrap-tree-table .treetable-bars .columns label").find("input[value='"+field+"']") + $input.prop("checked", 'checked'); + } + } + // 隐藏指定列 + target.hideColumn=function(field,flag) { + target.hiddenColumns.push(field); + target.find("."+field+"_cls").hide(); + //是否更新列选项状态 + if(flag&&options.showColumns){ + var $input = $(".bootstrap-tree-table .treetable-bars .columns label").find("input[value='"+field+"']") + $input.prop("checked", ''); + } + } + // ruoyi 解析数据,支持多层级访问 + var getItemField = function (item, field) { + var value = item; + + if (typeof field !== 'string' || item.hasOwnProperty(field)) { + return item[field]; + } + var props = field.split('.'); + for (var p in props) { + value = value && value[props[p]]; + } + return value; + }; + // 初始化 + init(); + return target; + }; + + // 组件方法封装........ + $.fn.bootstrapTreeTable.methods = { + // 为了兼容bootstrap-table的写法,统一返回数组,这里返回了表格显示列的数据 + getSelections: function(target, data) { + // 所有被选中的记录input + var _ipt = target.find("tbody").find("tr").find("input[name='select_item']:checked"); + var chk_value = []; + // 如果是radio + if (_ipt.attr("type") == "radio") { + var _data = target.data_obj["id_" + _ipt.val()]; + chk_value.push(_data); + } else { + _ipt.each(function(_i, _item) { + var _data = target.data_obj["id_" + $(_item).val()]; + chk_value.push(_data); + }); + } + return chk_value; + }, + // 刷新记录 + refresh: function(target, parms) { + if (parms) { + target.refresh(parms); + } else { + target.refresh(); + } + }, + // 添加数据到表格 + appendData: function(target, data) { + if (data) { + target.appendData(data); + } + }, + // 展开/折叠指定的行 + toggleRow: function(target, id) { + target.toggleRow(id); + }, + // 展开指定的行 + expandRow: function(target, id) { + target.expandRow(id); + }, + // 折叠 指定的行 + collapseRow: function(target, id) { + target.collapseRow(id); + }, + // 展开所有的行 + expandAll: function(target) { + target.expandAll(); + }, + // 折叠所有的行 + collapseAll: function(target) { + target.collapseAll(); + }, + // 显示指定列 + showColumn: function(target,field) { + target.showColumn(field,true); + }, + // 隐藏指定列 + hideColumn: function(target,field) { + target.hideColumn(field,true); + } + // 组件的其他方法也可以进行类似封装........ + }; + + $.fn.bootstrapTreeTable.defaults = { + code: 'code', // 选取记录返回的值,用于设置父子关系 + parentCode: 'parentCode', // 用于设置父子关系 + rootIdValue: null, // 设置根节点id值----可指定根节点,默认为null,"",0,"0" + data: null, // 构造table的数据集合 + type: "GET", // 请求数据的ajax类型 + url: null, // 请求数据的ajax的url + ajaxParams: {}, // 请求数据的ajax的data属性 + expandColumn: 0, // 在哪一列上面显示展开按钮 + expandAll: false, // 是否全部展开 + expandFirst: true, // 是否默认第一级展开--expandAll为false时生效 + striped: false, // 是否各行渐变色 + bordered: true, // 是否显示边框 + hover: true, // 是否鼠标悬停 + condensed: false, // 是否紧缩表格 + columns: [], // 列 + toolbar: null, // 顶部工具条 + height: 0, // 表格高度 + showTitle: true, // 是否采用title属性显示字段内容(被formatter格式化的字段不会显示) + showSearch: true, // 是否显示检索信息 + showColumns: true, // 是否显示内容列下拉框 + showRefresh: true, // 是否显示刷新按钮 + expanderExpandedClass: 'glyphicon glyphicon-chevron-down', // 展开的按钮的图标 + expanderCollapsedClass: 'glyphicon glyphicon-chevron-right' // 缩起的按钮的图标 + + }; })(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.css b/bmw-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.css similarity index 94% rename from ruoyi-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.css rename to bmw-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.css index b57f49d78..b208d9f53 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.css @@ -1,127 +1,127 @@ -@charset "utf-8"; -.container { - margin: 10px auto 0 auto; - position: relative; - font-family: 微软雅黑; - font-size: 12px; -} -.container p { - line-height: 12px; - line-height: 0px; - height: 0px; - margin: 10px; - color: #bbb -} -.action { - width: 400px; - height: 30px; - margin: 10px 0; -} -.cropped { - position: absolute; - left: 500px; - top: 0; - width: 200px; - border: 1px #ddd solid; - height: 440px; - padding: 4px; - box-shadow: 0px 0px 12px #ddd; - text-align: center; -} -.imageBox { - position: relative; - height: 400px; - width: 400px; - border: 1px solid #aaa; - background: #fff; - overflow: hidden; - background-repeat: no-repeat; - cursor: move; - box-shadow: 4px 4px 12px #B0B0B0; -} -.imageBox .thumbBox { - position: absolute; - top: 50%; - left: 50%; - width: 200px; - height: 200px; - margin-top: -100px; - margin-left: -100px; - box-sizing: border-box; - border: 1px solid rgb(102, 102, 102); - box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5); - background: none repeat scroll 0% 0% transparent; -} -.imageBox .spinner { - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 0; - text-align: center; - line-height: 400px; - background: rgba(0,0,0,0.7); -} -.Btnsty_peyton{ float: right; - width: 46px; - display: inline-block; - margin-bottom: 10px; - height: 37px; - line-height: 37px; - font-size: 14px; - color: #FFFFFF; - margin:0px 2px; - background-color: #f38e81; - border-radius: 3px; - text-decoration: none; - cursor: pointer; - box-shadow: 0px 0px 5px #B0B0B0; - border: 0px #fff solid;} -/*选择文件上传*/ -.new-contentarea { - width: 165px; - overflow:hidden; - margin: 0 auto; - position:relative;float:left; -} -.new-contentarea label { - width:100%; - height:100%; - display:block; -} -.new-contentarea input[type=file] { - width:188px; - height:60px; - background:#333; - margin: 0 auto; - position:absolute; - right:50%; - margin-right:-94px; - top:0; - right/*\**/:0px\9; - margin-right/*\**/:0px\9; - width/*\**/:10px\9; - opacity:0; - filter:alpha(opacity=0); - z-index:2; -} -a.upload-img{ - width:165px; - display: inline-block; - margin-bottom: 10px; - height:37px; - line-height: 37px; - font-size: 14px; - color: #FFFFFF; - background-color: #f38e81; - border-radius: 3px; - text-decoration:none; - cursor:pointer; - border: 0px #fff solid; - box-shadow: 0px 0px 5px #B0B0B0; -} -a.upload-img:hover{ - background-color: #ec7e70; -} - -.tc{text-align:center;} +@charset "utf-8"; +.container { + margin: 10px auto 0 auto; + position: relative; + font-family: 微软雅黑; + font-size: 12px; +} +.container p { + line-height: 12px; + line-height: 0px; + height: 0px; + margin: 10px; + color: #bbb +} +.action { + width: 400px; + height: 30px; + margin: 10px 0; +} +.cropped { + position: absolute; + left: 500px; + top: 0; + width: 200px; + border: 1px #ddd solid; + height: 440px; + padding: 4px; + box-shadow: 0px 0px 12px #ddd; + text-align: center; +} +.imageBox { + position: relative; + height: 400px; + width: 400px; + border: 1px solid #aaa; + background: #fff; + overflow: hidden; + background-repeat: no-repeat; + cursor: move; + box-shadow: 4px 4px 12px #B0B0B0; +} +.imageBox .thumbBox { + position: absolute; + top: 50%; + left: 50%; + width: 200px; + height: 200px; + margin-top: -100px; + margin-left: -100px; + box-sizing: border-box; + border: 1px solid rgb(102, 102, 102); + box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5); + background: none repeat scroll 0% 0% transparent; +} +.imageBox .spinner { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + text-align: center; + line-height: 400px; + background: rgba(0,0,0,0.7); +} +.Btnsty_peyton{ float: right; + width: 46px; + display: inline-block; + margin-bottom: 10px; + height: 37px; + line-height: 37px; + font-size: 14px; + color: #FFFFFF; + margin:0px 2px; + background-color: #f38e81; + border-radius: 3px; + text-decoration: none; + cursor: pointer; + box-shadow: 0px 0px 5px #B0B0B0; + border: 0px #fff solid;} +/*选择文件上传*/ +.new-contentarea { + width: 165px; + overflow:hidden; + margin: 0 auto; + position:relative;float:left; +} +.new-contentarea label { + width:100%; + height:100%; + display:block; +} +.new-contentarea input[type=file] { + width:188px; + height:60px; + background:#333; + margin: 0 auto; + position:absolute; + right:50%; + margin-right:-94px; + top:0; + right/*\**/:0px\9; + margin-right/*\**/:0px\9; + width/*\**/:10px\9; + opacity:0; + filter:alpha(opacity=0); + z-index:2; +} +a.upload-img{ + width:165px; + display: inline-block; + margin-bottom: 10px; + height:37px; + line-height: 37px; + font-size: 14px; + color: #FFFFFF; + background-color: #f38e81; + border-radius: 3px; + text-decoration:none; + cursor:pointer; + border: 0px #fff solid; + box-shadow: 0px 0px 5px #B0B0B0; +} +a.upload-img:hover{ + background-color: #ec7e70; +} + +.tc{text-align:center;} diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.js b/bmw-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.js rename to bmw-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.js index 4e3891e96..b7450c03f 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/cropbox/cropbox.js @@ -1,136 +1,136 @@ -"use strict"; -(function (factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } else { - factory(jQuery); - } -}(function ($) { - var cropbox = function(options, el){ - var el = el || $(options.imageBox), - obj = - { - state : {}, - ratio : 1, - options : options, - imageBox : el, - thumbBox : el.find(options.thumbBox), - spinner : el.find(options.spinner), - image : new Image(), - getDataURL: function () - { - var width = this.thumbBox.width(), - height = this.thumbBox.height(), - canvas = document.createElement("canvas"), - dim = el.css('background-position').split(' '), - size = el.css('background-size').split(' '), - dx = parseInt(dim[0]) - el.width()/2 + width/2, - dy = parseInt(dim[1]) - el.height()/2 + height/2, - dw = parseInt(size[0]), - dh = parseInt(size[1]), - sh = parseInt(this.image.height), - sw = parseInt(this.image.width); - - canvas.width = width; - canvas.height = height; - var context = canvas.getContext("2d"); - context.drawImage(this.image, 0, 0, sw, sh, dx, dy, dw, dh); - var imageData = canvas.toDataURL('image/png'); - return imageData; - }, - getBlob: function() - { - var imageData = this.getDataURL(); - var b64 = imageData.replace('data:image/png;base64,',''); - var binary = atob(b64); - var array = []; - for (var i = 0; i < binary.length; i++) { - array.push(binary.charCodeAt(i)); - } - return new Blob([new Uint8Array(array)], {type: 'image/png'}); - }, - zoomIn: function () - { - this.ratio*=1.1; - setBackground(); - }, - zoomOut: function () - { - this.ratio*=0.9; - setBackground(); - } - }, - setBackground = function() - { - var w = parseInt(obj.image.width)*obj.ratio; - var h = parseInt(obj.image.height)*obj.ratio; - - var pw = (el.width() - w) / 2; - var ph = (el.height() - h) / 2; - - el.css({ - 'background-image': 'url(' + obj.image.src + ')', - 'background-size': w +'px ' + h + 'px', - 'background-position': pw + 'px ' + ph + 'px', - 'background-repeat': 'no-repeat'}); - }, - imgMouseDown = function(e) - { - e.stopImmediatePropagation(); - - obj.state.dragable = true; - obj.state.mouseX = e.clientX; - obj.state.mouseY = e.clientY; - }, - imgMouseMove = function(e) - { - e.stopImmediatePropagation(); - - if (obj.state.dragable) - { - var x = e.clientX - obj.state.mouseX; - var y = e.clientY - obj.state.mouseY; - - var bg = el.css('background-position').split(' '); - - var bgX = x + parseInt(bg[0]); - var bgY = y + parseInt(bg[1]); - - el.css('background-position', bgX +'px ' + bgY + 'px'); - - obj.state.mouseX = e.clientX; - obj.state.mouseY = e.clientY; - } - }, - imgMouseUp = function(e) - { - e.stopImmediatePropagation(); - obj.state.dragable = false; - }, - zoomImage = function(e) - { - e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0 ? obj.ratio*=1.1 : obj.ratio*=0.9; - setBackground(); - } - - obj.spinner.show(); - obj.image.onload = function() { - obj.spinner.hide(); - setBackground(); - - el.bind('mousedown', imgMouseDown); - el.bind('mousemove', imgMouseMove); - $(window).bind('mouseup', imgMouseUp); - el.bind('mousewheel DOMMouseScroll', zoomImage); - }; - obj.image.crossOrigin = 'Anonymous'; - obj.image.src = options.imgSrc; - el.on('remove', function(){$(window).unbind('mouseup', imgMouseUp)}); - - return obj; - }; - - jQuery.fn.cropbox = function(options){ - return new cropbox(options, this); - }; -})); +"use strict"; +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(jQuery); + } +}(function ($) { + var cropbox = function(options, el){ + var el = el || $(options.imageBox), + obj = + { + state : {}, + ratio : 1, + options : options, + imageBox : el, + thumbBox : el.find(options.thumbBox), + spinner : el.find(options.spinner), + image : new Image(), + getDataURL: function () + { + var width = this.thumbBox.width(), + height = this.thumbBox.height(), + canvas = document.createElement("canvas"), + dim = el.css('background-position').split(' '), + size = el.css('background-size').split(' '), + dx = parseInt(dim[0]) - el.width()/2 + width/2, + dy = parseInt(dim[1]) - el.height()/2 + height/2, + dw = parseInt(size[0]), + dh = parseInt(size[1]), + sh = parseInt(this.image.height), + sw = parseInt(this.image.width); + + canvas.width = width; + canvas.height = height; + var context = canvas.getContext("2d"); + context.drawImage(this.image, 0, 0, sw, sh, dx, dy, dw, dh); + var imageData = canvas.toDataURL('image/png'); + return imageData; + }, + getBlob: function() + { + var imageData = this.getDataURL(); + var b64 = imageData.replace('data:image/png;base64,',''); + var binary = atob(b64); + var array = []; + for (var i = 0; i < binary.length; i++) { + array.push(binary.charCodeAt(i)); + } + return new Blob([new Uint8Array(array)], {type: 'image/png'}); + }, + zoomIn: function () + { + this.ratio*=1.1; + setBackground(); + }, + zoomOut: function () + { + this.ratio*=0.9; + setBackground(); + } + }, + setBackground = function() + { + var w = parseInt(obj.image.width)*obj.ratio; + var h = parseInt(obj.image.height)*obj.ratio; + + var pw = (el.width() - w) / 2; + var ph = (el.height() - h) / 2; + + el.css({ + 'background-image': 'url(' + obj.image.src + ')', + 'background-size': w +'px ' + h + 'px', + 'background-position': pw + 'px ' + ph + 'px', + 'background-repeat': 'no-repeat'}); + }, + imgMouseDown = function(e) + { + e.stopImmediatePropagation(); + + obj.state.dragable = true; + obj.state.mouseX = e.clientX; + obj.state.mouseY = e.clientY; + }, + imgMouseMove = function(e) + { + e.stopImmediatePropagation(); + + if (obj.state.dragable) + { + var x = e.clientX - obj.state.mouseX; + var y = e.clientY - obj.state.mouseY; + + var bg = el.css('background-position').split(' '); + + var bgX = x + parseInt(bg[0]); + var bgY = y + parseInt(bg[1]); + + el.css('background-position', bgX +'px ' + bgY + 'px'); + + obj.state.mouseX = e.clientX; + obj.state.mouseY = e.clientY; + } + }, + imgMouseUp = function(e) + { + e.stopImmediatePropagation(); + obj.state.dragable = false; + }, + zoomImage = function(e) + { + e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0 ? obj.ratio*=1.1 : obj.ratio*=0.9; + setBackground(); + } + + obj.spinner.show(); + obj.image.onload = function() { + obj.spinner.hide(); + setBackground(); + + el.bind('mousedown', imgMouseDown); + el.bind('mousemove', imgMouseMove); + $(window).bind('mouseup', imgMouseUp); + el.bind('mousewheel DOMMouseScroll', zoomImage); + }; + obj.image.crossOrigin = 'Anonymous'; + obj.image.src = options.imgSrc; + el.on('remove', function(){$(window).unbind('mouseup', imgMouseUp)}); + + return obj; + }; + + jQuery.fn.cropbox = function(options){ + return new cropbox(options, this); + }; +})); diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.css b/bmw-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.css rename to bmw-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.js b/bmw-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.js rename to bmw-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.min.css b/bmw-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.min.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.min.css rename to bmw-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.min.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.min.js b/bmw-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.min.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/datapicker/bootstrap-datetimepicker.min.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.css b/bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.css similarity index 95% rename from ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.css rename to bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.css index 0a88e59a2..ccdb7b5ff 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.css @@ -1,86 +1,86 @@ -/* - * Bootstrap Duallistbox - v3.0.7 - * A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices. - * https://www.virtuosoft.eu/code/bootstrap-duallistbox/ - * - * Made by István Ujj-Mészáros - * Under Apache License v2.0 License - */ -.bootstrap-duallistbox-container .buttons { - width: 100%; - margin-bottom: -1px; -} - -.bootstrap-duallistbox-container label { - display: block; -} - -.bootstrap-duallistbox-container .info { - display: inline-block; - margin-bottom: 5px; - font-size: 11px; -} - -.bootstrap-duallistbox-container .clear1, -.bootstrap-duallistbox-container .clear2 { - display: none; - font-size: 10px; -} - -.bootstrap-duallistbox-container .box1.filtered .clear1, -.bootstrap-duallistbox-container .box2.filtered .clear2 { - display: inline-block; -} - -.bootstrap-duallistbox-container .move, -.bootstrap-duallistbox-container .remove { - width: 60%; -} - -.bootstrap-duallistbox-container .btn-group .btn { - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; -} -.bootstrap-duallistbox-container select { - border-top-left-radius: 0; - border-top-right-radius: 0; -} - -.bootstrap-duallistbox-container .moveall, -.bootstrap-duallistbox-container .removeall { - width: 40%; -} - -.bootstrap-duallistbox-container.bs2compatible .btn-group > .btn + .btn { - margin-left: 0; -} - -.bootstrap-duallistbox-container select { - width: 100%; - height: 300px; - padding: 0; -} - -.bootstrap-duallistbox-container .filter { - display: inline-block; - width: 100%; - height: 31px; - margin: 0 0 5px 0; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -.bootstrap-duallistbox-container .filter.placeholder { - color: #aaa; -} - -.bootstrap-duallistbox-container.moveonselect .move, -.bootstrap-duallistbox-container.moveonselect .remove { - display:none; -} - -.bootstrap-duallistbox-container.moveonselect .moveall, -.bootstrap-duallistbox-container.moveonselect .removeall { - width: 100%; -} +/* + * Bootstrap Duallistbox - v3.0.7 + * A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices. + * https://www.virtuosoft.eu/code/bootstrap-duallistbox/ + * + * Made by István Ujj-Mészáros + * Under Apache License v2.0 License + */ +.bootstrap-duallistbox-container .buttons { + width: 100%; + margin-bottom: -1px; +} + +.bootstrap-duallistbox-container label { + display: block; +} + +.bootstrap-duallistbox-container .info { + display: inline-block; + margin-bottom: 5px; + font-size: 11px; +} + +.bootstrap-duallistbox-container .clear1, +.bootstrap-duallistbox-container .clear2 { + display: none; + font-size: 10px; +} + +.bootstrap-duallistbox-container .box1.filtered .clear1, +.bootstrap-duallistbox-container .box2.filtered .clear2 { + display: inline-block; +} + +.bootstrap-duallistbox-container .move, +.bootstrap-duallistbox-container .remove { + width: 60%; +} + +.bootstrap-duallistbox-container .btn-group .btn { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} +.bootstrap-duallistbox-container select { + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.bootstrap-duallistbox-container .moveall, +.bootstrap-duallistbox-container .removeall { + width: 40%; +} + +.bootstrap-duallistbox-container.bs2compatible .btn-group > .btn + .btn { + margin-left: 0; +} + +.bootstrap-duallistbox-container select { + width: 100%; + height: 300px; + padding: 0; +} + +.bootstrap-duallistbox-container .filter { + display: inline-block; + width: 100%; + height: 31px; + margin: 0 0 5px 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.bootstrap-duallistbox-container .filter.placeholder { + color: #aaa; +} + +.bootstrap-duallistbox-container.moveonselect .move, +.bootstrap-duallistbox-container.moveonselect .remove { + display:none; +} + +.bootstrap-duallistbox-container.moveonselect .moveall, +.bootstrap-duallistbox-container.moveonselect .removeall { + width: 100%; +} diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.js b/bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.js rename to bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.js index 109dfe17b..5cd578374 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.js @@ -1,841 +1,841 @@ -/* - * Bootstrap Duallistbox - v3.0.7 - * A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices. - * https://www.virtuosoft.eu/code/bootstrap-duallistbox/ - * - * Made by István Ujj-Mészáros - * Under Apache License v2.0 License - */ -;(function ($, window, document, undefined) { - // Create the defaults once - var pluginName = 'bootstrapDualListbox', - defaults = { - bootstrap2Compatible: false, - filterTextClear: 'show all', - filterPlaceHolder: 'Filter', - moveSelectedLabel: 'Move selected', - moveAllLabel: 'Move all', - removeSelectedLabel: 'Remove selected', - removeAllLabel: 'Remove all', - moveOnSelect: true, // true/false (forced true on androids, see the comment later) - moveOnDoubleClick: true, // true/false (forced false on androids, cause moveOnSelect is forced to true) - preserveSelectionOnMove: false, // 'all' / 'moved' / false - selectedListLabel: false, // 'string', false - nonSelectedListLabel: false, // 'string', false - helperSelectNamePostfix: '_helper', // 'string_of_postfix' / false - selectorMinimalHeight: 100, - showFilterInputs: true, // whether to show filter inputs - nonSelectedFilter: '', // string, filter the non selected options - selectedFilter: '', // string, filter the selected options - infoText: 'Showing all {0}', // text when all options are visible / false for no info text - infoTextFiltered: 'Filtered {0} from {1}', // when not all of the options are visible due to the filter - infoTextEmpty: 'Empty list', // when there are no options present in the list - filterOnValues: false, // filter by selector's values, boolean - sortByInputOrder: false, - eventMoveOverride: false, // boolean, allows user to unbind default event behaviour and run their own instead - eventMoveAllOverride: false, // boolean, allows user to unbind default event behaviour and run their own instead - eventRemoveOverride: false, // boolean, allows user to unbind default event behaviour and run their own instead - eventRemoveAllOverride: false // boolean, allows user to unbind default event behaviour and run their own instead - }, - // Selections are invisible on android if the containing select is styled with CSS - // http://code.google.com/p/android/issues/detail?id=16922 - isBuggyAndroid = /android/i.test(navigator.userAgent.toLowerCase()); - - // The actual plugin constructor - function BootstrapDualListbox(element, options) { - this.element = $(element); - // jQuery has an extend method which merges the contents of two or - // more objects, storing the result in the first object. The first object - // is generally empty as we don't want to alter the default options for - // future instances of the plugin - this.settings = $.extend({}, defaults, options); - this._defaults = defaults; - this._name = pluginName; - this.init(); - } - - function triggerChangeEvent(dualListbox) { - dualListbox.element.trigger('change'); - } - - function updateSelectionStates(dualListbox) { - dualListbox.element.find('option').each(function(index, item) { - var $item = $(item); - if (typeof($item.data('original-index')) === 'undefined') { - $item.data('original-index', dualListbox.elementCount++); - } - if (typeof($item.data('_selected')) === 'undefined') { - $item.data('_selected', false); - } - }); - } - - function changeSelectionState(dualListbox, original_index, selected) { - dualListbox.element.find('option').each(function(index, item) { - var $item = $(item); - if ($item.data('original-index') === original_index) { - $item.prop('selected', selected); - if(selected){ - $item.attr('data-sortindex', dualListbox.sortIndex); - dualListbox.sortIndex++; - } else { - $item.removeAttr('data-sortindex'); - } - } - }); - } - - function formatString(s, args) { - return s.replace(/\{(\d+)\}/g, function(match, number) { - return typeof args[number] !== 'undefined' ? args[number] : match; - }); - } - - function refreshInfo(dualListbox) { - if (!dualListbox.settings.infoText) { - return; - } - - var visible1 = dualListbox.elements.select1.find('option').length, - visible2 = dualListbox.elements.select2.find('option').length, - all1 = dualListbox.element.find('option').length - dualListbox.selectedElements, - all2 = dualListbox.selectedElements, - content = ''; - - if (all1 === 0) { - content = dualListbox.settings.infoTextEmpty; - } else if (visible1 === all1) { - content = formatString(dualListbox.settings.infoText, [visible1, all1]); - } else { - content = formatString(dualListbox.settings.infoTextFiltered, [visible1, all1]); - } - - dualListbox.elements.info1.html(content); - dualListbox.elements.box1.toggleClass('filtered', !(visible1 === all1 || all1 === 0)); - - if (all2 === 0) { - content = dualListbox.settings.infoTextEmpty; - } else if (visible2 === all2) { - content = formatString(dualListbox.settings.infoText, [visible2, all2]); - } else { - content = formatString(dualListbox.settings.infoTextFiltered, [visible2, all2]); - } - - dualListbox.elements.info2.html(content); - dualListbox.elements.box2.toggleClass('filtered', !(visible2 === all2 || all2 === 0)); - } - - function refreshSelects(dualListbox) { - dualListbox.selectedElements = 0; - - dualListbox.elements.select1.empty(); - dualListbox.elements.select2.empty(); - - dualListbox.element.find('option').each(function(index, item) { - var $item = $(item); - if ($item.prop('selected')) { - dualListbox.selectedElements++; - dualListbox.elements.select2.append($item.clone(true).prop('selected', $item.data('_selected'))); - } else { - dualListbox.elements.select1.append($item.clone(true).prop('selected', $item.data('_selected'))); - } - }); - - if (dualListbox.settings.showFilterInputs) { - filter(dualListbox, 1); - filter(dualListbox, 2); - } - refreshInfo(dualListbox); - } - - function filter(dualListbox, selectIndex) { - if (!dualListbox.settings.showFilterInputs) { - return; - } - - saveSelections(dualListbox, selectIndex); - - dualListbox.elements['select'+selectIndex].empty().scrollTop(0); - var regex = new RegExp($.trim(dualListbox.elements['filterInput'+selectIndex].val()), 'gi'), - allOptions = dualListbox.element.find('option'), - options = dualListbox.element; - - if (selectIndex === 1) { - options = allOptions.not(':selected'); - } else { - options = options.find('option:selected'); - } - - options.each(function(index, item) { - var $item = $(item), - isFiltered = true; - if (item.text.match(regex) || (dualListbox.settings.filterOnValues && $item.attr('value').match(regex) ) ) { - isFiltered = false; - dualListbox.elements['select'+selectIndex].append($item.clone(true).prop('selected', $item.data('_selected'))); - } - allOptions.eq($item.data('original-index')).data('filtered'+selectIndex, isFiltered); - }); - - refreshInfo(dualListbox); - } - - function saveSelections(dualListbox, selectIndex) { - var options = dualListbox.element.find('option'); - dualListbox.elements['select'+selectIndex].find('option').each(function(index, item) { - var $item = $(item); - options.eq($item.data('original-index')).data('_selected', $item.prop('selected')); - }); - } - - function sortOptionsByInputOrder(select){ - var selectopt = select.children('option'); - - selectopt.sort(function(a,b){ - var an = parseInt(a.getAttribute('data-sortindex')), - bn = parseInt(b.getAttribute('data-sortindex')); - - if(an > bn) { - return 1; - } - if(an < bn) { - return -1; - } - return 0; - }); - - selectopt.detach().appendTo(select); - } - - function sortOptions(select) { - select.find('option').sort(function(a, b) { - return ($(a).data('original-index') > $(b).data('original-index')) ? 1 : -1; - }).appendTo(select); - } - - function clearSelections(dualListbox) { - dualListbox.elements.select1.find('option').each(function() { - dualListbox.element.find('option').data('_selected', false); - }); - } - - function move(dualListbox) { - if (dualListbox.settings.preserveSelectionOnMove === 'all' && !dualListbox.settings.moveOnSelect) { - saveSelections(dualListbox, 1); - saveSelections(dualListbox, 2); - } else if (dualListbox.settings.preserveSelectionOnMove === 'moved' && !dualListbox.settings.moveOnSelect) { - saveSelections(dualListbox, 1); - } - - dualListbox.elements.select1.find('option:selected').each(function(index, item) { - var $item = $(item); - if (!$item.data('filtered1')) { - changeSelectionState(dualListbox, $item.data('original-index'), true); - } - }); - - refreshSelects(dualListbox); - triggerChangeEvent(dualListbox); - if(dualListbox.settings.sortByInputOrder){ - sortOptionsByInputOrder(dualListbox.elements.select2); - } else { - sortOptions(dualListbox.elements.select2); - } - } - - function remove(dualListbox) { - if (dualListbox.settings.preserveSelectionOnMove === 'all' && !dualListbox.settings.moveOnSelect) { - saveSelections(dualListbox, 1); - saveSelections(dualListbox, 2); - } else if (dualListbox.settings.preserveSelectionOnMove === 'moved' && !dualListbox.settings.moveOnSelect) { - saveSelections(dualListbox, 2); - } - - dualListbox.elements.select2.find('option:selected').each(function(index, item) { - var $item = $(item); - if (!$item.data('filtered2')) { - changeSelectionState(dualListbox, $item.data('original-index'), false); - } - }); - - refreshSelects(dualListbox); - triggerChangeEvent(dualListbox); - sortOptions(dualListbox.elements.select1); - if(dualListbox.settings.sortByInputOrder){ - sortOptionsByInputOrder(dualListbox.elements.select2); - } - } - - function moveAll(dualListbox) { - if (dualListbox.settings.preserveSelectionOnMove === 'all' && !dualListbox.settings.moveOnSelect) { - saveSelections(dualListbox, 1); - saveSelections(dualListbox, 2); - } else if (dualListbox.settings.preserveSelectionOnMove === 'moved' && !dualListbox.settings.moveOnSelect) { - saveSelections(dualListbox, 1); - } - - dualListbox.element.find('option').each(function(index, item) { - var $item = $(item); - if (!$item.data('filtered1')) { - $item.prop('selected', true); - $item.attr('data-sortindex', dualListbox.sortIndex); - dualListbox.sortIndex++; - } - }); - - refreshSelects(dualListbox); - triggerChangeEvent(dualListbox); - } - - function removeAll(dualListbox) { - if (dualListbox.settings.preserveSelectionOnMove === 'all' && !dualListbox.settings.moveOnSelect) { - saveSelections(dualListbox, 1); - saveSelections(dualListbox, 2); - } else if (dualListbox.settings.preserveSelectionOnMove === 'moved' && !dualListbox.settings.moveOnSelect) { - saveSelections(dualListbox, 2); - } - - dualListbox.element.find('option').each(function(index, item) { - var $item = $(item); - if (!$item.data('filtered2')) { - $item.prop('selected', false); - $item.removeAttr('data-sortindex'); - } - }); - - refreshSelects(dualListbox); - triggerChangeEvent(dualListbox); - } - - function bindEvents(dualListbox) { - dualListbox.elements.form.submit(function(e) { - if (dualListbox.elements.filterInput1.is(':focus')) { - e.preventDefault(); - dualListbox.elements.filterInput1.focusout(); - } else if (dualListbox.elements.filterInput2.is(':focus')) { - e.preventDefault(); - dualListbox.elements.filterInput2.focusout(); - } - }); - - dualListbox.element.on('bootstrapDualListbox.refresh', function(e, mustClearSelections){ - dualListbox.refresh(mustClearSelections); - }); - - dualListbox.elements.filterClear1.on('click', function() { - dualListbox.setNonSelectedFilter('', true); - }); - - dualListbox.elements.filterClear2.on('click', function() { - dualListbox.setSelectedFilter('', true); - }); - - if (dualListbox.settings.eventMoveOverride === false) { - dualListbox.elements.moveButton.on('click', function() { - move(dualListbox); - }); - } - - if (dualListbox.settings.eventMoveAllOverride === false) { - dualListbox.elements.moveAllButton.on('click', function() { - moveAll(dualListbox); - }); - } - - if (dualListbox.settings.eventRemoveOverride === false) { - dualListbox.elements.removeButton.on('click', function() { - remove(dualListbox); - }); - } - - if (dualListbox.settings.eventRemoveAllOverride === false) { - dualListbox.elements.removeAllButton.on('click', function() { - removeAll(dualListbox); - }); - } - - dualListbox.elements.filterInput1.on('change keyup', function() { - filter(dualListbox, 1); - }); - - dualListbox.elements.filterInput2.on('change keyup', function() { - filter(dualListbox, 2); - }); - } - - BootstrapDualListbox.prototype = { - init: function () { - // Add the custom HTML template - this.container = $('' + - '
    ' + - '
    ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - '
    ' + - ' ' + - ' ' + - '
    ' + - ' ' + - '
    ' + - '
    ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - '
    ' + - ' ' + - ' ' + - '
    ' + - ' ' + - '
    ' + - '
    ') - .insertBefore(this.element); - - // Cache the inner elements - this.elements = { - originalSelect: this.element, - box1: $('.box1', this.container), - box2: $('.box2', this.container), - filterInput1: $('.box1 .filter', this.container), - filterInput2: $('.box2 .filter', this.container), - filterClear1: $('.box1 .clear1', this.container), - filterClear2: $('.box2 .clear2', this.container), - label1: $('.box1 > label', this.container), - label2: $('.box2 > label', this.container), - info1: $('.box1 .info', this.container), - info2: $('.box2 .info', this.container), - select1: $('.box1 select', this.container), - select2: $('.box2 select', this.container), - moveButton: $('.box1 .move', this.container), - removeButton: $('.box2 .remove', this.container), - moveAllButton: $('.box1 .moveall', this.container), - removeAllButton: $('.box2 .removeall', this.container), - form: $($('.box1 .filter', this.container)[0].form) - }; - - // Set select IDs - this.originalSelectName = this.element.attr('name') || ''; - var select1Id = 'bootstrap-duallistbox-nonselected-list_' + this.originalSelectName, - select2Id = 'bootstrap-duallistbox-selected-list_' + this.originalSelectName; - this.elements.select1.attr('id', select1Id); - this.elements.select2.attr('id', select2Id); - this.elements.label1.attr('for', select1Id); - this.elements.label2.attr('for', select2Id); - - // Apply all settings - this.selectedElements = 0; - this.sortIndex = 0; - this.elementCount = 0; - this.setBootstrap2Compatible(this.settings.bootstrap2Compatible); - this.setFilterTextClear(this.settings.filterTextClear); - this.setFilterPlaceHolder(this.settings.filterPlaceHolder); - this.setMoveSelectedLabel(this.settings.moveSelectedLabel); - this.setMoveAllLabel(this.settings.moveAllLabel); - this.setRemoveSelectedLabel(this.settings.removeSelectedLabel); - this.setRemoveAllLabel(this.settings.removeAllLabel); - this.setMoveOnSelect(this.settings.moveOnSelect); - this.setMoveOnDoubleClick(this.settings.moveOnDoubleClick); - this.setPreserveSelectionOnMove(this.settings.preserveSelectionOnMove); - this.setSelectedListLabel(this.settings.selectedListLabel); - this.setNonSelectedListLabel(this.settings.nonSelectedListLabel); - this.setHelperSelectNamePostfix(this.settings.helperSelectNamePostfix); - this.setSelectOrMinimalHeight(this.settings.selectorMinimalHeight); - - updateSelectionStates(this); - - this.setShowFilterInputs(this.settings.showFilterInputs); - this.setNonSelectedFilter(this.settings.nonSelectedFilter); - this.setSelectedFilter(this.settings.selectedFilter); - this.setInfoText(this.settings.infoText); - this.setInfoTextFiltered(this.settings.infoTextFiltered); - this.setInfoTextEmpty(this.settings.infoTextEmpty); - this.setFilterOnValues(this.settings.filterOnValues); - this.setSortByInputOrder(this.settings.sortByInputOrder); - this.setEventMoveOverride(this.settings.eventMoveOverride); - this.setEventMoveAllOverride(this.settings.eventMoveAllOverride); - this.setEventRemoveOverride(this.settings.eventRemoveOverride); - this.setEventRemoveAllOverride(this.settings.eventRemoveAllOverride); - - // Hide the original select - this.element.hide(); - - bindEvents(this); - refreshSelects(this); - - return this.element; - }, - setBootstrap2Compatible: function(value, refresh) { - this.settings.bootstrap2Compatible = value; - if (value) { - this.container.removeClass('row').addClass('row-fluid bs2compatible'); - this.container.find('.box1, .box2').removeClass('col-md-6').addClass('span6'); - this.container.find('.clear1, .clear2').removeClass('btn-white btn-xs').addClass('btn-mini'); - this.container.find('input, select').removeClass('form-control'); - this.container.find('.btn').removeClass('btn-white'); - this.container.find('.moveall > i, .move > i').removeClass('glyphicon glyphicon-arrow-right').addClass('icon-arrow-right'); - this.container.find('.removeall > i, .remove > i').removeClass('glyphicon glyphicon-arrow-left').addClass('icon-arrow-left'); - } else { - this.container.removeClass('row-fluid bs2compatible').addClass('row'); - this.container.find('.box1, .box2').removeClass('span6').addClass('col-md-6'); - this.container.find('.clear1, .clear2').removeClass('btn-mini').addClass('btn-white btn-xs'); - this.container.find('input, select').addClass('form-control'); - this.container.find('.btn').addClass('btn-white'); - this.container.find('.moveall > i, .move > i').removeClass('icon-arrow-right').addClass('glyphicon glyphicon-arrow-right'); - this.container.find('.removeall > i, .remove > i').removeClass('icon-arrow-left').addClass('glyphicon glyphicon-arrow-left'); - } - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setFilterTextClear: function(value, refresh) { - this.settings.filterTextClear = value; - this.elements.filterClear1.html(value); - this.elements.filterClear2.html(value); - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setFilterPlaceHolder: function(value, refresh) { - this.settings.filterPlaceHolder = value; - this.elements.filterInput1.attr('placeholder', value); - this.elements.filterInput2.attr('placeholder', value); - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setMoveSelectedLabel: function(value, refresh) { - this.settings.moveSelectedLabel = value; - this.elements.moveButton.attr('title', value); - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setMoveAllLabel: function(value, refresh) { - this.settings.moveAllLabel = value; - this.elements.moveAllButton.attr('title', value); - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setRemoveSelectedLabel: function(value, refresh) { - this.settings.removeSelectedLabel = value; - this.elements.removeButton.attr('title', value); - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setRemoveAllLabel: function(value, refresh) { - this.settings.removeAllLabel = value; - this.elements.removeAllButton.attr('title', value); - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setMoveOnSelect: function(value, refresh) { - if (isBuggyAndroid) { - value = true; - } - this.settings.moveOnSelect = value; - if (this.settings.moveOnSelect) { - this.container.addClass('moveonselect'); - var self = this; - this.elements.select1.on('change', function() { - move(self); - }); - this.elements.select2.on('change', function() { - remove(self); - }); - } else { - this.container.removeClass('moveonselect'); - this.elements.select1.off('change'); - this.elements.select2.off('change'); - } - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setMoveOnDoubleClick: function(value, refresh) { - if (isBuggyAndroid) { - value = false; - } - this.settings.moveOnDoubleClick = value; - if (this.settings.moveOnDoubleClick) { - this.container.addClass('moveondoubleclick'); - var self = this; - this.elements.select1.on('dblclick', function() { - move(self); - }); - this.elements.select2.on('dblclick', function() { - remove(self); - }); - } else { - this.container.removeClass('moveondoubleclick'); - this.elements.select1.off('dblclick'); - this.elements.select2.off('dblclick'); - } - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setPreserveSelectionOnMove: function(value, refresh) { - // We are forcing to move on select and disabling preserveSelectionOnMove on Android - if (isBuggyAndroid) { - value = false; - } - this.settings.preserveSelectionOnMove = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setSelectedListLabel: function(value, refresh) { - this.settings.selectedListLabel = value; - if (value) { - this.elements.label2.show().html(value); - } else { - this.elements.label2.hide().html(value); - } - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setNonSelectedListLabel: function(value, refresh) { - this.settings.nonSelectedListLabel = value; - if (value) { - this.elements.label1.show().html(value); - } else { - this.elements.label1.hide().html(value); - } - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setHelperSelectNamePostfix: function(value, refresh) { - this.settings.helperSelectNamePostfix = value; - if (value) { - this.elements.select1.attr('name', this.originalSelectName + value + '1'); - this.elements.select2.attr('name', this.originalSelectName + value + '2'); - } else { - this.elements.select1.removeAttr('name'); - this.elements.select2.removeAttr('name'); - } - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setSelectOrMinimalHeight: function(value, refresh) { - this.settings.selectorMinimalHeight = value; - var height = this.element.height(); - if (this.element.height() < value) { - height = value; - } - this.elements.select1.height(height); - this.elements.select2.height(height); - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setShowFilterInputs: function(value, refresh) { - if (!value) { - this.setNonSelectedFilter(''); - this.setSelectedFilter(''); - refreshSelects(this); - this.elements.filterInput1.hide(); - this.elements.filterInput2.hide(); - } else { - this.elements.filterInput1.show(); - this.elements.filterInput2.show(); - } - this.settings.showFilterInputs = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setNonSelectedFilter: function(value, refresh) { - if (this.settings.showFilterInputs) { - this.settings.nonSelectedFilter = value; - this.elements.filterInput1.val(value); - if (refresh) { - refreshSelects(this); - } - return this.element; - } - }, - setSelectedFilter: function(value, refresh) { - if (this.settings.showFilterInputs) { - this.settings.selectedFilter = value; - this.elements.filterInput2.val(value); - if (refresh) { - refreshSelects(this); - } - return this.element; - } - }, - setInfoText: function(value, refresh) { - this.settings.infoText = value; - if (value) { - this.elements.info1.show(); - this.elements.info2.show(); - } else { - this.elements.info1.hide(); - this.elements.info2.hide(); - } - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setInfoTextFiltered: function(value, refresh) { - this.settings.infoTextFiltered = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setInfoTextEmpty: function(value, refresh) { - this.settings.infoTextEmpty = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setFilterOnValues: function(value, refresh) { - this.settings.filterOnValues = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setSortByInputOrder: function(value, refresh){ - this.settings.sortByInputOrder = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setEventMoveOverride: function(value, refresh) { - this.settings.eventMoveOverride = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setEventMoveAllOverride: function(value, refresh) { - this.settings.eventMoveAllOverride = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setEventRemoveOverride: function(value, refresh) { - this.settings.eventRemoveOverride = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - setEventRemoveAllOverride: function(value, refresh) { - this.settings.eventRemoveAllOverride = value; - if (refresh) { - refreshSelects(this); - } - return this.element; - }, - getContainer: function() { - return this.container; - }, - refresh: function(mustClearSelections) { - updateSelectionStates(this); - - if (!mustClearSelections) { - saveSelections(this, 1); - saveSelections(this, 2); - } else { - clearSelections(this); - } - - refreshSelects(this); - }, - destroy: function() { - this.container.remove(); - this.element.show(); - $.data(this, 'plugin_' + pluginName, null); - return this.element; - } - }; - - // A really lightweight plugin wrapper around the constructor, - // preventing against multiple instantiations - $.fn[ pluginName ] = function (options) { - var args = arguments; - - // Is the first parameter an object (options), or was omitted, instantiate a new instance of the plugin. - if (options === undefined || typeof options === 'object') { - return this.each(function () { - // If this is not a select - if (!$(this).is('select')) { - $(this).find('select').each(function(index, item) { - // For each nested select, instantiate the Dual List Box - $(item).bootstrapDualListbox(options); - }); - } else if (!$.data(this, 'plugin_' + pluginName)) { - // Only allow the plugin to be instantiated once so we check that the element has no plugin instantiation yet - - // if it has no instance, create a new one, pass options to our plugin constructor, - // and store the plugin instance in the elements jQuery data object. - $.data(this, 'plugin_' + pluginName, new BootstrapDualListbox(this, options)); - } - }); - // If the first parameter is a string and it doesn't start with an underscore or "contains" the `init`-function, - // treat this as a call to a public method. - } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { - - // Cache the method call to make it possible to return a value - var returns; - - this.each(function () { - var instance = $.data(this, 'plugin_' + pluginName); - // Tests that there's already a plugin-instance and checks that the requested public method exists - if (instance instanceof BootstrapDualListbox && typeof instance[options] === 'function') { - // Call the method of our plugin instance, and pass it the supplied arguments. - returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1)); - } - }); - - // If the earlier cached method gives a value back return the value, - // otherwise return this to preserve chainability. - return returns !== undefined ? returns : this; - } - - }; - -})(jQuery, window, document); +/* + * Bootstrap Duallistbox - v3.0.7 + * A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices. + * https://www.virtuosoft.eu/code/bootstrap-duallistbox/ + * + * Made by István Ujj-Mészáros + * Under Apache License v2.0 License + */ +;(function ($, window, document, undefined) { + // Create the defaults once + var pluginName = 'bootstrapDualListbox', + defaults = { + bootstrap2Compatible: false, + filterTextClear: 'show all', + filterPlaceHolder: 'Filter', + moveSelectedLabel: 'Move selected', + moveAllLabel: 'Move all', + removeSelectedLabel: 'Remove selected', + removeAllLabel: 'Remove all', + moveOnSelect: true, // true/false (forced true on androids, see the comment later) + moveOnDoubleClick: true, // true/false (forced false on androids, cause moveOnSelect is forced to true) + preserveSelectionOnMove: false, // 'all' / 'moved' / false + selectedListLabel: false, // 'string', false + nonSelectedListLabel: false, // 'string', false + helperSelectNamePostfix: '_helper', // 'string_of_postfix' / false + selectorMinimalHeight: 100, + showFilterInputs: true, // whether to show filter inputs + nonSelectedFilter: '', // string, filter the non selected options + selectedFilter: '', // string, filter the selected options + infoText: 'Showing all {0}', // text when all options are visible / false for no info text + infoTextFiltered: 'Filtered {0} from {1}', // when not all of the options are visible due to the filter + infoTextEmpty: 'Empty list', // when there are no options present in the list + filterOnValues: false, // filter by selector's values, boolean + sortByInputOrder: false, + eventMoveOverride: false, // boolean, allows user to unbind default event behaviour and run their own instead + eventMoveAllOverride: false, // boolean, allows user to unbind default event behaviour and run their own instead + eventRemoveOverride: false, // boolean, allows user to unbind default event behaviour and run their own instead + eventRemoveAllOverride: false // boolean, allows user to unbind default event behaviour and run their own instead + }, + // Selections are invisible on android if the containing select is styled with CSS + // http://code.google.com/p/android/issues/detail?id=16922 + isBuggyAndroid = /android/i.test(navigator.userAgent.toLowerCase()); + + // The actual plugin constructor + function BootstrapDualListbox(element, options) { + this.element = $(element); + // jQuery has an extend method which merges the contents of two or + // more objects, storing the result in the first object. The first object + // is generally empty as we don't want to alter the default options for + // future instances of the plugin + this.settings = $.extend({}, defaults, options); + this._defaults = defaults; + this._name = pluginName; + this.init(); + } + + function triggerChangeEvent(dualListbox) { + dualListbox.element.trigger('change'); + } + + function updateSelectionStates(dualListbox) { + dualListbox.element.find('option').each(function(index, item) { + var $item = $(item); + if (typeof($item.data('original-index')) === 'undefined') { + $item.data('original-index', dualListbox.elementCount++); + } + if (typeof($item.data('_selected')) === 'undefined') { + $item.data('_selected', false); + } + }); + } + + function changeSelectionState(dualListbox, original_index, selected) { + dualListbox.element.find('option').each(function(index, item) { + var $item = $(item); + if ($item.data('original-index') === original_index) { + $item.prop('selected', selected); + if(selected){ + $item.attr('data-sortindex', dualListbox.sortIndex); + dualListbox.sortIndex++; + } else { + $item.removeAttr('data-sortindex'); + } + } + }); + } + + function formatString(s, args) { + return s.replace(/\{(\d+)\}/g, function(match, number) { + return typeof args[number] !== 'undefined' ? args[number] : match; + }); + } + + function refreshInfo(dualListbox) { + if (!dualListbox.settings.infoText) { + return; + } + + var visible1 = dualListbox.elements.select1.find('option').length, + visible2 = dualListbox.elements.select2.find('option').length, + all1 = dualListbox.element.find('option').length - dualListbox.selectedElements, + all2 = dualListbox.selectedElements, + content = ''; + + if (all1 === 0) { + content = dualListbox.settings.infoTextEmpty; + } else if (visible1 === all1) { + content = formatString(dualListbox.settings.infoText, [visible1, all1]); + } else { + content = formatString(dualListbox.settings.infoTextFiltered, [visible1, all1]); + } + + dualListbox.elements.info1.html(content); + dualListbox.elements.box1.toggleClass('filtered', !(visible1 === all1 || all1 === 0)); + + if (all2 === 0) { + content = dualListbox.settings.infoTextEmpty; + } else if (visible2 === all2) { + content = formatString(dualListbox.settings.infoText, [visible2, all2]); + } else { + content = formatString(dualListbox.settings.infoTextFiltered, [visible2, all2]); + } + + dualListbox.elements.info2.html(content); + dualListbox.elements.box2.toggleClass('filtered', !(visible2 === all2 || all2 === 0)); + } + + function refreshSelects(dualListbox) { + dualListbox.selectedElements = 0; + + dualListbox.elements.select1.empty(); + dualListbox.elements.select2.empty(); + + dualListbox.element.find('option').each(function(index, item) { + var $item = $(item); + if ($item.prop('selected')) { + dualListbox.selectedElements++; + dualListbox.elements.select2.append($item.clone(true).prop('selected', $item.data('_selected'))); + } else { + dualListbox.elements.select1.append($item.clone(true).prop('selected', $item.data('_selected'))); + } + }); + + if (dualListbox.settings.showFilterInputs) { + filter(dualListbox, 1); + filter(dualListbox, 2); + } + refreshInfo(dualListbox); + } + + function filter(dualListbox, selectIndex) { + if (!dualListbox.settings.showFilterInputs) { + return; + } + + saveSelections(dualListbox, selectIndex); + + dualListbox.elements['select'+selectIndex].empty().scrollTop(0); + var regex = new RegExp($.trim(dualListbox.elements['filterInput'+selectIndex].val()), 'gi'), + allOptions = dualListbox.element.find('option'), + options = dualListbox.element; + + if (selectIndex === 1) { + options = allOptions.not(':selected'); + } else { + options = options.find('option:selected'); + } + + options.each(function(index, item) { + var $item = $(item), + isFiltered = true; + if (item.text.match(regex) || (dualListbox.settings.filterOnValues && $item.attr('value').match(regex) ) ) { + isFiltered = false; + dualListbox.elements['select'+selectIndex].append($item.clone(true).prop('selected', $item.data('_selected'))); + } + allOptions.eq($item.data('original-index')).data('filtered'+selectIndex, isFiltered); + }); + + refreshInfo(dualListbox); + } + + function saveSelections(dualListbox, selectIndex) { + var options = dualListbox.element.find('option'); + dualListbox.elements['select'+selectIndex].find('option').each(function(index, item) { + var $item = $(item); + options.eq($item.data('original-index')).data('_selected', $item.prop('selected')); + }); + } + + function sortOptionsByInputOrder(select){ + var selectopt = select.children('option'); + + selectopt.sort(function(a,b){ + var an = parseInt(a.getAttribute('data-sortindex')), + bn = parseInt(b.getAttribute('data-sortindex')); + + if(an > bn) { + return 1; + } + if(an < bn) { + return -1; + } + return 0; + }); + + selectopt.detach().appendTo(select); + } + + function sortOptions(select) { + select.find('option').sort(function(a, b) { + return ($(a).data('original-index') > $(b).data('original-index')) ? 1 : -1; + }).appendTo(select); + } + + function clearSelections(dualListbox) { + dualListbox.elements.select1.find('option').each(function() { + dualListbox.element.find('option').data('_selected', false); + }); + } + + function move(dualListbox) { + if (dualListbox.settings.preserveSelectionOnMove === 'all' && !dualListbox.settings.moveOnSelect) { + saveSelections(dualListbox, 1); + saveSelections(dualListbox, 2); + } else if (dualListbox.settings.preserveSelectionOnMove === 'moved' && !dualListbox.settings.moveOnSelect) { + saveSelections(dualListbox, 1); + } + + dualListbox.elements.select1.find('option:selected').each(function(index, item) { + var $item = $(item); + if (!$item.data('filtered1')) { + changeSelectionState(dualListbox, $item.data('original-index'), true); + } + }); + + refreshSelects(dualListbox); + triggerChangeEvent(dualListbox); + if(dualListbox.settings.sortByInputOrder){ + sortOptionsByInputOrder(dualListbox.elements.select2); + } else { + sortOptions(dualListbox.elements.select2); + } + } + + function remove(dualListbox) { + if (dualListbox.settings.preserveSelectionOnMove === 'all' && !dualListbox.settings.moveOnSelect) { + saveSelections(dualListbox, 1); + saveSelections(dualListbox, 2); + } else if (dualListbox.settings.preserveSelectionOnMove === 'moved' && !dualListbox.settings.moveOnSelect) { + saveSelections(dualListbox, 2); + } + + dualListbox.elements.select2.find('option:selected').each(function(index, item) { + var $item = $(item); + if (!$item.data('filtered2')) { + changeSelectionState(dualListbox, $item.data('original-index'), false); + } + }); + + refreshSelects(dualListbox); + triggerChangeEvent(dualListbox); + sortOptions(dualListbox.elements.select1); + if(dualListbox.settings.sortByInputOrder){ + sortOptionsByInputOrder(dualListbox.elements.select2); + } + } + + function moveAll(dualListbox) { + if (dualListbox.settings.preserveSelectionOnMove === 'all' && !dualListbox.settings.moveOnSelect) { + saveSelections(dualListbox, 1); + saveSelections(dualListbox, 2); + } else if (dualListbox.settings.preserveSelectionOnMove === 'moved' && !dualListbox.settings.moveOnSelect) { + saveSelections(dualListbox, 1); + } + + dualListbox.element.find('option').each(function(index, item) { + var $item = $(item); + if (!$item.data('filtered1')) { + $item.prop('selected', true); + $item.attr('data-sortindex', dualListbox.sortIndex); + dualListbox.sortIndex++; + } + }); + + refreshSelects(dualListbox); + triggerChangeEvent(dualListbox); + } + + function removeAll(dualListbox) { + if (dualListbox.settings.preserveSelectionOnMove === 'all' && !dualListbox.settings.moveOnSelect) { + saveSelections(dualListbox, 1); + saveSelections(dualListbox, 2); + } else if (dualListbox.settings.preserveSelectionOnMove === 'moved' && !dualListbox.settings.moveOnSelect) { + saveSelections(dualListbox, 2); + } + + dualListbox.element.find('option').each(function(index, item) { + var $item = $(item); + if (!$item.data('filtered2')) { + $item.prop('selected', false); + $item.removeAttr('data-sortindex'); + } + }); + + refreshSelects(dualListbox); + triggerChangeEvent(dualListbox); + } + + function bindEvents(dualListbox) { + dualListbox.elements.form.submit(function(e) { + if (dualListbox.elements.filterInput1.is(':focus')) { + e.preventDefault(); + dualListbox.elements.filterInput1.focusout(); + } else if (dualListbox.elements.filterInput2.is(':focus')) { + e.preventDefault(); + dualListbox.elements.filterInput2.focusout(); + } + }); + + dualListbox.element.on('bootstrapDualListbox.refresh', function(e, mustClearSelections){ + dualListbox.refresh(mustClearSelections); + }); + + dualListbox.elements.filterClear1.on('click', function() { + dualListbox.setNonSelectedFilter('', true); + }); + + dualListbox.elements.filterClear2.on('click', function() { + dualListbox.setSelectedFilter('', true); + }); + + if (dualListbox.settings.eventMoveOverride === false) { + dualListbox.elements.moveButton.on('click', function() { + move(dualListbox); + }); + } + + if (dualListbox.settings.eventMoveAllOverride === false) { + dualListbox.elements.moveAllButton.on('click', function() { + moveAll(dualListbox); + }); + } + + if (dualListbox.settings.eventRemoveOverride === false) { + dualListbox.elements.removeButton.on('click', function() { + remove(dualListbox); + }); + } + + if (dualListbox.settings.eventRemoveAllOverride === false) { + dualListbox.elements.removeAllButton.on('click', function() { + removeAll(dualListbox); + }); + } + + dualListbox.elements.filterInput1.on('change keyup', function() { + filter(dualListbox, 1); + }); + + dualListbox.elements.filterInput2.on('change keyup', function() { + filter(dualListbox, 2); + }); + } + + BootstrapDualListbox.prototype = { + init: function () { + // Add the custom HTML template + this.container = $('' + + '
    ' + + '
    ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '
    ' + + ' ' + + ' ' + + '
    ' + + ' ' + + '
    ' + + '
    ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '
    ' + + ' ' + + ' ' + + '
    ' + + ' ' + + '
    ' + + '
    ') + .insertBefore(this.element); + + // Cache the inner elements + this.elements = { + originalSelect: this.element, + box1: $('.box1', this.container), + box2: $('.box2', this.container), + filterInput1: $('.box1 .filter', this.container), + filterInput2: $('.box2 .filter', this.container), + filterClear1: $('.box1 .clear1', this.container), + filterClear2: $('.box2 .clear2', this.container), + label1: $('.box1 > label', this.container), + label2: $('.box2 > label', this.container), + info1: $('.box1 .info', this.container), + info2: $('.box2 .info', this.container), + select1: $('.box1 select', this.container), + select2: $('.box2 select', this.container), + moveButton: $('.box1 .move', this.container), + removeButton: $('.box2 .remove', this.container), + moveAllButton: $('.box1 .moveall', this.container), + removeAllButton: $('.box2 .removeall', this.container), + form: $($('.box1 .filter', this.container)[0].form) + }; + + // Set select IDs + this.originalSelectName = this.element.attr('name') || ''; + var select1Id = 'bootstrap-duallistbox-nonselected-list_' + this.originalSelectName, + select2Id = 'bootstrap-duallistbox-selected-list_' + this.originalSelectName; + this.elements.select1.attr('id', select1Id); + this.elements.select2.attr('id', select2Id); + this.elements.label1.attr('for', select1Id); + this.elements.label2.attr('for', select2Id); + + // Apply all settings + this.selectedElements = 0; + this.sortIndex = 0; + this.elementCount = 0; + this.setBootstrap2Compatible(this.settings.bootstrap2Compatible); + this.setFilterTextClear(this.settings.filterTextClear); + this.setFilterPlaceHolder(this.settings.filterPlaceHolder); + this.setMoveSelectedLabel(this.settings.moveSelectedLabel); + this.setMoveAllLabel(this.settings.moveAllLabel); + this.setRemoveSelectedLabel(this.settings.removeSelectedLabel); + this.setRemoveAllLabel(this.settings.removeAllLabel); + this.setMoveOnSelect(this.settings.moveOnSelect); + this.setMoveOnDoubleClick(this.settings.moveOnDoubleClick); + this.setPreserveSelectionOnMove(this.settings.preserveSelectionOnMove); + this.setSelectedListLabel(this.settings.selectedListLabel); + this.setNonSelectedListLabel(this.settings.nonSelectedListLabel); + this.setHelperSelectNamePostfix(this.settings.helperSelectNamePostfix); + this.setSelectOrMinimalHeight(this.settings.selectorMinimalHeight); + + updateSelectionStates(this); + + this.setShowFilterInputs(this.settings.showFilterInputs); + this.setNonSelectedFilter(this.settings.nonSelectedFilter); + this.setSelectedFilter(this.settings.selectedFilter); + this.setInfoText(this.settings.infoText); + this.setInfoTextFiltered(this.settings.infoTextFiltered); + this.setInfoTextEmpty(this.settings.infoTextEmpty); + this.setFilterOnValues(this.settings.filterOnValues); + this.setSortByInputOrder(this.settings.sortByInputOrder); + this.setEventMoveOverride(this.settings.eventMoveOverride); + this.setEventMoveAllOverride(this.settings.eventMoveAllOverride); + this.setEventRemoveOverride(this.settings.eventRemoveOverride); + this.setEventRemoveAllOverride(this.settings.eventRemoveAllOverride); + + // Hide the original select + this.element.hide(); + + bindEvents(this); + refreshSelects(this); + + return this.element; + }, + setBootstrap2Compatible: function(value, refresh) { + this.settings.bootstrap2Compatible = value; + if (value) { + this.container.removeClass('row').addClass('row-fluid bs2compatible'); + this.container.find('.box1, .box2').removeClass('col-md-6').addClass('span6'); + this.container.find('.clear1, .clear2').removeClass('btn-white btn-xs').addClass('btn-mini'); + this.container.find('input, select').removeClass('form-control'); + this.container.find('.btn').removeClass('btn-white'); + this.container.find('.moveall > i, .move > i').removeClass('glyphicon glyphicon-arrow-right').addClass('icon-arrow-right'); + this.container.find('.removeall > i, .remove > i').removeClass('glyphicon glyphicon-arrow-left').addClass('icon-arrow-left'); + } else { + this.container.removeClass('row-fluid bs2compatible').addClass('row'); + this.container.find('.box1, .box2').removeClass('span6').addClass('col-md-6'); + this.container.find('.clear1, .clear2').removeClass('btn-mini').addClass('btn-white btn-xs'); + this.container.find('input, select').addClass('form-control'); + this.container.find('.btn').addClass('btn-white'); + this.container.find('.moveall > i, .move > i').removeClass('icon-arrow-right').addClass('glyphicon glyphicon-arrow-right'); + this.container.find('.removeall > i, .remove > i').removeClass('icon-arrow-left').addClass('glyphicon glyphicon-arrow-left'); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setFilterTextClear: function(value, refresh) { + this.settings.filterTextClear = value; + this.elements.filterClear1.html(value); + this.elements.filterClear2.html(value); + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setFilterPlaceHolder: function(value, refresh) { + this.settings.filterPlaceHolder = value; + this.elements.filterInput1.attr('placeholder', value); + this.elements.filterInput2.attr('placeholder', value); + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setMoveSelectedLabel: function(value, refresh) { + this.settings.moveSelectedLabel = value; + this.elements.moveButton.attr('title', value); + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setMoveAllLabel: function(value, refresh) { + this.settings.moveAllLabel = value; + this.elements.moveAllButton.attr('title', value); + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setRemoveSelectedLabel: function(value, refresh) { + this.settings.removeSelectedLabel = value; + this.elements.removeButton.attr('title', value); + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setRemoveAllLabel: function(value, refresh) { + this.settings.removeAllLabel = value; + this.elements.removeAllButton.attr('title', value); + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setMoveOnSelect: function(value, refresh) { + if (isBuggyAndroid) { + value = true; + } + this.settings.moveOnSelect = value; + if (this.settings.moveOnSelect) { + this.container.addClass('moveonselect'); + var self = this; + this.elements.select1.on('change', function() { + move(self); + }); + this.elements.select2.on('change', function() { + remove(self); + }); + } else { + this.container.removeClass('moveonselect'); + this.elements.select1.off('change'); + this.elements.select2.off('change'); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setMoveOnDoubleClick: function(value, refresh) { + if (isBuggyAndroid) { + value = false; + } + this.settings.moveOnDoubleClick = value; + if (this.settings.moveOnDoubleClick) { + this.container.addClass('moveondoubleclick'); + var self = this; + this.elements.select1.on('dblclick', function() { + move(self); + }); + this.elements.select2.on('dblclick', function() { + remove(self); + }); + } else { + this.container.removeClass('moveondoubleclick'); + this.elements.select1.off('dblclick'); + this.elements.select2.off('dblclick'); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setPreserveSelectionOnMove: function(value, refresh) { + // We are forcing to move on select and disabling preserveSelectionOnMove on Android + if (isBuggyAndroid) { + value = false; + } + this.settings.preserveSelectionOnMove = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setSelectedListLabel: function(value, refresh) { + this.settings.selectedListLabel = value; + if (value) { + this.elements.label2.show().html(value); + } else { + this.elements.label2.hide().html(value); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setNonSelectedListLabel: function(value, refresh) { + this.settings.nonSelectedListLabel = value; + if (value) { + this.elements.label1.show().html(value); + } else { + this.elements.label1.hide().html(value); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setHelperSelectNamePostfix: function(value, refresh) { + this.settings.helperSelectNamePostfix = value; + if (value) { + this.elements.select1.attr('name', this.originalSelectName + value + '1'); + this.elements.select2.attr('name', this.originalSelectName + value + '2'); + } else { + this.elements.select1.removeAttr('name'); + this.elements.select2.removeAttr('name'); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setSelectOrMinimalHeight: function(value, refresh) { + this.settings.selectorMinimalHeight = value; + var height = this.element.height(); + if (this.element.height() < value) { + height = value; + } + this.elements.select1.height(height); + this.elements.select2.height(height); + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setShowFilterInputs: function(value, refresh) { + if (!value) { + this.setNonSelectedFilter(''); + this.setSelectedFilter(''); + refreshSelects(this); + this.elements.filterInput1.hide(); + this.elements.filterInput2.hide(); + } else { + this.elements.filterInput1.show(); + this.elements.filterInput2.show(); + } + this.settings.showFilterInputs = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setNonSelectedFilter: function(value, refresh) { + if (this.settings.showFilterInputs) { + this.settings.nonSelectedFilter = value; + this.elements.filterInput1.val(value); + if (refresh) { + refreshSelects(this); + } + return this.element; + } + }, + setSelectedFilter: function(value, refresh) { + if (this.settings.showFilterInputs) { + this.settings.selectedFilter = value; + this.elements.filterInput2.val(value); + if (refresh) { + refreshSelects(this); + } + return this.element; + } + }, + setInfoText: function(value, refresh) { + this.settings.infoText = value; + if (value) { + this.elements.info1.show(); + this.elements.info2.show(); + } else { + this.elements.info1.hide(); + this.elements.info2.hide(); + } + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setInfoTextFiltered: function(value, refresh) { + this.settings.infoTextFiltered = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setInfoTextEmpty: function(value, refresh) { + this.settings.infoTextEmpty = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setFilterOnValues: function(value, refresh) { + this.settings.filterOnValues = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setSortByInputOrder: function(value, refresh){ + this.settings.sortByInputOrder = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setEventMoveOverride: function(value, refresh) { + this.settings.eventMoveOverride = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setEventMoveAllOverride: function(value, refresh) { + this.settings.eventMoveAllOverride = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setEventRemoveOverride: function(value, refresh) { + this.settings.eventRemoveOverride = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + setEventRemoveAllOverride: function(value, refresh) { + this.settings.eventRemoveAllOverride = value; + if (refresh) { + refreshSelects(this); + } + return this.element; + }, + getContainer: function() { + return this.container; + }, + refresh: function(mustClearSelections) { + updateSelectionStates(this); + + if (!mustClearSelections) { + saveSelections(this, 1); + saveSelections(this, 2); + } else { + clearSelections(this); + } + + refreshSelects(this); + }, + destroy: function() { + this.container.remove(); + this.element.show(); + $.data(this, 'plugin_' + pluginName, null); + return this.element; + } + }; + + // A really lightweight plugin wrapper around the constructor, + // preventing against multiple instantiations + $.fn[ pluginName ] = function (options) { + var args = arguments; + + // Is the first parameter an object (options), or was omitted, instantiate a new instance of the plugin. + if (options === undefined || typeof options === 'object') { + return this.each(function () { + // If this is not a select + if (!$(this).is('select')) { + $(this).find('select').each(function(index, item) { + // For each nested select, instantiate the Dual List Box + $(item).bootstrapDualListbox(options); + }); + } else if (!$.data(this, 'plugin_' + pluginName)) { + // Only allow the plugin to be instantiated once so we check that the element has no plugin instantiation yet + + // if it has no instance, create a new one, pass options to our plugin constructor, + // and store the plugin instance in the elements jQuery data object. + $.data(this, 'plugin_' + pluginName, new BootstrapDualListbox(this, options)); + } + }); + // If the first parameter is a string and it doesn't start with an underscore or "contains" the `init`-function, + // treat this as a call to a public method. + } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { + + // Cache the method call to make it possible to return a value + var returns; + + this.each(function () { + var instance = $.data(this, 'plugin_' + pluginName); + // Tests that there's already a plugin-instance and checks that the requested public method exists + if (instance instanceof BootstrapDualListbox && typeof instance[options] === 'function') { + // Call the method of our plugin instance, and pass it the supplied arguments. + returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1)); + } + }); + + // If the earlier cached method gives a value back return the value, + // otherwise return this to preserve chainability. + return returns !== undefined ? returns : this; + } + + }; + +})(jQuery, window, document); diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.css b/bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.css rename to bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.js b/bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.js index ecc994ae8..eb8317e43 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/duallistbox/bootstrap-duallistbox.min.js @@ -1,10 +1,10 @@ -/* - * Bootstrap Duallistbox - v3.0.7 - * A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices. - * https://www.virtuosoft.eu/code/bootstrap-duallistbox/ - * - * Made by István Ujj-Mészáros - * Under Apache License v2.0 License - */ - +/* + * Bootstrap Duallistbox - v3.0.7 + * A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices. + * https://www.virtuosoft.eu/code/bootstrap-duallistbox/ + * + * Made by István Ujj-Mészáros + * Under Apache License v2.0 License + */ + !function(a,e,t,s){var l="bootstrapDualListbox",n={bootstrap2Compatible:!1,filterTextClear:"show all",filterPlaceHolder:"Filter",moveSelectedLabel:"Move selected",moveAllLabel:"Move all",removeSelectedLabel:"Remove selected",removeAllLabel:"Remove all",moveOnSelect:!0,moveOnDoubleClick:!0,preserveSelectionOnMove:!1,selectedListLabel:!1,nonSelectedListLabel:!1,helperSelectNamePostfix:"_helper",selectorMinimalHeight:100,showFilterInputs:!0,nonSelectedFilter:"",selectedFilter:"",infoText:"Showing all {0}",infoTextFiltered:'Filtered {0} from {1}',infoTextEmpty:"Empty list",filterOnValues:!1,sortByInputOrder:!1,eventMoveOverride:!1,eventMoveAllOverride:!1,eventRemoveOverride:!1,eventRemoveAllOverride:!1},i=/android/i.test(navigator.userAgent.toLowerCase());function o(e,t){this.element=a(e),this.settings=a.extend({},n,t),this._defaults=n,this._name=l,this.init()}function r(e){e.element.trigger("change")}function c(i){i.element.find("option").each(function(e,t){var n=a(t);void 0===n.data("original-index")&&n.data("original-index",i.elementCount++),void 0===n.data("_selected")&&n.data("_selected",!1)})}function h(i,s,l){i.element.find("option").each(function(e,t){var n=a(t);n.data("original-index")===s&&(n.prop("selected",l),l?(n.attr("data-sortindex",i.sortIndex),i.sortIndex++):n.removeAttr("data-sortindex"))})}function m(e,n){return e.replace(/\{(\d+)\}/g,function(e,t){return void 0!==n[t]?n[t]:e})}function d(e){if(e.settings.infoText){var t=e.elements.select1.find("option").length,n=e.elements.select2.find("option").length,i=e.element.find("option").length-e.selectedElements,s=e.selectedElements,l="";l=0===i?e.settings.infoTextEmpty:m(t===i?e.settings.infoText:e.settings.infoTextFiltered,[t,i]),e.elements.info1.html(l),e.elements.box1.toggleClass("filtered",!(t===i||0===i)),l=0===s?e.settings.infoTextEmpty:m(n===s?e.settings.infoText:e.settings.infoTextFiltered,[n,s]),e.elements.info2.html(l),e.elements.box2.toggleClass("filtered",!(n===s||0===s))}}function v(i){i.selectedElements=0,i.elements.select1.empty(),i.elements.select2.empty(),i.element.find("option").each(function(e,t){var n=a(t);n.prop("selected")?(i.selectedElements++,i.elements.select2.append(n.clone(!0).prop("selected",n.data("_selected")))):i.elements.select1.append(n.clone(!0).prop("selected",n.data("_selected")))}),i.settings.showFilterInputs&&(f(i,1),f(i,2)),d(i)}function f(s,l){if(s.settings.showFilterInputs){u(s,l),s.elements["select"+l].empty().scrollTop(0);var o=new RegExp(a.trim(s.elements["filterInput"+l].val()),"gi"),r=s.element.find("option"),e=s.element;(e=1===l?r.not(":selected"):e.find("option:selected")).each(function(e,t){var n=a(t),i=!0;(t.text.match(o)||s.settings.filterOnValues&&n.attr("value").match(o))&&(i=!1,s.elements["select"+l].append(n.clone(!0).prop("selected",n.data("_selected")))),r.eq(n.data("original-index")).data("filtered"+l,i)}),d(s)}}function u(e,t){var i=e.element.find("option");e.elements["select"+t].find("option").each(function(e,t){var n=a(t);i.eq(n.data("original-index")).data("_selected",n.prop("selected"))})}function p(e){var t=e.children("option");t.sort(function(e,t){var n=parseInt(e.getAttribute("data-sortindex")),i=parseInt(t.getAttribute("data-sortindex"));return ia(t).data("original-index")?1:-1}).appendTo(e)}function b(i){"all"!==i.settings.preserveSelectionOnMove||i.settings.moveOnSelect?"moved"!==i.settings.preserveSelectionOnMove||i.settings.moveOnSelect||u(i,1):(u(i,1),u(i,2)),i.elements.select1.find("option:selected").each(function(e,t){var n=a(t);n.data("filtered1")||h(i,n.data("original-index"),!0)}),v(i),r(i),i.settings.sortByInputOrder?p(i.elements.select2):g(i.elements.select2)}function x(i){"all"!==i.settings.preserveSelectionOnMove||i.settings.moveOnSelect?"moved"!==i.settings.preserveSelectionOnMove||i.settings.moveOnSelect||u(i,2):(u(i,1),u(i,2)),i.elements.select2.find("option:selected").each(function(e,t){var n=a(t);n.data("filtered2")||h(i,n.data("original-index"),!1)}),v(i),r(i),g(i.elements.select1),i.settings.sortByInputOrder&&p(i.elements.select2)}function S(n){n.elements.form.submit(function(e){n.elements.filterInput1.is(":focus")?(e.preventDefault(),n.elements.filterInput1.focusout()):n.elements.filterInput2.is(":focus")&&(e.preventDefault(),n.elements.filterInput2.focusout())}),n.element.on("bootstrapDualListbox.refresh",function(e,t){n.refresh(t)}),n.elements.filterClear1.on("click",function(){n.setNonSelectedFilter("",!0)}),n.elements.filterClear2.on("click",function(){n.setSelectedFilter("",!0)}),!1===n.settings.eventMoveOverride&&n.elements.moveButton.on("click",function(){b(n)}),!1===n.settings.eventMoveAllOverride&&n.elements.moveAllButton.on("click",function(){var i;"all"!==(i=n).settings.preserveSelectionOnMove||i.settings.moveOnSelect?"moved"!==i.settings.preserveSelectionOnMove||i.settings.moveOnSelect||u(i,1):(u(i,1),u(i,2)),i.element.find("option").each(function(e,t){var n=a(t);n.data("filtered1")||(n.prop("selected",!0),n.attr("data-sortindex",i.sortIndex),i.sortIndex++)}),v(i),r(i)}),!1===n.settings.eventRemoveOverride&&n.elements.removeButton.on("click",function(){x(n)}),!1===n.settings.eventRemoveAllOverride&&n.elements.removeAllButton.on("click",function(){var e;"all"!==(e=n).settings.preserveSelectionOnMove||e.settings.moveOnSelect?"moved"!==e.settings.preserveSelectionOnMove||e.settings.moveOnSelect||u(e,2):(u(e,1),u(e,2)),e.element.find("option").each(function(e,t){var n=a(t);n.data("filtered2")||(n.prop("selected",!1),n.removeAttr("data-sortindex"))}),v(e),r(e)}),n.elements.filterInput1.on("change keyup",function(){f(n,1)}),n.elements.filterInput2.on("change keyup",function(){f(n,2)})}o.prototype={init:function(){this.container=a('
    ').insertBefore(this.element),this.elements={originalSelect:this.element,box1:a(".box1",this.container),box2:a(".box2",this.container),filterInput1:a(".box1 .filter",this.container),filterInput2:a(".box2 .filter",this.container),filterClear1:a(".box1 .clear1",this.container),filterClear2:a(".box2 .clear2",this.container),label1:a(".box1 > label",this.container),label2:a(".box2 > label",this.container),info1:a(".box1 .info",this.container),info2:a(".box2 .info",this.container),select1:a(".box1 select",this.container),select2:a(".box2 select",this.container),moveButton:a(".box1 .move",this.container),removeButton:a(".box2 .remove",this.container),moveAllButton:a(".box1 .moveall",this.container),removeAllButton:a(".box2 .removeall",this.container),form:a(a(".box1 .filter",this.container)[0].form)},this.originalSelectName=this.element.attr("name")||"";var e="bootstrap-duallistbox-nonselected-list_"+this.originalSelectName,t="bootstrap-duallistbox-selected-list_"+this.originalSelectName;return this.elements.select1.attr("id",e),this.elements.select2.attr("id",t),this.elements.label1.attr("for",e),this.elements.label2.attr("for",t),this.selectedElements=0,this.sortIndex=0,this.elementCount=0,this.setBootstrap2Compatible(this.settings.bootstrap2Compatible),this.setFilterTextClear(this.settings.filterTextClear),this.setFilterPlaceHolder(this.settings.filterPlaceHolder),this.setMoveSelectedLabel(this.settings.moveSelectedLabel),this.setMoveAllLabel(this.settings.moveAllLabel),this.setRemoveSelectedLabel(this.settings.removeSelectedLabel),this.setRemoveAllLabel(this.settings.removeAllLabel),this.setMoveOnSelect(this.settings.moveOnSelect),this.setMoveOnDoubleClick(this.settings.moveOnDoubleClick),this.setPreserveSelectionOnMove(this.settings.preserveSelectionOnMove),this.setSelectedListLabel(this.settings.selectedListLabel),this.setNonSelectedListLabel(this.settings.nonSelectedListLabel),this.setHelperSelectNamePostfix(this.settings.helperSelectNamePostfix),this.setSelectOrMinimalHeight(this.settings.selectorMinimalHeight),c(this),this.setShowFilterInputs(this.settings.showFilterInputs),this.setNonSelectedFilter(this.settings.nonSelectedFilter),this.setSelectedFilter(this.settings.selectedFilter),this.setInfoText(this.settings.infoText),this.setInfoTextFiltered(this.settings.infoTextFiltered),this.setInfoTextEmpty(this.settings.infoTextEmpty),this.setFilterOnValues(this.settings.filterOnValues),this.setSortByInputOrder(this.settings.sortByInputOrder),this.setEventMoveOverride(this.settings.eventMoveOverride),this.setEventMoveAllOverride(this.settings.eventMoveAllOverride),this.setEventRemoveOverride(this.settings.eventRemoveOverride),this.setEventRemoveAllOverride(this.settings.eventRemoveAllOverride),this.element.hide(),S(this),v(this),this.element},setBootstrap2Compatible:function(e,t){return(this.settings.bootstrap2Compatible=e)?(this.container.removeClass("row").addClass("row-fluid bs2compatible"),this.container.find(".box1, .box2").removeClass("col-md-6").addClass("span6"),this.container.find(".clear1, .clear2").removeClass("btn-white btn-xs").addClass("btn-mini"),this.container.find("input, select").removeClass("form-control"),this.container.find(".btn").removeClass("btn-white"),this.container.find(".moveall > i, .move > i").removeClass("glyphicon glyphicon-arrow-right").addClass("icon-arrow-right"),this.container.find(".removeall > i, .remove > i").removeClass("glyphicon glyphicon-arrow-left").addClass("icon-arrow-left")):(this.container.removeClass("row-fluid bs2compatible").addClass("row"),this.container.find(".box1, .box2").removeClass("span6").addClass("col-md-6"),this.container.find(".clear1, .clear2").removeClass("btn-mini").addClass("btn-white btn-xs"),this.container.find("input, select").addClass("form-control"),this.container.find(".btn").addClass("btn-white"),this.container.find(".moveall > i, .move > i").removeClass("icon-arrow-right").addClass("glyphicon glyphicon-arrow-right"),this.container.find(".removeall > i, .remove > i").removeClass("icon-arrow-left").addClass("glyphicon glyphicon-arrow-left")),t&&v(this),this.element},setFilterTextClear:function(e,t){return this.settings.filterTextClear=e,this.elements.filterClear1.html(e),this.elements.filterClear2.html(e),t&&v(this),this.element},setFilterPlaceHolder:function(e,t){return this.settings.filterPlaceHolder=e,this.elements.filterInput1.attr("placeholder",e),this.elements.filterInput2.attr("placeholder",e),t&&v(this),this.element},setMoveSelectedLabel:function(e,t){return this.settings.moveSelectedLabel=e,this.elements.moveButton.attr("title",e),t&&v(this),this.element},setMoveAllLabel:function(e,t){return this.settings.moveAllLabel=e,this.elements.moveAllButton.attr("title",e),t&&v(this),this.element},setRemoveSelectedLabel:function(e,t){return this.settings.removeSelectedLabel=e,this.elements.removeButton.attr("title",e),t&&v(this),this.element},setRemoveAllLabel:function(e,t){return this.settings.removeAllLabel=e,this.elements.removeAllButton.attr("title",e),t&&v(this),this.element},setMoveOnSelect:function(e,t){if(i&&(e=!0),this.settings.moveOnSelect=e,this.settings.moveOnSelect){this.container.addClass("moveonselect");var n=this;this.elements.select1.on("change",function(){b(n)}),this.elements.select2.on("change",function(){x(n)})}else this.container.removeClass("moveonselect"),this.elements.select1.off("change"),this.elements.select2.off("change");return t&&v(this),this.element},setMoveOnDoubleClick:function(e,t){if(i&&(e=!1),this.settings.moveOnDoubleClick=e,this.settings.moveOnDoubleClick){this.container.addClass("moveondoubleclick");var n=this;this.elements.select1.on("dblclick",function(){b(n)}),this.elements.select2.on("dblclick",function(){x(n)})}else this.container.removeClass("moveondoubleclick"),this.elements.select1.off("dblclick"),this.elements.select2.off("dblclick");return t&&v(this),this.element},setPreserveSelectionOnMove:function(e,t){return i&&(e=!1),this.settings.preserveSelectionOnMove=e,t&&v(this),this.element},setSelectedListLabel:function(e,t){return(this.settings.selectedListLabel=e)?this.elements.label2.show().html(e):this.elements.label2.hide().html(e),t&&v(this),this.element},setNonSelectedListLabel:function(e,t){return(this.settings.nonSelectedListLabel=e)?this.elements.label1.show().html(e):this.elements.label1.hide().html(e),t&&v(this),this.element},setHelperSelectNamePostfix:function(e,t){return(this.settings.helperSelectNamePostfix=e)?(this.elements.select1.attr("name",this.originalSelectName+e+"1"),this.elements.select2.attr("name",this.originalSelectName+e+"2")):(this.elements.select1.removeAttr("name"),this.elements.select2.removeAttr("name")),t&&v(this),this.element},setSelectOrMinimalHeight:function(e,t){this.settings.selectorMinimalHeight=e;var n=this.element.height();return this.element.height()p&&(p=-50);g(this);return c.each(function(){var a=f(this);E(a);var c=this, - b=c.id,g=-p+"%",d=100+2*p+"%",d={position:"absolute",top:g,left:g,display:"block",width:d,height:d,margin:0,padding:0,background:"#fff",border:0,opacity:0},g=_mobile?{position:"absolute",visibility:"hidden"}:p?d:{position:"absolute",opacity:0},l="checkbox"==c[_type]?e.checkboxClass||"icheckbox":e.radioClass||"i"+r,z=f(_label+'[for="'+b+'"]').add(a.closest(_label)),u=!!e.aria,y=m+"-"+Math.random().toString(36).substr(2,6),h='
    ")[_callback]("ifCreated").parent().append(e.insert);d=f('').css(d).appendTo(h);a.data(m,{o:e,s:a.attr("style")}).css(g);e.inheritClass&&h[_add](c.className||"");e.inheritID&&b&&h.attr("id",m+"-"+b);"static"==h.css("position")&&h.css("position","relative");A(a,!0,_update);if(z.length)z.on(_click+".i mouseover.i mouseout.i "+_touch,function(b){var d=b[_type],e=f(this);if(!c[n]){if(d==_click){if(f(b.target).is("a"))return; - A(a,!1,!0)}else B&&(/ut|nd/.test(d)?(h[_remove](v),e[_remove](w)):(h[_add](v),e[_add](w)));if(_mobile)b.stopPropagation();else return!1}});a.on(_click+".i focus.i blur.i keyup.i keydown.i keypress.i",function(b){var d=b[_type];b=b.keyCode;if(d==_click)return!1;if("keydown"==d&&32==b)return c[_type]==r&&c[k]||(c[k]?q(a,k):x(a,k)),!1;if("keyup"==d&&c[_type]==r)!c[k]&&x(a,k);else if(/us|ur/.test(d))h["blur"==d?_remove:_add](s)});d.on(_click+" mousedown mouseup mouseover mouseout "+_touch,function(b){var d= - b[_type],e=/wn|up/.test(d)?t:v;if(!c[n]){if(d==_click)A(a,!1,!0);else{if(/wn|er|in/.test(d))h[_add](e);else h[_remove](e+" "+t);if(z.length&&B&&e==v)z[/ut|nd/.test(d)?_remove:_add](w)}if(_mobile)b.stopPropagation();else return!1}})})}})(window.jQuery||window.Zepto); +/*! iCheck v1.0.2 by Damir Sultanov, http://git.io/arlzeA, MIT Licensed */ +(function(f){function A(a,b,d){var c=a[0],g=/er/.test(d)?_indeterminate:/bl/.test(d)?n:k,e=d==_update?{checked:c[k],disabled:c[n],indeterminate:"true"==a.attr(_indeterminate)||"false"==a.attr(_determinate)}:c[g];if(/^(ch|di|in)/.test(d)&&!e)x(a,g);else if(/^(un|en|de)/.test(d)&&e)q(a,g);else if(d==_update)for(var f in e)e[f]?x(a,f,!0):q(a,f,!0);else if(!b||"toggle"==d){if(!b)a[_callback]("ifClicked");e?c[_type]!==r&&q(a,g):x(a,g)}}function x(a,b,d){var c=a[0],g=a.parent(),e=b==k,u=b==_indeterminate, + v=b==n,s=u?_determinate:e?y:"enabled",F=l(a,s+t(c[_type])),B=l(a,b+t(c[_type]));if(!0!==c[b]){if(!d&&b==k&&c[_type]==r&&c.name){var w=a.closest("form"),p='input[name="'+c.name+'"]',p=w.length?w.find(p):f(p);p.each(function(){this!==c&&f(this).data(m)&&q(f(this),b)})}u?(c[b]=!0,c[k]&&q(a,k,"force")):(d||(c[b]=!0),e&&c[_indeterminate]&&q(a,_indeterminate,!1));D(a,e,b,d)}c[n]&&l(a,_cursor,!0)&&g.find("."+C).css(_cursor,"default");g[_add](B||l(a,b)||"");g.attr("role")&&!u&&g.attr("aria-"+(v?n:k),"true"); + g[_remove](F||l(a,s)||"")}function q(a,b,d){var c=a[0],g=a.parent(),e=b==k,f=b==_indeterminate,m=b==n,s=f?_determinate:e?y:"enabled",q=l(a,s+t(c[_type])),r=l(a,b+t(c[_type]));if(!1!==c[b]){if(f||!d||"force"==d)c[b]=!1;D(a,e,s,d)}!c[n]&&l(a,_cursor,!0)&&g.find("."+C).css(_cursor,"pointer");g[_remove](r||l(a,b)||"");g.attr("role")&&!f&&g.attr("aria-"+(m?n:k),"false");g[_add](q||l(a,s)||"")}function E(a,b){if(a.data(m)){a.parent().html(a.attr("style",a.data(m).s||""));if(b)a[_callback](b);a.off(".i").unwrap(); + f(_label+'[for="'+a[0].id+'"]').add(a.closest(_label)).off(".i")}}function l(a,b,f){if(a.data(m))return a.data(m).o[b+(f?"":"Class")]}function t(a){return a.charAt(0).toUpperCase()+a.slice(1)}function D(a,b,f,c){if(!c){if(b)a[_callback]("ifToggled");a[_callback]("ifChanged")[_callback]("if"+t(f))}}var m="iCheck",C=m+"-helper",r="radio",k="checked",y="un"+k,n="disabled";_determinate="determinate";_indeterminate="in"+_determinate;_update="update";_type="type";_click="click";_touch="touchbegin.i touchend.i"; + _add="addClass";_remove="removeClass";_callback="trigger";_label="label";_cursor="cursor";_mobile=/ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);f.fn[m]=function(a,b){var d='input[type="checkbox"], input[type="'+r+'"]',c=f(),g=function(a){a.each(function(){var a=f(this);c=a.is(d)?c.add(a):c.add(a.find(d))})};if(/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(a))return a=a.toLowerCase(),g(this),c.each(function(){var c= + f(this);"destroy"==a?E(c,"ifDestroyed"):A(c,!0,a);f.isFunction(b)&&b()});if("object"!=typeof a&&a)return this;var e=f.extend({checkedClass:k,disabledClass:n,indeterminateClass:_indeterminate,labelHover:!0},a),l=e.handle,v=e.hoverClass||"hover",s=e.focusClass||"focus",t=e.activeClass||"active",B=!!e.labelHover,w=e.labelHoverClass||"hover",p=(""+e.increaseArea).replace("%","")|0;if("checkbox"==l||l==r)d='input[type="'+l+'"]';-50>p&&(p=-50);g(this);return c.each(function(){var a=f(this);E(a);var c=this, + b=c.id,g=-p+"%",d=100+2*p+"%",d={position:"absolute",top:g,left:g,display:"block",width:d,height:d,margin:0,padding:0,background:"#fff",border:0,opacity:0},g=_mobile?{position:"absolute",visibility:"hidden"}:p?d:{position:"absolute",opacity:0},l="checkbox"==c[_type]?e.checkboxClass||"icheckbox":e.radioClass||"i"+r,z=f(_label+'[for="'+b+'"]').add(a.closest(_label)),u=!!e.aria,y=m+"-"+Math.random().toString(36).substr(2,6),h='
    ")[_callback]("ifCreated").parent().append(e.insert);d=f('').css(d).appendTo(h);a.data(m,{o:e,s:a.attr("style")}).css(g);e.inheritClass&&h[_add](c.className||"");e.inheritID&&b&&h.attr("id",m+"-"+b);"static"==h.css("position")&&h.css("position","relative");A(a,!0,_update);if(z.length)z.on(_click+".i mouseover.i mouseout.i "+_touch,function(b){var d=b[_type],e=f(this);if(!c[n]){if(d==_click){if(f(b.target).is("a"))return; + A(a,!1,!0)}else B&&(/ut|nd/.test(d)?(h[_remove](v),e[_remove](w)):(h[_add](v),e[_add](w)));if(_mobile)b.stopPropagation();else return!1}});a.on(_click+".i focus.i blur.i keyup.i keydown.i keypress.i",function(b){var d=b[_type];b=b.keyCode;if(d==_click)return!1;if("keydown"==d&&32==b)return c[_type]==r&&c[k]||(c[k]?q(a,k):x(a,k)),!1;if("keyup"==d&&c[_type]==r)!c[k]&&x(a,k);else if(/us|ur/.test(d))h["blur"==d?_remove:_add](s)});d.on(_click+" mousedown mouseup mouseover mouseout "+_touch,function(b){var d= + b[_type],e=/wn|up/.test(d)?t:v;if(!c[n]){if(d==_click)A(a,!1,!0);else{if(/wn|er|in/.test(d))h[_add](e);else h[_remove](e+" "+t);if(z.length&&B&&e==v)z[/ut|nd/.test(d)?_remove:_add](w)}if(_mobile)b.stopPropagation();else return!1}})})}})(window.jQuery||window.Zepto); diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.css b/bmw-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.css rename to bmw-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.js b/bmw-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.js rename to bmw-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.min.css b/bmw-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.min.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.min.css rename to bmw-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.min.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.min.js b/bmw-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.min.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/jasny/jasny-bootstrap.min.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.css b/bmw-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.css rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.js b/bmw-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.js rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.js index a4373ae82..ae1015625 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-layout/jquery.layout-latest.js @@ -1,18 +1,18 @@ -(function($){var min=Math.min,max=Math.max,round=Math.floor,isStr=function(v){return $.type(v)==="string"},runPluginCallbacks=function(Instance,a_fn){if($.isArray(a_fn)){for(var i=0,c=a_fn.length;i
    ').appendTo("body"),d={width:$c.outerWidth-$c[0].clientWidth,height:100-$c[0].clientHeight};$c.remove();window.scrollbarWidth=d.width;window.scrollbarHeight=d.height;return dim.match(/^(width|height)$/)?d[dim]:d},disableTextSelection:function(){var $d=$(document),s="textSelectionDisabled",x="textSelectionInitialized";if($.fn.disableSelection){if(!$d.data(x)){$d.on("mouseup",$.layout.enableTextSelection).data(x,true)}if(!$d.data(s)){$d.disableSelection().data(s,true)}}},enableTextSelection:function(){var $d=$(document),s="textSelectionDisabled";if($.fn.enableSelection&&$d.data(s)){$d.enableSelection().data(s,false)}},showInvisibly:function($E,force){if($E&&$E.length&&(force||$E.css("display")==="none")){var s=$E[0].style,CSS={display:s.display||"",visibility:s.visibility||""};$E.css({display:"block",visibility:"hidden"});return CSS}return{}},getElementDimensions:function($E,inset){var d={css:{},inset:{}},x=d.css,i={bottom:0},N=$.layout.cssNum,R=Math.round,off=$E.offset(),b,p,ei;d.offsetLeft=off.left;d.offsetTop=off.top;if(!inset){inset={}}$.each("Left,Right,Top,Bottom".split(","),function(idx,e){b=x["border"+e]=$.layout.borderWidth($E,e);p=x["padding"+e]=$.layout.cssNum($E,"padding"+e); -ei=e.toLowerCase();d.inset[ei]=inset[ei]>=0?inset[ei]:p;i[ei]=d.inset[ei]+b});x.width=R($E.width());x.height=R($E.height());x.top=N($E,"top",true);x.bottom=N($E,"bottom",true);x.left=N($E,"left",true);x.right=N($E,"right",true);d.outerWidth=R($E.outerWidth());d.outerHeight=R($E.outerHeight());d.innerWidth=max(0,d.outerWidth-i.left-i.right);d.innerHeight=max(0,d.outerHeight-i.top-i.bottom);d.layoutWidth=R($E.innerWidth());d.layoutHeight=R($E.innerHeight());return d},getElementStyles:function($E,list){var CSS={},style=$E[0].style,props=list.split(","),sides="Top,Bottom,Left,Right".split(","),attrs="Color,Style,Width".split(","),p,s,a,i,j,k;for(i=0;i=L&&x<=R)&&(y>=T&&y<=B))},msg:function(info,popup,debugTitle,debugOpts){if($.isPlainObject(info)&&window.debugData){if(typeof popup==="string"){debugOpts=debugTitle;debugTitle=popup}else{if(typeof debugTitle==="object"){debugOpts=debugTitle;debugTitle=null}}var t=debugTitle||"log( )",o=$.extend({sort:false,returnHTML:false,display:false},debugOpts);if(popup===true||o.display){debugData(info,t,o)}else{if(window.console){console.log(debugData(info,t,o))}}}else{if(popup){alert(info)}else{if(window.console){console.log(info)}else{var id="#layoutLogger",$l=$(id);if(!$l.length){$l=createLog()}$l.children("ul").append('
  • '+info.replace(/\/g,">")+"
  • ")}}}function createLog(){var pos=$.support.fixedPosition?"fixed":"absolute",$e=$('
    '+'
    '+'XLayout console.log
    '+'
      '+"
      ").appendTo("body");$e.css("left",$(window).width()-$e.outerWidth()-5);if($.ui.draggable){$e.draggable({handle:":first-child"})}return $e}}};(function(){var u=navigator.userAgent.toLowerCase(),m=/(chrome)[ \/]([\w.]+)/.exec(u)||/(webkit)[ \/]([\w.]+)/.exec(u)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(u)||/(msie) ([\w.]+)/.exec(u)||u.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(u)||[],b=m[1]||"",v=m[2]||0,ie=b==="msie",cm=document.compatMode,$s=$.support,bs=$s.boxSizing!==undefined?$s.boxSizing:$s.boxSizingReliable,bm=!ie||!cm||cm==="CSS1Compat"||$s.boxModel||false,lb=$.layout.browser={version:v,safari:b==="webkit",webkit:b==="chrome",msie:ie,isIE6:ie&&v==6,boxModel:bm,boxSizing:!!(typeof bs==="function"?bs():bs)};if(b){lb[b]=true}if(!bm&&!cm){$(function(){lb.boxModel=$s.boxModel})}})();$.layout.defaults={name:"",containerClass:"ui-layout-container",inset:null,scrollToBookmarkOnLoad:true,resizeWithWindow:true,resizeWithWindowDelay:50,resizeWithWindowMaxDelay:0,maskPanesEarly:false,onresizeall_start:null,onresizeall_end:null,onload_start:null,onload_end:null,onunload_start:null,onunload_end:null,initPanes:true,showErrorMessages:true,showDebugMessages:false,zIndex:null,zIndexes:{pane_normal:0,content_mask:1,resizer_normal:2,pane_sliding:100,pane_animate:1000,resizer_drag:10000},errors:{pane:"pane",selector:"selector",addButtonError:"Error Adding Button\nInvalid ",containerMissing:"UI Layout Initialization Error\nThe specified layout-container does not exist.",centerPaneMissing:"UI Layout Initialization Error\nThe center-pane element does not exist.\nThe center-pane is a required element.",noContainerHeight:"UI Layout Initialization Warning\nThe layout-container \"CONTAINER\" has no height.\nTherefore the layout is 0-height and hence 'invisible'!",callbackError:"UI Layout Callback Error\nThe EVENT callback is not a valid function."},panes:{applyDemoStyles:false,closable:true,resizable:true,slidable:true,initClosed:false,initHidden:false,contentSelector:".ui-layout-content",contentIgnoreSelector:".ui-layout-ignore",findNestedContent:true,paneClass:"ui-layout-pane",resizerClass:"ui-layout-resizer",togglerClass:"ui-layout-toggler",buttonClass:"ui-layout-button",minSize:0,maxSize:0,spacing_open:8,spacing_closed:8,togglerLength_open:50,togglerLength_closed:50,togglerAlign_open:"center",togglerAlign_closed:"center",togglerContent_open:'',togglerContent_closed:'',resizerDblClickToggle:true,autoResize:true,autoReopen:true,resizerDragOpacity:1,maskContents:false,maskObjects:false,maskZindex:null,resizingGrid:false,livePaneResizing:false,liveContentResizing:false,liveResizingTolerance:1,sliderCursor:"pointer",slideTrigger_open:"mouseenter",slideTrigger_close:"mouseleave",slideDelay_open:100,slideDelay_close:500,hideTogglerOnSlide:false,preventQuickSlideClose:$.layout.browser.webkit,preventPrematureSlideClose:false,tips:{Open:"展开",Close:"折叠",Resize:"调整大小/双击折叠",Slide:"鼠标停留自动展开",Pin:"Pin",Unpin:"Un-Pin",noRoomToOpen:"Not enough room to show this panel.",minSizeWarning:"Panel has reached its minimum size",maxSizeWarning:"Panel has reached its maximum size"},showOverflowOnHover:false,enableCursorHotkey:true,customHotkeyModifier:"SHIFT",fxName:"slide",fxSpeed:null,fxSettings:{},fxOpacityFix:true,animatePaneSizing:false,children:null,containerSelector:"",initChildren:true,destroyChildren:true,resizeChildren:true,triggerEventsOnLoad:false,triggerEventsDuringLiveResize:true,onshow_start:null,onshow_end:null,onhide_start:null,onhide_end:null,onopen_start:null,onopen_end:null,onclose_start:null,onclose_end:null,onresize_start:null,onresize_end:null,onsizecontent_start:null,onsizecontent_end:null,onswap_start:null,onswap_end:null,ondrag_start:null,ondrag_end:null},north:{paneSelector:".ui-layout-north",size:"auto",resizerCursor:"n-resize",customHotkey:""},south:{paneSelector:".ui-layout-south",size:"auto",resizerCursor:"s-resize",customHotkey:""},east:{paneSelector:".ui-layout-east",size:200,resizerCursor:"e-resize",customHotkey:""},west:{paneSelector:".ui-layout-west",size:200,resizerCursor:"w-resize",customHotkey:""},center:{paneSelector:".ui-layout-center",minWidth:0,minHeight:0}}; -$.layout.optionsMap={layout:("name,instanceKey,stateManagement,effects,inset,zIndexes,errors,"+"zIndex,scrollToBookmarkOnLoad,showErrorMessages,maskPanesEarly,"+"outset,resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay,"+"onresizeall,onresizeall_start,onresizeall_end,onload,onload_start,onload_end,onunload,onunload_start,onunload_end").split(","),center:("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad,"+"showOverflowOnHover,maskContents,maskObjects,liveContentResizing,"+"containerSelector,children,initChildren,resizeChildren,destroyChildren,"+"onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(","),noDefault:("paneSelector,resizerCursor,customHotkey").split(",")};$.layout.transformData=function(hash,addKeys){var json=addKeys?{panes:{},center:{}}:{},branch,optKey,keys,key,val,i,c;if(typeof hash!=="object"){return json}for(optKey in hash){branch=json;val=hash[optKey];keys=optKey.split("__");c=keys.length-1;for(i=0;i<=c;i++){key=keys[i];if(i===c){if($.isPlainObject(val)){branch[key]=$.layout.transformData(val)}else{branch[key]=val}}else{if(!branch[key]){branch[key]={}}branch=branch[key]}}}return json};$.layout.backwardCompatibility={map:{applyDefaultStyles:"applyDemoStyles",childOptions:"children",initChildLayout:"initChildren",destroyChildLayout:"destroyChildren",resizeChildLayout:"resizeChildren",resizeNestedLayout:"resizeChildren",resizeWhileDragging:"livePaneResizing",resizeContentWhileDragging:"liveContentResizing",triggerEventsWhileDragging:"triggerEventsDuringLiveResize",maskIframesOnResize:"maskContents",useStateCookie:"stateManagement.enabled","cookie.autoLoad":"stateManagement.autoLoad","cookie.autoSave":"stateManagement.autoSave","cookie.keys":"stateManagement.stateKeys","cookie.name":"stateManagement.cookie.name","cookie.domain":"stateManagement.cookie.domain","cookie.path":"stateManagement.cookie.path","cookie.expires":"stateManagement.cookie.expires","cookie.secure":"stateManagement.cookie.secure",noRoomToOpenTip:"tips.noRoomToOpen",togglerTip_open:"tips.Close",togglerTip_closed:"tips.Open",resizerTip:"tips.Resize",sliderTip:"tips.Slide"},renameOptions:function(opts){var map=$.layout.backwardCompatibility.map,oldData,newData,value;for(var itemPath in map){oldData=getBranch(itemPath);value=oldData.branch[oldData.key];if(value!==undefined){newData=getBranch(map[itemPath],true);newData.branch[newData.key]=value;delete oldData.branch[oldData.key]}}function getBranch(path,create){var a=path.split("."),c=a.length-1,D={branch:opts,key:a[c]},i=0,k,undef;for(;i0){if(autoHide&&$E.data("autoHidden")&&$E.innerHeight()>0){$E.show().data("autoHidden",false);if(!browser.mozilla){$E.css(_c.hidden).css(_c.visible)}}}else{if(autoHide&&!$E.data("autoHidden")){$E.hide().data("autoHidden",true)}}},setOuterHeight=function(el,outerHeight,autoHide){var $E=el,h;if(isStr(el)){$E=$Ps[el]}else{if(!el.jquery){$E=$(el)}}h=cssH($E,outerHeight);$E.css({height:h,visibility:"visible"});if(h>0&&$E.innerWidth()>0){if(autoHide&&$E.data("autoHidden")){$E.show().data("autoHidden",false);if(!browser.mozilla){$E.css(_c.hidden).css(_c.visible)}}}else{if(autoHide&&!$E.data("autoHidden")){$E.hide().data("autoHidden",true)}}},_parseSize=function(pane,size,dir){if(!dir){dir=_c[pane].dir}if(isStr(size)&&size.match(/%/)){size=(size==="100%")?-1:parseInt(size,10)/100}if(size===0){return 0}else{if(size>=1){return parseInt(size,10)}}var o=options,avail=0;if(dir=="horz"){avail=sC.innerHeight-($Ps.north?o.north.spacing_open:0)-($Ps.south?o.south.spacing_open:0)}else{if(dir=="vert"){avail=sC.innerWidth-($Ps.west?o.west.spacing_open:0)-($Ps.east?o.east.spacing_open:0)}}if(size===-1){return avail}else{if(size>0){return round(avail*size)}else{if(pane=="center"){return 0}else{var dim=(dir==="horz"?"height":"width"),$P=$Ps[pane],$C=dim==="height"?$Cs[pane]:false,vis=$.layout.showInvisibly($P),szP=$P.css(dim),szC=$C?$C.css(dim):0;$P.css(dim,"auto");if($C){$C.css(dim,"auto")}size=(dim==="height")?$P.outerHeight():$P.outerWidth();$P.css(dim,szP).css(vis);if($C){$C.css(dim,szC)}return size}}}},getPaneSize=function(pane,inclSpace){var $P=$Ps[pane],o=options[pane],s=state[pane],oSp=(inclSpace?o.spacing_open:0),cSp=(inclSpace?o.spacing_closed:0);if(!$P||s.isHidden){return 0}else{if(s.isClosed||(s.isSliding&&inclSpace)){return cSp}else{if(_c[pane].dir==="horz"){return $P.outerHeight()+oSp}else{return $P.outerWidth()+oSp}}}},setSizeLimits=function(pane,slide){if(!isInitialized()){return}var o=options[pane],s=state[pane],c=_c[pane],dir=c.dir,type=c.sizeType.toLowerCase(),isSliding=(slide!=undefined?slide:s.isSliding),$P=$Ps[pane],paneSpacing=o.spacing_open,altPane=_c.oppositeEdge[pane],altS=state[altPane],$altP=$Ps[altPane],altPaneSize=(!$altP||altS.isVisible===false||altS.isSliding?0:(dir=="horz"?$altP.outerHeight():$altP.outerWidth())),altPaneSpacing=((!$altP||altS.isHidden?0:options[altPane][altS.isClosed!==false?"spacing_closed":"spacing_open"])||0),containerSize=(dir=="horz"?sC.innerHeight:sC.innerWidth),minCenterDims=cssMinDims("center"),minCenterSize=dir=="horz"?max(options.center.minHeight,minCenterDims.minHeight):max(options.center.minWidth,minCenterDims.minWidth),limitSize=(containerSize-paneSpacing-(isSliding?0:(_parseSize("center",minCenterSize,dir)+altPaneSize+altPaneSpacing))),minSize=s.minSize=max(_parseSize(pane,o.minSize),cssMinDims(pane).minSize),maxSize=s.maxSize=min((o.maxSize?_parseSize(pane,o.maxSize):100000),limitSize),r=s.resizerPosition={},top=sC.inset.top,left=sC.inset.left,W=sC.innerWidth,H=sC.innerHeight,rW=o.spacing_open;switch(pane){case"north":r.min=top+minSize;r.max=top+maxSize;break;case"west":r.min=left+minSize;r.max=left+maxSize;break;case"south":r.min=top+H-maxSize-rW;r.max=top+H-minSize-rW;break;case"east":r.min=left+W-maxSize-rW;r.max=left+W-minSize-rW;break}},calcNewCenterPaneDims=function(){var d={top:getPaneSize("north",true),bottom:getPaneSize("south",true),left:getPaneSize("west",true),right:getPaneSize("east",true),width:0,height:0};d.width=sC.innerWidth-d.left-d.right;d.height=sC.innerHeight-d.bottom-d.top;d.top+=sC.inset.top;d.bottom+=sC.inset.bottom;d.left+=sC.inset.left;d.right+=sC.inset.right;return d},getHoverClasses=function(el,allStates){var $El=$(el),type=$El.data("layoutRole"),pane=$El.data("layoutEdge"),o=options[pane],root=o[type+"Class"],_pane="-"+pane,_open="-open",_closed="-closed",_slide="-sliding",_hover="-hover ",_state=$El.hasClass(root+_closed)?_closed:_open,_alt=_state===_closed?_open:_closed,classes=(root+_hover)+(root+_pane+_hover)+(root+_state+_hover)+(root+_pane+_state+_hover); -if(allStates){classes+=(root+_alt+_hover)+(root+_pane+_alt+_hover)}if(type=="resizer"&&$El.hasClass(root+_slide)){classes+=(root+_slide+_hover)+(root+_pane+_slide+_hover)}return $.trim(classes)},addHover=function(evt,el){var $E=$(el||this);if(evt&&$E.data("layoutRole")==="toggler"){evt.stopPropagation()}$E.addClass(getHoverClasses($E))},removeHover=function(evt,el){var $E=$(el||this);$E.removeClass(getHoverClasses($E,true))},onResizerEnter=function(evt){var pane=$(this).data("layoutEdge"),s=state[pane],$d=$(document);if(s.isResizing||state.paneResizing){return}if(options.maskPanesEarly){showMasks(pane,{resizing:true})}},onResizerLeave=function(evt,el){var e=el||this,pane=$(e).data("layoutEdge"),name=pane+"ResizerLeave",$d=$(document);timer.clear(pane+"_openSlider");timer.clear(name);if(!el){timer.set(name,function(){onResizerLeave(evt,e)},200)}else{if(options.maskPanesEarly&&!state.paneResizing){hideMasks()}}},_create=function(){initOptions();var o=options,s=state;s.creatingLayout=true;runPluginCallbacks(Instance,$.layout.onCreate);if(false===_runCallbacks("onload_start")){return"cancel"}_initContainer();initHotkeys();$(window).bind("unload."+sID,unload);runPluginCallbacks(Instance,$.layout.onLoad);if(o.initPanes){_initLayoutElements()}delete s.creatingLayout;return state.initialized},isInitialized=function(){if(state.initialized||state.creatingLayout){return true}else{return _initLayoutElements()}},_initLayoutElements=function(retry){var o=options;if(!$N.is(":visible")){if(!retry&&browser.webkit&&$N[0].tagName==="BODY"){setTimeout(function(){_initLayoutElements(true)},50)}return false}if(!getPane("center").length){return _log(o.errors.centerPaneMissing)}state.creatingLayout=true;$.extend(sC,elDims($N,o.inset));initPanes();if(o.scrollToBookmarkOnLoad){var l=self.location;if(l.hash){l.replace(l.hash)}}if(Instance.hasParentLayout){o.resizeWithWindow=false}else{if(o.resizeWithWindow){$(window).bind("resize."+sID,windowResize)}}delete state.creatingLayout;state.initialized=true;runPluginCallbacks(Instance,$.layout.onReady);_runCallbacks("onload_end");return true},createChildren=function(evt_or_pane,opts){var pane=evtPane.call(this,evt_or_pane),$P=$Ps[pane];if(!$P){return}var $C=$Cs[pane],s=state[pane],o=options[pane],sm=options.stateManagement||{},cos=opts?(o.children=opts):o.children;if($.isPlainObject(cos)){cos=[cos]}else{if(!cos||!$.isArray(cos)){return}}$.each(cos,function(idx,co){if(!$.isPlainObject(co)){return}var $containers=co.containerSelector?$P.find(co.containerSelector):($C||$P);$containers.each(function(){var $cont=$(this),child=$cont.data("layout");if(!child){setInstanceKey({container:$cont,options:co},s);if(sm.includeChildren&&state.stateData[pane]){var paneChildren=state.stateData[pane].children||{},childState=paneChildren[co.instanceKey],co_sm=co.stateManagement||(co.stateManagement={autoLoad:true});if(co_sm.autoLoad===true&&childState){co_sm.autoSave=false;co_sm.includeChildren=true;co_sm.autoLoad=$.extend(true,{},childState)}}child=$cont.layout(co);if(child){refreshChildren(pane,child)}}})})},setInstanceKey=function(child,parentPaneState){var $c=child.container,o=child.options,sm=o.stateManagement,key=o.instanceKey||$c.data("layoutInstanceKey");if(!key){key=(sm&&sm.cookie?sm.cookie.name:"")||o.name}if(!key){key="layout"+(++parentPaneState.childIdx)}else{key=key.replace(/[^\w-]/gi,"_").replace(/_{2,}/g,"_")}o.instanceKey=key;$c.data("layoutInstanceKey",key);return key},refreshChildren=function(pane,newChild){var $P=$Ps[pane],pC=children[pane],s=state[pane],o;if($.isPlainObject(pC)){$.each(pC,function(key,child){if(child.destroyed){delete pC[key]}});if($.isEmptyObject(pC)){pC=children[pane]=null}}if(!newChild&&!pC){newChild=$P.data("layout")}if(newChild){newChild.hasParentLayout=true;o=newChild.options;setInstanceKey(newChild,s);if(!pC){pC=children[pane]={}}pC[o.instanceKey]=newChild.container.data("layout")}Instance[pane].children=children[pane];if(!newChild){createChildren(pane)}},windowResize=function(){var o=options,delay=Number(o.resizeWithWindowDelay);if(delay<10){delay=100}timer.clear("winResize");timer.set("winResize",function(){timer.clear("winResize");timer.clear("winResizeRepeater");var dims=elDims($N,o.inset);if(dims.innerWidth!==sC.innerWidth||dims.innerHeight!==sC.innerHeight){resizeAll()}},delay);if(!timer.data["winResizeRepeater"]){setWindowResizeRepeater()}},setWindowResizeRepeater=function(){var delay=Number(options.resizeWithWindowMaxDelay);if(delay>0){timer.set("winResizeRepeater",function(){setWindowResizeRepeater();resizeAll()},delay)}},unload=function(){var o=options;_runCallbacks("onunload_start");runPluginCallbacks(Instance,$.layout.onUnload);_runCallbacks("onunload_end")},_initContainer=function(){var N=$N[0],$H=$("html"),tag=sC.tagName=N.tagName,id=sC.id=N.id,cls=sC.className=N.className,o=options,name=o.name,props="position,margin,padding,border",css="layoutCSS",CSS={},hid="hidden",parent=$N.data("parentLayout"),pane=$N.data("layoutEdge"),isChild=parent&&pane,num=$.layout.cssNum,$parent,n; -sC.selector=$N.selector.split(".slice")[0];sC.ref=(o.name?o.name+" layout / ":"")+tag+(id?"#"+id:cls?".["+cls+"]":"");sC.isBody=(tag==="BODY");if(!isChild&&!sC.isBody){$parent=$N.closest("."+$.layout.defaults.panes.paneClass);parent=$parent.data("parentLayout");pane=$parent.data("layoutEdge");isChild=parent&&pane}$N.data({layout:Instance,layoutContainer:sID}).addClass(o.containerClass);var layoutMethods={destroy:"",initPanes:"",resizeAll:"resizeAll",resize:"resizeAll"};for(name in layoutMethods){$N.bind("layout"+name.toLowerCase()+"."+sID,Instance[layoutMethods[name]||name])}if(isChild){Instance.hasParentLayout=true;parent.refreshChildren(pane,Instance)}if(!$N.data(css)){if(sC.isBody){$N.data(css,$.extend(styles($N,props),{height:$N.css("height"),overflow:$N.css("overflow"),overflowX:$N.css("overflowX"),overflowY:$N.css("overflowY")}));$H.data(css,$.extend(styles($H,"padding"),{height:"auto",overflow:$H.css("overflow"),overflowX:$H.css("overflowX"),overflowY:$H.css("overflowY")}))}else{$N.data(css,styles($N,props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY"))}}try{CSS={overflow:hid,overflowX:hid,overflowY:hid};$N.css(CSS);if(o.inset&&!$.isPlainObject(o.inset)){n=parseInt(o.inset,10)||0;o.inset={top:n,bottom:n,left:n,right:n}}if(sC.isBody){if(!o.outset){o.outset={top:num($H,"paddingTop"),bottom:num($H,"paddingBottom"),left:num($H,"paddingLeft"),right:num($H,"paddingRight")}}else{if(!$.isPlainObject(o.outset)){n=parseInt(o.outset,10)||0;o.outset={top:n,bottom:n,left:n,right:n}}}$H.css(CSS).css({height:"100%",border:"none",padding:0,margin:0});if(browser.isIE6){$N.css({width:"100%",height:"100%",border:"none",padding:0,margin:0,position:"relative"});if(!o.inset){o.inset=elDims($N).inset}}else{$N.css({width:"auto",height:"auto",margin:0,position:"absolute"});$N.css(o.outset)}$.extend(sC,elDims($N,o.inset))}else{var p=$N.css("position");if(!p||!p.match(/(fixed|absolute|relative)/)){$N.css("position","relative")}if($N.is(":visible")){$.extend(sC,elDims($N,o.inset));if(sC.innerHeight<1){_log(o.errors.noContainerHeight.replace(/CONTAINER/,sC.ref))}}}if(num($N,"minWidth")){$N.parent().css("overflowX","auto")}if(num($N,"minHeight")){$N.parent().css("overflowY","auto")}}catch(ex){}},initHotkeys=function(panes){panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(i,pane){var o=options[pane];if(o.enableCursorHotkey||o.customHotkey){$(document).bind("keydown."+sID,keyDown);return false}})},initOptions=function(){var data,d,pane,key,val,i,c,o;opts=$.layout.transformData(opts,true);opts=$.layout.backwardCompatibility.renameAllOptions(opts);if(!$.isEmptyObject(opts.panes)){data=$.layout.optionsMap.noDefault;for(i=0,c=data.length;i0){z.pane_normal=zo;z.content_mask=max(zo+1,z.content_mask);z.resizer_normal=max(zo+2,z.resizer_normal)}delete options.panes;function createFxOptions(pane){var o=options[pane],d=options.panes;if(!o.fxSettings){o.fxSettings={}}if(!d.fxSettings){d.fxSettings={}}$.each(["_open","_close","_size"],function(i,n){var sName="fxName"+n,sSpeed="fxSpeed"+n,sSettings="fxSettings"+n,fxName=o[sName]=o[sName]||d[sName]||o.fxName||d.fxName||"none",fxExists=$.effects&&($.effects[fxName]||($.effects.effect&&$.effects.effect[fxName]));if(fxName==="none"||!options.effects[fxName]||!fxExists){fxName=o[sName]="none"}var fx=options.effects[fxName]||{},fx_all=fx.all||null,fx_pane=fx[pane]||null;o[sSpeed]=o[sSpeed]||d[sSpeed]||o.fxSpeed||d.fxSpeed||null;o[sSettings]=$.extend(true,{},fx_all,fx_pane,d.fxSettings,o.fxSettings,d[sSettings],o[sSettings])});delete o.fxName;delete o.fxSpeed;delete o.fxSettings}},getPane=function(pane){var sel=options[pane].paneSelector;if(sel.substr(0,1)==="#"){return $N.find(sel).eq(0)}else{var $P=$N.children(sel).eq(0);return $P.length?$P:$N.children("form:first").children(sel).eq(0)}},initPanes=function(evt){evtPane(evt);$.each(_c.allPanes,function(idx,pane){addPane(pane,true)});initHandles();$.each(_c.borderPanes,function(i,pane){if($Ps[pane]&&state[pane].isVisible){setSizeLimits(pane);makePaneFit(pane) -}});sizeMidPanes("center");$.each(_c.allPanes,function(idx,pane){afterInitPane(pane)})},addPane=function(pane,force){if(!force&&!isInitialized()){return}var o=options[pane],s=state[pane],c=_c[pane],dir=c.dir,fx=s.fx,spacing=o.spacing_open||0,isCenter=(pane==="center"),CSS={},$P=$Ps[pane],size,minSize,maxSize,child;if($P){removePane(pane,false,true,false)}else{$Cs[pane]=false}$P=$Ps[pane]=getPane(pane);if(!$P.length){$Ps[pane]=false;return}if(!$P.data("layoutCSS")){var props="position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border";$P.data("layoutCSS",styles($P,props))}Instance[pane]={name:pane,pane:$Ps[pane],content:$Cs[pane],options:options[pane],state:state[pane],children:children[pane]};$P.data({parentLayout:Instance,layoutPane:Instance[pane],layoutEdge:pane,layoutRole:"pane"}).css(c.cssReq).css("zIndex",options.zIndexes.pane_normal).css(o.applyDemoStyles?c.cssDemo:{}).addClass(o.paneClass+" "+o.paneClass+"-"+pane).bind("mouseenter."+sID,addHover).bind("mouseleave."+sID,removeHover);var paneMethods={hide:"",show:"",toggle:"",close:"",open:"",slideOpen:"",slideClose:"",slideToggle:"",size:"sizePane",sizePane:"sizePane",sizeContent:"",sizeHandles:"",enableClosable:"",disableClosable:"",enableSlideable:"",disableSlideable:"",enableResizable:"",disableResizable:"",swapPanes:"swapPanes",swap:"swapPanes",move:"swapPanes",removePane:"removePane",remove:"removePane",createChildren:"",resizeChildren:"",resizeAll:"resizeAll",resizeLayout:"resizeAll"},name;for(name in paneMethods){$P.bind("layoutpane"+name.toLowerCase()+"."+sID,Instance[paneMethods[name]||name])}initContent(pane,false);if(!isCenter){size=s.size=_parseSize(pane,o.size);minSize=_parseSize(pane,o.minSize)||1;maxSize=_parseSize(pane,o.maxSize)||100000;if(size>0){size=max(min(size,maxSize),minSize)}s.autoResize=o.autoResize;s.isClosed=false;s.isSliding=false;s.isResizing=false;s.isHidden=false;if(!s.pins){s.pins=[]}}s.tagName=$P[0].tagName;s.edge=pane;s.noRoom=false;s.isVisible=true;setPanePosition(pane);if(dir==="horz"){CSS.height=cssH($P,size)}else{if(dir==="vert"){CSS.width=cssW($P,size)}}$P.css(CSS);if(dir!="horz"){sizeMidPanes(pane,true)}if(state.initialized){initHandles(pane);initHotkeys(pane)}if(o.initClosed&&o.closable&&!o.initHidden){close(pane,true,true)}else{if(o.initHidden||o.initClosed){hide(pane)}else{if(!s.noRoom){$P.css("display","block")}}}$P.css("visibility","visible");if(o.showOverflowOnHover){$P.hover(allowOverflow,resetOverflow)}if(state.initialized){afterInitPane(pane)}},afterInitPane=function(pane){var $P=$Ps[pane],s=state[pane],o=options[pane];if(!$P){return}if($P.data("layout")){refreshChildren(pane,$P.data("layout"))}if(s.isVisible){if(state.initialized){resizeAll()}else{sizeContent(pane)}if(o.triggerEventsOnLoad){_runCallbacks("onresize_end",pane)}else{resizeChildren(pane,true)}}if(o.initChildren&&o.children){createChildren(pane)}},setPanePosition=function(panes){panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(i,pane){var $P=$Ps[pane],$R=$Rs[pane],o=options[pane],s=state[pane],side=_c[pane].side,CSS={};if(!$P){return}switch(pane){case"north":CSS.top=sC.inset.top;CSS.left=sC.inset.left;CSS.right=sC.inset.right;break;case"south":CSS.bottom=sC.inset.bottom;CSS.left=sC.inset.left;CSS.right=sC.inset.right;break;case"west":CSS.left=sC.inset.left;break;case"east":CSS.right=sC.inset.right;break;case"center":}$P.css(CSS);if($R&&s.isClosed){$R.css(side,sC.inset[side])}else{if($R&&!s.isHidden){$R.css(side,sC.inset[side]+getPaneSize(pane))}}})},initHandles=function(panes){panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(i,pane){var $P=$Ps[pane];$Rs[pane]=false;$Ts[pane]=false;if(!$P){return}var o=options[pane],s=state[pane],c=_c[pane],paneId=o.paneSelector.substr(0,1)==="#"?o.paneSelector.substr(1):"",rClass=o.resizerClass,tClass=o.togglerClass,spacing=(s.isVisible?o.spacing_open:o.spacing_closed),_pane="-"+pane,_state=(s.isVisible?"-open":"-closed"),I=Instance[pane],$R=I.resizer=$Rs[pane]=$("
      "),$T=I.toggler=(o.closable?$Ts[pane]=$("
      "):false);if(!s.isVisible&&o.slidable){$R.attr("title",o.tips.Slide).css("cursor",o.sliderCursor)}$R.attr("id",paneId?paneId+"-resizer":"").data({parentLayout:Instance,layoutPane:Instance[pane],layoutEdge:pane,layoutRole:"resizer"}).css(_c.resizers.cssReq).css("zIndex",options.zIndexes.resizer_normal).css(o.applyDemoStyles?_c.resizers.cssDemo:{}).addClass(rClass+" "+rClass+_pane).hover(addHover,removeHover).hover(onResizerEnter,onResizerLeave).mousedown($.layout.disableTextSelection).mouseup($.layout.enableTextSelection).appendTo($N);if($.fn.disableSelection){$R.disableSelection()}if(o.resizerDblClickToggle){$R.bind("dblclick."+sID,toggle)}if($T){$T.attr("id",paneId?paneId+"-toggler":"").data({parentLayout:Instance,layoutPane:Instance[pane],layoutEdge:pane,layoutRole:"toggler"}).css(_c.togglers.cssReq).css(o.applyDemoStyles?_c.togglers.cssDemo:{}).addClass(tClass+" "+tClass+_pane).hover(addHover,removeHover).bind("mouseenter",onResizerEnter).appendTo($R); -if(o.togglerContent_open){$(""+o.togglerContent_open+"").data({layoutEdge:pane,layoutRole:"togglerContent"}).data("layoutRole","togglerContent").data("layoutEdge",pane).addClass("ui-content content-open").css("display","none").appendTo($T)}if(o.togglerContent_closed){$(""+o.togglerContent_closed+"").data({layoutEdge:pane,layoutRole:"togglerContent"}).addClass("ui-content content-closed").css("display","none").appendTo($T)}enableClosable(pane)}initResizable(pane);if(s.isVisible){setAsOpen(pane)}else{setAsClosed(pane);bindStartSlidingEvents(pane,true)}});sizeHandles()},initContent=function(pane,resize){if(!isInitialized()){return}var o=options[pane],sel=o.contentSelector,I=Instance[pane],$P=$Ps[pane],$C;if(sel){$C=I.content=$Cs[pane]=(o.findNestedContent)?$P.find(sel).eq(0):$P.children(sel).eq(0)}if($C&&$C.length){$C.data("layoutRole","content");if(!$C.data("layoutCSS")){$C.data("layoutCSS",styles($C,"height"))}$C.css(_c.content.cssReq);if(o.applyDemoStyles){$C.css(_c.content.cssDemo);$P.css(_c.content.cssDemoPane)}if($P.css("overflowX").match(/(scroll|auto)/)){$P.css("overflow","hidden")}state[pane].content={};if(resize!==false){sizeContent(pane)}}else{I.content=$Cs[pane]=false}},initResizable=function(panes){var draggingAvailable=$.layout.plugins.draggable,side;panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(idx,pane){var o=options[pane];if(!draggingAvailable||!$Ps[pane]||!o.resizable){o.resizable=false;return true}var s=state[pane],z=options.zIndexes,c=_c[pane],side=c.dir=="horz"?"top":"left",$P=$Ps[pane],$R=$Rs[pane],base=o.resizerClass,lastPos=0,r,live,resizerClass=base+"-drag",resizerPaneClass=base+"-"+pane+"-drag",helperClass=base+"-dragging",helperPaneClass=base+"-"+pane+"-dragging",helperLimitClass=base+"-dragging-limit",helperPaneLimitClass=base+"-"+pane+"-dragging-limit",helperClassesSet=false;if(!s.isClosed){$R.attr("title",o.tips.Resize).css("cursor",o.resizerCursor)}$R.draggable({containment:$N[0],axis:(c.dir=="horz"?"y":"x"),delay:0,distance:1,grid:o.resizingGrid,helper:"clone",opacity:o.resizerDragOpacity,addClasses:false,zIndex:z.resizer_drag,iframeFix:true,start:function(e,ui){o=options[pane];s=state[pane];live=o.livePaneResizing;if(false===_runCallbacks("ondrag_start",pane)){return false}s.isResizing=true;state.paneResizing=pane;timer.clear(pane+"_closeSlider");setSizeLimits(pane);r=s.resizerPosition;lastPos=ui.position[side];$R.addClass(resizerClass+" "+resizerPaneClass);helperClassesSet=false;showMasks(pane,{resizing:true})},drag:function(e,ui){if(!helperClassesSet){ui.helper.addClass(helperClass+" "+helperPaneClass).css({right:"auto",bottom:"auto"}).children().css("visibility","hidden");helperClassesSet=true;if(s.isSliding){$Ps[pane].css("zIndex",z.pane_sliding)}}var limit=0;if(ui.position[side]r.max){ui.position[side]=r.max;limit=1}}if(limit){ui.helper.addClass(helperLimitClass+" "+helperPaneLimitClass);window.defaultStatus=(limit>0&&pane.match(/(north|west)/))||(limit<0&&pane.match(/(south|east)/))?o.tips.maxSizeWarning:o.tips.minSizeWarning}else{ui.helper.removeClass(helperLimitClass+" "+helperPaneLimitClass);window.defaultStatus=""}if(live&&Math.abs(ui.position[side]-lastPos)>=o.liveResizingTolerance){lastPos=ui.position[side];resizePanes(e,ui,pane)}},stop:function(e,ui){$("body").enableSelection();window.defaultStatus="";$R.removeClass(resizerClass+" "+resizerPaneClass);s.isResizing=false;state.paneResizing=false;resizePanes(e,ui,pane,true)}})});var resizePanes=function(evt,ui,pane,resizingDone){var dragPos=ui.position,c=_c[pane],o=options[pane],s=state[pane],resizerPos;switch(pane){case"north":resizerPos=dragPos.top;break;case"west":resizerPos=dragPos.left;break;case"south":resizerPos=sC.layoutHeight-dragPos.top-o.spacing_open;break;case"east":resizerPos=sC.layoutWidth-dragPos.left-o.spacing_open;break}var newSize=resizerPos-sC.inset[c.side];if(!resizingDone){if(Math.abs(newSize-s.size)=0;i--){$M=$Ms.eq(i);p=$M.data("layoutMask");if(!options[p].maskObjects){$M.hide()}}}}},getMasks=function(pane){var $Masks=$([]),$M,i=0,c=$Ms.length;for(;is.maxSize){syncPinBtns(pane,false);if(!noAlert&&o.tips.noRoomToOpen){alert(o.tips.noRoomToOpen)}return queueNext()}if(slide){bindStopSlidingEvents(pane,true)}else{if(s.isSliding){bindStopSlidingEvents(pane,false)}else{if(o.slidable){bindStartSlidingEvents(pane,false)}}}s.noRoom=false;makePaneFit(pane);isShowing=s.isShowing;delete s.isShowing;doFX=!noAnimation&&s.isClosed&&(o.fxName_open!="none");s.isMoving=true;s.isVisible=true;s.isClosed=false;if(isShowing){s.isHidden=false}if(doFX){lockPaneForFX(pane,true);$P.show(o.fxName_open,o.fxSettings_open,o.fxSpeed_open,function(){lockPaneForFX(pane,false);if(s.isVisible){open_2()}queueNext()})}else{_showPane(pane);open_2();queueNext()}});function open_2(){s.isMoving=false;_fixIframe(pane);if(!s.isSliding){sizeMidPanes(_c[pane].dir=="vert"?"center":"",false)}setAsOpen(pane)}},setAsOpen=function(pane,skipCallback){var $P=$Ps[pane],$R=$Rs[pane],$T=$Ts[pane],o=options[pane],s=state[pane],side=_c[pane].side,rClass=o.resizerClass,tClass=o.togglerClass,_pane="-"+pane,_open="-open",_closed="-closed",_sliding="-sliding";$R.css(side,sC.inset[side]+getPaneSize(pane)).removeClass(rClass+_closed+" "+rClass+_pane+_closed).addClass(rClass+_open+" "+rClass+_pane+_open); -if(s.isSliding){$R.addClass(rClass+_sliding+" "+rClass+_pane+_sliding)}else{$R.removeClass(rClass+_sliding+" "+rClass+_pane+_sliding)}removeHover(0,$R);if(o.resizable&&$.layout.plugins.draggable){$R.draggable("enable").css("cursor",o.resizerCursor).attr("title",o.tips.Resize)}else{if(!s.isSliding){$R.css("cursor","default")}}if($T){$T.removeClass(tClass+_closed+" "+tClass+_pane+_closed).addClass(tClass+_open+" "+tClass+_pane+_open).attr("title",o.tips.Close);removeHover(0,$T);$T.children(".content-closed").hide();$T.children(".content-open").css("display","block")}syncPinBtns(pane,!s.isSliding);$.extend(s,elDims($P));if(state.initialized){sizeHandles();sizeContent(pane,true)}if(!skipCallback&&(state.initialized||o.triggerEventsOnLoad)&&$P.is(":visible")){_runCallbacks("onopen_end",pane);if(s.isShowing){_runCallbacks("onshow_end",pane)}if(state.initialized){_runCallbacks("onresize_end",pane)}}},slideOpen=function(evt_or_pane){if(!isInitialized()){return}var evt=evtObj(evt_or_pane),pane=evtPane.call(this,evt_or_pane),s=state[pane],delay=options[pane].slideDelay_open;if(pane==="center"){return}if(evt){evt.stopImmediatePropagation()}if(s.isClosed&&evt&&evt.type==="mouseenter"&&delay>0){timer.set(pane+"_openSlider",open_NOW,delay)}else{open_NOW()}function open_NOW(){if(!s.isClosed){bindStopSlidingEvents(pane,true)}else{if(!s.isMoving){open(pane,true)}}}},slideClose=function(evt_or_pane){if(!isInitialized()){return}var evt=evtObj(evt_or_pane),pane=evtPane.call(this,evt_or_pane),o=options[pane],s=state[pane],delay=s.isMoving?1000:300;if(pane==="center"){return}if(s.isClosed||s.isResizing){return}else{if(o.slideTrigger_close==="click"){close_NOW()}else{if(o.preventQuickSlideClose&&s.isMoving){return}else{if(o.preventPrematureSlideClose&&evt&&$.layout.isMouseOverElem(evt,$Ps[pane])){return}else{if(evt){timer.set(pane+"_closeSlider",close_NOW,max(o.slideDelay_close,delay))}else{close_NOW()}}}}}function close_NOW(){if(s.isClosed){bindStopSlidingEvents(pane,false)}else{if(!s.isMoving){close(pane)}}}},slideToggle=function(evt_or_pane){var pane=evtPane.call(this,evt_or_pane);toggle(pane,true)},lockPaneForFX=function(pane,doLock){var $P=$Ps[pane],s=state[pane],o=options[pane],z=options.zIndexes;if(doLock){showMasks(pane,{animation:true,objectsOnly:true});$P.css({zIndex:z.pane_animate});if(pane=="south"){$P.css({top:sC.inset.top+sC.innerHeight-$P.outerHeight()})}else{if(pane=="east"){$P.css({left:sC.inset.left+sC.innerWidth-$P.outerWidth()})}}}else{hideMasks();$P.css({zIndex:(s.isSliding?z.pane_sliding:z.pane_normal)});if(pane=="south"){$P.css({top:"auto"})}else{if(pane=="east"&&!$P.css("left").match(/\-99999/)){$P.css({left:"auto"})}}if(browser.msie&&o.fxOpacityFix&&o.fxName_open!="slide"&&$P.css("filter")&&$P.css("opacity")==1){$P[0].style.removeAttribute("filter")}}},bindStartSlidingEvents=function(pane,enable){var o=options[pane],$P=$Ps[pane],$R=$Rs[pane],evtName=o.slideTrigger_open.toLowerCase();if(!$R||(enable&&!o.slidable)){return}if(evtName.match(/mouseover/)){evtName=o.slideTrigger_open="mouseenter"}else{if(!evtName.match(/(click|dblclick|mouseenter)/)){evtName=o.slideTrigger_open="click"}}if(o.resizerDblClickToggle&&evtName.match(/click/)){$R[enable?"unbind":"bind"]("dblclick."+sID,toggle)}$R[enable?"bind":"unbind"](evtName+"."+sID,slideOpen).css("cursor",enable?o.sliderCursor:"default").attr("title",enable?o.tips.Slide:"")},bindStopSlidingEvents=function(pane,enable){var o=options[pane],s=state[pane],c=_c[pane],z=options.zIndexes,evtName=o.slideTrigger_close.toLowerCase(),action=(enable?"bind":"unbind"),$P=$Ps[pane],$R=$Rs[pane];timer.clear(pane+"_closeSlider");if(enable){s.isSliding=true;state.panesSliding[pane]=true;bindStartSlidingEvents(pane,false)}else{s.isSliding=false;delete state.panesSliding[pane]}$P.css("zIndex",enable?z.pane_sliding:z.pane_normal);$R.css("zIndex",enable?z.pane_sliding+2:z.resizer_normal);if(!evtName.match(/(click|mouseleave)/)){evtName=o.slideTrigger_close="mouseleave"}$R[action](evtName,slideClose);if(evtName==="mouseleave"){$P[action]("mouseleave."+sID,slideClose);$R[action]("mouseenter."+sID,cancelMouseOut);$P[action]("mouseenter."+sID,cancelMouseOut)}if(!enable){timer.clear(pane+"_closeSlider")}else{if(evtName==="click"&&!o.resizable){$R.css("cursor",enable?o.sliderCursor:"default");$R.attr("title",enable?o.tips.Close:"")}}function cancelMouseOut(evt){timer.clear(pane+"_closeSlider");evt.stopPropagation()}},makePaneFit=function(pane,isOpening,skipCallback,force){var o=options[pane],s=state[pane],c=_c[pane],$P=$Ps[pane],$R=$Rs[pane],isSidePane=c.dir==="vert",hasRoom=false;if(pane==="center"||(isSidePane&&s.noVerticalRoom)){hasRoom=(s.maxHeight>=0);if(hasRoom&&s.noRoom){_showPane(pane);if($R){$R.show()}s.isVisible=true;s.noRoom=false;if(isSidePane){s.noVerticalRoom=false}_fixIframe(pane)}else{if(!hasRoom&&!s.noRoom){_hidePane(pane);if($R){$R.hide()}s.isVisible=false;s.noRoom=true}}}if(pane==="center"){}else{if(s.minSize<=s.maxSize){hasRoom=true;if(s.size>s.maxSize){sizePane(pane,s.maxSize,skipCallback,true,force) -}else{if(s.sizesize){thisTry.attempt=max(0,lastTry.attempt-(lastTry.actual-size))}else{thisTry.attempt=max(0,lastTry.attempt+(size-lastTry.actual))}thisTry.cssSize=cssSize(pane,thisTry.attempt);$P.css(dimName,thisTry.cssSize);thisTry.actual=dimName=="width"?$P.outerWidth():$P.outerHeight();thisTry.correct=(size===thisTry.actual);if(tries.length===1){_log(msg,false,true);_log(lastTry,false,true)}_log(thisTry,false,true);if(tries.length>3){break}tries.push(thisTry);lastTry=tries[tries.length-1]}s.size=size;$.extend(s,elDims($P));if(s.isVisible&&$P.is(":visible")){if($R){$R.css(side,size+sC.inset[side])}sizeContent(pane)}if(!skipCallback&&!skipResizeWhileDragging&&state.initialized&&s.isVisible){_runCallbacks("onresize_end",pane)}if(!skipCallback){if(!s.isSliding){sizeMidPanes(_c[pane].dir=="horz"?"":"center",skipResizeWhileDragging,force)}sizeHandles()}var altPane=_c.oppositeEdge[pane];if(size1){_log(msg+"\nSee the Error Console for details.",true,true)}}},sizeMidPanes=function(panes,skipCallback,force){panes=(panes?panes:"east,west,center").split(",");$.each(panes,function(i,pane){if(!$Ps[pane]){return}var o=options[pane],s=state[pane],$P=$Ps[pane],$R=$Rs[pane],isCenter=(pane=="center"),hasRoom=true,CSS={},visCSS=$.layout.showInvisibly($P),newCenter=calcNewCenterPaneDims();$.extend(s,elDims($P));if(pane==="center"){if(!force&&s.isVisible&&newCenter.width===s.outerWidth&&newCenter.height===s.outerHeight){$P.css(visCSS);return true}$.extend(s,cssMinDims(pane),{maxWidth:newCenter.width,maxHeight:newCenter.height});CSS=newCenter;s.newWidth=CSS.width;s.newHeight=CSS.height;CSS.width=cssW($P,CSS.width);CSS.height=cssH($P,CSS.height);hasRoom=CSS.width>=0&&CSS.height>=0;if(!state.initialized&&o.minWidth>newCenter.width){var reqPx=o.minWidth-s.outerWidth,minE=options.east.minSize||0,minW=options.west.minSize||0,sizeE=state.east.size,sizeW=state.west.size,newE=sizeE,newW=sizeW;if(reqPx>0&&state.east.isVisible&&sizeE>minE){newE=max(sizeE-minE,sizeE-reqPx);reqPx-=sizeE-newE}if(reqPx>0&&state.west.isVisible&&sizeW>minW){newW=max(sizeW-minW,sizeW-reqPx);reqPx-=sizeW-newW}if(reqPx===0){if(sizeE&&sizeE!=minE){sizePane("east",newE,true,true,force)}if(sizeW&&sizeW!=minW){sizePane("west",newW,true,true,force)}sizeMidPanes("center",skipCallback,force);$P.css(visCSS);return}}}else{if(s.isVisible&&!s.noVerticalRoom){$.extend(s,elDims($P),cssMinDims(pane)) -}if(!force&&!s.noVerticalRoom&&newCenter.height===s.outerHeight){$P.css(visCSS);return true}CSS.top=newCenter.top;CSS.bottom=newCenter.bottom;s.newSize=newCenter.height;CSS.height=cssH($P,newCenter.height);s.maxHeight=CSS.height;hasRoom=(s.maxHeight>=0);if(!hasRoom){s.noVerticalRoom=true}}if(hasRoom){if(!skipCallback&&state.initialized){_runCallbacks("onresize_start",pane)}$P.css(CSS);if(pane!=="center"){sizeHandles(pane)}if(s.noRoom&&!s.isClosed&&!s.isHidden){makePaneFit(pane)}if(s.isVisible){$.extend(s,elDims($P));if(state.initialized){sizeContent(pane)}}}else{if(!s.noRoom&&s.isVisible){makePaneFit(pane)}}$P.css(visCSS);delete s.newSize;delete s.newWidth;delete s.newHeight;if(!s.isVisible){return true}if(pane==="center"){var fix=browser.isIE6||!browser.boxModel;if($Ps.north&&(fix||state.north.tagName=="IFRAME")){$Ps.north.css("width",cssW($Ps.north,sC.innerWidth))}if($Ps.south&&(fix||state.south.tagName=="IFRAME")){$Ps.south.css("width",cssW($Ps.south,sC.innerWidth))}}if(!skipCallback&&state.initialized){_runCallbacks("onresize_end",pane)}})},resizeAll=function(evt_or_refresh){var oldW=sC.innerWidth,oldH=sC.innerHeight;evtPane(evt_or_refresh);if(!$N.is(":visible")){return}if(!state.initialized){_initLayoutElements();return}if(evt_or_refresh===true&&$.isPlainObject(options.outset)){$N.css(options.outset)}$.extend(sC,elDims($N,options.inset));if(!sC.outerHeight){return}if(evt_or_refresh===true){setPanePosition()}if(false===_runCallbacks("onresizeall_start")){return false}var shrunkH=(sC.innerHeight0&&$P.css("overflow")==="hidden"){$P.css("overflow","visible");_measure();$P.css("overflow","hidden")}}var newH=s.innerHeight-(m.spaceAbove-s.css.paddingTop)-(m.spaceBelow-s.css.paddingBottom);if(!$C.is(":visible")||m.height!=newH){setOuterHeight($C,newH,true);m.height=newH}if(state.initialized){_runCallbacks("onsizecontent_end",pane)}function _below($E){return max(s.css.paddingBottom,(parseInt($E.css("marginBottom"),10)||0))}function _measure(){var ignore=options[pane].contentIgnoreSelector,$Fs=$C.nextAll().not(".ui-layout-mask").not(ignore||":lt(0)"),$Fs_vis=$Fs.filter(":visible"),$F=$Fs_vis.filter(":last");m={top:$C[0].offsetTop,height:$C.outerHeight(),numFooters:$Fs.length,hiddenFooters:$Fs.length-$Fs_vis.length,spaceBelow:0};m.spaceAbove=m.top;m.bottom=m.top+m.height;if($F.length){m.spaceBelow=($F[0].offsetTop+$F.outerHeight())-m.bottom+_below($F)}else{m.spaceBelow=_below($C)}}})},sizeHandles=function(evt_or_panes){var panes=evtPane.call(this,evt_or_panes);panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(i,pane){var o=options[pane],s=state[pane],$P=$Ps[pane],$R=$Rs[pane],$T=$Ts[pane],$TC;if(!$P||!$R){return}var dir=_c[pane].dir,_state=(s.isClosed?"_closed":"_open"),spacing=o["spacing"+_state],togAlign=o["togglerAlign"+_state],togLen=o["togglerLength"+_state],paneLen,left,offset,CSS={};if(spacing===0){$R.hide();return}else{if(!s.noRoom&&!s.isHidden){$R.show()}}if(dir==="horz"){paneLen=sC.innerWidth;s.resizerLength=paneLen;left=$.layout.cssNum($P,"left");$R.css({width:cssW($R,paneLen),height:cssH($R,spacing),left:left>-9999?left:sC.inset.left})}else{paneLen=$P.outerHeight();s.resizerLength=paneLen;$R.css({height:cssH($R,paneLen),width:cssW($R,spacing),top:sC.inset.top+getPaneSize("north",true)})}removeHover(o,$R);if($T){if(togLen===0||(s.isSliding&&o.hideTogglerOnSlide)){$T.hide();return}else{$T.show()}if(!(togLen>0)||togLen==="100%"||togLen>paneLen){togLen=paneLen;offset=0}else{if(isStr(togAlign)){switch(togAlign){case"top":case"left":offset=0;break;case"bottom":case"right":offset=paneLen-togLen;break;case"middle":case"center":default:offset=round((paneLen-togLen)/2)}}else{var x=parseInt(togAlign,10);if(togAlign>=0){offset=x -}else{offset=paneLen-togLen+x}}}if(dir==="horz"){var width=cssW($T,togLen);$T.css({width:width,height:cssH($T,spacing),left:offset,top:0})}else{var height=cssH($T,togLen);$T.css({height:height,width:cssW($T,spacing),top:offset,left:0});$T.children(".ui-content").each(function(){$TC=$(this);$TC.css("marginTop",round((height-$TC.outerHeight())/2))})}removeHover(0,$T)}if(!state.initialized&&(o.initHidden||s.isHidden)){$R.hide();if($T){$T.hide()}}})},enableClosable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$T=$Ts[pane],o=options[pane];if(!$T){return}o.closable=true;$T.bind("click."+sID,function(evt){evt.stopPropagation();toggle(pane)}).css("visibility","visible").css("cursor","pointer").attr("title",state[pane].isClosed?o.tips.Open:o.tips.Close).show()},disableClosable=function(evt_or_pane,hide){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$T=$Ts[pane];if(!$T){return}options[pane].closable=false;if(state[pane].isClosed){open(pane,false,true)}$T.unbind("."+sID).css("visibility",hide?"hidden":"visible").css("cursor","default").attr("title","")},enableSlidable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$R=$Rs[pane];if(!$R||!$R.data("draggable")){return}options[pane].slidable=true;if(state[pane].isClosed){bindStartSlidingEvents(pane,true)}},disableSlidable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$R=$Rs[pane];if(!$R){return}options[pane].slidable=false;if(state[pane].isSliding){close(pane,false,true)}else{bindStartSlidingEvents(pane,false);$R.css("cursor","default").attr("title","");removeHover(null,$R[0])}},enableResizable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$R=$Rs[pane],o=options[pane];if(!$R||!$R.data("draggable")){return}o.resizable=true;$R.draggable("enable");if(!state[pane].isClosed){$R.css("cursor",o.resizerCursor).attr("title",o.tips.Resize)}},disableResizable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$R=$Rs[pane];if(!$R||!$R.data("draggable")){return}options[pane].resizable=false;$R.draggable("disable").css("cursor","default").attr("title","");removeHover(null,$R[0])},swapPanes=function(evt_or_pane1,pane2){if(!isInitialized()){return}var pane1=evtPane.call(this,evt_or_pane1);state[pane1].edge=pane2;state[pane2].edge=pane1;if(false===_runCallbacks("onswap_start",pane1)||false===_runCallbacks("onswap_start",pane2)){state[pane1].edge=pane1;state[pane2].edge=pane2;return}var oPane1=copy(pane1),oPane2=copy(pane2),sizes={};sizes[pane1]=oPane1?oPane1.state.size:0;sizes[pane2]=oPane2?oPane2.state.size:0;$Ps[pane1]=false;$Ps[pane2]=false;state[pane1]={};state[pane2]={};if($Ts[pane1]){$Ts[pane1].remove()}if($Ts[pane2]){$Ts[pane2].remove()}if($Rs[pane1]){$Rs[pane1].remove()}if($Rs[pane2]){$Rs[pane2].remove()}$Rs[pane1]=$Rs[pane2]=$Ts[pane1]=$Ts[pane2]=false;move(oPane1,pane2);move(oPane2,pane1);oPane1=oPane2=sizes=null;if($Ps[pane1]){$Ps[pane1].css(_c.visible)}if($Ps[pane2]){$Ps[pane2].css(_c.visible)}resizeAll();_runCallbacks("onswap_end",pane1);_runCallbacks("onswap_end",pane2);return;function copy(n){var $P=$Ps[n],$C=$Cs[n];return !$P?false:{pane:n,P:$P?$P[0]:false,C:$C?$C[0]:false,state:$.extend(true,{},state[n]),options:$.extend(true,{},options[n])}}function move(oPane,pane){if(!oPane){return}var P=oPane.P,C=oPane.C,oldPane=oPane.pane,c=_c[pane],s=$.extend(true,{},state[pane]),o=options[pane],fx={resizerCursor:o.resizerCursor},re,size,pos;$.each("fxName,fxSpeed,fxSettings".split(","),function(i,k){fx[k+"_open"]=o[k+"_open"];fx[k+"_close"]=o[k+"_close"];fx[k+"_size"]=o[k+"_size"]});$Ps[pane]=$(P).data({layoutPane:Instance[pane],layoutEdge:pane}).css(_c.hidden).css(c.cssReq);$Cs[pane]=C?$(C):false;options[pane]=$.extend(true,{},oPane.options,fx);state[pane]=$.extend(true,{},oPane.state);re=new RegExp(o.paneClass+"-"+oldPane,"g");P.className=P.className.replace(re,o.paneClass+"-"+pane);initHandles(pane);if(c.dir!=_c[oldPane].dir){size=sizes[pane]||0;setSizeLimits(pane);size=max(size,state[pane].minSize);manualSizePane(pane,size,true,true)}else{$Rs[pane].css(c.side,sC.inset[c.side]+(state[pane].isVisible?getPaneSize(pane):0))}if(oPane.state.isVisible&&!s.isVisible){setAsOpen(pane,true)}else{setAsClosed(pane);bindStartSlidingEvents(pane,true)}oPane=null}},syncPinBtns=function(pane,doPin){if($.layout.plugins.buttons){$.each(state[pane].pins,function(i,selector){$.layout.buttons.setPinState(Instance,$(selector),pane,doPin)})}};function keyDown(evt){if(!evt){return true}var code=evt.keyCode;if(code<33){return true}var PANE={38:"north",40:"south",37:"west",39:"east"},ALT=evt.altKey,SHIFT=evt.shiftKey,CTRL=evt.ctrlKey,CURSOR=(CTRL&&code>=37&&code<=40),o,k,m,pane;if(CURSOR&&options[PANE[code]].enableCursorHotkey){pane=PANE[code]}else{if(CTRL||SHIFT){$.each(_c.borderPanes,function(i,p){o=options[p];k=o.customHotkey;m=o.customHotkeyModifier;if((SHIFT&&m=="SHIFT")||(CTRL&&m=="CTRL")||(CTRL&&SHIFT)){if(k&&code===(isNaN(k)||k<=9?k.toUpperCase().charCodeAt(0):k)){pane=p; -return false}}})}}if(!pane||!$Ps[pane]||!options[pane].closable||state[pane].isHidden){return true}toggle(pane);evt.stopPropagation();evt.returnValue=false;return false}function allowOverflow(el){if(!isInitialized()){return}if(this&&this.tagName){el=this}var $P;if(isStr(el)){$P=$Ps[el]}else{if($(el).data("layoutRole")){$P=$(el)}else{$(el).parents().each(function(){if($(this).data("layoutRole")){$P=$(this);return false}})}}if(!$P||!$P.length){return}var pane=$P.data("layoutEdge"),s=state[pane];if(s.cssSaved){resetOverflow(pane)}if(s.isSliding||s.isResizing||s.isClosed){s.cssSaved=false;return}var newCSS={zIndex:(options.zIndexes.resizer_normal+1)},curCSS={},of=$P.css("overflow"),ofX=$P.css("overflowX"),ofY=$P.css("overflowY");if(of!="visible"){curCSS.overflow=of;newCSS.overflow="visible"}if(ofX&&!ofX.match(/(visible|auto)/)){curCSS.overflowX=ofX;newCSS.overflowX="visible"}if(ofY&&!ofY.match(/(visible|auto)/)){curCSS.overflowY=ofX;newCSS.overflowY="visible"}s.cssSaved=curCSS;$P.css(newCSS);$.each(_c.allPanes,function(i,p){if(p!=pane){resetOverflow(p)}})}function resetOverflow(el){if(!isInitialized()){return}if(this&&this.tagName){el=this}var $P;if(isStr(el)){$P=$Ps[el]}else{if($(el).data("layoutRole")){$P=$(el)}else{$(el).parents().each(function(){if($(this).data("layoutRole")){$P=$(this);return false}})}}if(!$P||!$P.length){return}var pane=$P.data("layoutEdge"),s=state[pane],CSS=s.cssSaved||{};if(!s.isSliding&&!s.isResizing){$P.css("zIndex",options.zIndexes.pane_normal)}$P.css(CSS);s.cssSaved=false}var $N=$(this).eq(0);if(!$N.length){return _log(options.errors.containerMissing)}if($N.data("layoutContainer")&&$N.data("layout")){return $N.data("layout")}var $Ps={},$Cs={},$Rs={},$Ts={},$Ms=$([]),sC=state.container,sID=state.id;var Instance={options:options,state:state,container:$N,panes:$Ps,contents:$Cs,resizers:$Rs,togglers:$Ts,hide:hide,show:show,toggle:toggle,open:open,close:close,slideOpen:slideOpen,slideClose:slideClose,slideToggle:slideToggle,setSizeLimits:setSizeLimits,_sizePane:sizePane,sizePane:manualSizePane,sizeContent:sizeContent,swapPanes:swapPanes,showMasks:showMasks,hideMasks:hideMasks,initContent:initContent,addPane:addPane,removePane:removePane,createChildren:createChildren,refreshChildren:refreshChildren,enableClosable:enableClosable,disableClosable:disableClosable,enableSlidable:enableSlidable,disableSlidable:disableSlidable,enableResizable:enableResizable,disableResizable:disableResizable,allowOverflow:allowOverflow,resetOverflow:resetOverflow,destroy:destroy,initPanes:isInitialized,resizeAll:resizeAll,runCallbacks:_runCallbacks,hasParentLayout:false,children:children,north:false,south:false,west:false,east:false,center:false};if(_create()==="cancel"){return null}else{return Instance}}})(jQuery);(function($){if(!$.layout){return}if(!$.ui){$.ui={}}$.ui.cookie={acceptsCookies:!!navigator.cookieEnabled,read:function(name){var c=document.cookie,cs=c?c.split(";"):[],pair,data,i;for(i=0;pair=cs[i];i++){data=$.trim(pair).split("=");if(data[0]==name){return decodeURIComponent(data[1])}}return null},write:function(name,val,cookieOpts){var params="",date="",clear=false,o=cookieOpts||{},x=o.expires||null,t=$.type(x);if(t==="date"){date=x}else{if(t==="string"&&x>0){x=parseInt(x,10);t="number"}}if(t==="number"){date=new Date();if(x>0){date.setDate(date.getDate()+x)}else{date.setFullYear(1970);clear=true}}if(date){params+=";expires="+date.toUTCString()}if(o.path){params+=";path="+o.path}if(o.domain){params+=";domain="+o.domain}if(o.secure){params+=";secure"}document.cookie=name+"="+(clear?"":encodeURIComponent(val))+params},clear:function(name){$.ui.cookie.write(name,"",{expires:-1})}};if(!$.cookie){$.cookie=function(k,v,o){var C=$.ui.cookie;if(v===null){C.clear(k)}else{if(v===undefined){return C.read(k)}else{C.write(k,v,o)}}}}$.layout.plugins.stateManagement=true;$.layout.defaults.stateManagement={enabled:false,autoSave:true,autoLoad:true,animateLoad:true,includeChildren:true,stateKeys:"north.size,south.size,east.size,west.size,"+"north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+"north.isHidden,south.isHidden,east.isHidden,west.isHidden",cookie:{name:"",domain:"",path:"",expires:"",secure:false}};$.layout.optionsMap.layout.push("stateManagement");$.layout.config.optionRootKeys.push("stateManagement");$.layout.state={saveCookie:function(inst,keys,cookieOpts){var o=inst.options,sm=o.stateManagement,oC=$.extend(true,{},sm.cookie,cookieOpts||null),data=inst.state.stateData=inst.readState(keys||sm.stateKeys);$.ui.cookie.write(oC.name||o.name||"Layout",$.layout.state.encodeJSON(data),oC);return $.extend(true,{},data)},deleteCookie:function(inst){var o=inst.options;$.ui.cookie.clear(o.stateManagement.cookie.name||o.name||"Layout")},readCookie:function(inst){var o=inst.options;var c=$.ui.cookie.read(o.stateManagement.cookie.name||o.name||"Layout");return c?$.layout.state.decodeJSON(c):{}},loadCookie:function(inst){var c=$.layout.state.readCookie(inst);if(c&&!$.isEmptyObject(c)){inst.state.stateData=$.extend(true,{},c); -inst.loadState(c)}return c},loadState:function(inst,data,opts){if(!$.isPlainObject(data)||$.isEmptyObject(data)){return}data=inst.state.stateData=$.layout.transformData(data);var smo=inst.options.stateManagement;opts=$.extend({animateLoad:false,includeChildren:smo.includeChildren},opts);if(!inst.state.initialized){var o=$.extend(true,{},data);$.each($.layout.config.allPanes,function(idx,pane){if(o[pane]){delete o[pane].children}});$.extend(true,inst.options,o)}else{var noAnimate=!opts.animateLoad,o,c,h,state,open;$.each($.layout.config.borderPanes,function(idx,pane){o=data[pane];if(!$.isPlainObject(o)){return}s=o.size;c=o.initClosed;h=o.initHidden;ar=o.autoResize;state=inst.state[pane];open=state.isVisible;if(ar){state.autoResize=ar}if(!open){inst._sizePane(pane,s,false,false,false)}if(h===true){inst.hide(pane,noAnimate)}else{if(c===true){inst.close(pane,false,noAnimate)}else{if(c===false){inst.open(pane,false,noAnimate)}else{if(h===false){inst.show(pane,false,noAnimate)}}}}if(open){inst._sizePane(pane,s,false,false,noAnimate)}});if(opts.includeChildren){var paneStateChildren,childState;$.each(inst.children,function(pane,paneChildren){paneStateChildren=data[pane]?data[pane].children:0;if(paneStateChildren&&paneChildren){$.each(paneChildren,function(stateKey,child){childState=paneStateChildren[stateKey];if(child&&childState){child.loadState(childState)}})}})}}},readState:function(inst,opts){if($.type(opts)==="string"){opts={keys:opts}}if(!opts){opts={}}var sm=inst.options.stateManagement,ic=opts.includeChildren,recurse=ic!==undefined?ic:sm.includeChildren,keys=opts.stateKeys||sm.stateKeys,alt={isClosed:"initClosed",isHidden:"initHidden"},state=inst.state,panes=$.layout.config.allPanes,data={},pair,pane,key,val,ps,pC,child,array,count,branch;if($.isArray(keys)){keys=keys.join(",")}keys=keys.replace(/__/g,".").split(",");for(var i=0,n=keys.length;i=0){var btn=o[pane].buttonClass+"-"+action; -$E.addClass(btn+" "+btn+"-"+pane).data("layoutName",o.name)}return $E},bind:function(inst,sel,action,pane){var _=$.layout.buttons;switch(action.toLowerCase()){case"toggle":_.addToggle(inst,sel,pane);break;case"open":_.addOpen(inst,sel,pane);break;case"close":_.addClose(inst,sel,pane);break;case"pin":_.addPin(inst,sel,pane);break;case"toggle-slide":_.addToggle(inst,sel,pane,true);break;case"open-slide":_.addOpen(inst,sel,pane,true);break}return inst},addToggle:function(inst,selector,pane,slide){$.layout.buttons.get(inst,selector,pane,"toggle").click(function(evt){inst.toggle(pane,!!slide);evt.stopPropagation()});return inst},addOpen:function(inst,selector,pane,slide){$.layout.buttons.get(inst,selector,pane,"open").attr("title",inst.options[pane].tips.Open).click(function(evt){inst.open(pane,!!slide);evt.stopPropagation()});return inst},addClose:function(inst,selector,pane){$.layout.buttons.get(inst,selector,pane,"close").attr("title",inst.options[pane].tips.Close).click(function(evt){inst.close(pane);evt.stopPropagation()});return inst},addPin:function(inst,selector,pane){var $E=$.layout.buttons.get(inst,selector,pane,"pin");if($E.length){var s=inst.state[pane];$E.click(function(evt){$.layout.buttons.setPinState(inst,$(this),pane,(s.isSliding||s.isClosed));if(s.isSliding||s.isClosed){inst.open(pane)}else{inst.close(pane)}evt.stopPropagation()});$.layout.buttons.setPinState(inst,$E,pane,(!s.isClosed&&!s.isSliding));s.pins.push(selector)}return inst},setPinState:function(inst,$Pin,pane,doPin){var updown=$Pin.attr("pin");if(updown&&doPin===(updown=="down")){return}var po=inst.options[pane],lang=po.tips,pin=po.buttonClass+"-pin",side=pin+"-"+pane,UP=pin+"-up "+side+"-up",DN=pin+"-down "+side+"-down";$Pin.attr("pin",doPin?"down":"up").attr("title",doPin?lang.Unpin:lang.Pin).removeClass(doPin?UP:DN).addClass(doPin?DN:UP)},syncPinBtns:function(inst,pane,doPin){$.each(state[pane].pins,function(i,selector){$.layout.buttons.setPinState(inst,$(selector),pane,doPin)})},_load:function(inst){$.extend(inst,{bindButton:function(selector,action,pane){return $.layout.buttons.bind(inst,selector,action,pane)},addToggleBtn:function(selector,pane,slide){return $.layout.buttons.addToggle(inst,selector,pane,slide)},addOpenBtn:function(selector,pane,slide){return $.layout.buttons.addOpen(inst,selector,pane,slide)},addCloseBtn:function(selector,pane){return $.layout.buttons.addClose(inst,selector,pane)},addPinBtn:function(selector,pane){return $.layout.buttons.addPin(inst,selector,pane)}});for(var i=0;i<4;i++){var pane=$.layout.buttons.config.borderPanes[i];inst.state[pane].pins=[]}if(inst.options.autoBindCustomButtons){$.layout.buttons.init(inst)}},_unload:function(inst){}};$.layout.onLoad.push($.layout.buttons._load)})(jQuery);(function($){$.layout.plugins.browserZoom=true;$.layout.defaults.browserZoomCheckInterval=1000;$.layout.optionsMap.layout.push("browserZoomCheckInterval");$.layout.browserZoom={_init:function(inst){if($.layout.browserZoom.ratio()!==false){$.layout.browserZoom._setTimer(inst)}},_setTimer:function(inst){if(inst.destroyed){return}var o=inst.options,s=inst.state,ms=inst.hasParentLayout?5000:Math.max(o.browserZoomCheckInterval,100);setTimeout(function(){if(inst.destroyed||!o.resizeWithWindow){return}var d=$.layout.browserZoom.ratio();if(d!==s.browserZoom){s.browserZoom=d;inst.resizeAll()}$.layout.browserZoom._setTimer(inst)},ms)},ratio:function(){var w=window,s=screen,d=document,dE=d.documentElement||d.body,b=$.layout.browser,v=b.version,r,sW,cW;if(!b.msie||v>8){return false}if(s.deviceXDPI&&s.systemXDPI){return calc(s.deviceXDPI,s.systemXDPI)}if(b.webkit&&(r=d.body.getBoundingClientRect)){return calc((r.left-r.right),d.body.offsetWidth)}if(b.webkit&&(sW=w.outerWidth)){return calc(sW,w.innerWidth)}if((sW=s.width)&&(cW=dE.clientWidth)){return calc(sW,cW)}return false;function calc(x,y){return(parseInt(x,10)/parseInt(y,10)*100).toFixed()}}};$.layout.onReady.push($.layout.browserZoom._init)})(jQuery);(function($){if($.effects){$.layout.defaults.panes.useOffscreenClose=false;if($.layout.plugins){$.layout.plugins.effects.slideOffscreen=true}$.layout.effects.slideOffscreen=$.extend(true,{},$.layout.effects.slide);$.effects.slideOffscreen=function(o){return this.queue(function(){var fx=$.effects,opt=o.options,$el=$(this),pane=$el.data("layoutEdge"),state=$el.data("parentLayout").state,dist=state[pane].size,s=this.style,props=["top","bottom","left","right"],mode=fx.setMode($el,opt.mode||"show"),show=(mode=="show"),dir=opt.direction||"left",ref=(dir=="up"||dir=="down")?"top":"left",pos=(dir=="up"||dir=="left"),offscrn=$.layout.config.offscreenCSS||{},keyLR=$.layout.config.offscreenReset,keyTB="offscreenResetTop",animation={};animation[ref]=(show?(pos?"+=":"-="):(pos?"-=":"+="))+dist;if(show){$el.data(keyTB,{top:s.top,bottom:s.bottom});if(pos){$el.css(ref,isNaN(dist)?"-"+dist:-dist)}else{if(dir==="right"){$el.css({left:state.container.layoutWidth,right:"auto"})}else{$el.css({top:state.container.layoutHeight,bottom:"auto"})}}if(ref==="top"){$el.css($el.data(keyLR)||{}) +(function($){var min=Math.min,max=Math.max,round=Math.floor,isStr=function(v){return $.type(v)==="string"},runPluginCallbacks=function(Instance,a_fn){if($.isArray(a_fn)){for(var i=0,c=a_fn.length;i').appendTo("body"),d={width:$c.outerWidth-$c[0].clientWidth,height:100-$c[0].clientHeight};$c.remove();window.scrollbarWidth=d.width;window.scrollbarHeight=d.height;return dim.match(/^(width|height)$/)?d[dim]:d},disableTextSelection:function(){var $d=$(document),s="textSelectionDisabled",x="textSelectionInitialized";if($.fn.disableSelection){if(!$d.data(x)){$d.on("mouseup",$.layout.enableTextSelection).data(x,true)}if(!$d.data(s)){$d.disableSelection().data(s,true)}}},enableTextSelection:function(){var $d=$(document),s="textSelectionDisabled";if($.fn.enableSelection&&$d.data(s)){$d.enableSelection().data(s,false)}},showInvisibly:function($E,force){if($E&&$E.length&&(force||$E.css("display")==="none")){var s=$E[0].style,CSS={display:s.display||"",visibility:s.visibility||""};$E.css({display:"block",visibility:"hidden"});return CSS}return{}},getElementDimensions:function($E,inset){var d={css:{},inset:{}},x=d.css,i={bottom:0},N=$.layout.cssNum,R=Math.round,off=$E.offset(),b,p,ei;d.offsetLeft=off.left;d.offsetTop=off.top;if(!inset){inset={}}$.each("Left,Right,Top,Bottom".split(","),function(idx,e){b=x["border"+e]=$.layout.borderWidth($E,e);p=x["padding"+e]=$.layout.cssNum($E,"padding"+e); +ei=e.toLowerCase();d.inset[ei]=inset[ei]>=0?inset[ei]:p;i[ei]=d.inset[ei]+b});x.width=R($E.width());x.height=R($E.height());x.top=N($E,"top",true);x.bottom=N($E,"bottom",true);x.left=N($E,"left",true);x.right=N($E,"right",true);d.outerWidth=R($E.outerWidth());d.outerHeight=R($E.outerHeight());d.innerWidth=max(0,d.outerWidth-i.left-i.right);d.innerHeight=max(0,d.outerHeight-i.top-i.bottom);d.layoutWidth=R($E.innerWidth());d.layoutHeight=R($E.innerHeight());return d},getElementStyles:function($E,list){var CSS={},style=$E[0].style,props=list.split(","),sides="Top,Bottom,Left,Right".split(","),attrs="Color,Style,Width".split(","),p,s,a,i,j,k;for(i=0;i=L&&x<=R)&&(y>=T&&y<=B))},msg:function(info,popup,debugTitle,debugOpts){if($.isPlainObject(info)&&window.debugData){if(typeof popup==="string"){debugOpts=debugTitle;debugTitle=popup}else{if(typeof debugTitle==="object"){debugOpts=debugTitle;debugTitle=null}}var t=debugTitle||"log( )",o=$.extend({sort:false,returnHTML:false,display:false},debugOpts);if(popup===true||o.display){debugData(info,t,o)}else{if(window.console){console.log(debugData(info,t,o))}}}else{if(popup){alert(info)}else{if(window.console){console.log(info)}else{var id="#layoutLogger",$l=$(id);if(!$l.length){$l=createLog()}$l.children("ul").append('
    • '+info.replace(/\/g,">")+"
    • ")}}}function createLog(){var pos=$.support.fixedPosition?"fixed":"absolute",$e=$('
      '+'
      '+'XLayout console.log
      '+'
        '+"
        ").appendTo("body");$e.css("left",$(window).width()-$e.outerWidth()-5);if($.ui.draggable){$e.draggable({handle:":first-child"})}return $e}}};(function(){var u=navigator.userAgent.toLowerCase(),m=/(chrome)[ \/]([\w.]+)/.exec(u)||/(webkit)[ \/]([\w.]+)/.exec(u)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(u)||/(msie) ([\w.]+)/.exec(u)||u.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(u)||[],b=m[1]||"",v=m[2]||0,ie=b==="msie",cm=document.compatMode,$s=$.support,bs=$s.boxSizing!==undefined?$s.boxSizing:$s.boxSizingReliable,bm=!ie||!cm||cm==="CSS1Compat"||$s.boxModel||false,lb=$.layout.browser={version:v,safari:b==="webkit",webkit:b==="chrome",msie:ie,isIE6:ie&&v==6,boxModel:bm,boxSizing:!!(typeof bs==="function"?bs():bs)};if(b){lb[b]=true}if(!bm&&!cm){$(function(){lb.boxModel=$s.boxModel})}})();$.layout.defaults={name:"",containerClass:"ui-layout-container",inset:null,scrollToBookmarkOnLoad:true,resizeWithWindow:true,resizeWithWindowDelay:50,resizeWithWindowMaxDelay:0,maskPanesEarly:false,onresizeall_start:null,onresizeall_end:null,onload_start:null,onload_end:null,onunload_start:null,onunload_end:null,initPanes:true,showErrorMessages:true,showDebugMessages:false,zIndex:null,zIndexes:{pane_normal:0,content_mask:1,resizer_normal:2,pane_sliding:100,pane_animate:1000,resizer_drag:10000},errors:{pane:"pane",selector:"selector",addButtonError:"Error Adding Button\nInvalid ",containerMissing:"UI Layout Initialization Error\nThe specified layout-container does not exist.",centerPaneMissing:"UI Layout Initialization Error\nThe center-pane element does not exist.\nThe center-pane is a required element.",noContainerHeight:"UI Layout Initialization Warning\nThe layout-container \"CONTAINER\" has no height.\nTherefore the layout is 0-height and hence 'invisible'!",callbackError:"UI Layout Callback Error\nThe EVENT callback is not a valid function."},panes:{applyDemoStyles:false,closable:true,resizable:true,slidable:true,initClosed:false,initHidden:false,contentSelector:".ui-layout-content",contentIgnoreSelector:".ui-layout-ignore",findNestedContent:true,paneClass:"ui-layout-pane",resizerClass:"ui-layout-resizer",togglerClass:"ui-layout-toggler",buttonClass:"ui-layout-button",minSize:0,maxSize:0,spacing_open:8,spacing_closed:8,togglerLength_open:50,togglerLength_closed:50,togglerAlign_open:"center",togglerAlign_closed:"center",togglerContent_open:'',togglerContent_closed:'',resizerDblClickToggle:true,autoResize:true,autoReopen:true,resizerDragOpacity:1,maskContents:false,maskObjects:false,maskZindex:null,resizingGrid:false,livePaneResizing:false,liveContentResizing:false,liveResizingTolerance:1,sliderCursor:"pointer",slideTrigger_open:"mouseenter",slideTrigger_close:"mouseleave",slideDelay_open:100,slideDelay_close:500,hideTogglerOnSlide:false,preventQuickSlideClose:$.layout.browser.webkit,preventPrematureSlideClose:false,tips:{Open:"展开",Close:"折叠",Resize:"调整大小/双击折叠",Slide:"鼠标停留自动展开",Pin:"Pin",Unpin:"Un-Pin",noRoomToOpen:"Not enough room to show this panel.",minSizeWarning:"Panel has reached its minimum size",maxSizeWarning:"Panel has reached its maximum size"},showOverflowOnHover:false,enableCursorHotkey:true,customHotkeyModifier:"SHIFT",fxName:"slide",fxSpeed:null,fxSettings:{},fxOpacityFix:true,animatePaneSizing:false,children:null,containerSelector:"",initChildren:true,destroyChildren:true,resizeChildren:true,triggerEventsOnLoad:false,triggerEventsDuringLiveResize:true,onshow_start:null,onshow_end:null,onhide_start:null,onhide_end:null,onopen_start:null,onopen_end:null,onclose_start:null,onclose_end:null,onresize_start:null,onresize_end:null,onsizecontent_start:null,onsizecontent_end:null,onswap_start:null,onswap_end:null,ondrag_start:null,ondrag_end:null},north:{paneSelector:".ui-layout-north",size:"auto",resizerCursor:"n-resize",customHotkey:""},south:{paneSelector:".ui-layout-south",size:"auto",resizerCursor:"s-resize",customHotkey:""},east:{paneSelector:".ui-layout-east",size:200,resizerCursor:"e-resize",customHotkey:""},west:{paneSelector:".ui-layout-west",size:200,resizerCursor:"w-resize",customHotkey:""},center:{paneSelector:".ui-layout-center",minWidth:0,minHeight:0}}; +$.layout.optionsMap={layout:("name,instanceKey,stateManagement,effects,inset,zIndexes,errors,"+"zIndex,scrollToBookmarkOnLoad,showErrorMessages,maskPanesEarly,"+"outset,resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay,"+"onresizeall,onresizeall_start,onresizeall_end,onload,onload_start,onload_end,onunload,onunload_start,onunload_end").split(","),center:("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad,"+"showOverflowOnHover,maskContents,maskObjects,liveContentResizing,"+"containerSelector,children,initChildren,resizeChildren,destroyChildren,"+"onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(","),noDefault:("paneSelector,resizerCursor,customHotkey").split(",")};$.layout.transformData=function(hash,addKeys){var json=addKeys?{panes:{},center:{}}:{},branch,optKey,keys,key,val,i,c;if(typeof hash!=="object"){return json}for(optKey in hash){branch=json;val=hash[optKey];keys=optKey.split("__");c=keys.length-1;for(i=0;i<=c;i++){key=keys[i];if(i===c){if($.isPlainObject(val)){branch[key]=$.layout.transformData(val)}else{branch[key]=val}}else{if(!branch[key]){branch[key]={}}branch=branch[key]}}}return json};$.layout.backwardCompatibility={map:{applyDefaultStyles:"applyDemoStyles",childOptions:"children",initChildLayout:"initChildren",destroyChildLayout:"destroyChildren",resizeChildLayout:"resizeChildren",resizeNestedLayout:"resizeChildren",resizeWhileDragging:"livePaneResizing",resizeContentWhileDragging:"liveContentResizing",triggerEventsWhileDragging:"triggerEventsDuringLiveResize",maskIframesOnResize:"maskContents",useStateCookie:"stateManagement.enabled","cookie.autoLoad":"stateManagement.autoLoad","cookie.autoSave":"stateManagement.autoSave","cookie.keys":"stateManagement.stateKeys","cookie.name":"stateManagement.cookie.name","cookie.domain":"stateManagement.cookie.domain","cookie.path":"stateManagement.cookie.path","cookie.expires":"stateManagement.cookie.expires","cookie.secure":"stateManagement.cookie.secure",noRoomToOpenTip:"tips.noRoomToOpen",togglerTip_open:"tips.Close",togglerTip_closed:"tips.Open",resizerTip:"tips.Resize",sliderTip:"tips.Slide"},renameOptions:function(opts){var map=$.layout.backwardCompatibility.map,oldData,newData,value;for(var itemPath in map){oldData=getBranch(itemPath);value=oldData.branch[oldData.key];if(value!==undefined){newData=getBranch(map[itemPath],true);newData.branch[newData.key]=value;delete oldData.branch[oldData.key]}}function getBranch(path,create){var a=path.split("."),c=a.length-1,D={branch:opts,key:a[c]},i=0,k,undef;for(;i0){if(autoHide&&$E.data("autoHidden")&&$E.innerHeight()>0){$E.show().data("autoHidden",false);if(!browser.mozilla){$E.css(_c.hidden).css(_c.visible)}}}else{if(autoHide&&!$E.data("autoHidden")){$E.hide().data("autoHidden",true)}}},setOuterHeight=function(el,outerHeight,autoHide){var $E=el,h;if(isStr(el)){$E=$Ps[el]}else{if(!el.jquery){$E=$(el)}}h=cssH($E,outerHeight);$E.css({height:h,visibility:"visible"});if(h>0&&$E.innerWidth()>0){if(autoHide&&$E.data("autoHidden")){$E.show().data("autoHidden",false);if(!browser.mozilla){$E.css(_c.hidden).css(_c.visible)}}}else{if(autoHide&&!$E.data("autoHidden")){$E.hide().data("autoHidden",true)}}},_parseSize=function(pane,size,dir){if(!dir){dir=_c[pane].dir}if(isStr(size)&&size.match(/%/)){size=(size==="100%")?-1:parseInt(size,10)/100}if(size===0){return 0}else{if(size>=1){return parseInt(size,10)}}var o=options,avail=0;if(dir=="horz"){avail=sC.innerHeight-($Ps.north?o.north.spacing_open:0)-($Ps.south?o.south.spacing_open:0)}else{if(dir=="vert"){avail=sC.innerWidth-($Ps.west?o.west.spacing_open:0)-($Ps.east?o.east.spacing_open:0)}}if(size===-1){return avail}else{if(size>0){return round(avail*size)}else{if(pane=="center"){return 0}else{var dim=(dir==="horz"?"height":"width"),$P=$Ps[pane],$C=dim==="height"?$Cs[pane]:false,vis=$.layout.showInvisibly($P),szP=$P.css(dim),szC=$C?$C.css(dim):0;$P.css(dim,"auto");if($C){$C.css(dim,"auto")}size=(dim==="height")?$P.outerHeight():$P.outerWidth();$P.css(dim,szP).css(vis);if($C){$C.css(dim,szC)}return size}}}},getPaneSize=function(pane,inclSpace){var $P=$Ps[pane],o=options[pane],s=state[pane],oSp=(inclSpace?o.spacing_open:0),cSp=(inclSpace?o.spacing_closed:0);if(!$P||s.isHidden){return 0}else{if(s.isClosed||(s.isSliding&&inclSpace)){return cSp}else{if(_c[pane].dir==="horz"){return $P.outerHeight()+oSp}else{return $P.outerWidth()+oSp}}}},setSizeLimits=function(pane,slide){if(!isInitialized()){return}var o=options[pane],s=state[pane],c=_c[pane],dir=c.dir,type=c.sizeType.toLowerCase(),isSliding=(slide!=undefined?slide:s.isSliding),$P=$Ps[pane],paneSpacing=o.spacing_open,altPane=_c.oppositeEdge[pane],altS=state[altPane],$altP=$Ps[altPane],altPaneSize=(!$altP||altS.isVisible===false||altS.isSliding?0:(dir=="horz"?$altP.outerHeight():$altP.outerWidth())),altPaneSpacing=((!$altP||altS.isHidden?0:options[altPane][altS.isClosed!==false?"spacing_closed":"spacing_open"])||0),containerSize=(dir=="horz"?sC.innerHeight:sC.innerWidth),minCenterDims=cssMinDims("center"),minCenterSize=dir=="horz"?max(options.center.minHeight,minCenterDims.minHeight):max(options.center.minWidth,minCenterDims.minWidth),limitSize=(containerSize-paneSpacing-(isSliding?0:(_parseSize("center",minCenterSize,dir)+altPaneSize+altPaneSpacing))),minSize=s.minSize=max(_parseSize(pane,o.minSize),cssMinDims(pane).minSize),maxSize=s.maxSize=min((o.maxSize?_parseSize(pane,o.maxSize):100000),limitSize),r=s.resizerPosition={},top=sC.inset.top,left=sC.inset.left,W=sC.innerWidth,H=sC.innerHeight,rW=o.spacing_open;switch(pane){case"north":r.min=top+minSize;r.max=top+maxSize;break;case"west":r.min=left+minSize;r.max=left+maxSize;break;case"south":r.min=top+H-maxSize-rW;r.max=top+H-minSize-rW;break;case"east":r.min=left+W-maxSize-rW;r.max=left+W-minSize-rW;break}},calcNewCenterPaneDims=function(){var d={top:getPaneSize("north",true),bottom:getPaneSize("south",true),left:getPaneSize("west",true),right:getPaneSize("east",true),width:0,height:0};d.width=sC.innerWidth-d.left-d.right;d.height=sC.innerHeight-d.bottom-d.top;d.top+=sC.inset.top;d.bottom+=sC.inset.bottom;d.left+=sC.inset.left;d.right+=sC.inset.right;return d},getHoverClasses=function(el,allStates){var $El=$(el),type=$El.data("layoutRole"),pane=$El.data("layoutEdge"),o=options[pane],root=o[type+"Class"],_pane="-"+pane,_open="-open",_closed="-closed",_slide="-sliding",_hover="-hover ",_state=$El.hasClass(root+_closed)?_closed:_open,_alt=_state===_closed?_open:_closed,classes=(root+_hover)+(root+_pane+_hover)+(root+_state+_hover)+(root+_pane+_state+_hover); +if(allStates){classes+=(root+_alt+_hover)+(root+_pane+_alt+_hover)}if(type=="resizer"&&$El.hasClass(root+_slide)){classes+=(root+_slide+_hover)+(root+_pane+_slide+_hover)}return $.trim(classes)},addHover=function(evt,el){var $E=$(el||this);if(evt&&$E.data("layoutRole")==="toggler"){evt.stopPropagation()}$E.addClass(getHoverClasses($E))},removeHover=function(evt,el){var $E=$(el||this);$E.removeClass(getHoverClasses($E,true))},onResizerEnter=function(evt){var pane=$(this).data("layoutEdge"),s=state[pane],$d=$(document);if(s.isResizing||state.paneResizing){return}if(options.maskPanesEarly){showMasks(pane,{resizing:true})}},onResizerLeave=function(evt,el){var e=el||this,pane=$(e).data("layoutEdge"),name=pane+"ResizerLeave",$d=$(document);timer.clear(pane+"_openSlider");timer.clear(name);if(!el){timer.set(name,function(){onResizerLeave(evt,e)},200)}else{if(options.maskPanesEarly&&!state.paneResizing){hideMasks()}}},_create=function(){initOptions();var o=options,s=state;s.creatingLayout=true;runPluginCallbacks(Instance,$.layout.onCreate);if(false===_runCallbacks("onload_start")){return"cancel"}_initContainer();initHotkeys();$(window).bind("unload."+sID,unload);runPluginCallbacks(Instance,$.layout.onLoad);if(o.initPanes){_initLayoutElements()}delete s.creatingLayout;return state.initialized},isInitialized=function(){if(state.initialized||state.creatingLayout){return true}else{return _initLayoutElements()}},_initLayoutElements=function(retry){var o=options;if(!$N.is(":visible")){if(!retry&&browser.webkit&&$N[0].tagName==="BODY"){setTimeout(function(){_initLayoutElements(true)},50)}return false}if(!getPane("center").length){return _log(o.errors.centerPaneMissing)}state.creatingLayout=true;$.extend(sC,elDims($N,o.inset));initPanes();if(o.scrollToBookmarkOnLoad){var l=self.location;if(l.hash){l.replace(l.hash)}}if(Instance.hasParentLayout){o.resizeWithWindow=false}else{if(o.resizeWithWindow){$(window).bind("resize."+sID,windowResize)}}delete state.creatingLayout;state.initialized=true;runPluginCallbacks(Instance,$.layout.onReady);_runCallbacks("onload_end");return true},createChildren=function(evt_or_pane,opts){var pane=evtPane.call(this,evt_or_pane),$P=$Ps[pane];if(!$P){return}var $C=$Cs[pane],s=state[pane],o=options[pane],sm=options.stateManagement||{},cos=opts?(o.children=opts):o.children;if($.isPlainObject(cos)){cos=[cos]}else{if(!cos||!$.isArray(cos)){return}}$.each(cos,function(idx,co){if(!$.isPlainObject(co)){return}var $containers=co.containerSelector?$P.find(co.containerSelector):($C||$P);$containers.each(function(){var $cont=$(this),child=$cont.data("layout");if(!child){setInstanceKey({container:$cont,options:co},s);if(sm.includeChildren&&state.stateData[pane]){var paneChildren=state.stateData[pane].children||{},childState=paneChildren[co.instanceKey],co_sm=co.stateManagement||(co.stateManagement={autoLoad:true});if(co_sm.autoLoad===true&&childState){co_sm.autoSave=false;co_sm.includeChildren=true;co_sm.autoLoad=$.extend(true,{},childState)}}child=$cont.layout(co);if(child){refreshChildren(pane,child)}}})})},setInstanceKey=function(child,parentPaneState){var $c=child.container,o=child.options,sm=o.stateManagement,key=o.instanceKey||$c.data("layoutInstanceKey");if(!key){key=(sm&&sm.cookie?sm.cookie.name:"")||o.name}if(!key){key="layout"+(++parentPaneState.childIdx)}else{key=key.replace(/[^\w-]/gi,"_").replace(/_{2,}/g,"_")}o.instanceKey=key;$c.data("layoutInstanceKey",key);return key},refreshChildren=function(pane,newChild){var $P=$Ps[pane],pC=children[pane],s=state[pane],o;if($.isPlainObject(pC)){$.each(pC,function(key,child){if(child.destroyed){delete pC[key]}});if($.isEmptyObject(pC)){pC=children[pane]=null}}if(!newChild&&!pC){newChild=$P.data("layout")}if(newChild){newChild.hasParentLayout=true;o=newChild.options;setInstanceKey(newChild,s);if(!pC){pC=children[pane]={}}pC[o.instanceKey]=newChild.container.data("layout")}Instance[pane].children=children[pane];if(!newChild){createChildren(pane)}},windowResize=function(){var o=options,delay=Number(o.resizeWithWindowDelay);if(delay<10){delay=100}timer.clear("winResize");timer.set("winResize",function(){timer.clear("winResize");timer.clear("winResizeRepeater");var dims=elDims($N,o.inset);if(dims.innerWidth!==sC.innerWidth||dims.innerHeight!==sC.innerHeight){resizeAll()}},delay);if(!timer.data["winResizeRepeater"]){setWindowResizeRepeater()}},setWindowResizeRepeater=function(){var delay=Number(options.resizeWithWindowMaxDelay);if(delay>0){timer.set("winResizeRepeater",function(){setWindowResizeRepeater();resizeAll()},delay)}},unload=function(){var o=options;_runCallbacks("onunload_start");runPluginCallbacks(Instance,$.layout.onUnload);_runCallbacks("onunload_end")},_initContainer=function(){var N=$N[0],$H=$("html"),tag=sC.tagName=N.tagName,id=sC.id=N.id,cls=sC.className=N.className,o=options,name=o.name,props="position,margin,padding,border",css="layoutCSS",CSS={},hid="hidden",parent=$N.data("parentLayout"),pane=$N.data("layoutEdge"),isChild=parent&&pane,num=$.layout.cssNum,$parent,n; +sC.selector=$N.selector.split(".slice")[0];sC.ref=(o.name?o.name+" layout / ":"")+tag+(id?"#"+id:cls?".["+cls+"]":"");sC.isBody=(tag==="BODY");if(!isChild&&!sC.isBody){$parent=$N.closest("."+$.layout.defaults.panes.paneClass);parent=$parent.data("parentLayout");pane=$parent.data("layoutEdge");isChild=parent&&pane}$N.data({layout:Instance,layoutContainer:sID}).addClass(o.containerClass);var layoutMethods={destroy:"",initPanes:"",resizeAll:"resizeAll",resize:"resizeAll"};for(name in layoutMethods){$N.bind("layout"+name.toLowerCase()+"."+sID,Instance[layoutMethods[name]||name])}if(isChild){Instance.hasParentLayout=true;parent.refreshChildren(pane,Instance)}if(!$N.data(css)){if(sC.isBody){$N.data(css,$.extend(styles($N,props),{height:$N.css("height"),overflow:$N.css("overflow"),overflowX:$N.css("overflowX"),overflowY:$N.css("overflowY")}));$H.data(css,$.extend(styles($H,"padding"),{height:"auto",overflow:$H.css("overflow"),overflowX:$H.css("overflowX"),overflowY:$H.css("overflowY")}))}else{$N.data(css,styles($N,props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY"))}}try{CSS={overflow:hid,overflowX:hid,overflowY:hid};$N.css(CSS);if(o.inset&&!$.isPlainObject(o.inset)){n=parseInt(o.inset,10)||0;o.inset={top:n,bottom:n,left:n,right:n}}if(sC.isBody){if(!o.outset){o.outset={top:num($H,"paddingTop"),bottom:num($H,"paddingBottom"),left:num($H,"paddingLeft"),right:num($H,"paddingRight")}}else{if(!$.isPlainObject(o.outset)){n=parseInt(o.outset,10)||0;o.outset={top:n,bottom:n,left:n,right:n}}}$H.css(CSS).css({height:"100%",border:"none",padding:0,margin:0});if(browser.isIE6){$N.css({width:"100%",height:"100%",border:"none",padding:0,margin:0,position:"relative"});if(!o.inset){o.inset=elDims($N).inset}}else{$N.css({width:"auto",height:"auto",margin:0,position:"absolute"});$N.css(o.outset)}$.extend(sC,elDims($N,o.inset))}else{var p=$N.css("position");if(!p||!p.match(/(fixed|absolute|relative)/)){$N.css("position","relative")}if($N.is(":visible")){$.extend(sC,elDims($N,o.inset));if(sC.innerHeight<1){_log(o.errors.noContainerHeight.replace(/CONTAINER/,sC.ref))}}}if(num($N,"minWidth")){$N.parent().css("overflowX","auto")}if(num($N,"minHeight")){$N.parent().css("overflowY","auto")}}catch(ex){}},initHotkeys=function(panes){panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(i,pane){var o=options[pane];if(o.enableCursorHotkey||o.customHotkey){$(document).bind("keydown."+sID,keyDown);return false}})},initOptions=function(){var data,d,pane,key,val,i,c,o;opts=$.layout.transformData(opts,true);opts=$.layout.backwardCompatibility.renameAllOptions(opts);if(!$.isEmptyObject(opts.panes)){data=$.layout.optionsMap.noDefault;for(i=0,c=data.length;i0){z.pane_normal=zo;z.content_mask=max(zo+1,z.content_mask);z.resizer_normal=max(zo+2,z.resizer_normal)}delete options.panes;function createFxOptions(pane){var o=options[pane],d=options.panes;if(!o.fxSettings){o.fxSettings={}}if(!d.fxSettings){d.fxSettings={}}$.each(["_open","_close","_size"],function(i,n){var sName="fxName"+n,sSpeed="fxSpeed"+n,sSettings="fxSettings"+n,fxName=o[sName]=o[sName]||d[sName]||o.fxName||d.fxName||"none",fxExists=$.effects&&($.effects[fxName]||($.effects.effect&&$.effects.effect[fxName]));if(fxName==="none"||!options.effects[fxName]||!fxExists){fxName=o[sName]="none"}var fx=options.effects[fxName]||{},fx_all=fx.all||null,fx_pane=fx[pane]||null;o[sSpeed]=o[sSpeed]||d[sSpeed]||o.fxSpeed||d.fxSpeed||null;o[sSettings]=$.extend(true,{},fx_all,fx_pane,d.fxSettings,o.fxSettings,d[sSettings],o[sSettings])});delete o.fxName;delete o.fxSpeed;delete o.fxSettings}},getPane=function(pane){var sel=options[pane].paneSelector;if(sel.substr(0,1)==="#"){return $N.find(sel).eq(0)}else{var $P=$N.children(sel).eq(0);return $P.length?$P:$N.children("form:first").children(sel).eq(0)}},initPanes=function(evt){evtPane(evt);$.each(_c.allPanes,function(idx,pane){addPane(pane,true)});initHandles();$.each(_c.borderPanes,function(i,pane){if($Ps[pane]&&state[pane].isVisible){setSizeLimits(pane);makePaneFit(pane) +}});sizeMidPanes("center");$.each(_c.allPanes,function(idx,pane){afterInitPane(pane)})},addPane=function(pane,force){if(!force&&!isInitialized()){return}var o=options[pane],s=state[pane],c=_c[pane],dir=c.dir,fx=s.fx,spacing=o.spacing_open||0,isCenter=(pane==="center"),CSS={},$P=$Ps[pane],size,minSize,maxSize,child;if($P){removePane(pane,false,true,false)}else{$Cs[pane]=false}$P=$Ps[pane]=getPane(pane);if(!$P.length){$Ps[pane]=false;return}if(!$P.data("layoutCSS")){var props="position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border";$P.data("layoutCSS",styles($P,props))}Instance[pane]={name:pane,pane:$Ps[pane],content:$Cs[pane],options:options[pane],state:state[pane],children:children[pane]};$P.data({parentLayout:Instance,layoutPane:Instance[pane],layoutEdge:pane,layoutRole:"pane"}).css(c.cssReq).css("zIndex",options.zIndexes.pane_normal).css(o.applyDemoStyles?c.cssDemo:{}).addClass(o.paneClass+" "+o.paneClass+"-"+pane).bind("mouseenter."+sID,addHover).bind("mouseleave."+sID,removeHover);var paneMethods={hide:"",show:"",toggle:"",close:"",open:"",slideOpen:"",slideClose:"",slideToggle:"",size:"sizePane",sizePane:"sizePane",sizeContent:"",sizeHandles:"",enableClosable:"",disableClosable:"",enableSlideable:"",disableSlideable:"",enableResizable:"",disableResizable:"",swapPanes:"swapPanes",swap:"swapPanes",move:"swapPanes",removePane:"removePane",remove:"removePane",createChildren:"",resizeChildren:"",resizeAll:"resizeAll",resizeLayout:"resizeAll"},name;for(name in paneMethods){$P.bind("layoutpane"+name.toLowerCase()+"."+sID,Instance[paneMethods[name]||name])}initContent(pane,false);if(!isCenter){size=s.size=_parseSize(pane,o.size);minSize=_parseSize(pane,o.minSize)||1;maxSize=_parseSize(pane,o.maxSize)||100000;if(size>0){size=max(min(size,maxSize),minSize)}s.autoResize=o.autoResize;s.isClosed=false;s.isSliding=false;s.isResizing=false;s.isHidden=false;if(!s.pins){s.pins=[]}}s.tagName=$P[0].tagName;s.edge=pane;s.noRoom=false;s.isVisible=true;setPanePosition(pane);if(dir==="horz"){CSS.height=cssH($P,size)}else{if(dir==="vert"){CSS.width=cssW($P,size)}}$P.css(CSS);if(dir!="horz"){sizeMidPanes(pane,true)}if(state.initialized){initHandles(pane);initHotkeys(pane)}if(o.initClosed&&o.closable&&!o.initHidden){close(pane,true,true)}else{if(o.initHidden||o.initClosed){hide(pane)}else{if(!s.noRoom){$P.css("display","block")}}}$P.css("visibility","visible");if(o.showOverflowOnHover){$P.hover(allowOverflow,resetOverflow)}if(state.initialized){afterInitPane(pane)}},afterInitPane=function(pane){var $P=$Ps[pane],s=state[pane],o=options[pane];if(!$P){return}if($P.data("layout")){refreshChildren(pane,$P.data("layout"))}if(s.isVisible){if(state.initialized){resizeAll()}else{sizeContent(pane)}if(o.triggerEventsOnLoad){_runCallbacks("onresize_end",pane)}else{resizeChildren(pane,true)}}if(o.initChildren&&o.children){createChildren(pane)}},setPanePosition=function(panes){panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(i,pane){var $P=$Ps[pane],$R=$Rs[pane],o=options[pane],s=state[pane],side=_c[pane].side,CSS={};if(!$P){return}switch(pane){case"north":CSS.top=sC.inset.top;CSS.left=sC.inset.left;CSS.right=sC.inset.right;break;case"south":CSS.bottom=sC.inset.bottom;CSS.left=sC.inset.left;CSS.right=sC.inset.right;break;case"west":CSS.left=sC.inset.left;break;case"east":CSS.right=sC.inset.right;break;case"center":}$P.css(CSS);if($R&&s.isClosed){$R.css(side,sC.inset[side])}else{if($R&&!s.isHidden){$R.css(side,sC.inset[side]+getPaneSize(pane))}}})},initHandles=function(panes){panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(i,pane){var $P=$Ps[pane];$Rs[pane]=false;$Ts[pane]=false;if(!$P){return}var o=options[pane],s=state[pane],c=_c[pane],paneId=o.paneSelector.substr(0,1)==="#"?o.paneSelector.substr(1):"",rClass=o.resizerClass,tClass=o.togglerClass,spacing=(s.isVisible?o.spacing_open:o.spacing_closed),_pane="-"+pane,_state=(s.isVisible?"-open":"-closed"),I=Instance[pane],$R=I.resizer=$Rs[pane]=$("
        "),$T=I.toggler=(o.closable?$Ts[pane]=$("
        "):false);if(!s.isVisible&&o.slidable){$R.attr("title",o.tips.Slide).css("cursor",o.sliderCursor)}$R.attr("id",paneId?paneId+"-resizer":"").data({parentLayout:Instance,layoutPane:Instance[pane],layoutEdge:pane,layoutRole:"resizer"}).css(_c.resizers.cssReq).css("zIndex",options.zIndexes.resizer_normal).css(o.applyDemoStyles?_c.resizers.cssDemo:{}).addClass(rClass+" "+rClass+_pane).hover(addHover,removeHover).hover(onResizerEnter,onResizerLeave).mousedown($.layout.disableTextSelection).mouseup($.layout.enableTextSelection).appendTo($N);if($.fn.disableSelection){$R.disableSelection()}if(o.resizerDblClickToggle){$R.bind("dblclick."+sID,toggle)}if($T){$T.attr("id",paneId?paneId+"-toggler":"").data({parentLayout:Instance,layoutPane:Instance[pane],layoutEdge:pane,layoutRole:"toggler"}).css(_c.togglers.cssReq).css(o.applyDemoStyles?_c.togglers.cssDemo:{}).addClass(tClass+" "+tClass+_pane).hover(addHover,removeHover).bind("mouseenter",onResizerEnter).appendTo($R); +if(o.togglerContent_open){$(""+o.togglerContent_open+"").data({layoutEdge:pane,layoutRole:"togglerContent"}).data("layoutRole","togglerContent").data("layoutEdge",pane).addClass("ui-content content-open").css("display","none").appendTo($T)}if(o.togglerContent_closed){$(""+o.togglerContent_closed+"").data({layoutEdge:pane,layoutRole:"togglerContent"}).addClass("ui-content content-closed").css("display","none").appendTo($T)}enableClosable(pane)}initResizable(pane);if(s.isVisible){setAsOpen(pane)}else{setAsClosed(pane);bindStartSlidingEvents(pane,true)}});sizeHandles()},initContent=function(pane,resize){if(!isInitialized()){return}var o=options[pane],sel=o.contentSelector,I=Instance[pane],$P=$Ps[pane],$C;if(sel){$C=I.content=$Cs[pane]=(o.findNestedContent)?$P.find(sel).eq(0):$P.children(sel).eq(0)}if($C&&$C.length){$C.data("layoutRole","content");if(!$C.data("layoutCSS")){$C.data("layoutCSS",styles($C,"height"))}$C.css(_c.content.cssReq);if(o.applyDemoStyles){$C.css(_c.content.cssDemo);$P.css(_c.content.cssDemoPane)}if($P.css("overflowX").match(/(scroll|auto)/)){$P.css("overflow","hidden")}state[pane].content={};if(resize!==false){sizeContent(pane)}}else{I.content=$Cs[pane]=false}},initResizable=function(panes){var draggingAvailable=$.layout.plugins.draggable,side;panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(idx,pane){var o=options[pane];if(!draggingAvailable||!$Ps[pane]||!o.resizable){o.resizable=false;return true}var s=state[pane],z=options.zIndexes,c=_c[pane],side=c.dir=="horz"?"top":"left",$P=$Ps[pane],$R=$Rs[pane],base=o.resizerClass,lastPos=0,r,live,resizerClass=base+"-drag",resizerPaneClass=base+"-"+pane+"-drag",helperClass=base+"-dragging",helperPaneClass=base+"-"+pane+"-dragging",helperLimitClass=base+"-dragging-limit",helperPaneLimitClass=base+"-"+pane+"-dragging-limit",helperClassesSet=false;if(!s.isClosed){$R.attr("title",o.tips.Resize).css("cursor",o.resizerCursor)}$R.draggable({containment:$N[0],axis:(c.dir=="horz"?"y":"x"),delay:0,distance:1,grid:o.resizingGrid,helper:"clone",opacity:o.resizerDragOpacity,addClasses:false,zIndex:z.resizer_drag,iframeFix:true,start:function(e,ui){o=options[pane];s=state[pane];live=o.livePaneResizing;if(false===_runCallbacks("ondrag_start",pane)){return false}s.isResizing=true;state.paneResizing=pane;timer.clear(pane+"_closeSlider");setSizeLimits(pane);r=s.resizerPosition;lastPos=ui.position[side];$R.addClass(resizerClass+" "+resizerPaneClass);helperClassesSet=false;showMasks(pane,{resizing:true})},drag:function(e,ui){if(!helperClassesSet){ui.helper.addClass(helperClass+" "+helperPaneClass).css({right:"auto",bottom:"auto"}).children().css("visibility","hidden");helperClassesSet=true;if(s.isSliding){$Ps[pane].css("zIndex",z.pane_sliding)}}var limit=0;if(ui.position[side]r.max){ui.position[side]=r.max;limit=1}}if(limit){ui.helper.addClass(helperLimitClass+" "+helperPaneLimitClass);window.defaultStatus=(limit>0&&pane.match(/(north|west)/))||(limit<0&&pane.match(/(south|east)/))?o.tips.maxSizeWarning:o.tips.minSizeWarning}else{ui.helper.removeClass(helperLimitClass+" "+helperPaneLimitClass);window.defaultStatus=""}if(live&&Math.abs(ui.position[side]-lastPos)>=o.liveResizingTolerance){lastPos=ui.position[side];resizePanes(e,ui,pane)}},stop:function(e,ui){$("body").enableSelection();window.defaultStatus="";$R.removeClass(resizerClass+" "+resizerPaneClass);s.isResizing=false;state.paneResizing=false;resizePanes(e,ui,pane,true)}})});var resizePanes=function(evt,ui,pane,resizingDone){var dragPos=ui.position,c=_c[pane],o=options[pane],s=state[pane],resizerPos;switch(pane){case"north":resizerPos=dragPos.top;break;case"west":resizerPos=dragPos.left;break;case"south":resizerPos=sC.layoutHeight-dragPos.top-o.spacing_open;break;case"east":resizerPos=sC.layoutWidth-dragPos.left-o.spacing_open;break}var newSize=resizerPos-sC.inset[c.side];if(!resizingDone){if(Math.abs(newSize-s.size)=0;i--){$M=$Ms.eq(i);p=$M.data("layoutMask");if(!options[p].maskObjects){$M.hide()}}}}},getMasks=function(pane){var $Masks=$([]),$M,i=0,c=$Ms.length;for(;is.maxSize){syncPinBtns(pane,false);if(!noAlert&&o.tips.noRoomToOpen){alert(o.tips.noRoomToOpen)}return queueNext()}if(slide){bindStopSlidingEvents(pane,true)}else{if(s.isSliding){bindStopSlidingEvents(pane,false)}else{if(o.slidable){bindStartSlidingEvents(pane,false)}}}s.noRoom=false;makePaneFit(pane);isShowing=s.isShowing;delete s.isShowing;doFX=!noAnimation&&s.isClosed&&(o.fxName_open!="none");s.isMoving=true;s.isVisible=true;s.isClosed=false;if(isShowing){s.isHidden=false}if(doFX){lockPaneForFX(pane,true);$P.show(o.fxName_open,o.fxSettings_open,o.fxSpeed_open,function(){lockPaneForFX(pane,false);if(s.isVisible){open_2()}queueNext()})}else{_showPane(pane);open_2();queueNext()}});function open_2(){s.isMoving=false;_fixIframe(pane);if(!s.isSliding){sizeMidPanes(_c[pane].dir=="vert"?"center":"",false)}setAsOpen(pane)}},setAsOpen=function(pane,skipCallback){var $P=$Ps[pane],$R=$Rs[pane],$T=$Ts[pane],o=options[pane],s=state[pane],side=_c[pane].side,rClass=o.resizerClass,tClass=o.togglerClass,_pane="-"+pane,_open="-open",_closed="-closed",_sliding="-sliding";$R.css(side,sC.inset[side]+getPaneSize(pane)).removeClass(rClass+_closed+" "+rClass+_pane+_closed).addClass(rClass+_open+" "+rClass+_pane+_open); +if(s.isSliding){$R.addClass(rClass+_sliding+" "+rClass+_pane+_sliding)}else{$R.removeClass(rClass+_sliding+" "+rClass+_pane+_sliding)}removeHover(0,$R);if(o.resizable&&$.layout.plugins.draggable){$R.draggable("enable").css("cursor",o.resizerCursor).attr("title",o.tips.Resize)}else{if(!s.isSliding){$R.css("cursor","default")}}if($T){$T.removeClass(tClass+_closed+" "+tClass+_pane+_closed).addClass(tClass+_open+" "+tClass+_pane+_open).attr("title",o.tips.Close);removeHover(0,$T);$T.children(".content-closed").hide();$T.children(".content-open").css("display","block")}syncPinBtns(pane,!s.isSliding);$.extend(s,elDims($P));if(state.initialized){sizeHandles();sizeContent(pane,true)}if(!skipCallback&&(state.initialized||o.triggerEventsOnLoad)&&$P.is(":visible")){_runCallbacks("onopen_end",pane);if(s.isShowing){_runCallbacks("onshow_end",pane)}if(state.initialized){_runCallbacks("onresize_end",pane)}}},slideOpen=function(evt_or_pane){if(!isInitialized()){return}var evt=evtObj(evt_or_pane),pane=evtPane.call(this,evt_or_pane),s=state[pane],delay=options[pane].slideDelay_open;if(pane==="center"){return}if(evt){evt.stopImmediatePropagation()}if(s.isClosed&&evt&&evt.type==="mouseenter"&&delay>0){timer.set(pane+"_openSlider",open_NOW,delay)}else{open_NOW()}function open_NOW(){if(!s.isClosed){bindStopSlidingEvents(pane,true)}else{if(!s.isMoving){open(pane,true)}}}},slideClose=function(evt_or_pane){if(!isInitialized()){return}var evt=evtObj(evt_or_pane),pane=evtPane.call(this,evt_or_pane),o=options[pane],s=state[pane],delay=s.isMoving?1000:300;if(pane==="center"){return}if(s.isClosed||s.isResizing){return}else{if(o.slideTrigger_close==="click"){close_NOW()}else{if(o.preventQuickSlideClose&&s.isMoving){return}else{if(o.preventPrematureSlideClose&&evt&&$.layout.isMouseOverElem(evt,$Ps[pane])){return}else{if(evt){timer.set(pane+"_closeSlider",close_NOW,max(o.slideDelay_close,delay))}else{close_NOW()}}}}}function close_NOW(){if(s.isClosed){bindStopSlidingEvents(pane,false)}else{if(!s.isMoving){close(pane)}}}},slideToggle=function(evt_or_pane){var pane=evtPane.call(this,evt_or_pane);toggle(pane,true)},lockPaneForFX=function(pane,doLock){var $P=$Ps[pane],s=state[pane],o=options[pane],z=options.zIndexes;if(doLock){showMasks(pane,{animation:true,objectsOnly:true});$P.css({zIndex:z.pane_animate});if(pane=="south"){$P.css({top:sC.inset.top+sC.innerHeight-$P.outerHeight()})}else{if(pane=="east"){$P.css({left:sC.inset.left+sC.innerWidth-$P.outerWidth()})}}}else{hideMasks();$P.css({zIndex:(s.isSliding?z.pane_sliding:z.pane_normal)});if(pane=="south"){$P.css({top:"auto"})}else{if(pane=="east"&&!$P.css("left").match(/\-99999/)){$P.css({left:"auto"})}}if(browser.msie&&o.fxOpacityFix&&o.fxName_open!="slide"&&$P.css("filter")&&$P.css("opacity")==1){$P[0].style.removeAttribute("filter")}}},bindStartSlidingEvents=function(pane,enable){var o=options[pane],$P=$Ps[pane],$R=$Rs[pane],evtName=o.slideTrigger_open.toLowerCase();if(!$R||(enable&&!o.slidable)){return}if(evtName.match(/mouseover/)){evtName=o.slideTrigger_open="mouseenter"}else{if(!evtName.match(/(click|dblclick|mouseenter)/)){evtName=o.slideTrigger_open="click"}}if(o.resizerDblClickToggle&&evtName.match(/click/)){$R[enable?"unbind":"bind"]("dblclick."+sID,toggle)}$R[enable?"bind":"unbind"](evtName+"."+sID,slideOpen).css("cursor",enable?o.sliderCursor:"default").attr("title",enable?o.tips.Slide:"")},bindStopSlidingEvents=function(pane,enable){var o=options[pane],s=state[pane],c=_c[pane],z=options.zIndexes,evtName=o.slideTrigger_close.toLowerCase(),action=(enable?"bind":"unbind"),$P=$Ps[pane],$R=$Rs[pane];timer.clear(pane+"_closeSlider");if(enable){s.isSliding=true;state.panesSliding[pane]=true;bindStartSlidingEvents(pane,false)}else{s.isSliding=false;delete state.panesSliding[pane]}$P.css("zIndex",enable?z.pane_sliding:z.pane_normal);$R.css("zIndex",enable?z.pane_sliding+2:z.resizer_normal);if(!evtName.match(/(click|mouseleave)/)){evtName=o.slideTrigger_close="mouseleave"}$R[action](evtName,slideClose);if(evtName==="mouseleave"){$P[action]("mouseleave."+sID,slideClose);$R[action]("mouseenter."+sID,cancelMouseOut);$P[action]("mouseenter."+sID,cancelMouseOut)}if(!enable){timer.clear(pane+"_closeSlider")}else{if(evtName==="click"&&!o.resizable){$R.css("cursor",enable?o.sliderCursor:"default");$R.attr("title",enable?o.tips.Close:"")}}function cancelMouseOut(evt){timer.clear(pane+"_closeSlider");evt.stopPropagation()}},makePaneFit=function(pane,isOpening,skipCallback,force){var o=options[pane],s=state[pane],c=_c[pane],$P=$Ps[pane],$R=$Rs[pane],isSidePane=c.dir==="vert",hasRoom=false;if(pane==="center"||(isSidePane&&s.noVerticalRoom)){hasRoom=(s.maxHeight>=0);if(hasRoom&&s.noRoom){_showPane(pane);if($R){$R.show()}s.isVisible=true;s.noRoom=false;if(isSidePane){s.noVerticalRoom=false}_fixIframe(pane)}else{if(!hasRoom&&!s.noRoom){_hidePane(pane);if($R){$R.hide()}s.isVisible=false;s.noRoom=true}}}if(pane==="center"){}else{if(s.minSize<=s.maxSize){hasRoom=true;if(s.size>s.maxSize){sizePane(pane,s.maxSize,skipCallback,true,force) +}else{if(s.sizesize){thisTry.attempt=max(0,lastTry.attempt-(lastTry.actual-size))}else{thisTry.attempt=max(0,lastTry.attempt+(size-lastTry.actual))}thisTry.cssSize=cssSize(pane,thisTry.attempt);$P.css(dimName,thisTry.cssSize);thisTry.actual=dimName=="width"?$P.outerWidth():$P.outerHeight();thisTry.correct=(size===thisTry.actual);if(tries.length===1){_log(msg,false,true);_log(lastTry,false,true)}_log(thisTry,false,true);if(tries.length>3){break}tries.push(thisTry);lastTry=tries[tries.length-1]}s.size=size;$.extend(s,elDims($P));if(s.isVisible&&$P.is(":visible")){if($R){$R.css(side,size+sC.inset[side])}sizeContent(pane)}if(!skipCallback&&!skipResizeWhileDragging&&state.initialized&&s.isVisible){_runCallbacks("onresize_end",pane)}if(!skipCallback){if(!s.isSliding){sizeMidPanes(_c[pane].dir=="horz"?"":"center",skipResizeWhileDragging,force)}sizeHandles()}var altPane=_c.oppositeEdge[pane];if(size1){_log(msg+"\nSee the Error Console for details.",true,true)}}},sizeMidPanes=function(panes,skipCallback,force){panes=(panes?panes:"east,west,center").split(",");$.each(panes,function(i,pane){if(!$Ps[pane]){return}var o=options[pane],s=state[pane],$P=$Ps[pane],$R=$Rs[pane],isCenter=(pane=="center"),hasRoom=true,CSS={},visCSS=$.layout.showInvisibly($P),newCenter=calcNewCenterPaneDims();$.extend(s,elDims($P));if(pane==="center"){if(!force&&s.isVisible&&newCenter.width===s.outerWidth&&newCenter.height===s.outerHeight){$P.css(visCSS);return true}$.extend(s,cssMinDims(pane),{maxWidth:newCenter.width,maxHeight:newCenter.height});CSS=newCenter;s.newWidth=CSS.width;s.newHeight=CSS.height;CSS.width=cssW($P,CSS.width);CSS.height=cssH($P,CSS.height);hasRoom=CSS.width>=0&&CSS.height>=0;if(!state.initialized&&o.minWidth>newCenter.width){var reqPx=o.minWidth-s.outerWidth,minE=options.east.minSize||0,minW=options.west.minSize||0,sizeE=state.east.size,sizeW=state.west.size,newE=sizeE,newW=sizeW;if(reqPx>0&&state.east.isVisible&&sizeE>minE){newE=max(sizeE-minE,sizeE-reqPx);reqPx-=sizeE-newE}if(reqPx>0&&state.west.isVisible&&sizeW>minW){newW=max(sizeW-minW,sizeW-reqPx);reqPx-=sizeW-newW}if(reqPx===0){if(sizeE&&sizeE!=minE){sizePane("east",newE,true,true,force)}if(sizeW&&sizeW!=minW){sizePane("west",newW,true,true,force)}sizeMidPanes("center",skipCallback,force);$P.css(visCSS);return}}}else{if(s.isVisible&&!s.noVerticalRoom){$.extend(s,elDims($P),cssMinDims(pane)) +}if(!force&&!s.noVerticalRoom&&newCenter.height===s.outerHeight){$P.css(visCSS);return true}CSS.top=newCenter.top;CSS.bottom=newCenter.bottom;s.newSize=newCenter.height;CSS.height=cssH($P,newCenter.height);s.maxHeight=CSS.height;hasRoom=(s.maxHeight>=0);if(!hasRoom){s.noVerticalRoom=true}}if(hasRoom){if(!skipCallback&&state.initialized){_runCallbacks("onresize_start",pane)}$P.css(CSS);if(pane!=="center"){sizeHandles(pane)}if(s.noRoom&&!s.isClosed&&!s.isHidden){makePaneFit(pane)}if(s.isVisible){$.extend(s,elDims($P));if(state.initialized){sizeContent(pane)}}}else{if(!s.noRoom&&s.isVisible){makePaneFit(pane)}}$P.css(visCSS);delete s.newSize;delete s.newWidth;delete s.newHeight;if(!s.isVisible){return true}if(pane==="center"){var fix=browser.isIE6||!browser.boxModel;if($Ps.north&&(fix||state.north.tagName=="IFRAME")){$Ps.north.css("width",cssW($Ps.north,sC.innerWidth))}if($Ps.south&&(fix||state.south.tagName=="IFRAME")){$Ps.south.css("width",cssW($Ps.south,sC.innerWidth))}}if(!skipCallback&&state.initialized){_runCallbacks("onresize_end",pane)}})},resizeAll=function(evt_or_refresh){var oldW=sC.innerWidth,oldH=sC.innerHeight;evtPane(evt_or_refresh);if(!$N.is(":visible")){return}if(!state.initialized){_initLayoutElements();return}if(evt_or_refresh===true&&$.isPlainObject(options.outset)){$N.css(options.outset)}$.extend(sC,elDims($N,options.inset));if(!sC.outerHeight){return}if(evt_or_refresh===true){setPanePosition()}if(false===_runCallbacks("onresizeall_start")){return false}var shrunkH=(sC.innerHeight0&&$P.css("overflow")==="hidden"){$P.css("overflow","visible");_measure();$P.css("overflow","hidden")}}var newH=s.innerHeight-(m.spaceAbove-s.css.paddingTop)-(m.spaceBelow-s.css.paddingBottom);if(!$C.is(":visible")||m.height!=newH){setOuterHeight($C,newH,true);m.height=newH}if(state.initialized){_runCallbacks("onsizecontent_end",pane)}function _below($E){return max(s.css.paddingBottom,(parseInt($E.css("marginBottom"),10)||0))}function _measure(){var ignore=options[pane].contentIgnoreSelector,$Fs=$C.nextAll().not(".ui-layout-mask").not(ignore||":lt(0)"),$Fs_vis=$Fs.filter(":visible"),$F=$Fs_vis.filter(":last");m={top:$C[0].offsetTop,height:$C.outerHeight(),numFooters:$Fs.length,hiddenFooters:$Fs.length-$Fs_vis.length,spaceBelow:0};m.spaceAbove=m.top;m.bottom=m.top+m.height;if($F.length){m.spaceBelow=($F[0].offsetTop+$F.outerHeight())-m.bottom+_below($F)}else{m.spaceBelow=_below($C)}}})},sizeHandles=function(evt_or_panes){var panes=evtPane.call(this,evt_or_panes);panes=panes?panes.split(","):_c.borderPanes;$.each(panes,function(i,pane){var o=options[pane],s=state[pane],$P=$Ps[pane],$R=$Rs[pane],$T=$Ts[pane],$TC;if(!$P||!$R){return}var dir=_c[pane].dir,_state=(s.isClosed?"_closed":"_open"),spacing=o["spacing"+_state],togAlign=o["togglerAlign"+_state],togLen=o["togglerLength"+_state],paneLen,left,offset,CSS={};if(spacing===0){$R.hide();return}else{if(!s.noRoom&&!s.isHidden){$R.show()}}if(dir==="horz"){paneLen=sC.innerWidth;s.resizerLength=paneLen;left=$.layout.cssNum($P,"left");$R.css({width:cssW($R,paneLen),height:cssH($R,spacing),left:left>-9999?left:sC.inset.left})}else{paneLen=$P.outerHeight();s.resizerLength=paneLen;$R.css({height:cssH($R,paneLen),width:cssW($R,spacing),top:sC.inset.top+getPaneSize("north",true)})}removeHover(o,$R);if($T){if(togLen===0||(s.isSliding&&o.hideTogglerOnSlide)){$T.hide();return}else{$T.show()}if(!(togLen>0)||togLen==="100%"||togLen>paneLen){togLen=paneLen;offset=0}else{if(isStr(togAlign)){switch(togAlign){case"top":case"left":offset=0;break;case"bottom":case"right":offset=paneLen-togLen;break;case"middle":case"center":default:offset=round((paneLen-togLen)/2)}}else{var x=parseInt(togAlign,10);if(togAlign>=0){offset=x +}else{offset=paneLen-togLen+x}}}if(dir==="horz"){var width=cssW($T,togLen);$T.css({width:width,height:cssH($T,spacing),left:offset,top:0})}else{var height=cssH($T,togLen);$T.css({height:height,width:cssW($T,spacing),top:offset,left:0});$T.children(".ui-content").each(function(){$TC=$(this);$TC.css("marginTop",round((height-$TC.outerHeight())/2))})}removeHover(0,$T)}if(!state.initialized&&(o.initHidden||s.isHidden)){$R.hide();if($T){$T.hide()}}})},enableClosable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$T=$Ts[pane],o=options[pane];if(!$T){return}o.closable=true;$T.bind("click."+sID,function(evt){evt.stopPropagation();toggle(pane)}).css("visibility","visible").css("cursor","pointer").attr("title",state[pane].isClosed?o.tips.Open:o.tips.Close).show()},disableClosable=function(evt_or_pane,hide){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$T=$Ts[pane];if(!$T){return}options[pane].closable=false;if(state[pane].isClosed){open(pane,false,true)}$T.unbind("."+sID).css("visibility",hide?"hidden":"visible").css("cursor","default").attr("title","")},enableSlidable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$R=$Rs[pane];if(!$R||!$R.data("draggable")){return}options[pane].slidable=true;if(state[pane].isClosed){bindStartSlidingEvents(pane,true)}},disableSlidable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$R=$Rs[pane];if(!$R){return}options[pane].slidable=false;if(state[pane].isSliding){close(pane,false,true)}else{bindStartSlidingEvents(pane,false);$R.css("cursor","default").attr("title","");removeHover(null,$R[0])}},enableResizable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$R=$Rs[pane],o=options[pane];if(!$R||!$R.data("draggable")){return}o.resizable=true;$R.draggable("enable");if(!state[pane].isClosed){$R.css("cursor",o.resizerCursor).attr("title",o.tips.Resize)}},disableResizable=function(evt_or_pane){if(!isInitialized()){return}var pane=evtPane.call(this,evt_or_pane),$R=$Rs[pane];if(!$R||!$R.data("draggable")){return}options[pane].resizable=false;$R.draggable("disable").css("cursor","default").attr("title","");removeHover(null,$R[0])},swapPanes=function(evt_or_pane1,pane2){if(!isInitialized()){return}var pane1=evtPane.call(this,evt_or_pane1);state[pane1].edge=pane2;state[pane2].edge=pane1;if(false===_runCallbacks("onswap_start",pane1)||false===_runCallbacks("onswap_start",pane2)){state[pane1].edge=pane1;state[pane2].edge=pane2;return}var oPane1=copy(pane1),oPane2=copy(pane2),sizes={};sizes[pane1]=oPane1?oPane1.state.size:0;sizes[pane2]=oPane2?oPane2.state.size:0;$Ps[pane1]=false;$Ps[pane2]=false;state[pane1]={};state[pane2]={};if($Ts[pane1]){$Ts[pane1].remove()}if($Ts[pane2]){$Ts[pane2].remove()}if($Rs[pane1]){$Rs[pane1].remove()}if($Rs[pane2]){$Rs[pane2].remove()}$Rs[pane1]=$Rs[pane2]=$Ts[pane1]=$Ts[pane2]=false;move(oPane1,pane2);move(oPane2,pane1);oPane1=oPane2=sizes=null;if($Ps[pane1]){$Ps[pane1].css(_c.visible)}if($Ps[pane2]){$Ps[pane2].css(_c.visible)}resizeAll();_runCallbacks("onswap_end",pane1);_runCallbacks("onswap_end",pane2);return;function copy(n){var $P=$Ps[n],$C=$Cs[n];return !$P?false:{pane:n,P:$P?$P[0]:false,C:$C?$C[0]:false,state:$.extend(true,{},state[n]),options:$.extend(true,{},options[n])}}function move(oPane,pane){if(!oPane){return}var P=oPane.P,C=oPane.C,oldPane=oPane.pane,c=_c[pane],s=$.extend(true,{},state[pane]),o=options[pane],fx={resizerCursor:o.resizerCursor},re,size,pos;$.each("fxName,fxSpeed,fxSettings".split(","),function(i,k){fx[k+"_open"]=o[k+"_open"];fx[k+"_close"]=o[k+"_close"];fx[k+"_size"]=o[k+"_size"]});$Ps[pane]=$(P).data({layoutPane:Instance[pane],layoutEdge:pane}).css(_c.hidden).css(c.cssReq);$Cs[pane]=C?$(C):false;options[pane]=$.extend(true,{},oPane.options,fx);state[pane]=$.extend(true,{},oPane.state);re=new RegExp(o.paneClass+"-"+oldPane,"g");P.className=P.className.replace(re,o.paneClass+"-"+pane);initHandles(pane);if(c.dir!=_c[oldPane].dir){size=sizes[pane]||0;setSizeLimits(pane);size=max(size,state[pane].minSize);manualSizePane(pane,size,true,true)}else{$Rs[pane].css(c.side,sC.inset[c.side]+(state[pane].isVisible?getPaneSize(pane):0))}if(oPane.state.isVisible&&!s.isVisible){setAsOpen(pane,true)}else{setAsClosed(pane);bindStartSlidingEvents(pane,true)}oPane=null}},syncPinBtns=function(pane,doPin){if($.layout.plugins.buttons){$.each(state[pane].pins,function(i,selector){$.layout.buttons.setPinState(Instance,$(selector),pane,doPin)})}};function keyDown(evt){if(!evt){return true}var code=evt.keyCode;if(code<33){return true}var PANE={38:"north",40:"south",37:"west",39:"east"},ALT=evt.altKey,SHIFT=evt.shiftKey,CTRL=evt.ctrlKey,CURSOR=(CTRL&&code>=37&&code<=40),o,k,m,pane;if(CURSOR&&options[PANE[code]].enableCursorHotkey){pane=PANE[code]}else{if(CTRL||SHIFT){$.each(_c.borderPanes,function(i,p){o=options[p];k=o.customHotkey;m=o.customHotkeyModifier;if((SHIFT&&m=="SHIFT")||(CTRL&&m=="CTRL")||(CTRL&&SHIFT)){if(k&&code===(isNaN(k)||k<=9?k.toUpperCase().charCodeAt(0):k)){pane=p; +return false}}})}}if(!pane||!$Ps[pane]||!options[pane].closable||state[pane].isHidden){return true}toggle(pane);evt.stopPropagation();evt.returnValue=false;return false}function allowOverflow(el){if(!isInitialized()){return}if(this&&this.tagName){el=this}var $P;if(isStr(el)){$P=$Ps[el]}else{if($(el).data("layoutRole")){$P=$(el)}else{$(el).parents().each(function(){if($(this).data("layoutRole")){$P=$(this);return false}})}}if(!$P||!$P.length){return}var pane=$P.data("layoutEdge"),s=state[pane];if(s.cssSaved){resetOverflow(pane)}if(s.isSliding||s.isResizing||s.isClosed){s.cssSaved=false;return}var newCSS={zIndex:(options.zIndexes.resizer_normal+1)},curCSS={},of=$P.css("overflow"),ofX=$P.css("overflowX"),ofY=$P.css("overflowY");if(of!="visible"){curCSS.overflow=of;newCSS.overflow="visible"}if(ofX&&!ofX.match(/(visible|auto)/)){curCSS.overflowX=ofX;newCSS.overflowX="visible"}if(ofY&&!ofY.match(/(visible|auto)/)){curCSS.overflowY=ofX;newCSS.overflowY="visible"}s.cssSaved=curCSS;$P.css(newCSS);$.each(_c.allPanes,function(i,p){if(p!=pane){resetOverflow(p)}})}function resetOverflow(el){if(!isInitialized()){return}if(this&&this.tagName){el=this}var $P;if(isStr(el)){$P=$Ps[el]}else{if($(el).data("layoutRole")){$P=$(el)}else{$(el).parents().each(function(){if($(this).data("layoutRole")){$P=$(this);return false}})}}if(!$P||!$P.length){return}var pane=$P.data("layoutEdge"),s=state[pane],CSS=s.cssSaved||{};if(!s.isSliding&&!s.isResizing){$P.css("zIndex",options.zIndexes.pane_normal)}$P.css(CSS);s.cssSaved=false}var $N=$(this).eq(0);if(!$N.length){return _log(options.errors.containerMissing)}if($N.data("layoutContainer")&&$N.data("layout")){return $N.data("layout")}var $Ps={},$Cs={},$Rs={},$Ts={},$Ms=$([]),sC=state.container,sID=state.id;var Instance={options:options,state:state,container:$N,panes:$Ps,contents:$Cs,resizers:$Rs,togglers:$Ts,hide:hide,show:show,toggle:toggle,open:open,close:close,slideOpen:slideOpen,slideClose:slideClose,slideToggle:slideToggle,setSizeLimits:setSizeLimits,_sizePane:sizePane,sizePane:manualSizePane,sizeContent:sizeContent,swapPanes:swapPanes,showMasks:showMasks,hideMasks:hideMasks,initContent:initContent,addPane:addPane,removePane:removePane,createChildren:createChildren,refreshChildren:refreshChildren,enableClosable:enableClosable,disableClosable:disableClosable,enableSlidable:enableSlidable,disableSlidable:disableSlidable,enableResizable:enableResizable,disableResizable:disableResizable,allowOverflow:allowOverflow,resetOverflow:resetOverflow,destroy:destroy,initPanes:isInitialized,resizeAll:resizeAll,runCallbacks:_runCallbacks,hasParentLayout:false,children:children,north:false,south:false,west:false,east:false,center:false};if(_create()==="cancel"){return null}else{return Instance}}})(jQuery);(function($){if(!$.layout){return}if(!$.ui){$.ui={}}$.ui.cookie={acceptsCookies:!!navigator.cookieEnabled,read:function(name){var c=document.cookie,cs=c?c.split(";"):[],pair,data,i;for(i=0;pair=cs[i];i++){data=$.trim(pair).split("=");if(data[0]==name){return decodeURIComponent(data[1])}}return null},write:function(name,val,cookieOpts){var params="",date="",clear=false,o=cookieOpts||{},x=o.expires||null,t=$.type(x);if(t==="date"){date=x}else{if(t==="string"&&x>0){x=parseInt(x,10);t="number"}}if(t==="number"){date=new Date();if(x>0){date.setDate(date.getDate()+x)}else{date.setFullYear(1970);clear=true}}if(date){params+=";expires="+date.toUTCString()}if(o.path){params+=";path="+o.path}if(o.domain){params+=";domain="+o.domain}if(o.secure){params+=";secure"}document.cookie=name+"="+(clear?"":encodeURIComponent(val))+params},clear:function(name){$.ui.cookie.write(name,"",{expires:-1})}};if(!$.cookie){$.cookie=function(k,v,o){var C=$.ui.cookie;if(v===null){C.clear(k)}else{if(v===undefined){return C.read(k)}else{C.write(k,v,o)}}}}$.layout.plugins.stateManagement=true;$.layout.defaults.stateManagement={enabled:false,autoSave:true,autoLoad:true,animateLoad:true,includeChildren:true,stateKeys:"north.size,south.size,east.size,west.size,"+"north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+"north.isHidden,south.isHidden,east.isHidden,west.isHidden",cookie:{name:"",domain:"",path:"",expires:"",secure:false}};$.layout.optionsMap.layout.push("stateManagement");$.layout.config.optionRootKeys.push("stateManagement");$.layout.state={saveCookie:function(inst,keys,cookieOpts){var o=inst.options,sm=o.stateManagement,oC=$.extend(true,{},sm.cookie,cookieOpts||null),data=inst.state.stateData=inst.readState(keys||sm.stateKeys);$.ui.cookie.write(oC.name||o.name||"Layout",$.layout.state.encodeJSON(data),oC);return $.extend(true,{},data)},deleteCookie:function(inst){var o=inst.options;$.ui.cookie.clear(o.stateManagement.cookie.name||o.name||"Layout")},readCookie:function(inst){var o=inst.options;var c=$.ui.cookie.read(o.stateManagement.cookie.name||o.name||"Layout");return c?$.layout.state.decodeJSON(c):{}},loadCookie:function(inst){var c=$.layout.state.readCookie(inst);if(c&&!$.isEmptyObject(c)){inst.state.stateData=$.extend(true,{},c); +inst.loadState(c)}return c},loadState:function(inst,data,opts){if(!$.isPlainObject(data)||$.isEmptyObject(data)){return}data=inst.state.stateData=$.layout.transformData(data);var smo=inst.options.stateManagement;opts=$.extend({animateLoad:false,includeChildren:smo.includeChildren},opts);if(!inst.state.initialized){var o=$.extend(true,{},data);$.each($.layout.config.allPanes,function(idx,pane){if(o[pane]){delete o[pane].children}});$.extend(true,inst.options,o)}else{var noAnimate=!opts.animateLoad,o,c,h,state,open;$.each($.layout.config.borderPanes,function(idx,pane){o=data[pane];if(!$.isPlainObject(o)){return}s=o.size;c=o.initClosed;h=o.initHidden;ar=o.autoResize;state=inst.state[pane];open=state.isVisible;if(ar){state.autoResize=ar}if(!open){inst._sizePane(pane,s,false,false,false)}if(h===true){inst.hide(pane,noAnimate)}else{if(c===true){inst.close(pane,false,noAnimate)}else{if(c===false){inst.open(pane,false,noAnimate)}else{if(h===false){inst.show(pane,false,noAnimate)}}}}if(open){inst._sizePane(pane,s,false,false,noAnimate)}});if(opts.includeChildren){var paneStateChildren,childState;$.each(inst.children,function(pane,paneChildren){paneStateChildren=data[pane]?data[pane].children:0;if(paneStateChildren&&paneChildren){$.each(paneChildren,function(stateKey,child){childState=paneStateChildren[stateKey];if(child&&childState){child.loadState(childState)}})}})}}},readState:function(inst,opts){if($.type(opts)==="string"){opts={keys:opts}}if(!opts){opts={}}var sm=inst.options.stateManagement,ic=opts.includeChildren,recurse=ic!==undefined?ic:sm.includeChildren,keys=opts.stateKeys||sm.stateKeys,alt={isClosed:"initClosed",isHidden:"initHidden"},state=inst.state,panes=$.layout.config.allPanes,data={},pair,pane,key,val,ps,pC,child,array,count,branch;if($.isArray(keys)){keys=keys.join(",")}keys=keys.replace(/__/g,".").split(",");for(var i=0,n=keys.length;i=0){var btn=o[pane].buttonClass+"-"+action; +$E.addClass(btn+" "+btn+"-"+pane).data("layoutName",o.name)}return $E},bind:function(inst,sel,action,pane){var _=$.layout.buttons;switch(action.toLowerCase()){case"toggle":_.addToggle(inst,sel,pane);break;case"open":_.addOpen(inst,sel,pane);break;case"close":_.addClose(inst,sel,pane);break;case"pin":_.addPin(inst,sel,pane);break;case"toggle-slide":_.addToggle(inst,sel,pane,true);break;case"open-slide":_.addOpen(inst,sel,pane,true);break}return inst},addToggle:function(inst,selector,pane,slide){$.layout.buttons.get(inst,selector,pane,"toggle").click(function(evt){inst.toggle(pane,!!slide);evt.stopPropagation()});return inst},addOpen:function(inst,selector,pane,slide){$.layout.buttons.get(inst,selector,pane,"open").attr("title",inst.options[pane].tips.Open).click(function(evt){inst.open(pane,!!slide);evt.stopPropagation()});return inst},addClose:function(inst,selector,pane){$.layout.buttons.get(inst,selector,pane,"close").attr("title",inst.options[pane].tips.Close).click(function(evt){inst.close(pane);evt.stopPropagation()});return inst},addPin:function(inst,selector,pane){var $E=$.layout.buttons.get(inst,selector,pane,"pin");if($E.length){var s=inst.state[pane];$E.click(function(evt){$.layout.buttons.setPinState(inst,$(this),pane,(s.isSliding||s.isClosed));if(s.isSliding||s.isClosed){inst.open(pane)}else{inst.close(pane)}evt.stopPropagation()});$.layout.buttons.setPinState(inst,$E,pane,(!s.isClosed&&!s.isSliding));s.pins.push(selector)}return inst},setPinState:function(inst,$Pin,pane,doPin){var updown=$Pin.attr("pin");if(updown&&doPin===(updown=="down")){return}var po=inst.options[pane],lang=po.tips,pin=po.buttonClass+"-pin",side=pin+"-"+pane,UP=pin+"-up "+side+"-up",DN=pin+"-down "+side+"-down";$Pin.attr("pin",doPin?"down":"up").attr("title",doPin?lang.Unpin:lang.Pin).removeClass(doPin?UP:DN).addClass(doPin?DN:UP)},syncPinBtns:function(inst,pane,doPin){$.each(state[pane].pins,function(i,selector){$.layout.buttons.setPinState(inst,$(selector),pane,doPin)})},_load:function(inst){$.extend(inst,{bindButton:function(selector,action,pane){return $.layout.buttons.bind(inst,selector,action,pane)},addToggleBtn:function(selector,pane,slide){return $.layout.buttons.addToggle(inst,selector,pane,slide)},addOpenBtn:function(selector,pane,slide){return $.layout.buttons.addOpen(inst,selector,pane,slide)},addCloseBtn:function(selector,pane){return $.layout.buttons.addClose(inst,selector,pane)},addPinBtn:function(selector,pane){return $.layout.buttons.addPin(inst,selector,pane)}});for(var i=0;i<4;i++){var pane=$.layout.buttons.config.borderPanes[i];inst.state[pane].pins=[]}if(inst.options.autoBindCustomButtons){$.layout.buttons.init(inst)}},_unload:function(inst){}};$.layout.onLoad.push($.layout.buttons._load)})(jQuery);(function($){$.layout.plugins.browserZoom=true;$.layout.defaults.browserZoomCheckInterval=1000;$.layout.optionsMap.layout.push("browserZoomCheckInterval");$.layout.browserZoom={_init:function(inst){if($.layout.browserZoom.ratio()!==false){$.layout.browserZoom._setTimer(inst)}},_setTimer:function(inst){if(inst.destroyed){return}var o=inst.options,s=inst.state,ms=inst.hasParentLayout?5000:Math.max(o.browserZoomCheckInterval,100);setTimeout(function(){if(inst.destroyed||!o.resizeWithWindow){return}var d=$.layout.browserZoom.ratio();if(d!==s.browserZoom){s.browserZoom=d;inst.resizeAll()}$.layout.browserZoom._setTimer(inst)},ms)},ratio:function(){var w=window,s=screen,d=document,dE=d.documentElement||d.body,b=$.layout.browser,v=b.version,r,sW,cW;if(!b.msie||v>8){return false}if(s.deviceXDPI&&s.systemXDPI){return calc(s.deviceXDPI,s.systemXDPI)}if(b.webkit&&(r=d.body.getBoundingClientRect)){return calc((r.left-r.right),d.body.offsetWidth)}if(b.webkit&&(sW=w.outerWidth)){return calc(sW,w.innerWidth)}if((sW=s.width)&&(cW=dE.clientWidth)){return calc(sW,cW)}return false;function calc(x,y){return(parseInt(x,10)/parseInt(y,10)*100).toFixed()}}};$.layout.onReady.push($.layout.browserZoom._init)})(jQuery);(function($){if($.effects){$.layout.defaults.panes.useOffscreenClose=false;if($.layout.plugins){$.layout.plugins.effects.slideOffscreen=true}$.layout.effects.slideOffscreen=$.extend(true,{},$.layout.effects.slide);$.effects.slideOffscreen=function(o){return this.queue(function(){var fx=$.effects,opt=o.options,$el=$(this),pane=$el.data("layoutEdge"),state=$el.data("parentLayout").state,dist=state[pane].size,s=this.style,props=["top","bottom","left","right"],mode=fx.setMode($el,opt.mode||"show"),show=(mode=="show"),dir=opt.direction||"left",ref=(dir=="up"||dir=="down")?"top":"left",pos=(dir=="up"||dir=="left"),offscrn=$.layout.config.offscreenCSS||{},keyLR=$.layout.config.offscreenReset,keyTB="offscreenResetTop",animation={};animation[ref]=(show?(pos?"+=":"-="):(pos?"-=":"+="))+dist;if(show){$el.data(keyTB,{top:s.top,bottom:s.bottom});if(pos){$el.css(ref,isNaN(dist)?"-"+dist:-dist)}else{if(dir==="right"){$el.css({left:state.container.layoutWidth,right:"auto"})}else{$el.css({top:state.container.layoutHeight,bottom:"auto"})}}if(ref==="top"){$el.css($el.data(keyLR)||{}) }}else{$el.data(keyTB,{top:s.top,bottom:s.bottom});$el.data(keyLR,{left:s.left,right:s.right})}$el.show().animate(animation,{queue:false,duration:o.duration,easing:opt.easing,complete:function(){if($el.data(keyTB)){$el.css($el.data(keyTB)).removeData(keyTB)}if(show){$el.css($el.data(keyLR)||{}).removeData(keyLR)}else{$el.css(offscrn)}if(o.callback){o.callback.apply(this,arguments)}$el.dequeue()}})})}}})(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/1_close.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/1_close.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/1_close.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/1_close.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/1_open.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/1_open.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/1_open.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/1_open.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/2.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/2.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/2.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/2.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/3.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/3.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/3.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/3.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/4.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/4.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/4.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/4.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/5.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/5.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/5.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/5.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/6.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/6.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/6.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/6.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/7.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/7.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/7.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/7.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/8.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/8.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/8.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/8.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/9.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/9.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/9.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/diy/9.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/line_conn.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/line_conn.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/line_conn.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/line_conn.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/loading.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/loading.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/loading.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/loading.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/zTreeStandard.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/zTreeStandard.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/zTreeStandard.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/zTreeStandard.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/zTreeStandard.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/zTreeStandard.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/zTreeStandard.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/img/zTreeStandard.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/zTreeStyle.css b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/zTreeStyle.css similarity index 98% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/zTreeStyle.css rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/zTreeStyle.css index 93083f161..8a9115aa7 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/zTreeStyle.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/default/zTreeStyle.css @@ -1,102 +1,102 @@ -/*------------------------------------- -zTree Style - -version: 3.4 -author: Hunter.z -email: hunter.z@263.net -website: http://code.google.com/p/jquerytree/ - --------------------------------------*/ - -.ztree * {padding:0; margin:0; font-size:12px;} -.ztree {margin:0; padding:2px; color:#333} -.ztree li{padding:0; margin:0; list-style:none; line-height:18px; text-align:left; white-space:nowrap; outline:0} -.ztree li ul{ margin:0; padding:0 0 0 18px} -.ztree li ul.line{ background:url(./img/line_conn.gif) 0 0 repeat-y;} - -.ztree li a {padding:1px 3px 0 0; margin:0; cursor:pointer; /* height:17px; */ color:#333; background-color: transparent; - text-decoration:none; vertical-align:top; display: inline-block} -.ztree li a:hover {text-decoration:underline} -/*.ztree li a.curSelectedNode {padding-top:0px; background-color:#FFE6B0; color:black; height:16px; border:1px #FFB951 solid; opacity:0.8;}*/ -.ztree li a.curSelectedNode {padding-top:0px; background-color:#F6F6F6; color:#0663A2; border:1px #DDDDDD solid; opacity:0.8;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;} -/*.ztree li a.curSelectedNode {padding-top:0px; color:#0663a2; font-weight:bold; height:16px; opacity:0.8;}*/ -.ztree li a.curSelectedNode_Edit {padding-top:0px; background-color:#FFE6B0; color:black; height:16px; border:1px #FFB951 solid; opacity:0.8;} -.ztree li a.tmpTargetNode_inner {padding-top:0px; background-color:#316AC5; color:white; height:16px; border:1px #316AC5 solid; - opacity:0.8; filter:alpha(opacity=80)} -.ztree li a.tmpTargetNode_prev {} -.ztree li a.tmpTargetNode_next {} -.ztree li a input.rename {height:14px; width:80px; padding:0; margin:0; - font-size:12px; border:1px #7EC4CC solid; *border:0px} -.ztree li span {line-height:16px; margin-right:2px} -.ztree li span.button {line-height:0; margin:0; width:16px; height:16px; display: inline-block; vertical-align:middle; - border:0 none; cursor: pointer;outline:none; - background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; - background-image:url("./img/zTreeStandard.png"); *background-image:url("./img/zTreeStandard.gif")} - -/* IE7 fix */ -.ztree li span.button.level0 {*margin-left:-15px;} - -.ztree li span.button.chk {width:13px; height:13px; margin:0 3px 0 0; cursor: auto} -.ztree li span.button.chk.checkbox_false_full {background-position:0 0} -.ztree li span.button.chk.checkbox_false_full_focus {background-position:0 -14px} -.ztree li span.button.chk.checkbox_false_part {background-position:0 -28px} -.ztree li span.button.chk.checkbox_false_part_focus {background-position:0 -42px} -.ztree li span.button.chk.checkbox_false_disable {background-position:0 -56px} -.ztree li span.button.chk.checkbox_true_full {background-position:-14px 0} -.ztree li span.button.chk.checkbox_true_full_focus {background-position:-14px -14px} -.ztree li span.button.chk.checkbox_true_part {background-position:-14px -28px} -.ztree li span.button.chk.checkbox_true_part_focus {background-position:-14px -42px} -.ztree li span.button.chk.checkbox_true_disable {background-position:-14px -56px} -.ztree li span.button.chk.radio_false_full {background-position:-28px 0} -.ztree li span.button.chk.radio_false_full_focus {background-position:-28px -14px} -.ztree li span.button.chk.radio_false_part {background-position:-28px -28px} -.ztree li span.button.chk.radio_false_part_focus {background-position:-28px -42px} -.ztree li span.button.chk.radio_false_disable {background-position:-28px -56px} -.ztree li span.button.chk.radio_true_full {background-position:-42px 0} -.ztree li span.button.chk.radio_true_full_focus {background-position:-42px -14px} -.ztree li span.button.chk.radio_true_part {background-position:-42px -28px} -.ztree li span.button.chk.radio_true_part_focus {background-position:-42px -42px} -.ztree li span.button.chk.radio_true_disable {background-position:-42px -56px} - -.ztree li span.button.switch {width:18px; height:18px} -.ztree li span.button.root_open{background-position:-92px -54px} -.ztree li span.button.root_close{background-position:-74px -54px} -.ztree li span.button.roots_open{background-position:-92px 0} -.ztree li span.button.roots_close{background-position:-74px 0} -.ztree li span.button.center_open{background-position:-92px -18px} -.ztree li span.button.center_close{background-position:-74px -18px} -.ztree li span.button.bottom_open{background-position:-92px -36px} -.ztree li span.button.bottom_close{background-position:-74px -36px} -.ztree li span.button.noline_open{background-position:-92px -72px} -.ztree li span.button.noline_close{background-position:-74px -72px} -.ztree li span.button.root_docu{ background:none;} -.ztree li span.button.roots_docu{background-position:-56px 0} -.ztree li span.button.center_docu{background-position:-56px -18px} -.ztree li span.button.bottom_docu{background-position:-56px -36px} -.ztree li span.button.noline_docu{ background:none;} - -.ztree li span.button.ico_open{margin-right:2px; background-position:-110px -16px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.ico_close{margin-right:2px; background-position:-110px 0; vertical-align:top; *vertical-align:middle} -.ztree li span.button.ico_docu{margin-right:2px; background-position:-110px -32px; /* vertical-align:top; * */vertical-align:middle} -.ztree li span.button.edit {margin-right:2px; background-position:-110px -48px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.remove {margin-right:2px; background-position:-110px -64px; vertical-align:top; *vertical-align:middle} - -.ztree li span.button.ico_loading{margin-right:2px; background:url(./img/loading.gif) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle} - -ul.tmpTargetzTree {background-color:#FFE6B0; opacity:0.8; filter:alpha(opacity=80)} - -span.tmpzTreeMove_arrow {width:16px; height:16px; display: inline-block; padding:0; margin:2px 0 0 1px; border:0 none; position:absolute; - background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; - background-position:-110px -80px; background-image:url("./img/zTreeStandard.png"); *background-image:url("./img/zTreeStandard.gif")} - -ul.ztree.zTreeDragUL {margin:0; padding:0; position:absolute; width:auto; height:auto;overflow:hidden; background-color:#cfcfcf; border:1px #00B83F dotted; opacity:0.8; filter:alpha(opacity=80)} -.zTreeMask {z-index:10000; background-color:#cfcfcf; opacity:0.0; filter:alpha(opacity=0); position:absolute} - -/* level style*/ -/*.ztree li span.button.level0 { - display:none; -} -.ztree li ul.level0 { - padding:0; - background:none; -}*/ +/*------------------------------------- +zTree Style + +version: 3.4 +author: Hunter.z +email: hunter.z@263.net +website: http://code.google.com/p/jquerytree/ + +-------------------------------------*/ + +.ztree * {padding:0; margin:0; font-size:12px;} +.ztree {margin:0; padding:2px; color:#333} +.ztree li{padding:0; margin:0; list-style:none; line-height:18px; text-align:left; white-space:nowrap; outline:0} +.ztree li ul{ margin:0; padding:0 0 0 18px} +.ztree li ul.line{ background:url(./img/line_conn.gif) 0 0 repeat-y;} + +.ztree li a {padding:1px 3px 0 0; margin:0; cursor:pointer; /* height:17px; */ color:#333; background-color: transparent; + text-decoration:none; vertical-align:top; display: inline-block} +.ztree li a:hover {text-decoration:underline} +/*.ztree li a.curSelectedNode {padding-top:0px; background-color:#FFE6B0; color:black; height:16px; border:1px #FFB951 solid; opacity:0.8;}*/ +.ztree li a.curSelectedNode {padding-top:0px; background-color:#F6F6F6; color:#0663A2; border:1px #DDDDDD solid; opacity:0.8;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;} +/*.ztree li a.curSelectedNode {padding-top:0px; color:#0663a2; font-weight:bold; height:16px; opacity:0.8;}*/ +.ztree li a.curSelectedNode_Edit {padding-top:0px; background-color:#FFE6B0; color:black; height:16px; border:1px #FFB951 solid; opacity:0.8;} +.ztree li a.tmpTargetNode_inner {padding-top:0px; background-color:#316AC5; color:white; height:16px; border:1px #316AC5 solid; + opacity:0.8; filter:alpha(opacity=80)} +.ztree li a.tmpTargetNode_prev {} +.ztree li a.tmpTargetNode_next {} +.ztree li a input.rename {height:14px; width:80px; padding:0; margin:0; + font-size:12px; border:1px #7EC4CC solid; *border:0px} +.ztree li span {line-height:16px; margin-right:2px} +.ztree li span.button {line-height:0; margin:0; width:16px; height:16px; display: inline-block; vertical-align:middle; + border:0 none; cursor: pointer;outline:none; + background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; + background-image:url("./img/zTreeStandard.png"); *background-image:url("./img/zTreeStandard.gif")} + +/* IE7 fix */ +.ztree li span.button.level0 {*margin-left:-15px;} + +.ztree li span.button.chk {width:13px; height:13px; margin:0 3px 0 0; cursor: auto} +.ztree li span.button.chk.checkbox_false_full {background-position:0 0} +.ztree li span.button.chk.checkbox_false_full_focus {background-position:0 -14px} +.ztree li span.button.chk.checkbox_false_part {background-position:0 -28px} +.ztree li span.button.chk.checkbox_false_part_focus {background-position:0 -42px} +.ztree li span.button.chk.checkbox_false_disable {background-position:0 -56px} +.ztree li span.button.chk.checkbox_true_full {background-position:-14px 0} +.ztree li span.button.chk.checkbox_true_full_focus {background-position:-14px -14px} +.ztree li span.button.chk.checkbox_true_part {background-position:-14px -28px} +.ztree li span.button.chk.checkbox_true_part_focus {background-position:-14px -42px} +.ztree li span.button.chk.checkbox_true_disable {background-position:-14px -56px} +.ztree li span.button.chk.radio_false_full {background-position:-28px 0} +.ztree li span.button.chk.radio_false_full_focus {background-position:-28px -14px} +.ztree li span.button.chk.radio_false_part {background-position:-28px -28px} +.ztree li span.button.chk.radio_false_part_focus {background-position:-28px -42px} +.ztree li span.button.chk.radio_false_disable {background-position:-28px -56px} +.ztree li span.button.chk.radio_true_full {background-position:-42px 0} +.ztree li span.button.chk.radio_true_full_focus {background-position:-42px -14px} +.ztree li span.button.chk.radio_true_part {background-position:-42px -28px} +.ztree li span.button.chk.radio_true_part_focus {background-position:-42px -42px} +.ztree li span.button.chk.radio_true_disable {background-position:-42px -56px} + +.ztree li span.button.switch {width:18px; height:18px} +.ztree li span.button.root_open{background-position:-92px -54px} +.ztree li span.button.root_close{background-position:-74px -54px} +.ztree li span.button.roots_open{background-position:-92px 0} +.ztree li span.button.roots_close{background-position:-74px 0} +.ztree li span.button.center_open{background-position:-92px -18px} +.ztree li span.button.center_close{background-position:-74px -18px} +.ztree li span.button.bottom_open{background-position:-92px -36px} +.ztree li span.button.bottom_close{background-position:-74px -36px} +.ztree li span.button.noline_open{background-position:-92px -72px} +.ztree li span.button.noline_close{background-position:-74px -72px} +.ztree li span.button.root_docu{ background:none;} +.ztree li span.button.roots_docu{background-position:-56px 0} +.ztree li span.button.center_docu{background-position:-56px -18px} +.ztree li span.button.bottom_docu{background-position:-56px -36px} +.ztree li span.button.noline_docu{ background:none;} + +.ztree li span.button.ico_open{margin-right:2px; background-position:-110px -16px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.ico_close{margin-right:2px; background-position:-110px 0; vertical-align:top; *vertical-align:middle} +.ztree li span.button.ico_docu{margin-right:2px; background-position:-110px -32px; /* vertical-align:top; * */vertical-align:middle} +.ztree li span.button.edit {margin-right:2px; background-position:-110px -48px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.remove {margin-right:2px; background-position:-110px -64px; vertical-align:top; *vertical-align:middle} + +.ztree li span.button.ico_loading{margin-right:2px; background:url(./img/loading.gif) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle} + +ul.tmpTargetzTree {background-color:#FFE6B0; opacity:0.8; filter:alpha(opacity=80)} + +span.tmpzTreeMove_arrow {width:16px; height:16px; display: inline-block; padding:0; margin:2px 0 0 1px; border:0 none; position:absolute; + background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; + background-position:-110px -80px; background-image:url("./img/zTreeStandard.png"); *background-image:url("./img/zTreeStandard.gif")} + +ul.ztree.zTreeDragUL {margin:0; padding:0; position:absolute; width:auto; height:auto;overflow:hidden; background-color:#cfcfcf; border:1px #00B83F dotted; opacity:0.8; filter:alpha(opacity=80)} +.zTreeMask {z-index:10000; background-color:#cfcfcf; opacity:0.0; filter:alpha(opacity=0); position:absolute} + +/* level style*/ +/*.ztree li span.button.level0 { + display:none; +} +.ztree li ul.level0 { + padding:0; + background:none; +}*/ diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/line_conn.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/line_conn.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/line_conn.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/line_conn.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/line_conn.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/line_conn.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/line_conn.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/line_conn.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/loading.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/loading.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/loading.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/loading.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/metro.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/metro.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/metro.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/metro.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/metro.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/metro.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/metro.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/img/metro.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css similarity index 98% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css index cf22b1e85..bddc10240 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css @@ -1,107 +1,107 @@ -/*------------------------------------- -zTree Style - -version: 3.4 -author: Hunter.z -email: hunter.z@263.net -website: http://code.google.com/p/jquerytree/ - --------------------------------------*/ - -.ztree * {padding:0; margin:0; font-size:12px; font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif} -.ztree {margin:0; padding:5px; color:#333} -.ztree li{padding:0; margin:0; list-style:none; line-height:21px; text-align:left; white-space:nowrap; outline:0} -.ztree li ul{ margin:0; padding:0 0 0 18px} -.ztree li ul.line{ background:url(./img/line_conn.png) 0 0 repeat-y;} - -.ztree li a {padding-right:3px; margin:0; cursor:pointer; height:21px; color:#333; background-color: transparent; text-decoration:none; display: inline-block} -.ztree li a:hover {text-decoration:underline} -.ztree li a.curSelectedNode {padding-top:0px; background-color:#e5e5e5; color:black; height:22px; -webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;} -.ztree li a.curSelectedNode_Edit {padding-top:0px; background-color:#e5e5e5; color:black; height:22px; border:1px #666 solid; -webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;} -.ztree li a.tmpTargetNode_inner {padding-top:0px; background-color:#aaa; color:white; height:21px; border:1px #666 solid; - opacity:0.8; filter:alpha(opacity=80)} -.ztree li a.tmpTargetNode_prev {} -.ztree li a.tmpTargetNode_next {} -.ztree li a input.rename {height:14px; width:80px; padding:0; margin:0; - font-size:12px; border:1px #7EC4CC solid; *border:0px} -.ztree li span {line-height:21px; margin-right:2px} -.ztree li span.button {line-height:0; margin:0; width:21px; height:21px; display: inline-block; vertical-align:middle; - border:0 none; cursor: pointer;outline:none; - background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; - background-image:url("./img/metro.png"); *background-image:url("./img/metro.gif")} - -.ztree li span.button.chk {width:13px; height:13px; margin:0 2px; cursor: auto} -.ztree li span.button.chk.checkbox_false_full {background-position: -5px -5px;} -.ztree li span.button.chk.checkbox_false_full_focus {background-position: -5px -26px;} -.ztree li span.button.chk.checkbox_false_part {background-position: -5px -48px;} -.ztree li span.button.chk.checkbox_false_part_focus {background-position: -5px -68px;} -.ztree li span.button.chk.checkbox_false_disable {background-position: -5px -89px;} -.ztree li span.button.chk.checkbox_true_full {background-position: -26px -5px;} -.ztree li span.button.chk.checkbox_true_full_focus {background-position: -26px -26px;} -.ztree li span.button.chk.checkbox_true_part {background-position: -26px -48px;} -.ztree li span.button.chk.checkbox_true_part_focus {background-position: -26px -68px;} -.ztree li span.button.chk.checkbox_true_disable {background-position: -26px -89px;} -.ztree li span.button.chk.radio_false_full {background-position: -47px -5px;} -.ztree li span.button.chk.radio_false_full_focus {background-position: -47px -26px;} -.ztree li span.button.chk.radio_false_part {background-position: -47px -47px;} -.ztree li span.button.chk.radio_false_part_focus {background-position: -47px -68px;} -.ztree li span.button.chk.radio_false_disable {background-position: -47px -89px;} -.ztree li span.button.chk.radio_true_full {background-position: -68px -5px;} -.ztree li span.button.chk.radio_true_full_focus {background-position: -68px -26px;} -.ztree li span.button.chk.radio_true_part {background-position: -68px -47px;} -.ztree li span.button.chk.radio_true_part_focus {background-position: -68px -68px;} -.ztree li span.button.chk.radio_true_disable {background-position: -68px -89px;} - -.ztree li span.button.switch {width:21px; height:21px} -.ztree li span.button.root_open{background-position:-105px -85px} -.ztree li span.button.root_close{background-position:-126px -85px} -.ztree li span.button.roots_open{background-position: -105px 0;} -.ztree li span.button.roots_close{background-position: -126px 0;} -.ztree li span.button.center_open{background-position: -105px -21px;} -.ztree li span.button.center_close{background-position: -126px -21px;} -.ztree li span.button.bottom_open{background-position: -105px -42px;} -.ztree li span.button.bottom_close{background-position: -126px -42px;} -.ztree li span.button.noline_open{background-position: -126px -84px;} -.ztree li span.button.noline_close{background-position: -105px -84px;} -.ztree li span.button.root_docu{ background:none;} -.ztree li span.button.roots_docu{background-position: -84px 0;} -.ztree li span.button.center_docu{background-position: -84px -21px;} -.ztree li span.button.bottom_docu{background-position: -84px -42px;} -.ztree li span.button.noline_docu{ background:none;} - -.ztree li span.button.ico_open{margin-right:2px; background-position: -147px -21px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.ico_close{margin-right:2px; margin-right:2px; background-position: -147px 0; vertical-align:top; *vertical-align:middle} -.ztree li span.button.ico_docu{margin-right:2px; background-position: -147px -42px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.edit {margin-left:2px; margin-right: -1px; background-position: -189px -21px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.edit:hover { - background-position: -168px -21px; -} -.ztree li span.button.remove {margin-left:2px; margin-right: -1px; background-position: -189px -42px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.remove:hover { - background-position: -168px -42px; -} -.ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position: -189px 0; vertical-align:top; *vertical-align:middle} -.ztree li span.button.add:hover { - background-position: -168px 0; -} -.ztree li span.button.ico_loading{margin-right:2px; background:url(./img/loading.gif) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle} - -ul.tmpTargetzTree {background-color:#FFE6B0; opacity:0.8; filter:alpha(opacity=80)} - -span.tmpzTreeMove_arrow {width:16px; height:21px; display: inline-block; padding:0; margin:2px 0 0 1px; border:0 none; position:absolute; - background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; - background-position:-168px -84px; background-image:url("./img/metro.png"); *background-image:url("./img/metro.gif")} - -ul.ztree.zTreeDragUL {margin:0; padding:0; position:absolute; width:auto; height:auto;overflow:hidden; background-color:#cfcfcf; border:1px #00B83F dotted; opacity:0.8; filter:alpha(opacity=80)} -.zTreeMask {z-index:10000; background-color:#cfcfcf; opacity:0.0; filter:alpha(opacity=0); position:absolute} - -/* 树搜索相关 */ -.treeSearchInput {padding:13px 0 0 20px;} -.treeSearchInput label {padding:5px 0 3px 0;font-size:13px;font-weight:normal;vertical-align:middle;} -.treeSearchInput input {width:145px;vertical-align:middle;line-height:24px;height:26px;border:1px solid #bbb;padding:0 4px;} -.treeSearchInput button {border:1px solid #bbb;vertical-align:middle;height:26px;height:26px\9;font-size:13px;background:#efefef;padding:0 8px;} -.treeShowHideButton {position:absolute;right:8px;top:2px;font-size:12px;color:#333;z-index:3;} -.treeShowHideButton label {cursor:pointer;} -.treeExpandCollapse {float:right;margin:6px 5px;padding:5px;font-size:12px;color:#333;position:relative;z-index:2;background:#fff;} -.treeExpandCollapse a {text-decoration:none;color:#333} -.treeselect.ztree {padding:10px 20px;} +/*------------------------------------- +zTree Style + +version: 3.4 +author: Hunter.z +email: hunter.z@263.net +website: http://code.google.com/p/jquerytree/ + +-------------------------------------*/ + +.ztree * {padding:0; margin:0; font-size:12px; font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif} +.ztree {margin:0; padding:5px; color:#333} +.ztree li{padding:0; margin:0; list-style:none; line-height:21px; text-align:left; white-space:nowrap; outline:0} +.ztree li ul{ margin:0; padding:0 0 0 18px} +.ztree li ul.line{ background:url(./img/line_conn.png) 0 0 repeat-y;} + +.ztree li a {padding-right:3px; margin:0; cursor:pointer; height:21px; color:#333; background-color: transparent; text-decoration:none; display: inline-block} +.ztree li a:hover {text-decoration:underline} +.ztree li a.curSelectedNode {padding-top:0px; background-color:#e5e5e5; color:black; height:22px; -webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;} +.ztree li a.curSelectedNode_Edit {padding-top:0px; background-color:#e5e5e5; color:black; height:22px; border:1px #666 solid; -webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;} +.ztree li a.tmpTargetNode_inner {padding-top:0px; background-color:#aaa; color:white; height:21px; border:1px #666 solid; + opacity:0.8; filter:alpha(opacity=80)} +.ztree li a.tmpTargetNode_prev {} +.ztree li a.tmpTargetNode_next {} +.ztree li a input.rename {height:14px; width:80px; padding:0; margin:0; + font-size:12px; border:1px #7EC4CC solid; *border:0px} +.ztree li span {line-height:21px; margin-right:2px} +.ztree li span.button {line-height:0; margin:0; width:21px; height:21px; display: inline-block; vertical-align:middle; + border:0 none; cursor: pointer;outline:none; + background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; + background-image:url("./img/metro.png"); *background-image:url("./img/metro.gif")} + +.ztree li span.button.chk {width:13px; height:13px; margin:0 2px; cursor: auto} +.ztree li span.button.chk.checkbox_false_full {background-position: -5px -5px;} +.ztree li span.button.chk.checkbox_false_full_focus {background-position: -5px -26px;} +.ztree li span.button.chk.checkbox_false_part {background-position: -5px -48px;} +.ztree li span.button.chk.checkbox_false_part_focus {background-position: -5px -68px;} +.ztree li span.button.chk.checkbox_false_disable {background-position: -5px -89px;} +.ztree li span.button.chk.checkbox_true_full {background-position: -26px -5px;} +.ztree li span.button.chk.checkbox_true_full_focus {background-position: -26px -26px;} +.ztree li span.button.chk.checkbox_true_part {background-position: -26px -48px;} +.ztree li span.button.chk.checkbox_true_part_focus {background-position: -26px -68px;} +.ztree li span.button.chk.checkbox_true_disable {background-position: -26px -89px;} +.ztree li span.button.chk.radio_false_full {background-position: -47px -5px;} +.ztree li span.button.chk.radio_false_full_focus {background-position: -47px -26px;} +.ztree li span.button.chk.radio_false_part {background-position: -47px -47px;} +.ztree li span.button.chk.radio_false_part_focus {background-position: -47px -68px;} +.ztree li span.button.chk.radio_false_disable {background-position: -47px -89px;} +.ztree li span.button.chk.radio_true_full {background-position: -68px -5px;} +.ztree li span.button.chk.radio_true_full_focus {background-position: -68px -26px;} +.ztree li span.button.chk.radio_true_part {background-position: -68px -47px;} +.ztree li span.button.chk.radio_true_part_focus {background-position: -68px -68px;} +.ztree li span.button.chk.radio_true_disable {background-position: -68px -89px;} + +.ztree li span.button.switch {width:21px; height:21px} +.ztree li span.button.root_open{background-position:-105px -85px} +.ztree li span.button.root_close{background-position:-126px -85px} +.ztree li span.button.roots_open{background-position: -105px 0;} +.ztree li span.button.roots_close{background-position: -126px 0;} +.ztree li span.button.center_open{background-position: -105px -21px;} +.ztree li span.button.center_close{background-position: -126px -21px;} +.ztree li span.button.bottom_open{background-position: -105px -42px;} +.ztree li span.button.bottom_close{background-position: -126px -42px;} +.ztree li span.button.noline_open{background-position: -126px -84px;} +.ztree li span.button.noline_close{background-position: -105px -84px;} +.ztree li span.button.root_docu{ background:none;} +.ztree li span.button.roots_docu{background-position: -84px 0;} +.ztree li span.button.center_docu{background-position: -84px -21px;} +.ztree li span.button.bottom_docu{background-position: -84px -42px;} +.ztree li span.button.noline_docu{ background:none;} + +.ztree li span.button.ico_open{margin-right:2px; background-position: -147px -21px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.ico_close{margin-right:2px; margin-right:2px; background-position: -147px 0; vertical-align:top; *vertical-align:middle} +.ztree li span.button.ico_docu{margin-right:2px; background-position: -147px -42px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.edit {margin-left:2px; margin-right: -1px; background-position: -189px -21px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.edit:hover { + background-position: -168px -21px; +} +.ztree li span.button.remove {margin-left:2px; margin-right: -1px; background-position: -189px -42px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.remove:hover { + background-position: -168px -42px; +} +.ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position: -189px 0; vertical-align:top; *vertical-align:middle} +.ztree li span.button.add:hover { + background-position: -168px 0; +} +.ztree li span.button.ico_loading{margin-right:2px; background:url(./img/loading.gif) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle} + +ul.tmpTargetzTree {background-color:#FFE6B0; opacity:0.8; filter:alpha(opacity=80)} + +span.tmpzTreeMove_arrow {width:16px; height:21px; display: inline-block; padding:0; margin:2px 0 0 1px; border:0 none; position:absolute; + background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; + background-position:-168px -84px; background-image:url("./img/metro.png"); *background-image:url("./img/metro.gif")} + +ul.ztree.zTreeDragUL {margin:0; padding:0; position:absolute; width:auto; height:auto;overflow:hidden; background-color:#cfcfcf; border:1px #00B83F dotted; opacity:0.8; filter:alpha(opacity=80)} +.zTreeMask {z-index:10000; background-color:#cfcfcf; opacity:0.0; filter:alpha(opacity=0); position:absolute} + +/* 树搜索相关 */ +.treeSearchInput {padding:13px 0 0 20px;} +.treeSearchInput label {padding:5px 0 3px 0;font-size:13px;font-weight:normal;vertical-align:middle;} +.treeSearchInput input {width:145px;vertical-align:middle;line-height:24px;height:26px;border:1px solid #bbb;padding:0 4px;} +.treeSearchInput button {border:1px solid #bbb;vertical-align:middle;height:26px;height:26px\9;font-size:13px;background:#efefef;padding:0 8px;} +.treeShowHideButton {position:absolute;right:8px;top:2px;font-size:12px;color:#333;z-index:3;} +.treeShowHideButton label {cursor:pointer;} +.treeExpandCollapse {float:right;margin:6px 5px;padding:5px;font-size:12px;color:#333;position:relative;z-index:2;background:#fff;} +.treeExpandCollapse a {text-decoration:none;color:#333} +.treeselect.ztree {padding:10px 20px;} diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/left_menu.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/left_menu.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/left_menu.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/left_menu.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/left_menu.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/left_menu.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/left_menu.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/left_menu.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/line_conn.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/line_conn.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/line_conn.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/line_conn.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/loading.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/loading.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/loading.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/loading.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/zTreeStandard.gif b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/zTreeStandard.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/zTreeStandard.gif rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/zTreeStandard.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/zTreeStandard.png b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/zTreeStandard.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/zTreeStandard.png rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/img/zTreeStandard.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/zTreeStyle.css b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/zTreeStyle.css similarity index 98% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/zTreeStyle.css rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/zTreeStyle.css index 75765c530..5bdcd76f0 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/zTreeStyle.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/css/simple/zTreeStyle.css @@ -1,118 +1,118 @@ -/*------------------------------------- -zTree Style - -version: 3.4 -author: Hunter.z -email: hunter.z@263.net -website: http://code.google.com/p/jquerytree/ - --------------------------------------*/ - -.ztree * {padding:0; margin:0; font-size:12px; font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif} -.ztree {margin:0; padding:5px; color:#333} -.ztree li{padding:0; margin:0; list-style:none; line-height:21px; text-align:left; white-space:nowrap; outline:0} -.ztree li ul{ margin:0; padding:0 0 0 18px} -.ztree li ul.line{ background:url(./img/line_conn.png) 0 0 repeat-y;} - -.ztree li a {padding-right:3px; margin:0; cursor:pointer; height:21px; color:#333; background-color: transparent; text-decoration:none; display: inline-block} -.ztree li a:hover {text-decoration:underline} -.ztree li a.curSelectedNode {padding-top:0px; background-color:#e5e5e5; color:black; height:21px; opacity:0.8;} -.ztree li a.curSelectedNode_Edit {padding-top:0px; background-color:#e5e5e5; color:black; height:21px; border:1px #666 solid; opacity:0.8;} -.ztree li a.tmpTargetNode_inner {padding-top:0px; background-color:#aaa; color:white; height:21px; border:1px #666 solid; - opacity:0.8; filter:alpha(opacity=80)} -.ztree li a.tmpTargetNode_prev {} -.ztree li a.tmpTargetNode_next {} -.ztree li a input.rename {height:14px; width:80px; padding:0; margin:0; - font-size:12px; border:1px #7EC4CC solid; *border:0px} -.ztree li span {line-height:21px; margin-right:2px} -.ztree li span.button {line-height:0; margin:0; width:21px; height:21px; display: inline-block; vertical-align:middle; - border:0 none; cursor: pointer;outline:none; - background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; - background-image:url("./img/metro.png"); *background-image:url("./img/metro.gif")} - -.ztree li span.button.chk {width:13px; height:13px; margin:0 2px; cursor: auto} -.ztree li span.button.chk.checkbox_false_full {background-position: -5px -5px;} -.ztree li span.button.chk.checkbox_false_full_focus {background-position: -5px -26px;} -.ztree li span.button.chk.checkbox_false_part {background-position: -5px -48px;} -.ztree li span.button.chk.checkbox_false_part_focus {background-position: -5px -68px;} -.ztree li span.button.chk.checkbox_false_disable {background-position: -5px -89px;} -.ztree li span.button.chk.checkbox_true_full {background-position: -26px -5px;} -.ztree li span.button.chk.checkbox_true_full_focus {background-position: -26px -26px;} -.ztree li span.button.chk.checkbox_true_part {background-position: -26px -48px;} -.ztree li span.button.chk.checkbox_true_part_focus {background-position: -26px -68px;} -.ztree li span.button.chk.checkbox_true_disable {background-position: -26px -89px;} -.ztree li span.button.chk.radio_false_full {background-position: -47px -5px;} -.ztree li span.button.chk.radio_false_full_focus {background-position: -47px -26px;} -.ztree li span.button.chk.radio_false_part {background-position: -47px -47px;} -.ztree li span.button.chk.radio_false_part_focus {background-position: -47px -68px;} -.ztree li span.button.chk.radio_false_disable {background-position: -47px -89px;} -.ztree li span.button.chk.radio_true_full {background-position: -68px -5px;} -.ztree li span.button.chk.radio_true_full_focus {background-position: -68px -26px;} -.ztree li span.button.chk.radio_true_part {background-position: -68px -47px;} -.ztree li span.button.chk.radio_true_part_focus {background-position: -68px -68px;} -.ztree li span.button.chk.radio_true_disable {background-position: -68px -89px;} - -.ztree li span.button.switch {width:21px; height:21px} -.ztree li span.button.root_open{background-position:-92px -54px} -.ztree li span.button.root_close{background-position:-74px -54px} -.ztree li span.button.roots_open{background-position: -105px 0;} -.ztree li span.button.roots_close{background-position: -126px 0;} -.ztree li span.button.center_open{background-position: -105px -21px;} -.ztree li span.button.center_close{background-position: -126px -21px;} -.ztree li span.button.bottom_open{background-position: -105px -42px;} -.ztree li span.button.bottom_close{background-position: -126px -42px;} -.ztree li span.button.noline_open{background-position: -126px -84px;} -.ztree li span.button.noline_close{background-position: -105px -84px;} -.ztree li span.button.root_docu{ background:none;} -.ztree li span.button.roots_docu{background-position: -84px 0;} -.ztree li span.button.center_docu{background-position: -84px -21px;} -.ztree li span.button.bottom_docu{background-position: -84px -42px;} -.ztree li span.button.noline_docu{ background:none;} - -.ztree li span.button.ico_open{margin-right:2px; background-position: -147px -21px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.ico_close{margin-right:2px; margin-right:2px; background-position: -147px 0; vertical-align:top; *vertical-align:middle} -.ztree li span.button.ico_docu{margin-right:2px; background-position: -147px -42px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.edit {margin-left:2px; margin-right: -1px; background-position: -189px -21px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.edit:hover { - background-position: -168px -21px; -} -.ztree li span.button.remove {margin-left:2px; margin-right: -1px; background-position: -189px -42px; vertical-align:top; *vertical-align:middle} -.ztree li span.button.remove:hover { - background-position: -168px -42px; -} -.ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position: -189px 0; vertical-align:top; *vertical-align:middle} -.ztree li span.button.add:hover { - background-position: -168px 0; -} -.ztree li span.button.ico_loading{margin-right:2px; background:url(./img/loading.gif) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle} - -ul.tmpTargetzTree {background-color:#FFE6B0; opacity:0.8; filter:alpha(opacity=80)} - -span.tmpzTreeMove_arrow {width:16px; height:21px; display: inline-block; padding:0; margin:2px 0 0 1px; border:0 none; position:absolute; - background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; - background-position:-168px -84px; background-image:url("./img/metro.png"); *background-image:url("./img/metro.gif")} - -ul.ztree.zTreeDragUL {margin:0; padding:0; position:absolute; width:auto; height:auto;overflow:hidden; background-color:#cfcfcf; border:1px #00B83F dotted; opacity:0.8; filter:alpha(opacity=80)} -.zTreeMask {z-index:10000; background-color:#cfcfcf; opacity:0.0; filter:alpha(opacity=0); position:absolute} - -/* simple */ - -.ztree * {font-size:14px;font-family:"Microsoft Yahei",Verdana,Simsun,"Segoe UI Web Light","Segoe UI Light","Segoe UI Web Regular","Segoe UI","Segoe UI Symbol","Helvetica Neue",Arial;} -.ztree li ul{ margin:0; padding:0} -.ztree li {line-height:28px;} -.ztree li a {width:100%;height:28px;padding-top: 0px;} -.ztree li a:hover {text-decoration:none; background-color: #E7E7E7;} -.ztree11 li a span.button.switch {visibility:hidden} -.ztree11.showIcon li a span.button.switch {visibility:visible} -.ztree li a.curSelectedNode {background-color:#D4D4D4;border:0;height:28px;} -.ztree li span {line-height:26px;margin-right:0px;} -.ztree li span.button {margin-top: -7px;} -.ztree li span.button.switch {width:16px;height: 16px;} -.ztree li a.level0 span {font-size:15px;font-weight:bold;} -.ztree li span.button {background-image:url("img/left_menu.png"); *background-image:url("./left_menu.gif")} -.ztree li span.button.switch.level0 {width: 20px; height:20px} -.ztree li span.button.switch.level1 {width: 20px; height:20px} -.ztree li span.button.noline_open {background-position: 0 0;} -.ztree li span.button.noline_close {background-position: -18px 0;} -.ztree li span.button.noline_open.level0 {background-position: 0 -17px;} -.ztree li span.button.noline_close.level0 {background-position: -18px -17px;} +/*------------------------------------- +zTree Style + +version: 3.4 +author: Hunter.z +email: hunter.z@263.net +website: http://code.google.com/p/jquerytree/ + +-------------------------------------*/ + +.ztree * {padding:0; margin:0; font-size:12px; font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif} +.ztree {margin:0; padding:5px; color:#333} +.ztree li{padding:0; margin:0; list-style:none; line-height:21px; text-align:left; white-space:nowrap; outline:0} +.ztree li ul{ margin:0; padding:0 0 0 18px} +.ztree li ul.line{ background:url(./img/line_conn.png) 0 0 repeat-y;} + +.ztree li a {padding-right:3px; margin:0; cursor:pointer; height:21px; color:#333; background-color: transparent; text-decoration:none; display: inline-block} +.ztree li a:hover {text-decoration:underline} +.ztree li a.curSelectedNode {padding-top:0px; background-color:#e5e5e5; color:black; height:21px; opacity:0.8;} +.ztree li a.curSelectedNode_Edit {padding-top:0px; background-color:#e5e5e5; color:black; height:21px; border:1px #666 solid; opacity:0.8;} +.ztree li a.tmpTargetNode_inner {padding-top:0px; background-color:#aaa; color:white; height:21px; border:1px #666 solid; + opacity:0.8; filter:alpha(opacity=80)} +.ztree li a.tmpTargetNode_prev {} +.ztree li a.tmpTargetNode_next {} +.ztree li a input.rename {height:14px; width:80px; padding:0; margin:0; + font-size:12px; border:1px #7EC4CC solid; *border:0px} +.ztree li span {line-height:21px; margin-right:2px} +.ztree li span.button {line-height:0; margin:0; width:21px; height:21px; display: inline-block; vertical-align:middle; + border:0 none; cursor: pointer;outline:none; + background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; + background-image:url("./img/metro.png"); *background-image:url("./img/metro.gif")} + +.ztree li span.button.chk {width:13px; height:13px; margin:0 2px; cursor: auto} +.ztree li span.button.chk.checkbox_false_full {background-position: -5px -5px;} +.ztree li span.button.chk.checkbox_false_full_focus {background-position: -5px -26px;} +.ztree li span.button.chk.checkbox_false_part {background-position: -5px -48px;} +.ztree li span.button.chk.checkbox_false_part_focus {background-position: -5px -68px;} +.ztree li span.button.chk.checkbox_false_disable {background-position: -5px -89px;} +.ztree li span.button.chk.checkbox_true_full {background-position: -26px -5px;} +.ztree li span.button.chk.checkbox_true_full_focus {background-position: -26px -26px;} +.ztree li span.button.chk.checkbox_true_part {background-position: -26px -48px;} +.ztree li span.button.chk.checkbox_true_part_focus {background-position: -26px -68px;} +.ztree li span.button.chk.checkbox_true_disable {background-position: -26px -89px;} +.ztree li span.button.chk.radio_false_full {background-position: -47px -5px;} +.ztree li span.button.chk.radio_false_full_focus {background-position: -47px -26px;} +.ztree li span.button.chk.radio_false_part {background-position: -47px -47px;} +.ztree li span.button.chk.radio_false_part_focus {background-position: -47px -68px;} +.ztree li span.button.chk.radio_false_disable {background-position: -47px -89px;} +.ztree li span.button.chk.radio_true_full {background-position: -68px -5px;} +.ztree li span.button.chk.radio_true_full_focus {background-position: -68px -26px;} +.ztree li span.button.chk.radio_true_part {background-position: -68px -47px;} +.ztree li span.button.chk.radio_true_part_focus {background-position: -68px -68px;} +.ztree li span.button.chk.radio_true_disable {background-position: -68px -89px;} + +.ztree li span.button.switch {width:21px; height:21px} +.ztree li span.button.root_open{background-position:-92px -54px} +.ztree li span.button.root_close{background-position:-74px -54px} +.ztree li span.button.roots_open{background-position: -105px 0;} +.ztree li span.button.roots_close{background-position: -126px 0;} +.ztree li span.button.center_open{background-position: -105px -21px;} +.ztree li span.button.center_close{background-position: -126px -21px;} +.ztree li span.button.bottom_open{background-position: -105px -42px;} +.ztree li span.button.bottom_close{background-position: -126px -42px;} +.ztree li span.button.noline_open{background-position: -126px -84px;} +.ztree li span.button.noline_close{background-position: -105px -84px;} +.ztree li span.button.root_docu{ background:none;} +.ztree li span.button.roots_docu{background-position: -84px 0;} +.ztree li span.button.center_docu{background-position: -84px -21px;} +.ztree li span.button.bottom_docu{background-position: -84px -42px;} +.ztree li span.button.noline_docu{ background:none;} + +.ztree li span.button.ico_open{margin-right:2px; background-position: -147px -21px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.ico_close{margin-right:2px; margin-right:2px; background-position: -147px 0; vertical-align:top; *vertical-align:middle} +.ztree li span.button.ico_docu{margin-right:2px; background-position: -147px -42px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.edit {margin-left:2px; margin-right: -1px; background-position: -189px -21px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.edit:hover { + background-position: -168px -21px; +} +.ztree li span.button.remove {margin-left:2px; margin-right: -1px; background-position: -189px -42px; vertical-align:top; *vertical-align:middle} +.ztree li span.button.remove:hover { + background-position: -168px -42px; +} +.ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position: -189px 0; vertical-align:top; *vertical-align:middle} +.ztree li span.button.add:hover { + background-position: -168px 0; +} +.ztree li span.button.ico_loading{margin-right:2px; background:url(./img/loading.gif) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle} + +ul.tmpTargetzTree {background-color:#FFE6B0; opacity:0.8; filter:alpha(opacity=80)} + +span.tmpzTreeMove_arrow {width:16px; height:21px; display: inline-block; padding:0; margin:2px 0 0 1px; border:0 none; position:absolute; + background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; + background-position:-168px -84px; background-image:url("./img/metro.png"); *background-image:url("./img/metro.gif")} + +ul.ztree.zTreeDragUL {margin:0; padding:0; position:absolute; width:auto; height:auto;overflow:hidden; background-color:#cfcfcf; border:1px #00B83F dotted; opacity:0.8; filter:alpha(opacity=80)} +.zTreeMask {z-index:10000; background-color:#cfcfcf; opacity:0.0; filter:alpha(opacity=0); position:absolute} + +/* simple */ + +.ztree * {font-size:14px;font-family:"Microsoft Yahei",Verdana,Simsun,"Segoe UI Web Light","Segoe UI Light","Segoe UI Web Regular","Segoe UI","Segoe UI Symbol","Helvetica Neue",Arial;} +.ztree li ul{ margin:0; padding:0} +.ztree li {line-height:28px;} +.ztree li a {width:100%;height:28px;padding-top: 0px;} +.ztree li a:hover {text-decoration:none; background-color: #E7E7E7;} +.ztree11 li a span.button.switch {visibility:hidden} +.ztree11.showIcon li a span.button.switch {visibility:visible} +.ztree li a.curSelectedNode {background-color:#D4D4D4;border:0;height:28px;} +.ztree li span {line-height:26px;margin-right:0px;} +.ztree li span.button {margin-top: -7px;} +.ztree li span.button.switch {width:16px;height: 16px;} +.ztree li a.level0 span {font-size:15px;font-weight:bold;} +.ztree li span.button {background-image:url("img/left_menu.png"); *background-image:url("./left_menu.gif")} +.ztree li span.button.switch.level0 {width: 20px; height:20px} +.ztree li span.button.switch.level1 {width: 20px; height:20px} +.ztree li span.button.noline_open {background-position: 0 0;} +.ztree li span.button.noline_close {background-position: -18px 0;} +.ztree li span.button.noline_open.level0 {background-position: 0 -17px;} +.ztree li span.button.noline_close.level0 {background-position: -18px -17px;} diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js index 6dac9b30f..d71caf869 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js @@ -1,3820 +1,3820 @@ - -/* - * JQuery zTree core 3.5.12 - * http://zTree.me/ - * - * Copyright (c) 2010 Hunter.z - * - * Licensed same as jquery - MIT License - * http://www.opensource.org/licenses/mit-license.php - * - * email: hunter.z@263.net - * Date: 2013-03-11 - */ -(function($){ - var settings = {}, roots = {}, caches = {}, - //default consts of core - _consts = { - className: { - BUTTON: "button", - LEVEL: "level", - ICO_LOADING: "ico_loading", - SWITCH: "switch" - }, - event: { - NODECREATED: "ztree_nodeCreated", - CLICK: "ztree_click", - EXPAND: "ztree_expand", - COLLAPSE: "ztree_collapse", - ASYNC_SUCCESS: "ztree_async_success", - ASYNC_ERROR: "ztree_async_error" - }, - id: { - A: "_a", - ICON: "_ico", - SPAN: "_span", - SWITCH: "_switch", - UL: "_ul" - }, - line: { - ROOT: "root", - ROOTS: "roots", - CENTER: "center", - BOTTOM: "bottom", - NOLINE: "noline", - LINE: "line" - }, - folder: { - OPEN: "open", - CLOSE: "close", - DOCU: "docu" - }, - node: { - CURSELECTED: "curSelectedNode" - } - }, - //default setting of core - _setting = { - treeId: "", - treeObj: null, - view: { - addDiyDom: null, - autoCancelSelected: true, - dblClickExpand: true, - expandSpeed: "fast", - fontCss: {}, - nameIsHTML: false, - selectedMulti: true, - showIcon: true, - showLine: true, - showTitle: true - }, - data: { - key: { - children: "children", - name: "name", - title: "", - url: "url" - }, - simpleData: { - enable: false, - idKey: "id", - pIdKey: "pId", - rootPId: null - }, - keep: { - parent: false, - leaf: false - } - }, - async: { - enable: false, - contentType: "application/x-www-form-urlencoded", - type: "post", - dataType: "text", - url: "", - autoParam: [], - otherParam: [], - dataFilter: null - }, - callback: { - beforeAsync:null, - beforeClick:null, - beforeDblClick:null, - beforeRightClick:null, - beforeMouseDown:null, - beforeMouseUp:null, - beforeExpand:null, - beforeCollapse:null, - beforeRemove:null, - - onAsyncError:null, - onAsyncSuccess:null, - onNodeCreated:null, - onClick:null, - onDblClick:null, - onRightClick:null, - onMouseDown:null, - onMouseUp:null, - onExpand:null, - onCollapse:null, - onRemove:null - } - }, - //default root of core - //zTree use root to save full data - _initRoot = function (setting) { - var r = data.getRoot(setting); - if (!r) { - r = {}; - data.setRoot(setting, r); - } - r[setting.data.key.children] = []; - r.expandTriggerFlag = false; - r.curSelectedList = []; - r.noSelection = true; - r.createdNodes = []; - r.zId = 0; - r._ver = (new Date()).getTime(); - }, - //default cache of core - _initCache = function(setting) { - var c = data.getCache(setting); - if (!c) { - c = {}; - data.setCache(setting, c); - } - c.nodes = []; - c.doms = []; - }, - //default bindEvent of core - _bindEvent = function(setting) { - var o = setting.treeObj, - c = consts.event; - o.bind(c.NODECREATED, function (event, treeId, node) { - tools.apply(setting.callback.onNodeCreated, [event, treeId, node]); - }); - - o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) { - tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]); - }); - - o.bind(c.EXPAND, function (event, treeId, node) { - tools.apply(setting.callback.onExpand, [event, treeId, node]); - }); - - o.bind(c.COLLAPSE, function (event, treeId, node) { - tools.apply(setting.callback.onCollapse, [event, treeId, node]); - }); - - o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) { - tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]); - }); - - o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) { - tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]); - }); - }, - _unbindEvent = function(setting) { - var o = setting.treeObj, - c = consts.event; - o.unbind(c.NODECREATED) - .unbind(c.CLICK) - .unbind(c.EXPAND) - .unbind(c.COLLAPSE) - .unbind(c.ASYNC_SUCCESS) - .unbind(c.ASYNC_ERROR); - }, - //default event proxy of core - _eventProxy = function(event) { - var target = event.target, - setting = data.getSetting(event.data.treeId), - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null, - tmp = null; - - if (tools.eqs(event.type, "mousedown")) { - treeEventType = "mousedown"; - } else if (tools.eqs(event.type, "mouseup")) { - treeEventType = "mouseup"; - } else if (tools.eqs(event.type, "contextmenu")) { - treeEventType = "contextmenu"; - } else if (tools.eqs(event.type, "click")) { - if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.SWITCH) !== null) { - tId = ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)).id; - nodeEventType = "switchNode"; - } else { - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) { - tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id; - nodeEventType = "clickNode"; - } - } - } else if (tools.eqs(event.type, "dblclick")) { - treeEventType = "dblclick"; - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) { - tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id; - nodeEventType = "switchNode"; - } - } - if (treeEventType.length > 0 && tId.length == 0) { - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) {tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;} - } - // event to node - if (tId.length>0) { - node = data.getNodeCache(setting, tId); - switch (nodeEventType) { - case "switchNode" : - if (!node.isParent) { - nodeEventType = ""; - } else if (tools.eqs(event.type, "click") - || (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) { - nodeEventCallback = handler.onSwitchNode; - } else { - nodeEventType = ""; - } - break; - case "clickNode" : - nodeEventCallback = handler.onClickNode; - break; - } - } - // event to zTree - switch (treeEventType) { - case "mousedown" : - treeEventCallback = handler.onZTreeMousedown; - break; - case "mouseup" : - treeEventCallback = handler.onZTreeMouseup; - break; - case "dblclick" : - treeEventCallback = handler.onZTreeDblclick; - break; - case "contextmenu" : - treeEventCallback = handler.onZTreeContextmenu; - break; - } - var proxyResult = { - stop: false, - node: node, - nodeEventType: nodeEventType, - nodeEventCallback: nodeEventCallback, - treeEventType: treeEventType, - treeEventCallback: treeEventCallback - }; - return proxyResult - }, - //default init node of core - _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { - if (!n) return; - var r = data.getRoot(setting), - childKey = setting.data.key.children; - n.level = level; - n.tId = setting.treeId + "_" + (++r.zId); - n.parentTId = parentNode ? parentNode.tId : null; - if (n[childKey] && n[childKey].length > 0) { - if (typeof n.open == "string") n.open = tools.eqs(n.open, "true"); - n.open = !!n.open; - n.isParent = true; - n.zAsync = true; - } else { - n.open = false; - if (typeof n.isParent == "string") n.isParent = tools.eqs(n.isParent, "true"); - n.isParent = !!n.isParent; - n.zAsync = !n.isParent; - } - n.isFirstNode = isFirstNode; - n.isLastNode = isLastNode; - n.getParentNode = function() {return data.getNodeCache(setting, n.parentTId);}; - n.getPreNode = function() {return data.getPreNode(setting, n);}; - n.getNextNode = function() {return data.getNextNode(setting, n);}; - n.isAjaxing = false; - data.fixPIdKeyValue(setting, n); - }, - _init = { - bind: [_bindEvent], - unbind: [_unbindEvent], - caches: [_initCache], - nodes: [_initNode], - proxys: [_eventProxy], - roots: [_initRoot], - beforeA: [], - afterA: [], - innerBeforeA: [], - innerAfterA: [], - zTreeTools: [] - }, - //method of operate data - data = { - addNodeCache: function(setting, node) { - data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node; - }, - getNodeCacheId: function(tId) { - return tId.substring(tId.lastIndexOf("_")+1); - }, - addAfterA: function(afterA) { - _init.afterA.push(afterA); - }, - addBeforeA: function(beforeA) { - _init.beforeA.push(beforeA); - }, - addInnerAfterA: function(innerAfterA) { - _init.innerAfterA.push(innerAfterA); - }, - addInnerBeforeA: function(innerBeforeA) { - _init.innerBeforeA.push(innerBeforeA); - }, - addInitBind: function(bindEvent) { - _init.bind.push(bindEvent); - }, - addInitUnBind: function(unbindEvent) { - _init.unbind.push(unbindEvent); - }, - addInitCache: function(initCache) { - _init.caches.push(initCache); - }, - addInitNode: function(initNode) { - _init.nodes.push(initNode); - }, - addInitProxy: function(initProxy) { - _init.proxys.push(initProxy); - }, - addInitRoot: function(initRoot) { - _init.roots.push(initRoot); - }, - addNodesData: function(setting, parentNode, nodes) { - var childKey = setting.data.key.children; - if (!parentNode[childKey]) parentNode[childKey] = []; - if (parentNode[childKey].length > 0) { - parentNode[childKey][parentNode[childKey].length - 1].isLastNode = false; - view.setNodeLineIcos(setting, parentNode[childKey][parentNode[childKey].length - 1]); - } - parentNode.isParent = true; - parentNode[childKey] = parentNode[childKey].concat(nodes); - }, - addSelectedNode: function(setting, node) { - var root = data.getRoot(setting); - if (!data.isSelectedNode(setting, node)) { - root.curSelectedList.push(node); - } - }, - addCreatedNode: function(setting, node) { - if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { - var root = data.getRoot(setting); - root.createdNodes.push(node); - } - }, - addZTreeTools: function(zTreeTools) { - _init.zTreeTools.push(zTreeTools); - }, - exSetting: function(s) { - $.extend(true, _setting, s); - }, - fixPIdKeyValue: function(setting, node) { - if (setting.data.simpleData.enable) { - node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId; - } - }, - getAfterA: function(setting, node, array) { - for (var i=0, j=_init.afterA.length; i-1) { - result.push(nodes[i]); - } - result = result.concat(data.getNodesByParamFuzzy(setting, nodes[i][childKey], key, value)); - } - return result; - }, - getNodesByFilter: function(setting, nodes, filter, isSingle, invokeParam) { - if (!nodes) return (isSingle ? null : []); - var childKey = setting.data.key.children, - result = isSingle ? null : []; - for (var i = 0, l = nodes.length; i < l; i++) { - if (tools.apply(filter, [nodes[i], invokeParam], false)) { - if (isSingle) {return nodes[i];} - result.push(nodes[i]); - } - var tmpResult = data.getNodesByFilter(setting, nodes[i][childKey], filter, isSingle, invokeParam); - if (isSingle && !!tmpResult) {return tmpResult;} - result = isSingle ? tmpResult : result.concat(tmpResult); - } - return result; - }, - getPreNode: function(setting, node) { - if (!node) return null; - var childKey = setting.data.key.children, - p = node.parentTId ? node.getParentNode() : data.getRoot(setting); - for (var i=0, l=p[childKey].length; i 0))); - }, - clone: function (obj){ - if (obj === null) return null; - var o = obj.constructor === Array ? [] : {}; - for(var i in obj){ - o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? arguments.callee(obj[i]) : obj[i]); - } - return o; - }, - eqs: function(str1, str2) { - return str1.toLowerCase() === str2.toLowerCase(); - }, - isArray: function(arr) { - return Object.prototype.toString.apply(arr) === "[object Array]"; - }, - getMDom: function (setting, curDom, targetExpr) { - if (!curDom) return null; - while (curDom && curDom.id !== setting.treeId) { - for (var i=0, l=targetExpr.length; curDom.tagName && i 0) { - //make child html first, because checkType - childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open); - } - if (openFlag) { - - view.makeDOMNodeMainBefore(html, setting, node); - view.makeDOMNodeLine(html, setting, node); - data.getBeforeA(setting, node, html); - view.makeDOMNodeNameBefore(html, setting, node); - data.getInnerBeforeA(setting, node, html); - view.makeDOMNodeIcon(html, setting, node); - data.getInnerAfterA(setting, node, html); - view.makeDOMNodeNameAfter(html, setting, node); - data.getAfterA(setting, node, html); - if (node.isParent && node.open) { - view.makeUlHtml(setting, node, html, childHtml.join('')); - } - view.makeDOMNodeMainAfter(html, setting, node); - data.addCreatedNode(setting, node); - } - } - return html; - }, - appendParentULDom: function(setting, node) { - var html = [], - nObj = $("#" + node.tId), - ulObj = $("#" + node.tId + consts.id.UL), - childKey = setting.data.key.children, - childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true); - view.makeUlHtml(setting, node, html, childHtml.join('')); - if (!nObj.get(0) && !!node.parentTId) { - view.appendParentULDom(setting, node.getParentNode()); - nObj = $("#" + node.tId); - } - if (ulObj.get(0)) { - ulObj.remove(); - } - nObj.append(html.join('')); - }, - asyncNode: function(setting, node, isSilent, callback) { - var i, l; - if (node && !node.isParent) { - tools.apply(callback); - return false; - } else if (node && node.isAjaxing) { - return false; - } else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) { - tools.apply(callback); - return false; - } - if (node) { - node.isAjaxing = true; - var icoObj = $("#" + node.tId + consts.id.ICON); - icoObj.attr({"style":"", "class":consts.className.BUTTON + " " + consts.className.ICO_LOADING}); - } - - var tmpParam = {}; - for (i = 0, l = setting.async.autoParam.length; node && i < l; i++) { - var pKey = setting.async.autoParam[i].split("="), spKey = pKey; - if (pKey.length>1) { - spKey = pKey[1]; - pKey = pKey[0]; - } - tmpParam[spKey] = node[pKey]; - } - if (tools.isArray(setting.async.otherParam)) { - for (i = 0, l = setting.async.otherParam.length; i < l; i += 2) { - tmpParam[setting.async.otherParam[i]] = setting.async.otherParam[i + 1]; - } - } else { - for (var p in setting.async.otherParam) { - tmpParam[p] = setting.async.otherParam[p]; - } - } - - var _tmpV = data.getRoot(setting)._ver; - $.ajax({ - contentType: setting.async.contentType, - type: setting.async.type, - url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url), - data: tmpParam, - dataType: setting.async.dataType, - success: function(msg) { - if (_tmpV != data.getRoot(setting)._ver) { - return; - } - var newNodes = []; - try { - if (!msg || msg.length == 0) { - newNodes = []; - } else if (typeof msg == "string") { - newNodes = eval("(" + msg + ")"); - } else { - newNodes = msg; - } - } catch(err) { - newNodes = msg; - } - - if (node) { - node.isAjaxing = null; - node.zAsync = true; - } - view.setNodeLineIcos(setting, node); - if (newNodes && newNodes !== "") { - newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes); - view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent); - } else { - view.addNodes(setting, node, [], !!isSilent); - } - setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]); - tools.apply(callback); - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - if (_tmpV != data.getRoot(setting)._ver) { - return; - } - if (node) node.isAjaxing = null; - view.setNodeLineIcos(setting, node); - setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]); - } - }); - return true; - }, - cancelPreSelectedNode: function (setting, node) { - var list = data.getRoot(setting).curSelectedList; - for (var i=0, j=list.length-1; j>=i; j--) { - if (!node || node === list[j]) { - $("#" + list[j].tId + consts.id.A).removeClass(consts.node.CURSELECTED); - if (node) { - data.removeSelectedNode(setting, node); - break; - } - } - } - if (!node) data.getRoot(setting).curSelectedList = []; - }, - createNodeCallback: function(setting) { - if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { - var root = data.getRoot(setting); - while (root.createdNodes.length>0) { - var node = root.createdNodes.shift(); - tools.apply(setting.view.addDiyDom, [setting.treeId, node]); - if (!!setting.callback.onNodeCreated) { - setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]); - } - } - } - }, - createNodes: function(setting, level, nodes, parentNode) { - if (!nodes || nodes.length == 0) return; - var root = data.getRoot(setting), - childKey = setting.data.key.children, - openFlag = !parentNode || parentNode.open || !!$("#" + parentNode[childKey][0].tId).get(0); - root.createdNodes = []; - var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag); - if (!parentNode) { - setting.treeObj.append(zTreeHtml.join('')); - } else { - var ulObj = $("#" + parentNode.tId + consts.id.UL); - if (ulObj.get(0)) { - ulObj.append(zTreeHtml.join('')); - } - } - view.createNodeCallback(setting); - }, - destroy: function(setting) { - if (!setting) return; - data.initCache(setting); - data.initRoot(setting); - event.unbindTree(setting); - event.unbindEvent(setting); - setting.treeObj.empty(); - }, - expandCollapseNode: function(setting, node, expandFlag, animateFlag, callback) { - var root = data.getRoot(setting), - childKey = setting.data.key.children; - if (!node) { - tools.apply(callback, []); - return; - } - if (root.expandTriggerFlag) { - var _callback = callback; - callback = function(){ - if (_callback) _callback(); - if (node.open) { - setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]); - } else { - setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]); - } - }; - root.expandTriggerFlag = false; - } - if (!node.open && node.isParent && ((!$("#" + node.tId + consts.id.UL).get(0)) || (node[childKey] && node[childKey].length>0 && !$("#" + node[childKey][0].tId).get(0)))) { - view.appendParentULDom(setting, node); - view.createNodeCallback(setting); - } - if (node.open == expandFlag) { - tools.apply(callback, []); - return; - } - var ulObj = $("#" + node.tId + consts.id.UL), - switchObj = $("#" + node.tId + consts.id.SWITCH), - icoObj = $("#" + node.tId + consts.id.ICON); - - if (node.isParent) { - node.open = !node.open; - if (node.iconOpen && node.iconClose) { - icoObj.attr("style", view.makeNodeIcoStyle(setting, node)); - } - - if (node.open) { - view.replaceSwitchClass(node, switchObj, consts.folder.OPEN); - view.replaceIcoClass(node, icoObj, consts.folder.OPEN); - if (animateFlag == false || setting.view.expandSpeed == "") { - ulObj.show(); - tools.apply(callback, []); - } else { - if (node[childKey] && node[childKey].length > 0) { - ulObj.slideDown(setting.view.expandSpeed, callback); - } else { - ulObj.show(); - tools.apply(callback, []); - } - } - } else { - view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE); - view.replaceIcoClass(node, icoObj, consts.folder.CLOSE); - if (animateFlag == false || setting.view.expandSpeed == "" || !(node[childKey] && node[childKey].length > 0)) { - ulObj.hide(); - tools.apply(callback, []); - } else { - ulObj.slideUp(setting.view.expandSpeed, callback); - } - } - } else { - tools.apply(callback, []); - } - }, - expandCollapseParentNode: function(setting, node, expandFlag, animateFlag, callback) { - if (!node) return; - if (!node.parentTId) { - view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback); - return; - } else { - view.expandCollapseNode(setting, node, expandFlag, animateFlag); - } - if (node.parentTId) { - view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback); - } - }, - expandCollapseSonNode: function(setting, node, expandFlag, animateFlag, callback) { - var root = data.getRoot(setting), - childKey = setting.data.key.children, - treeNodes = (node) ? node[childKey]: root[childKey], - selfAnimateSign = (node) ? false : animateFlag, - expandTriggerFlag = data.getRoot(setting).expandTriggerFlag; - data.getRoot(setting).expandTriggerFlag = false; - if (treeNodes) { - for (var i = 0, l = treeNodes.length; i < l; i++) { - if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign); - } - } - data.getRoot(setting).expandTriggerFlag = expandTriggerFlag; - view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback ); - }, - makeDOMNodeIcon: function(html, setting, node) { - var nameStr = data.getNodeName(setting, node), - name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g,'&').replace(//g,'>'); - html.push("",name,""); - }, - makeDOMNodeLine: function(html, setting, node) { - html.push(""); - }, - makeDOMNodeMainAfter: function(html, setting, node) { - html.push(""); - }, - makeDOMNodeMainBefore: function(html, setting, node) { - html.push("
      • "); - }, - makeDOMNodeNameAfter: function(html, setting, node) { - html.push(""); - }, - makeDOMNodeNameBefore: function(html, setting, node) { - var title = data.getNodeTitle(setting, node), - url = view.makeNodeUrl(setting, node), - fontcss = view.makeNodeFontCss(setting, node), - fontStyle = []; - for (var f in fontcss) { - fontStyle.push(f, ":", fontcss[f], ";"); - } - html.push(" 0) ? "href='" + url + "'" : ""), " target='",view.makeNodeTarget(node),"' style='", fontStyle.join(''), - "'"); - if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) {html.push("title='", title.replace(/'/g,"'").replace(//g,'>'),"'");} - html.push(">"); - }, - makeNodeFontCss: function(setting, node) { - var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss); - return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {}; - }, - makeNodeIcoClass: function(setting, node) { - var icoCss = ["ico"]; - if (!node.isAjaxing) { - icoCss[0] = (node.iconSkin ? node.iconSkin + "_" : "") + icoCss[0]; - if (node.isParent) { - icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); - } else { - icoCss.push(consts.folder.DOCU); - } - } - return consts.className.BUTTON + " " + icoCss.join('_'); - }, - makeNodeIcoStyle: function(setting, node) { - var icoStyle = []; - if (!node.isAjaxing) { - var icon = (node.isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node.icon; - if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;"); - if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) { - icoStyle.push("width:0px;height:0px;"); - } - } - return icoStyle.join(''); - }, - makeNodeLineClass: function(setting, node) { - var lineClass = []; - if (setting.view.showLine) { - if (node.level == 0 && node.isFirstNode && node.isLastNode) { - lineClass.push(consts.line.ROOT); - } else if (node.level == 0 && node.isFirstNode) { - lineClass.push(consts.line.ROOTS); - } else if (node.isLastNode) { - lineClass.push(consts.line.BOTTOM); - } else { - lineClass.push(consts.line.CENTER); - } - } else { - lineClass.push(consts.line.NOLINE); - } - if (node.isParent) { - lineClass.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); - } else { - lineClass.push(consts.folder.DOCU); - } - return view.makeNodeLineClassEx(node) + lineClass.join('_'); - }, - makeNodeLineClassEx: function(node) { - return consts.className.BUTTON + " " + consts.className.LEVEL + node.level + " " + consts.className.SWITCH + " "; - }, - makeNodeTarget: function(node) { - return (node.target || "_blank"); - }, - makeNodeUrl: function(setting, node) { - var urlKey = setting.data.key.url; - return node[urlKey] ? node[urlKey] : null; - }, - makeUlHtml: function(setting, node, html, content) { - html.push("
          "); - html.push(content); - html.push("
        "); - }, - makeUlLineClass: function(setting, node) { - return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : ""); - }, - removeChildNodes: function(setting, node) { - if (!node) return; - var childKey = setting.data.key.children, - nodes = node[childKey]; - if (!nodes) return; - - for (var i = 0, l = nodes.length; i < l; i++) { - data.removeNodeCache(setting, nodes[i]); - } - data.removeSelectedNode(setting); - delete node[childKey]; - - if (!setting.data.keep.parent) { - node.isParent = false; - node.open = false; - var tmp_switchObj = $("#" + node.tId + consts.id.SWITCH), - tmp_icoObj = $("#" + node.tId + consts.id.ICON); - view.replaceSwitchClass(node, tmp_switchObj, consts.folder.DOCU); - view.replaceIcoClass(node, tmp_icoObj, consts.folder.DOCU); - $("#" + node.tId + consts.id.UL).remove(); - } else { - $("#" + node.tId + consts.id.UL).empty(); - } - }, - setFirstNode: function(setting, parentNode) { - var childKey = setting.data.key.children, childLength = parentNode[childKey].length; - if ( childLength > 0) { - parentNode[childKey][0].isFirstNode = true; - } - }, - setLastNode: function(setting, parentNode) { - var childKey = setting.data.key.children, childLength = parentNode[childKey].length; - if ( childLength > 0) { - parentNode[childKey][childLength - 1].isLastNode = true; - } - }, - removeNode: function(setting, node) { - var root = data.getRoot(setting), - childKey = setting.data.key.children, - parentNode = (node.parentTId) ? node.getParentNode() : root; - - node.isFirstNode = false; - node.isLastNode = false; - node.getPreNode = function() {return null;}; - node.getNextNode = function() {return null;}; - - if (!data.getNodeCache(setting, node.tId)) { - return; - } - - $("#" + node.tId).remove(); - data.removeNodeCache(setting, node); - data.removeSelectedNode(setting, node); - - for (var i = 0, l = parentNode[childKey].length; i < l; i++) { - if (parentNode[childKey][i].tId == node.tId) { - parentNode[childKey].splice(i, 1); - break; - } - } - view.setFirstNode(setting, parentNode); - view.setLastNode(setting, parentNode); - - var tmp_ulObj,tmp_switchObj,tmp_icoObj, - childLength = parentNode[childKey].length; - - //repair nodes old parent - if (!setting.data.keep.parent && childLength == 0) { - //old parentNode has no child nodes - parentNode.isParent = false; - parentNode.open = false; - tmp_ulObj = $("#" + parentNode.tId + consts.id.UL); - tmp_switchObj = $("#" + parentNode.tId + consts.id.SWITCH); - tmp_icoObj = $("#" + parentNode.tId + consts.id.ICON); - view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU); - view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU); - tmp_ulObj.css("display", "none"); - - } else if (setting.view.showLine && childLength > 0) { - //old parentNode has child nodes - var newLast = parentNode[childKey][childLength - 1]; - tmp_ulObj = $("#" + newLast.tId + consts.id.UL); - tmp_switchObj = $("#" + newLast.tId + consts.id.SWITCH); - tmp_icoObj = $("#" + newLast.tId + consts.id.ICON); - if (parentNode == root) { - if (parentNode[childKey].length == 1) { - //node was root, and ztree has only one root after move node - view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT); - } else { - var tmp_first_switchObj = $("#" + parentNode[childKey][0].tId + consts.id.SWITCH); - view.replaceSwitchClass(parentNode[childKey][0], tmp_first_switchObj, consts.line.ROOTS); - view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); - } - } else { - view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); - } - tmp_ulObj.removeClass(consts.line.LINE); - } - }, - replaceIcoClass: function(node, obj, newName) { - if (!obj || node.isAjaxing) return; - var tmpName = obj.attr("class"); - if (tmpName == undefined) return; - var tmpList = tmpName.split("_"); - switch (newName) { - case consts.folder.OPEN: - case consts.folder.CLOSE: - case consts.folder.DOCU: - tmpList[tmpList.length-1] = newName; - break; - } - obj.attr("class", tmpList.join("_")); - }, - replaceSwitchClass: function(node, obj, newName) { - if (!obj) return; - var tmpName = obj.attr("class"); - if (tmpName == undefined) return; - var tmpList = tmpName.split("_"); - switch (newName) { - case consts.line.ROOT: - case consts.line.ROOTS: - case consts.line.CENTER: - case consts.line.BOTTOM: - case consts.line.NOLINE: - tmpList[0] = view.makeNodeLineClassEx(node) + newName; - break; - case consts.folder.OPEN: - case consts.folder.CLOSE: - case consts.folder.DOCU: - tmpList[1] = newName; - break; - } - obj.attr("class", tmpList.join("_")); - if (newName !== consts.folder.DOCU) { - obj.removeAttr("disabled"); - } else { - obj.attr("disabled", "disabled"); - } - }, - selectNode: function(setting, node, addFlag) { - if (!addFlag) { - view.cancelPreSelectedNode(setting); - } - $("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED); - data.addSelectedNode(setting, node); - }, - setNodeFontCss: function(setting, treeNode) { - var aObj = $("#" + treeNode.tId + consts.id.A), - fontCss = view.makeNodeFontCss(setting, treeNode); - if (fontCss) { - aObj.css(fontCss); - } - }, - setNodeLineIcos: function(setting, node) { - if (!node) return; - var switchObj = $("#" + node.tId + consts.id.SWITCH), - ulObj = $("#" + node.tId + consts.id.UL), - icoObj = $("#" + node.tId + consts.id.ICON), - ulLine = view.makeUlLineClass(setting, node); - if (ulLine.length==0) { - ulObj.removeClass(consts.line.LINE); - } else { - ulObj.addClass(ulLine); - } - switchObj.attr("class", view.makeNodeLineClass(setting, node)); - if (node.isParent) { - switchObj.removeAttr("disabled"); - } else { - switchObj.attr("disabled", "disabled"); - } - icoObj.removeAttr("style"); - icoObj.attr("style", view.makeNodeIcoStyle(setting, node)); - icoObj.attr("class", view.makeNodeIcoClass(setting, node)); - }, - setNodeName: function(setting, node) { - var title = data.getNodeTitle(setting, node), - nObj = $("#" + node.tId + consts.id.SPAN); - nObj.empty(); - if (setting.view.nameIsHTML) { - nObj.html(data.getNodeName(setting, node)); - } else { - nObj.text(data.getNodeName(setting, node)); - } - if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) { - var aObj = $("#" + node.tId + consts.id.A); - aObj.attr("title", !title ? "" : title); - } - }, - setNodeTarget: function(node) { - var aObj = $("#" + node.tId + consts.id.A); - aObj.attr("target", view.makeNodeTarget(node)); - }, - setNodeUrl: function(setting, node) { - var aObj = $("#" + node.tId + consts.id.A), - url = view.makeNodeUrl(setting, node); - if (url == null || url.length == 0) { - aObj.removeAttr("href"); - } else { - aObj.attr("href", url); - } - }, - switchNode: function(setting, node) { - if (node.open || !tools.canAsync(setting, node)) { - view.expandCollapseNode(setting, node, !node.open); - } else if (setting.async.enable) { - if (!view.asyncNode(setting, node)) { - view.expandCollapseNode(setting, node, !node.open); - return; - } - } else if (node) { - view.expandCollapseNode(setting, node, !node.open); - } - } - }; - // zTree defind - $.fn.zTree = { - consts : _consts, - _z : { - tools: tools, - view: view, - event: event, - data: data - }, - getZTreeObj: function(treeId) { - var o = data.getZTreeTools(treeId); - return o ? o : null; - }, - destroy: function(treeId) { - if (!!treeId && treeId.length > 0) { - view.destroy(data.getSetting(treeId)); - } else { - for(var s in settings) { - view.destroy(settings[s]); - } - } - }, - init: function(obj, zSetting, zNodes) { - var setting = tools.clone(_setting); - $.extend(true, setting, zSetting); - setting.treeId = obj.attr("id"); - setting.treeObj = obj; - setting.treeObj.empty(); - settings[setting.treeId] = setting; - //For some older browser,(e.g., ie6) - if(typeof document.body.style.maxHeight === "undefined") { - setting.view.expandSpeed = ""; - } - data.initRoot(setting); - var root = data.getRoot(setting), - childKey = setting.data.key.children; - zNodes = zNodes ? tools.clone(tools.isArray(zNodes)? zNodes : [zNodes]) : []; - if (setting.data.simpleData.enable) { - root[childKey] = data.transformTozTreeFormat(setting, zNodes); - } else { - root[childKey] = zNodes; - } - - data.initCache(setting); - event.unbindTree(setting); - event.bindTree(setting); - event.unbindEvent(setting); - event.bindEvent(setting); - - var zTreeTools = { - setting : setting, - addNodes : function(parentNode, newNodes, isSilent) { - if (!newNodes) return null; - if (!parentNode) parentNode = null; - if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null; - var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]); - function addCallback() { - view.addNodes(setting, parentNode, xNewNodes, (isSilent==true)); - } - - if (tools.canAsync(setting, parentNode)) { - view.asyncNode(setting, parentNode, isSilent, addCallback); - } else { - addCallback(); - } - return xNewNodes; - }, - cancelSelectedNode : function(node) { - view.cancelPreSelectedNode(this.setting, node); - }, - destroy : function() { - view.destroy(this.setting); - }, - expandAll : function(expandFlag) { - expandFlag = !!expandFlag; - view.expandCollapseSonNode(this.setting, null, expandFlag, true); - return expandFlag; - }, - expandNode : function(node, expandFlag, sonSign, focus, callbackFlag) { - if (!node || !node.isParent) return null; - if (expandFlag !== true && expandFlag !== false) { - expandFlag = !node.open; - } - callbackFlag = !!callbackFlag; - - if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) { - return null; - } else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) { - return null; - } - if (expandFlag && node.parentTId) { - view.expandCollapseParentNode(this.setting, node.getParentNode(), expandFlag, false); - } - if (expandFlag === node.open && !sonSign) { - return null; - } - - data.getRoot(setting).expandTriggerFlag = callbackFlag; - if (sonSign) { - view.expandCollapseSonNode(this.setting, node, expandFlag, true, function() { - if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}} - }); - } else { - node.open = !expandFlag; - view.switchNode(this.setting, node); - if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}} - } - return expandFlag; - }, - getNodes : function() { - return data.getNodes(this.setting); - }, - getNodeByParam : function(key, value, parentNode) { - if (!key) return null; - return data.getNodeByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); - }, - getNodeByTId : function(tId) { - return data.getNodeCache(this.setting, tId); - }, - getNodesByParam : function(key, value, parentNode) { - if (!key) return null; - return data.getNodesByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); - }, - getNodesByParamFuzzy : function(key, value, parentNode) { - if (!key) return null; - return data.getNodesByParamFuzzy(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); - }, - getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) { - isSingle = !!isSingle; - if (!filter || (typeof filter != "function")) return (isSingle ? null : []); - return data.getNodesByFilter(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), filter, isSingle, invokeParam); - }, - getNodeIndex : function(node) { - if (!node) return null; - var childKey = setting.data.key.children, - parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(this.setting); - for (var i=0, l = parentNode[childKey].length; i < l; i++) { - if (parentNode[childKey][i] == node) return i; - } - return -1; - }, - getSelectedNodes : function() { - var r = [], list = data.getRoot(this.setting).curSelectedList; - for (var i=0, l=list.length; i 0) { - view.createNodes(setting, 0, root[childKey]); - } else if (setting.async.enable && setting.async.url && setting.async.url !== '') { - view.asyncNode(setting); - } - return zTreeTools; - } - }; - - var zt = $.fn.zTree, - consts = zt.consts; -})(jQuery); -/* - * JQuery zTree excheck 3.5.12 - * http://zTree.me/ - * - * Copyright (c) 2010 Hunter.z - * - * Licensed same as jquery - MIT License - * http://www.opensource.org/licenses/mit-license.php - * - * email: hunter.z@263.net - * Date: 2013-03-11 - */ -(function($){ - //default consts of excheck - var _consts = { - event: { - CHECK: "ztree_check" - }, - id: { - CHECK: "_check" - }, - checkbox: { - STYLE: "checkbox", - DEFAULT: "chk", - DISABLED: "disable", - FALSE: "false", - TRUE: "true", - FULL: "full", - PART: "part", - FOCUS: "focus" - }, - radio: { - STYLE: "radio", - TYPE_ALL: "all", - TYPE_LEVEL: "level" - } - }, - //default setting of excheck - _setting = { - check: { - enable: false, - autoCheckTrigger: false, - chkStyle: _consts.checkbox.STYLE, - nocheckInherit: false, - chkDisabledInherit: false, - radioType: _consts.radio.TYPE_LEVEL, - chkboxType: { - "Y": "ps", - "N": "ps" - } - }, - data: { - key: { - checked: "checked" - } - }, - callback: { - beforeCheck:null, - onCheck:null - } - }, - //default root of excheck - _initRoot = function (setting) { - var r = data.getRoot(setting); - r.radioCheckedList = []; - }, - //default cache of excheck - _initCache = function(treeId) {}, - //default bind event of excheck - _bindEvent = function(setting) { - var o = setting.treeObj, - c = consts.event; - o.bind(c.CHECK, function (event, srcEvent, treeId, node) { - tools.apply(setting.callback.onCheck, [!!srcEvent?srcEvent : event, treeId, node]); - }); - }, - _unbindEvent = function(setting) { - var o = setting.treeObj, - c = consts.event; - o.unbind(c.CHECK); - }, - //default event proxy of excheck - _eventProxy = function(e) { - var target = e.target, - setting = data.getSetting(e.data.treeId), - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null; - - if (tools.eqs(e.type, "mouseover")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { - tId = target.parentNode.id; - nodeEventType = "mouseoverCheck"; - } - } else if (tools.eqs(e.type, "mouseout")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { - tId = target.parentNode.id; - nodeEventType = "mouseoutCheck"; - } - } else if (tools.eqs(e.type, "click")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { - tId = target.parentNode.id; - nodeEventType = "checkNode"; - } - } - if (tId.length>0) { - node = data.getNodeCache(setting, tId); - switch (nodeEventType) { - case "checkNode" : - nodeEventCallback = _handler.onCheckNode; - break; - case "mouseoverCheck" : - nodeEventCallback = _handler.onMouseoverCheck; - break; - case "mouseoutCheck" : - nodeEventCallback = _handler.onMouseoutCheck; - break; - } - } - var proxyResult = { - stop: false, - node: node, - nodeEventType: nodeEventType, - nodeEventCallback: nodeEventCallback, - treeEventType: treeEventType, - treeEventCallback: treeEventCallback - }; - return proxyResult - }, - //default init node of excheck - _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { - if (!n) return; - var checkedKey = setting.data.key.checked; - if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true"); - n[checkedKey] = !!n[checkedKey]; - n.checkedOld = n[checkedKey]; - if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); - n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); - if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); - n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); - if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); - n.halfCheck = !!n.halfCheck; - n.check_Child_State = -1; - n.check_Focus = false; - n.getCheckStatus = function() {return data.getCheckStatus(setting, n);}; - }, - //add dom for check - _beforeA = function(setting, node, html) { - var checkedKey = setting.data.key.checked; - if (setting.check.enable) { - data.makeChkFlag(setting, node); - if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && node[checkedKey] ) { - var r = data.getRoot(setting); - r.radioCheckedList.push(node); - } - html.push(""); - } - }, - //update zTreeObj, add method of check - _zTreeTools = function(setting, zTreeTools) { - zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) { - var checkedKey = this.setting.data.key.checked; - if (node.chkDisabled === true) return; - if (checked !== true && checked !== false) { - checked = !node[checkedKey]; - } - callbackFlag = !!callbackFlag; - - if (node[checkedKey] === checked && !checkTypeFlag) { - return; - } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) { - return; - } - if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) { - node[checkedKey] = checked; - var checkObj = $("#" + node.tId + consts.id.CHECK); - if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); - view.setChkClass(this.setting, checkObj, node); - view.repairParentChkClassWithSelf(this.setting, node); - if (callbackFlag) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); - } - } - } - - zTreeTools.checkAllNodes = function(checked) { - view.repairAllChk(this.setting, !!checked); - } - - zTreeTools.getCheckedNodes = function(checked) { - var childKey = this.setting.data.key.children; - checked = (checked !== false); - return data.getTreeCheckedNodes(this.setting, data.getRoot(setting)[childKey], checked); - } - - zTreeTools.getChangeCheckedNodes = function() { - var childKey = this.setting.data.key.children; - return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(setting)[childKey]); - } - - zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) { - disabled = !!disabled; - inheritParent = !!inheritParent; - inheritChildren = !!inheritChildren; - view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); - view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); - } - - var _updateNode = zTreeTools.updateNode; - zTreeTools.updateNode = function(node, checkTypeFlag) { - if (_updateNode) _updateNode.apply(zTreeTools, arguments); - if (!node || !this.setting.check.enable) return; - var nObj = $("#" + node.tId); - if (nObj.get(0) && tools.uCanDo(this.setting)) { - var checkObj = $("#" + node.tId + consts.id.CHECK); - if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); - view.setChkClass(this.setting, checkObj, node); - view.repairParentChkClassWithSelf(this.setting, node); - } - } - }, - //method of operate data - _data = { - getRadioCheckedList: function(setting) { - var checkedList = data.getRoot(setting).radioCheckedList; - for (var i=0, j=checkedList.length; i -1 && node.check_Child_State < 2) : (node.check_Child_State > 0))) - }; - return r; - }, - getTreeCheckedNodes: function(setting, nodes, checked, results) { - if (!nodes) return []; - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL); - results = !results ? [] : results; - for (var i = 0, l = nodes.length; i < l; i++) { - if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) { - results.push(nodes[i]); - if(onlyOne) { - break; - } - } - data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results); - if(onlyOne && results.length > 0) { - break; - } - } - return results; - }, - getTreeChangeCheckedNodes: function(setting, nodes, results) { - if (!nodes) return []; - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked; - results = !results ? [] : results; - for (var i = 0, l = nodes.length; i < l; i++) { - if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) { - results.push(nodes[i]); - } - data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results); - } - return results; - }, - makeChkFlag: function(setting, node) { - if (!node) return; - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - chkFlag = -1; - if (node[childKey]) { - for (var i = 0, l = node[childKey].length; i < l; i++) { - var cNode = node[childKey][i]; - var tmp = -1; - if (setting.check.chkStyle == consts.radio.STYLE) { - if (cNode.nocheck === true || cNode.chkDisabled === true) { - tmp = cNode.check_Child_State; - } else if (cNode.halfCheck === true) { - tmp = 2; - } else if (cNode[checkedKey]) { - tmp = 2; - } else { - tmp = cNode.check_Child_State > 0 ? 2:0; - } - if (tmp == 2) { - chkFlag = 2; break; - } else if (tmp == 0){ - chkFlag = 0; - } - } else if (setting.check.chkStyle == consts.checkbox.STYLE) { - if (cNode.nocheck === true || cNode.chkDisabled === true) { - tmp = cNode.check_Child_State; - } else if (cNode.halfCheck === true) { - tmp = 1; - } else if (cNode[checkedKey] ) { - tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; - } else { - tmp = (cNode.check_Child_State > 0) ? 1 : 0; - } - if (tmp === 1) { - chkFlag = 1; break; - } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { - chkFlag = 1; break; - } else if (chkFlag === 2 && tmp > -1 && tmp < 2) { - chkFlag = 1; break; - } else if (tmp > -1) { - chkFlag = tmp; - } - } - } - } - node.check_Child_State = chkFlag; - } - }, - //method of event proxy - _event = { - - }, - //method of event handler - _handler = { - onCheckNode: function (event, node) { - if (node.chkDisabled === true) return false; - var setting = data.getSetting(event.data.treeId), - checkedKey = setting.data.key.checked; - if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true; - node[checkedKey] = !node[checkedKey]; - view.checkNodeRelation(setting, node); - var checkObj = $("#" + node.tId + consts.id.CHECK); - view.setChkClass(setting, checkObj, node); - view.repairParentChkClassWithSelf(setting, node); - setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); - return true; - }, - onMouseoverCheck: function(event, node) { - if (node.chkDisabled === true) return false; - var setting = data.getSetting(event.data.treeId), - checkObj = $("#" + node.tId + consts.id.CHECK); - node.check_Focus = true; - view.setChkClass(setting, checkObj, node); - return true; - }, - onMouseoutCheck: function(event, node) { - if (node.chkDisabled === true) return false; - var setting = data.getSetting(event.data.treeId), - checkObj = $("#" + node.tId + consts.id.CHECK); - node.check_Focus = false; - view.setChkClass(setting, checkObj, node); - return true; - } - }, - //method of tools for zTree - _tools = { - - }, - //method of operate ztree dom - _view = { - checkNodeRelation: function(setting, node) { - var pNode, i, l, - childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - r = consts.radio; - if (setting.check.chkStyle == r.STYLE) { - var checkedList = data.getRadioCheckedList(setting); - if (node[checkedKey]) { - if (setting.check.radioType == r.TYPE_ALL) { - for (i = checkedList.length-1; i >= 0; i--) { - pNode = checkedList[i]; - pNode[checkedKey] = false; - checkedList.splice(i, 1); - - view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode); - if (pNode.parentTId != node.parentTId) { - view.repairParentChkClassWithSelf(setting, pNode); - } - } - checkedList.push(node); - } else { - var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); - for (i = 0, l = parentNode[childKey].length; i < l; i++) { - pNode = parentNode[childKey][i]; - if (pNode[checkedKey] && pNode != node) { - pNode[checkedKey] = false; - view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode); - } - } - } - } else if (setting.check.radioType == r.TYPE_ALL) { - for (i = 0, l = checkedList.length; i < l; i++) { - if (node == checkedList[i]) { - checkedList.splice(i, 1); - break; - } - } - } - - } else { - if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { - view.setSonNodeCheckBox(setting, node, true); - } - if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) { - view.setSonNodeCheckBox(setting, node, false); - } - if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) { - view.setParentNodeCheckBox(setting, node, true); - } - if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) { - view.setParentNodeCheckBox(setting, node, false); - } - } - }, - makeChkClass: function(setting, node) { - var checkedKey = setting.data.key.checked, - c = consts.checkbox, r = consts.radio, - fullStyle = ""; - if (node.chkDisabled === true) { - fullStyle = c.DISABLED; - } else if (node.halfCheck) { - fullStyle = c.PART; - } else if (setting.check.chkStyle == r.STYLE) { - fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART; - } else { - fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART); - } - var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle; - chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; - return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; - }, - repairAllChk: function(setting, checked) { - if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { - var checkedKey = setting.data.key.checked, - childKey = setting.data.key.children, - root = data.getRoot(setting); - for (var i = 0, l = root[childKey].length; i 0) { - view.repairParentChkClass(setting, node[childKey][0]); - } else { - view.repairParentChkClass(setting, node); - } - }, - repairSonChkDisabled: function(setting, node, chkDisabled, inherit) { - if (!node) return; - var childKey = setting.data.key.children; - if (node.chkDisabled != chkDisabled) { - node.chkDisabled = chkDisabled; - } - view.repairChkClass(setting, node); - if (node[childKey] && inherit) { - for (var i = 0, l = node[childKey].length; i < l; i++) { - var sNode = node[childKey][i]; - view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit); - } - } - }, - repairParentChkDisabled: function(setting, node, chkDisabled, inherit) { - if (!node) return; - if (node.chkDisabled != chkDisabled && inherit) { - node.chkDisabled = chkDisabled; - } - view.repairChkClass(setting, node); - view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); - }, - setChkClass: function(setting, obj, node) { - if (!obj) return; - if (node.nocheck === true) { - obj.hide(); - } else { - obj.show(); - } - obj.removeClass(); - obj.addClass(view.makeChkClass(setting, node)); - }, - setParentNodeCheckBox: function(setting, node, value, srcNode) { - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - checkObj = $("#" + node.tId + consts.id.CHECK); - if (!srcNode) srcNode = node; - data.makeChkFlag(setting, node); - if (node.nocheck !== true && node.chkDisabled !== true) { - node[checkedKey] = value; - view.setChkClass(setting, checkObj, node); - if (setting.check.autoCheckTrigger && node != srcNode) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); - } - } - if (node.parentTId) { - var pSign = true; - if (!value) { - var pNodes = node.getParentNode()[childKey]; - for (var i = 0, l = pNodes.length; i < l; i++) { - if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey]) - || ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) { - pSign = false; - break; - } - } - } - if (pSign) { - view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode); - } - } - }, - setSonNodeCheckBox: function(setting, node, value, srcNode) { - if (!node) return; - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - checkObj = $("#" + node.tId + consts.id.CHECK); - if (!srcNode) srcNode = node; - - var hasDisable = false; - if (node[childKey]) { - for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) { - var sNode = node[childKey][i]; - view.setSonNodeCheckBox(setting, sNode, value, srcNode); - if (sNode.chkDisabled === true) hasDisable = true; - } - } - - if (node != data.getRoot(setting) && node.chkDisabled !== true) { - if (hasDisable && node.nocheck !== true) { - data.makeChkFlag(setting, node); - } - if (node.nocheck !== true && node.chkDisabled !== true) { - node[checkedKey] = value; - if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1; - } else { - node.check_Child_State = -1; - } - view.setChkClass(setting, checkObj, node); - if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); - } - } - - } - }, - - _z = { - tools: _tools, - view: _view, - event: _event, - data: _data - }; - $.extend(true, $.fn.zTree.consts, _consts); - $.extend(true, $.fn.zTree._z, _z); - - var zt = $.fn.zTree, - tools = zt._z.tools, - consts = zt.consts, - view = zt._z.view, - data = zt._z.data, - event = zt._z.event; - - data.exSetting(_setting); - data.addInitBind(_bindEvent); - data.addInitUnBind(_unbindEvent); - data.addInitCache(_initCache); - data.addInitNode(_initNode); - data.addInitProxy(_eventProxy); - data.addInitRoot(_initRoot); - data.addBeforeA(_beforeA); - data.addZTreeTools(_zTreeTools); - - var _createNodes = view.createNodes; - view.createNodes = function(setting, level, nodes, parentNode) { - if (_createNodes) _createNodes.apply(view, arguments); - if (!nodes) return; - view.repairParentChkClassWithSelf(setting, parentNode); - } - var _removeNode = view.removeNode; - view.removeNode = function(setting, node) { - var parentNode = node.getParentNode(); - if (_removeNode) _removeNode.apply(view, arguments); - if (!node || !parentNode) return; - view.repairChkClass(setting, parentNode); - view.repairParentChkClass(setting, parentNode); - } - - var _appendNodes = view.appendNodes; - view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) { - var html = ""; - if (_appendNodes) { - html = _appendNodes.apply(view, arguments); - } - if (parentNode) { - data.makeChkFlag(setting, parentNode); - } - return html; - } -})(jQuery); -/* - * JQuery zTree exedit 3.5.12 - * http://zTree.me/ - * - * Copyright (c) 2010 Hunter.z - * - * Licensed same as jquery - MIT License - * http://www.opensource.org/licenses/mit-license.php - * - * email: hunter.z@263.net - * Date: 2013-03-11 - */ -(function($){ - //default consts of exedit - var _consts = { - event: { - DRAG: "ztree_drag", - DROP: "ztree_drop", - REMOVE: "ztree_remove", - RENAME: "ztree_rename" - }, - id: { - EDIT: "_edit", - INPUT: "_input", - REMOVE: "_remove" - }, - move: { - TYPE_INNER: "inner", - TYPE_PREV: "prev", - TYPE_NEXT: "next" - }, - node: { - CURSELECTED_EDIT: "curSelectedNode_Edit", - TMPTARGET_TREE: "tmpTargetzTree", - TMPTARGET_NODE: "tmpTargetNode" - } - }, - //default setting of exedit - _setting = { - edit: { - enable: false, - editNameSelectAll: false, - showRemoveBtn: true, - showRenameBtn: true, - removeTitle: "remove", - renameTitle: "rename", - drag: { - autoExpandTrigger: false, - isCopy: true, - isMove: true, - prev: true, - next: true, - inner: true, - minMoveSize: 5, - borderMax: 10, - borderMin: -5, - maxShowNodeNum: 5, - autoOpenTime: 500 - } - }, - view: { - addHoverDom: null, - removeHoverDom: null - }, - callback: { - beforeDrag:null, - beforeDragOpen:null, - beforeDrop:null, - beforeEditName:null, - beforeRename:null, - onDrag:null, - onDrop:null, - onRename:null - } - }, - //default root of exedit - _initRoot = function (setting) { - var r = data.getRoot(setting); - r.curEditNode = null; - r.curEditInput = null; - r.curHoverNode = null; - r.dragFlag = 0; - r.dragNodeShowBefore = []; - r.dragMaskList = new Array(); - r.showHoverDom = true; - }, - //default cache of exedit - _initCache = function(treeId) {}, - //default bind event of exedit - _bindEvent = function(setting) { - var o = setting.treeObj; - var c = consts.event; - o.bind(c.RENAME, function (event, treeId, treeNode) { - tools.apply(setting.callback.onRename, [event, treeId, treeNode]); - }); - - o.bind(c.REMOVE, function (event, treeId, treeNode) { - tools.apply(setting.callback.onRemove, [event, treeId, treeNode]); - }); - - o.bind(c.DRAG, function (event, srcEvent, treeId, treeNodes) { - tools.apply(setting.callback.onDrag, [srcEvent, treeId, treeNodes]); - }); - - o.bind(c.DROP, function (event, srcEvent, treeId, treeNodes, targetNode, moveType, isCopy) { - tools.apply(setting.callback.onDrop, [srcEvent, treeId, treeNodes, targetNode, moveType, isCopy]); - }); - }, - _unbindEvent = function(setting) { - var o = setting.treeObj; - var c = consts.event; - o.unbind(c.RENAME); - o.unbind(c.REMOVE); - o.unbind(c.DRAG); - o.unbind(c.DROP); - }, - //default event proxy of exedit - _eventProxy = function(e) { - var target = e.target, - setting = data.getSetting(e.data.treeId), - relatedTarget = e.relatedTarget, - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null, - tmp = null; - - if (tools.eqs(e.type, "mouseover")) { - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) { - tId = tmp.parentNode.id; - nodeEventType = "hoverOverNode"; - } - } else if (tools.eqs(e.type, "mouseout")) { - tmp = tools.getMDom(setting, relatedTarget, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (!tmp) { - tId = "remove"; - nodeEventType = "hoverOutNode"; - } - } else if (tools.eqs(e.type, "mousedown")) { - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) { - tId = tmp.parentNode.id; - nodeEventType = "mousedownNode"; - } - } - if (tId.length>0) { - node = data.getNodeCache(setting, tId); - switch (nodeEventType) { - case "mousedownNode" : - nodeEventCallback = _handler.onMousedownNode; - break; - case "hoverOverNode" : - nodeEventCallback = _handler.onHoverOverNode; - break; - case "hoverOutNode" : - nodeEventCallback = _handler.onHoverOutNode; - break; - } - } - var proxyResult = { - stop: false, - node: node, - nodeEventType: nodeEventType, - nodeEventCallback: nodeEventCallback, - treeEventType: treeEventType, - treeEventCallback: treeEventCallback - }; - return proxyResult - }, - //default init node of exedit - _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { - if (!n) return; - n.isHover = false; - n.editNameFlag = false; - }, - //update zTreeObj, add method of edit - _zTreeTools = function(setting, zTreeTools) { - zTreeTools.cancelEditName = function(newName) { - var root = data.getRoot(setting), - nameKey = setting.data.key.name, - node = root.curEditNode; - if (!root.curEditNode) return; - view.cancelCurEditNode(setting, newName?newName:node[nameKey]); - } - zTreeTools.copyNode = function(targetNode, node, moveType, isSilent) { - if (!node) return null; - if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null; - var newNode = tools.clone(node); - if (!targetNode) { - targetNode = null; - moveType = consts.move.TYPE_INNER; - } - if (moveType == consts.move.TYPE_INNER) { - function copyCallback() { - view.addNodes(setting, targetNode, [newNode], isSilent); - } - - if (tools.canAsync(setting, targetNode)) { - view.asyncNode(setting, targetNode, isSilent, copyCallback); - } else { - copyCallback(); - } - } else { - view.addNodes(setting, targetNode.parentNode, [newNode], isSilent); - view.moveNode(setting, targetNode, newNode, moveType, false, isSilent); - } - return newNode; - } - zTreeTools.editName = function(node) { - if (!node || !node.tId || node !== data.getNodeCache(setting, node.tId)) return; - if (node.parentTId) view.expandCollapseParentNode(setting, node.getParentNode(), true); - view.editNode(setting, node) - } - zTreeTools.moveNode = function(targetNode, node, moveType, isSilent) { - if (!node) return node; - if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) { - return null; - } else if (targetNode && ((node.parentTId == targetNode.tId && moveType == consts.move.TYPE_INNER) || $("#" + node.tId).find("#" + targetNode.tId).length > 0)) { - return null; - } else if (!targetNode) { - targetNode = null; - } - function moveCallback() { - view.moveNode(setting, targetNode, node, moveType, false, isSilent); - } - if (tools.canAsync(setting, targetNode) && moveType === consts.move.TYPE_INNER) { - view.asyncNode(setting, targetNode, isSilent, moveCallback); - } else { - moveCallback(); - } - return node; - } - zTreeTools.setEditable = function(editable) { - setting.edit.enable = editable; - return this.refresh(); - } - }, - //method of operate data - _data = { - setSonNodeLevel: function(setting, parentNode, node) { - if (!node) return; - var childKey = setting.data.key.children; - node.level = (parentNode)? parentNode.level + 1 : 0; - if (!node[childKey]) return; - for (var i = 0, l = node[childKey].length; i < l; i++) { - if (node[childKey][i]) data.setSonNodeLevel(setting, node, node[childKey][i]); - } - } - }, - //method of event proxy - _event = { - - }, - //method of event handler - _handler = { - onHoverOverNode: function(event, node) { - var setting = data.getSetting(event.data.treeId), - root = data.getRoot(setting); - if (root.curHoverNode != node) { - _handler.onHoverOutNode(event); - } - root.curHoverNode = node; - view.addHoverDom(setting, node); - }, - onHoverOutNode: function(event, node) { - var setting = data.getSetting(event.data.treeId), - root = data.getRoot(setting); - if (root.curHoverNode && !data.isSelectedNode(setting, root.curHoverNode)) { - view.removeTreeDom(setting, root.curHoverNode); - root.curHoverNode = null; - } - }, - onMousedownNode: function(eventMouseDown, _node) { - var i,l, - setting = data.getSetting(eventMouseDown.data.treeId), - root = data.getRoot(setting); - //right click can't drag & drop - if (eventMouseDown.button == 2 || !setting.edit.enable || (!setting.edit.drag.isCopy && !setting.edit.drag.isMove)) return true; - - //input of edit node name can't drag & drop - var target = eventMouseDown.target, - _nodes = data.getRoot(setting).curSelectedList, - nodes = []; - if (!data.isSelectedNode(setting, _node)) { - nodes = [_node]; - } else { - for (i=0, l=_nodes.length; i1) { - var pNodes = nodes[0].parentTId ? nodes[0].getParentNode()[childKey] : data.getNodes(setting); - tmpNodes = []; - for (i=0, l=pNodes.length; i -1 && (lastIndex+1) !== i) { - isOrder = false; - } - tmpNodes.push(pNodes[i]); - lastIndex = i; - } - if (nodes.length === tmpNodes.length) { - nodes = tmpNodes; - break; - } - } - } - if (isOrder) { - preNode = nodes[0].getPreNode(); - nextNode = nodes[nodes.length-1].getNextNode(); - } - - //set node in selected - curNode = $("
          "); - for (i=0, l=nodes.length; i0); - view.removeTreeDom(setting, tmpNode); - - tmpDom = $("
        • "); - tmpDom.append($("#" + tmpNode.tId + consts.id.A).clone()); - tmpDom.css("padding", "0"); - tmpDom.children("#" + tmpNode.tId + consts.id.A).removeClass(consts.node.CURSELECTED); - curNode.append(tmpDom); - if (i == setting.edit.drag.maxShowNodeNum-1) { - tmpDom = $("
        • ...
        • "); - curNode.append(tmpDom); - break; - } - } - curNode.attr("id", nodes[0].tId + consts.id.UL + "_tmp"); - curNode.addClass(setting.treeObj.attr("class")); - curNode.appendTo("body"); - - tmpArrow = $(""); - tmpArrow.attr("id", "zTreeMove_arrow_tmp"); - tmpArrow.appendTo("body"); - - setting.treeObj.trigger(consts.event.DRAG, [event, setting.treeId, nodes]); - } - - if (root.dragFlag == 1) { - if (tmpTarget && tmpArrow.attr("id") == event.target.id && tmpTargetNodeId && (event.clientX + doc.scrollLeft()+2) > ($("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left)) { - var xT = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget); - event.target = (xT.length > 0) ? xT.get(0) : event.target; - } else if (tmpTarget) { - tmpTarget.removeClass(consts.node.TMPTARGET_TREE); - if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) - .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); - } - tmpTarget = null; - tmpTargetNodeId = null; - - //judge drag & drop in multi ztree - isOtherTree = false; - targetSetting = setting; - var settings = data.getSettings(); - for (var s in settings) { - if (settings[s].treeId && settings[s].edit.enable && settings[s].treeId != setting.treeId - && (event.target.id == settings[s].treeId || $(event.target).parents("#" + settings[s].treeId).length>0)) { - isOtherTree = true; - targetSetting = settings[s]; - } - } - - var docScrollTop = doc.scrollTop(), - docScrollLeft = doc.scrollLeft(), - treeOffset = targetSetting.treeObj.offset(), - scrollHeight = targetSetting.treeObj.get(0).scrollHeight, - scrollWidth = targetSetting.treeObj.get(0).scrollWidth, - dTop = (event.clientY + docScrollTop - treeOffset.top), - dBottom = (targetSetting.treeObj.height() + treeOffset.top - event.clientY - docScrollTop), - dLeft = (event.clientX + docScrollLeft - treeOffset.left), - dRight = (targetSetting.treeObj.width() + treeOffset.left - event.clientX - docScrollLeft), - isTop = (dTop < setting.edit.drag.borderMax && dTop > setting.edit.drag.borderMin), - isBottom = (dBottom < setting.edit.drag.borderMax && dBottom > setting.edit.drag.borderMin), - isLeft = (dLeft < setting.edit.drag.borderMax && dLeft > setting.edit.drag.borderMin), - isRight = (dRight < setting.edit.drag.borderMax && dRight > setting.edit.drag.borderMin), - isTreeInner = dTop > setting.edit.drag.borderMin && dBottom > setting.edit.drag.borderMin && dLeft > setting.edit.drag.borderMin && dRight > setting.edit.drag.borderMin, - isTreeTop = (isTop && targetSetting.treeObj.scrollTop() <= 0), - isTreeBottom = (isBottom && (targetSetting.treeObj.scrollTop() + targetSetting.treeObj.height()+10) >= scrollHeight), - isTreeLeft = (isLeft && targetSetting.treeObj.scrollLeft() <= 0), - isTreeRight = (isRight && (targetSetting.treeObj.scrollLeft() + targetSetting.treeObj.width()+10) >= scrollWidth); - - if (event.target.id && targetSetting.treeObj.find("#" + event.target.id).length > 0) { - //get node
        • dom - var targetObj = event.target; - while (targetObj && targetObj.tagName && !tools.eqs(targetObj.tagName, "li") && targetObj.id != targetSetting.treeId) { - targetObj = targetObj.parentNode; - } - - var canMove = true; - //don't move to self or children of self - for (i=0, l=nodes.length; i 0) { - canMove = false; - break; - } - } - if (canMove) { - if (event.target.id && - (event.target.id == (targetObj.id + consts.id.A) || $(event.target).parents("#" + targetObj.id + consts.id.A).length > 0)) { - tmpTarget = $(targetObj); - tmpTargetNodeId = targetObj.id; - } - } - } - - //the mouse must be in zTree - tmpNode = nodes[0]; - if (isTreeInner && (event.target.id == targetSetting.treeId || $(event.target).parents("#" + targetSetting.treeId).length>0)) { - //judge mouse move in root of ztree - if (!tmpTarget && (event.target.id == targetSetting.treeId || isTreeTop || isTreeBottom || isTreeLeft || isTreeRight) && (isOtherTree || (!isOtherTree && tmpNode.parentTId))) { - tmpTarget = targetSetting.treeObj; - } - //auto scroll top - if (isTop) { - targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()-10); - } else if (isBottom) { - targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()+10); - } - if (isLeft) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()-10); - } else if (isRight) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+10); - } - //auto scroll left - if (tmpTarget && tmpTarget != targetSetting.treeObj && tmpTarget.offset().left < targetSetting.treeObj.offset().left) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+ tmpTarget.offset().left - targetSetting.treeObj.offset().left); - } - } - - curNode.css({ - "top": (event.clientY + docScrollTop + 3) + "px", - "left": (event.clientX + docScrollLeft + 3) + "px" - }); - - var dX = 0; - var dY = 0; - if (tmpTarget && tmpTarget.attr("id")!=targetSetting.treeId) { - var tmpTargetNode = tmpTargetNodeId == null ? null: data.getNodeCache(targetSetting, tmpTargetNodeId), - isCopy = (event.ctrlKey && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy), - isPrev = !!(preNode && tmpTargetNodeId === preNode.tId), - isNext = !!(nextNode && tmpTargetNodeId === nextNode.tId), - isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId), - canPrev = (isCopy || !isNext) && tools.apply(targetSetting.edit.drag.prev, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.prev), - canNext = (isCopy || !isPrev) && tools.apply(targetSetting.edit.drag.next, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.next), - canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !tmpTargetNode.isParent) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner); - if (!canPrev && !canNext && !canInner) { - tmpTarget = null; - tmpTargetNodeId = ""; - moveType = consts.move.TYPE_INNER; - tmpArrow.css({ - "display":"none" - }); - if (window.zTreeMoveTimer) { - clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null - } - } else { - var tmpTargetA = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget), - tmpNextA = tmpTargetNode.isLastNode ? null : $("#" + tmpTargetNode.getNextNode().tId + consts.id.A, tmpTarget.next()), - tmpTop = tmpTargetA.offset().top, - tmpLeft = tmpTargetA.offset().left, - prevPercent = canPrev ? (canInner ? 0.25 : (canNext ? 0.5 : 1) ) : -1, - nextPercent = canNext ? (canInner ? 0.75 : (canPrev ? 0.5 : 0) ) : -1, - dY_percent = (event.clientY + docScrollTop - tmpTop)/tmpTargetA.height(); - if ((prevPercent==1 ||dY_percent<=prevPercent && dY_percent>=-.2) && canPrev) { - dX = 1 - tmpArrow.width(); - dY = tmpTop - tmpArrow.height()/2; - moveType = consts.move.TYPE_PREV; - } else if ((nextPercent==0 || dY_percent>=nextPercent && dY_percent<=1.2) && canNext) { - dX = 1 - tmpArrow.width(); - dY = (tmpNextA == null || (tmpTargetNode.isParent && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height()/2) : (tmpNextA.offset().top - tmpArrow.height()/2); - moveType = consts.move.TYPE_NEXT; - }else { - dX = 5 - tmpArrow.width(); - dY = tmpTop; - moveType = consts.move.TYPE_INNER; - } - tmpArrow.css({ - "display":"block", - "top": dY + "px", - "left": (tmpLeft + dX) + "px" - }); - tmpTargetA.addClass(consts.node.TMPTARGET_NODE + "_" + moveType); - - if (preTmpTargetNodeId != tmpTargetNodeId || preTmpMoveType != moveType) { - startTime = (new Date()).getTime(); - } - if (tmpTargetNode && tmpTargetNode.isParent && moveType == consts.move.TYPE_INNER) { - var startTimer = true; - if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId) { - clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null; - } else if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId === tmpTargetNode.tId) { - startTimer = false; - } - if (startTimer) { - window.zTreeMoveTimer = setTimeout(function() { - if (moveType != consts.move.TYPE_INNER) return; - if (tmpTargetNode && tmpTargetNode.isParent && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime - && tools.apply(targetSetting.callback.beforeDragOpen, [targetSetting.treeId, tmpTargetNode], true)) { - view.switchNode(targetSetting, tmpTargetNode); - if (targetSetting.edit.drag.autoExpandTrigger) { - targetSetting.treeObj.trigger(consts.event.EXPAND, [targetSetting.treeId, tmpTargetNode]); - } - } - }, targetSetting.edit.drag.autoOpenTime+50); - window.zTreeMoveTargetNodeTId = tmpTargetNode.tId; - } - } - } - } else { - moveType = consts.move.TYPE_INNER; - if (tmpTarget && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, null], !!targetSetting.edit.drag.inner)) { - tmpTarget.addClass(consts.node.TMPTARGET_TREE); - } else { - tmpTarget = null; - } - tmpArrow.css({ - "display":"none" - }); - if (window.zTreeMoveTimer) { - clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null; - } - } - preTmpTargetNodeId = tmpTargetNodeId; - preTmpMoveType = moveType; - } - return false; - } - - doc.bind("mouseup", _docMouseUp); - function _docMouseUp(event) { - if (window.zTreeMoveTimer) { - clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null; - } - preTmpTargetNodeId = null; - preTmpMoveType = null; - doc.unbind("mousemove", _docMouseMove); - doc.unbind("mouseup", _docMouseUp); - doc.unbind("selectstart", _docSelect); - $("body").css("cursor", "auto"); - if (tmpTarget) { - tmpTarget.removeClass(consts.node.TMPTARGET_TREE); - if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) - .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); - } - tools.showIfameMask(setting, false); - - root.showHoverDom = true; - if (root.dragFlag == 0) return; - root.dragFlag = 0; - - var i, l, tmpNode; - for (i=0, l=nodes.length; i0); - } - $("#" + newNodes[0].tId).focus().blur(); - - setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]); - } - - if (moveType == consts.move.TYPE_INNER && tools.canAsync(targetSetting, dragTargetNode)) { - view.asyncNode(targetSetting, dragTargetNode, false, dropCallback); - } else { - dropCallback(); - } - - } else { - for (i=0, l=nodes.length; i0); - } - setting.treeObj.trigger(consts.event.DROP, [event, setting.treeId, nodes, null, null, null]); - } - } - - doc.bind("selectstart", _docSelect); - function _docSelect() { - return false; - } - - //Avoid FireFox's Bug - //If zTree Div CSS set 'overflow', so drag node outside of zTree, and event.target is error. - if(eventMouseDown.preventDefault) { - eventMouseDown.preventDefault(); - } - return true; - } - }, - //method of tools for zTree - _tools = { - getAbs: function (obj) { - var oRect = obj.getBoundingClientRect(); - return [oRect.left,oRect.top] - }, - inputFocus: function(inputObj) { - if (inputObj.get(0)) { - inputObj.focus(); - tools.setCursorPosition(inputObj.get(0), inputObj.val().length); - } - }, - inputSelect: function(inputObj) { - if (inputObj.get(0)) { - inputObj.focus(); - inputObj.select(); - } - }, - setCursorPosition: function(obj, pos){ - if(obj.setSelectionRange) { - obj.focus(); - obj.setSelectionRange(pos,pos); - } else if (obj.createTextRange) { - var range = obj.createTextRange(); - range.collapse(true); - range.moveEnd('character', pos); - range.moveStart('character', pos); - range.select(); - } - }, - showIfameMask: function(setting, showSign) { - var root = data.getRoot(setting); - //clear full mask - while (root.dragMaskList.length > 0) { - root.dragMaskList[0].remove(); - root.dragMaskList.shift(); - } - if (showSign) { - //show mask - var iframeList = $("iframe"); - for (var i = 0, l = iframeList.length; i < l; i++) { - var obj = iframeList.get(i), - r = tools.getAbs(obj), - dragMask = $("
          "); - dragMask.appendTo("body"); - root.dragMaskList.push(dragMask); - } - } - } - }, - //method of operate ztree dom - _view = { - addEditBtn: function(setting, node) { - if (node.editNameFlag || $("#" + node.tId + consts.id.EDIT).length > 0) { - return; - } - if (!tools.apply(setting.edit.showRenameBtn, [setting.treeId, node], setting.edit.showRenameBtn)) { - return; - } - var aObj = $("#" + node.tId + consts.id.A), - editStr = ""; - aObj.append(editStr); - - $("#" + node.tId + consts.id.EDIT).bind('click', - function() { - if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeEditName, [setting.treeId, node], true) == false) return false; - view.editNode(setting, node); - return false; - } - ).show(); - }, - addRemoveBtn: function(setting, node) { - if (node.editNameFlag || $("#" + node.tId + consts.id.REMOVE).length > 0) { - return; - } - if (!tools.apply(setting.edit.showRemoveBtn, [setting.treeId, node], setting.edit.showRemoveBtn)) { - return; - } - var aObj = $("#" + node.tId + consts.id.A), - removeStr = ""; - aObj.append(removeStr); - - $("#" + node.tId + consts.id.REMOVE).bind('click', - function() { - if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return false; - view.removeNode(setting, node); - setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]); - return false; - } - ).bind('mousedown', - function(eventMouseDown) { - return true; - } - ).show(); - }, - addHoverDom: function(setting, node) { - if (data.getRoot(setting).showHoverDom) { - node.isHover = true; - if (setting.edit.enable) { - view.addEditBtn(setting, node); - view.addRemoveBtn(setting, node); - } - tools.apply(setting.view.addHoverDom, [setting.treeId, node]); - } - }, - cancelCurEditNode: function (setting, forceName) { - var root = data.getRoot(setting), - nameKey = setting.data.key.name, - node = root.curEditNode; - - if (node) { - var inputObj = root.curEditInput; - var newName = forceName ? forceName:inputObj.val(); - if (!forceName && tools.apply(setting.callback.beforeRename, [setting.treeId, node, newName], true) === false) { - return false; - } else { - node[nameKey] = newName ? newName:inputObj.val(); - if (!forceName) { - setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node]); - } - } - var aObj = $("#" + node.tId + consts.id.A); - aObj.removeClass(consts.node.CURSELECTED_EDIT); - inputObj.unbind(); - view.setNodeName(setting, node); - node.editNameFlag = false; - root.curEditNode = null; - root.curEditInput = null; - view.selectNode(setting, node, false); - } - root.noSelection = true; - return true; - }, - editNode: function(setting, node) { - var root = data.getRoot(setting); - view.editNodeBlur = false; - if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) { - setTimeout(function() {tools.inputFocus(root.curEditInput);}, 0); - return; - } - var nameKey = setting.data.key.name; - node.editNameFlag = true; - view.removeTreeDom(setting, node); - view.cancelCurEditNode(setting); - view.selectNode(setting, node, false); - $("#" + node.tId + consts.id.SPAN).html(""); - var inputObj = $("#" + node.tId + consts.id.INPUT); - inputObj.attr("value", node[nameKey]); - if (setting.edit.editNameSelectAll) { - tools.inputSelect(inputObj); - } else { - tools.inputFocus(inputObj); - } - - inputObj.bind('blur', function(event) { - if (!view.editNodeBlur) { - view.cancelCurEditNode(setting); - } - }).bind('keydown', function(event) { - if (event.keyCode=="13") { - view.editNodeBlur = true; - view.cancelCurEditNode(setting, null, true); - } else if (event.keyCode=="27") { - view.cancelCurEditNode(setting, node[nameKey]); - } - }).bind('click', function(event) { - return false; - }).bind('dblclick', function(event) { - return false; - }); - - $("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED_EDIT); - root.curEditInput = inputObj; - root.noSelection = false; - root.curEditNode = node; - }, - moveNode: function(setting, targetNode, node, moveType, animateFlag, isSilent) { - var root = data.getRoot(setting), - childKey = setting.data.key.children; - if (targetNode == node) return; - if (setting.data.keep.leaf && targetNode && !targetNode.isParent && moveType == consts.move.TYPE_INNER) return; - var oldParentNode = (node.parentTId ? node.getParentNode(): root), - targetNodeIsRoot = (targetNode === null || targetNode == root); - if (targetNodeIsRoot && targetNode === null) targetNode = root; - if (targetNodeIsRoot) moveType = consts.move.TYPE_INNER; - var targetParentNode = (targetNode.parentTId ? targetNode.getParentNode() : root); - - if (moveType != consts.move.TYPE_PREV && moveType != consts.move.TYPE_NEXT) { - moveType = consts.move.TYPE_INNER; - } - - if (moveType == consts.move.TYPE_INNER) { - if (targetNodeIsRoot) { - //parentTId of root node is null - node.parentTId = null; - } else { - if (!targetNode.isParent) { - targetNode.isParent = true; - targetNode.open = !!targetNode.open; - view.setNodeLineIcos(setting, targetNode); - } - node.parentTId = targetNode.tId; - } - } - - //move node Dom - var targetObj, target_ulObj; - if (targetNodeIsRoot) { - targetObj = setting.treeObj; - target_ulObj = targetObj; - } else { - if (!isSilent && moveType == consts.move.TYPE_INNER) { - view.expandCollapseNode(setting, targetNode, true, false); - } else if (!isSilent) { - view.expandCollapseNode(setting, targetNode.getParentNode(), true, false); - } - targetObj = $("#" + targetNode.tId); - target_ulObj = $("#" + targetNode.tId + consts.id.UL); - if (!!targetObj.get(0) && !target_ulObj.get(0)) { - var ulstr = []; - view.makeUlHtml(setting, targetNode, ulstr, ''); - targetObj.append(ulstr.join('')); - } - target_ulObj = $("#" + targetNode.tId + consts.id.UL); - } - var nodeDom = $("#" + node.tId); - if (!nodeDom.get(0)) { - nodeDom = view.appendNodes(setting, node.level, [node], null, false, true).join(''); - } else if (!targetObj.get(0)) { - nodeDom.remove(); - } - if (target_ulObj.get(0) && moveType == consts.move.TYPE_INNER) { - target_ulObj.append(nodeDom); - } else if (targetObj.get(0) && moveType == consts.move.TYPE_PREV) { - targetObj.before(nodeDom); - } else if (targetObj.get(0) && moveType == consts.move.TYPE_NEXT) { - targetObj.after(nodeDom); - } - - //repair the data after move - var i,l, - tmpSrcIndex = -1, - tmpTargetIndex = 0, - oldNeighbor = null, - newNeighbor = null, - oldLevel = node.level; - if (node.isFirstNode) { - tmpSrcIndex = 0; - if (oldParentNode[childKey].length > 1 ) { - oldNeighbor = oldParentNode[childKey][1]; - oldNeighbor.isFirstNode = true; - } - } else if (node.isLastNode) { - tmpSrcIndex = oldParentNode[childKey].length -1; - oldNeighbor = oldParentNode[childKey][tmpSrcIndex - 1]; - oldNeighbor.isLastNode = true; - } else { - for (i = 0, l = oldParentNode[childKey].length; i < l; i++) { - if (oldParentNode[childKey][i].tId == node.tId) { - tmpSrcIndex = i; - break; - } - } - } - if (tmpSrcIndex >= 0) { - oldParentNode[childKey].splice(tmpSrcIndex, 1); - } - if (moveType != consts.move.TYPE_INNER) { - for (i = 0, l = targetParentNode[childKey].length; i < l; i++) { - if (targetParentNode[childKey][i].tId == targetNode.tId) tmpTargetIndex = i; - } - } - if (moveType == consts.move.TYPE_INNER) { - if (!targetNode[childKey]) targetNode[childKey] = new Array(); - if (targetNode[childKey].length > 0) { - newNeighbor = targetNode[childKey][targetNode[childKey].length - 1]; - newNeighbor.isLastNode = false; - } - targetNode[childKey].splice(targetNode[childKey].length, 0, node); - node.isLastNode = true; - node.isFirstNode = (targetNode[childKey].length == 1); - } else if (targetNode.isFirstNode && moveType == consts.move.TYPE_PREV) { - targetParentNode[childKey].splice(tmpTargetIndex, 0, node); - newNeighbor = targetNode; - newNeighbor.isFirstNode = false; - node.parentTId = targetNode.parentTId; - node.isFirstNode = true; - node.isLastNode = false; - - } else if (targetNode.isLastNode && moveType == consts.move.TYPE_NEXT) { - targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node); - newNeighbor = targetNode; - newNeighbor.isLastNode = false; - node.parentTId = targetNode.parentTId; - node.isFirstNode = false; - node.isLastNode = true; - - } else { - if (moveType == consts.move.TYPE_PREV) { - targetParentNode[childKey].splice(tmpTargetIndex, 0, node); - } else { - targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node); - } - node.parentTId = targetNode.parentTId; - node.isFirstNode = false; - node.isLastNode = false; - } - data.fixPIdKeyValue(setting, node); - data.setSonNodeLevel(setting, node.getParentNode(), node); - - //repair node what been moved - view.setNodeLineIcos(setting, node); - view.repairNodeLevelClass(setting, node, oldLevel) - - //repair node's old parentNode dom - if (!setting.data.keep.parent && oldParentNode[childKey].length < 1) { - //old parentNode has no child nodes - oldParentNode.isParent = false; - oldParentNode.open = false; - var tmp_ulObj = $("#" + oldParentNode.tId + consts.id.UL), - tmp_switchObj = $("#" + oldParentNode.tId + consts.id.SWITCH), - tmp_icoObj = $("#" + oldParentNode.tId + consts.id.ICON); - view.replaceSwitchClass(oldParentNode, tmp_switchObj, consts.folder.DOCU); - view.replaceIcoClass(oldParentNode, tmp_icoObj, consts.folder.DOCU); - tmp_ulObj.css("display", "none"); - - } else if (oldNeighbor) { - //old neigbor node - view.setNodeLineIcos(setting, oldNeighbor); - } - - //new neigbor node - if (newNeighbor) { - view.setNodeLineIcos(setting, newNeighbor); - } - - //repair checkbox / radio - if (!!setting.check && setting.check.enable && view.repairChkClass) { - view.repairChkClass(setting, oldParentNode); - view.repairParentChkClassWithSelf(setting, oldParentNode); - if (oldParentNode != node.parent) - view.repairParentChkClassWithSelf(setting, node); - } - - //expand parents after move - if (!isSilent) { - view.expandCollapseParentNode(setting, node.getParentNode(), true, animateFlag); - } - }, - removeEditBtn: function(node) { - $("#" + node.tId + consts.id.EDIT).unbind().remove(); - }, - removeRemoveBtn: function(node) { - $("#" + node.tId + consts.id.REMOVE).unbind().remove(); - }, - removeTreeDom: function(setting, node) { - node.isHover = false; - view.removeEditBtn(node); - view.removeRemoveBtn(node); - tools.apply(setting.view.removeHoverDom, [setting.treeId, node]); - }, - repairNodeLevelClass: function(setting, node, oldLevel) { - if (oldLevel === node.level) return; - var liObj = $("#" + node.tId), - aObj = $("#" + node.tId + consts.id.A), - ulObj = $("#" + node.tId + consts.id.UL), - oldClass = consts.className.LEVEL + oldLevel, - newClass = consts.className.LEVEL + node.level; - liObj.removeClass(oldClass); - liObj.addClass(newClass); - aObj.removeClass(oldClass); - aObj.addClass(newClass); - ulObj.removeClass(oldClass); - ulObj.addClass(newClass); - } - }, - - _z = { - tools: _tools, - view: _view, - event: _event, - data: _data - }; - $.extend(true, $.fn.zTree.consts, _consts); - $.extend(true, $.fn.zTree._z, _z); - - var zt = $.fn.zTree, - tools = zt._z.tools, - consts = zt.consts, - view = zt._z.view, - data = zt._z.data, - event = zt._z.event; - - data.exSetting(_setting); - data.addInitBind(_bindEvent); - data.addInitUnBind(_unbindEvent); - data.addInitCache(_initCache); - data.addInitNode(_initNode); - data.addInitProxy(_eventProxy); - data.addInitRoot(_initRoot); - data.addZTreeTools(_zTreeTools); - - var _cancelPreSelectedNode = view.cancelPreSelectedNode; - view.cancelPreSelectedNode = function (setting, node) { - var list = data.getRoot(setting).curSelectedList; - for (var i=0, j=list.length; i"); - }, - showNode: function(setting, node, options) { - node.isHidden = false; - data.initShowForExCheck(setting, node); - $("#" + node.tId).show(); - }, - showNodes: function(setting, nodes, options) { - if (!nodes || nodes.length == 0) { - return; - } - var pList = {}, i, j; - for (i=0, j=nodes.length; i 0 && !parentNode[childKey][0].isHidden) { - parentNode[childKey][0].isFirstNode = true; - } else if (childLength > 0) { - view.setFirstNodeForHide(setting, parentNode[childKey]); - } - }, - setLastNode: function(setting, parentNode) { - var childKey = setting.data.key.children, childLength = parentNode[childKey].length; - if (childLength > 0 && !parentNode[childKey][0].isHidden) { - parentNode[childKey][childLength - 1].isLastNode = true; - } else if (childLength > 0) { - view.setLastNodeForHide(setting, parentNode[childKey]); - } - }, - setFirstNodeForHide: function(setting, nodes) { - var n,i,j; - for (i=0, j=nodes.length; i=0; i--) { - n = nodes[i]; - if (n.isLastNode) { - break; - } - if (!n.isHidden && !n.isLastNode) { - n.isLastNode = true; - view.setNodeLineIcos(setting, n); - break; - } else { - n = null; - } - } - return n; - }, - setLastNodeForShow: function(setting, nodes) { - var n,i,j, last, old; - for (i=nodes.length-1; i>=0; i--) { - n = nodes[i]; - if (!last && !n.isHidden && n.isLastNode) { - last = n; - break; - } else if (!last && !n.isHidden && !n.isLastNode) { - n.isLastNode = true; - last = n; - view.setNodeLineIcos(setting, n); - } else if (last && n.isLastNode) { - n.isLastNode = false; - old = n; - view.setNodeLineIcos(setting, n); - break; - } else { - n = null; - } - } - return {"new":last, "old":old}; - } - }, - - _z = { - view: _view, - data: _data - }; - $.extend(true, $.fn.zTree._z, _z); - - var zt = $.fn.zTree, - tools = zt._z.tools, - consts = zt.consts, - view = zt._z.view, - data = zt._z.data, - event = zt._z.event; - - data.addInitNode(_initNode); - data.addBeforeA(_beforeA); - data.addZTreeTools(_zTreeTools); - -// Override method in core - var _dInitNode = data.initNode; - data.tmpHideParent = -1; - data.initNode = function(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag) { - if (data.tmpHideParent !== parentNode) { - data.tmpHideParent = parentNode; - var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting), - children = tmpPNode[setting.data.key.children]; - data.tmpHideFirstNode = view.setFirstNodeForHide(setting, children); - data.tmpHideLastNode = view.setLastNodeForHide(setting, children); - view.setNodeLineIcos(setting, data.tmpHideFirstNode); - view.setNodeLineIcos(setting, data.tmpHideLastNode); - } - isFirstNode = (data.tmpHideFirstNode === node); - isLastNode = (data.tmpHideLastNode === node); - if (_dInitNode) _dInitNode.apply(data, arguments); - if (isLastNode) { - view.clearOldLastNode(setting, node); - } - } - - var _makeChkFlag = data.makeChkFlag; - if (!!_makeChkFlag) { - data.makeChkFlag = function(setting, node) { - if (!!node && !!node.isHidden) { - return; - } - _makeChkFlag.apply(data, arguments); - } - } - - var _getTreeCheckedNodes = data.getTreeCheckedNodes; - if (!!_getTreeCheckedNodes) { - data.getTreeCheckedNodes = function(setting, nodes, checked, results) { - if (!!nodes && nodes.length > 0) { - var p = nodes[0].getParentNode(); - if (!!p && !!p.isHidden) { - return []; - } - } - return _getTreeCheckedNodes.apply(data, arguments); - } - } - - var _getTreeChangeCheckedNodes = data.getTreeChangeCheckedNodes; - if (!!_getTreeChangeCheckedNodes) { - data.getTreeChangeCheckedNodes = function(setting, nodes, results) { - if (!!nodes && nodes.length > 0) { - var p = nodes[0].getParentNode(); - if (!!p && !!p.isHidden) { - return []; - } - } - return _getTreeChangeCheckedNodes.apply(data, arguments); - } - } - - var _expandCollapseSonNode = view.expandCollapseSonNode; - if (!!_expandCollapseSonNode) { - view.expandCollapseSonNode = function(setting, node, expandFlag, animateFlag, callback) { - if (!!node && !!node.isHidden) { - return; - } - _expandCollapseSonNode.apply(view, arguments); - } - } - - var _setSonNodeCheckBox = view.setSonNodeCheckBox; - if (!!_setSonNodeCheckBox) { - view.setSonNodeCheckBox = function(setting, node, value, srcNode) { - if (!!node && !!node.isHidden) { - return; - } - _setSonNodeCheckBox.apply(view, arguments); - } - } - - var _repairParentChkClassWithSelf = view.repairParentChkClassWithSelf; - if (!!_repairParentChkClassWithSelf) { - view.repairParentChkClassWithSelf = function(setting, node) { - if (!!node && !!node.isHidden) { - return; - } - _repairParentChkClassWithSelf.apply(view, arguments); - } - } + +/* + * JQuery zTree core 3.5.12 + * http://zTree.me/ + * + * Copyright (c) 2010 Hunter.z + * + * Licensed same as jquery - MIT License + * http://www.opensource.org/licenses/mit-license.php + * + * email: hunter.z@263.net + * Date: 2013-03-11 + */ +(function($){ + var settings = {}, roots = {}, caches = {}, + //default consts of core + _consts = { + className: { + BUTTON: "button", + LEVEL: "level", + ICO_LOADING: "ico_loading", + SWITCH: "switch" + }, + event: { + NODECREATED: "ztree_nodeCreated", + CLICK: "ztree_click", + EXPAND: "ztree_expand", + COLLAPSE: "ztree_collapse", + ASYNC_SUCCESS: "ztree_async_success", + ASYNC_ERROR: "ztree_async_error" + }, + id: { + A: "_a", + ICON: "_ico", + SPAN: "_span", + SWITCH: "_switch", + UL: "_ul" + }, + line: { + ROOT: "root", + ROOTS: "roots", + CENTER: "center", + BOTTOM: "bottom", + NOLINE: "noline", + LINE: "line" + }, + folder: { + OPEN: "open", + CLOSE: "close", + DOCU: "docu" + }, + node: { + CURSELECTED: "curSelectedNode" + } + }, + //default setting of core + _setting = { + treeId: "", + treeObj: null, + view: { + addDiyDom: null, + autoCancelSelected: true, + dblClickExpand: true, + expandSpeed: "fast", + fontCss: {}, + nameIsHTML: false, + selectedMulti: true, + showIcon: true, + showLine: true, + showTitle: true + }, + data: { + key: { + children: "children", + name: "name", + title: "", + url: "url" + }, + simpleData: { + enable: false, + idKey: "id", + pIdKey: "pId", + rootPId: null + }, + keep: { + parent: false, + leaf: false + } + }, + async: { + enable: false, + contentType: "application/x-www-form-urlencoded", + type: "post", + dataType: "text", + url: "", + autoParam: [], + otherParam: [], + dataFilter: null + }, + callback: { + beforeAsync:null, + beforeClick:null, + beforeDblClick:null, + beforeRightClick:null, + beforeMouseDown:null, + beforeMouseUp:null, + beforeExpand:null, + beforeCollapse:null, + beforeRemove:null, + + onAsyncError:null, + onAsyncSuccess:null, + onNodeCreated:null, + onClick:null, + onDblClick:null, + onRightClick:null, + onMouseDown:null, + onMouseUp:null, + onExpand:null, + onCollapse:null, + onRemove:null + } + }, + //default root of core + //zTree use root to save full data + _initRoot = function (setting) { + var r = data.getRoot(setting); + if (!r) { + r = {}; + data.setRoot(setting, r); + } + r[setting.data.key.children] = []; + r.expandTriggerFlag = false; + r.curSelectedList = []; + r.noSelection = true; + r.createdNodes = []; + r.zId = 0; + r._ver = (new Date()).getTime(); + }, + //default cache of core + _initCache = function(setting) { + var c = data.getCache(setting); + if (!c) { + c = {}; + data.setCache(setting, c); + } + c.nodes = []; + c.doms = []; + }, + //default bindEvent of core + _bindEvent = function(setting) { + var o = setting.treeObj, + c = consts.event; + o.bind(c.NODECREATED, function (event, treeId, node) { + tools.apply(setting.callback.onNodeCreated, [event, treeId, node]); + }); + + o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) { + tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]); + }); + + o.bind(c.EXPAND, function (event, treeId, node) { + tools.apply(setting.callback.onExpand, [event, treeId, node]); + }); + + o.bind(c.COLLAPSE, function (event, treeId, node) { + tools.apply(setting.callback.onCollapse, [event, treeId, node]); + }); + + o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) { + tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]); + }); + + o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) { + tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]); + }); + }, + _unbindEvent = function(setting) { + var o = setting.treeObj, + c = consts.event; + o.unbind(c.NODECREATED) + .unbind(c.CLICK) + .unbind(c.EXPAND) + .unbind(c.COLLAPSE) + .unbind(c.ASYNC_SUCCESS) + .unbind(c.ASYNC_ERROR); + }, + //default event proxy of core + _eventProxy = function(event) { + var target = event.target, + setting = data.getSetting(event.data.treeId), + tId = "", node = null, + nodeEventType = "", treeEventType = "", + nodeEventCallback = null, treeEventCallback = null, + tmp = null; + + if (tools.eqs(event.type, "mousedown")) { + treeEventType = "mousedown"; + } else if (tools.eqs(event.type, "mouseup")) { + treeEventType = "mouseup"; + } else if (tools.eqs(event.type, "contextmenu")) { + treeEventType = "contextmenu"; + } else if (tools.eqs(event.type, "click")) { + if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.SWITCH) !== null) { + tId = ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)).id; + nodeEventType = "switchNode"; + } else { + tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (tmp) { + tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id; + nodeEventType = "clickNode"; + } + } + } else if (tools.eqs(event.type, "dblclick")) { + treeEventType = "dblclick"; + tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (tmp) { + tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id; + nodeEventType = "switchNode"; + } + } + if (treeEventType.length > 0 && tId.length == 0) { + tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (tmp) {tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;} + } + // event to node + if (tId.length>0) { + node = data.getNodeCache(setting, tId); + switch (nodeEventType) { + case "switchNode" : + if (!node.isParent) { + nodeEventType = ""; + } else if (tools.eqs(event.type, "click") + || (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) { + nodeEventCallback = handler.onSwitchNode; + } else { + nodeEventType = ""; + } + break; + case "clickNode" : + nodeEventCallback = handler.onClickNode; + break; + } + } + // event to zTree + switch (treeEventType) { + case "mousedown" : + treeEventCallback = handler.onZTreeMousedown; + break; + case "mouseup" : + treeEventCallback = handler.onZTreeMouseup; + break; + case "dblclick" : + treeEventCallback = handler.onZTreeDblclick; + break; + case "contextmenu" : + treeEventCallback = handler.onZTreeContextmenu; + break; + } + var proxyResult = { + stop: false, + node: node, + nodeEventType: nodeEventType, + nodeEventCallback: nodeEventCallback, + treeEventType: treeEventType, + treeEventCallback: treeEventCallback + }; + return proxyResult + }, + //default init node of core + _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + if (!n) return; + var r = data.getRoot(setting), + childKey = setting.data.key.children; + n.level = level; + n.tId = setting.treeId + "_" + (++r.zId); + n.parentTId = parentNode ? parentNode.tId : null; + if (n[childKey] && n[childKey].length > 0) { + if (typeof n.open == "string") n.open = tools.eqs(n.open, "true"); + n.open = !!n.open; + n.isParent = true; + n.zAsync = true; + } else { + n.open = false; + if (typeof n.isParent == "string") n.isParent = tools.eqs(n.isParent, "true"); + n.isParent = !!n.isParent; + n.zAsync = !n.isParent; + } + n.isFirstNode = isFirstNode; + n.isLastNode = isLastNode; + n.getParentNode = function() {return data.getNodeCache(setting, n.parentTId);}; + n.getPreNode = function() {return data.getPreNode(setting, n);}; + n.getNextNode = function() {return data.getNextNode(setting, n);}; + n.isAjaxing = false; + data.fixPIdKeyValue(setting, n); + }, + _init = { + bind: [_bindEvent], + unbind: [_unbindEvent], + caches: [_initCache], + nodes: [_initNode], + proxys: [_eventProxy], + roots: [_initRoot], + beforeA: [], + afterA: [], + innerBeforeA: [], + innerAfterA: [], + zTreeTools: [] + }, + //method of operate data + data = { + addNodeCache: function(setting, node) { + data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node; + }, + getNodeCacheId: function(tId) { + return tId.substring(tId.lastIndexOf("_")+1); + }, + addAfterA: function(afterA) { + _init.afterA.push(afterA); + }, + addBeforeA: function(beforeA) { + _init.beforeA.push(beforeA); + }, + addInnerAfterA: function(innerAfterA) { + _init.innerAfterA.push(innerAfterA); + }, + addInnerBeforeA: function(innerBeforeA) { + _init.innerBeforeA.push(innerBeforeA); + }, + addInitBind: function(bindEvent) { + _init.bind.push(bindEvent); + }, + addInitUnBind: function(unbindEvent) { + _init.unbind.push(unbindEvent); + }, + addInitCache: function(initCache) { + _init.caches.push(initCache); + }, + addInitNode: function(initNode) { + _init.nodes.push(initNode); + }, + addInitProxy: function(initProxy) { + _init.proxys.push(initProxy); + }, + addInitRoot: function(initRoot) { + _init.roots.push(initRoot); + }, + addNodesData: function(setting, parentNode, nodes) { + var childKey = setting.data.key.children; + if (!parentNode[childKey]) parentNode[childKey] = []; + if (parentNode[childKey].length > 0) { + parentNode[childKey][parentNode[childKey].length - 1].isLastNode = false; + view.setNodeLineIcos(setting, parentNode[childKey][parentNode[childKey].length - 1]); + } + parentNode.isParent = true; + parentNode[childKey] = parentNode[childKey].concat(nodes); + }, + addSelectedNode: function(setting, node) { + var root = data.getRoot(setting); + if (!data.isSelectedNode(setting, node)) { + root.curSelectedList.push(node); + } + }, + addCreatedNode: function(setting, node) { + if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { + var root = data.getRoot(setting); + root.createdNodes.push(node); + } + }, + addZTreeTools: function(zTreeTools) { + _init.zTreeTools.push(zTreeTools); + }, + exSetting: function(s) { + $.extend(true, _setting, s); + }, + fixPIdKeyValue: function(setting, node) { + if (setting.data.simpleData.enable) { + node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId; + } + }, + getAfterA: function(setting, node, array) { + for (var i=0, j=_init.afterA.length; i-1) { + result.push(nodes[i]); + } + result = result.concat(data.getNodesByParamFuzzy(setting, nodes[i][childKey], key, value)); + } + return result; + }, + getNodesByFilter: function(setting, nodes, filter, isSingle, invokeParam) { + if (!nodes) return (isSingle ? null : []); + var childKey = setting.data.key.children, + result = isSingle ? null : []; + for (var i = 0, l = nodes.length; i < l; i++) { + if (tools.apply(filter, [nodes[i], invokeParam], false)) { + if (isSingle) {return nodes[i];} + result.push(nodes[i]); + } + var tmpResult = data.getNodesByFilter(setting, nodes[i][childKey], filter, isSingle, invokeParam); + if (isSingle && !!tmpResult) {return tmpResult;} + result = isSingle ? tmpResult : result.concat(tmpResult); + } + return result; + }, + getPreNode: function(setting, node) { + if (!node) return null; + var childKey = setting.data.key.children, + p = node.parentTId ? node.getParentNode() : data.getRoot(setting); + for (var i=0, l=p[childKey].length; i 0))); + }, + clone: function (obj){ + if (obj === null) return null; + var o = obj.constructor === Array ? [] : {}; + for(var i in obj){ + o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? arguments.callee(obj[i]) : obj[i]); + } + return o; + }, + eqs: function(str1, str2) { + return str1.toLowerCase() === str2.toLowerCase(); + }, + isArray: function(arr) { + return Object.prototype.toString.apply(arr) === "[object Array]"; + }, + getMDom: function (setting, curDom, targetExpr) { + if (!curDom) return null; + while (curDom && curDom.id !== setting.treeId) { + for (var i=0, l=targetExpr.length; curDom.tagName && i 0) { + //make child html first, because checkType + childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open); + } + if (openFlag) { + + view.makeDOMNodeMainBefore(html, setting, node); + view.makeDOMNodeLine(html, setting, node); + data.getBeforeA(setting, node, html); + view.makeDOMNodeNameBefore(html, setting, node); + data.getInnerBeforeA(setting, node, html); + view.makeDOMNodeIcon(html, setting, node); + data.getInnerAfterA(setting, node, html); + view.makeDOMNodeNameAfter(html, setting, node); + data.getAfterA(setting, node, html); + if (node.isParent && node.open) { + view.makeUlHtml(setting, node, html, childHtml.join('')); + } + view.makeDOMNodeMainAfter(html, setting, node); + data.addCreatedNode(setting, node); + } + } + return html; + }, + appendParentULDom: function(setting, node) { + var html = [], + nObj = $("#" + node.tId), + ulObj = $("#" + node.tId + consts.id.UL), + childKey = setting.data.key.children, + childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true); + view.makeUlHtml(setting, node, html, childHtml.join('')); + if (!nObj.get(0) && !!node.parentTId) { + view.appendParentULDom(setting, node.getParentNode()); + nObj = $("#" + node.tId); + } + if (ulObj.get(0)) { + ulObj.remove(); + } + nObj.append(html.join('')); + }, + asyncNode: function(setting, node, isSilent, callback) { + var i, l; + if (node && !node.isParent) { + tools.apply(callback); + return false; + } else if (node && node.isAjaxing) { + return false; + } else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) { + tools.apply(callback); + return false; + } + if (node) { + node.isAjaxing = true; + var icoObj = $("#" + node.tId + consts.id.ICON); + icoObj.attr({"style":"", "class":consts.className.BUTTON + " " + consts.className.ICO_LOADING}); + } + + var tmpParam = {}; + for (i = 0, l = setting.async.autoParam.length; node && i < l; i++) { + var pKey = setting.async.autoParam[i].split("="), spKey = pKey; + if (pKey.length>1) { + spKey = pKey[1]; + pKey = pKey[0]; + } + tmpParam[spKey] = node[pKey]; + } + if (tools.isArray(setting.async.otherParam)) { + for (i = 0, l = setting.async.otherParam.length; i < l; i += 2) { + tmpParam[setting.async.otherParam[i]] = setting.async.otherParam[i + 1]; + } + } else { + for (var p in setting.async.otherParam) { + tmpParam[p] = setting.async.otherParam[p]; + } + } + + var _tmpV = data.getRoot(setting)._ver; + $.ajax({ + contentType: setting.async.contentType, + type: setting.async.type, + url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url), + data: tmpParam, + dataType: setting.async.dataType, + success: function(msg) { + if (_tmpV != data.getRoot(setting)._ver) { + return; + } + var newNodes = []; + try { + if (!msg || msg.length == 0) { + newNodes = []; + } else if (typeof msg == "string") { + newNodes = eval("(" + msg + ")"); + } else { + newNodes = msg; + } + } catch(err) { + newNodes = msg; + } + + if (node) { + node.isAjaxing = null; + node.zAsync = true; + } + view.setNodeLineIcos(setting, node); + if (newNodes && newNodes !== "") { + newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes); + view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent); + } else { + view.addNodes(setting, node, [], !!isSilent); + } + setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]); + tools.apply(callback); + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + if (_tmpV != data.getRoot(setting)._ver) { + return; + } + if (node) node.isAjaxing = null; + view.setNodeLineIcos(setting, node); + setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]); + } + }); + return true; + }, + cancelPreSelectedNode: function (setting, node) { + var list = data.getRoot(setting).curSelectedList; + for (var i=0, j=list.length-1; j>=i; j--) { + if (!node || node === list[j]) { + $("#" + list[j].tId + consts.id.A).removeClass(consts.node.CURSELECTED); + if (node) { + data.removeSelectedNode(setting, node); + break; + } + } + } + if (!node) data.getRoot(setting).curSelectedList = []; + }, + createNodeCallback: function(setting) { + if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { + var root = data.getRoot(setting); + while (root.createdNodes.length>0) { + var node = root.createdNodes.shift(); + tools.apply(setting.view.addDiyDom, [setting.treeId, node]); + if (!!setting.callback.onNodeCreated) { + setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]); + } + } + } + }, + createNodes: function(setting, level, nodes, parentNode) { + if (!nodes || nodes.length == 0) return; + var root = data.getRoot(setting), + childKey = setting.data.key.children, + openFlag = !parentNode || parentNode.open || !!$("#" + parentNode[childKey][0].tId).get(0); + root.createdNodes = []; + var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag); + if (!parentNode) { + setting.treeObj.append(zTreeHtml.join('')); + } else { + var ulObj = $("#" + parentNode.tId + consts.id.UL); + if (ulObj.get(0)) { + ulObj.append(zTreeHtml.join('')); + } + } + view.createNodeCallback(setting); + }, + destroy: function(setting) { + if (!setting) return; + data.initCache(setting); + data.initRoot(setting); + event.unbindTree(setting); + event.unbindEvent(setting); + setting.treeObj.empty(); + }, + expandCollapseNode: function(setting, node, expandFlag, animateFlag, callback) { + var root = data.getRoot(setting), + childKey = setting.data.key.children; + if (!node) { + tools.apply(callback, []); + return; + } + if (root.expandTriggerFlag) { + var _callback = callback; + callback = function(){ + if (_callback) _callback(); + if (node.open) { + setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]); + } else { + setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]); + } + }; + root.expandTriggerFlag = false; + } + if (!node.open && node.isParent && ((!$("#" + node.tId + consts.id.UL).get(0)) || (node[childKey] && node[childKey].length>0 && !$("#" + node[childKey][0].tId).get(0)))) { + view.appendParentULDom(setting, node); + view.createNodeCallback(setting); + } + if (node.open == expandFlag) { + tools.apply(callback, []); + return; + } + var ulObj = $("#" + node.tId + consts.id.UL), + switchObj = $("#" + node.tId + consts.id.SWITCH), + icoObj = $("#" + node.tId + consts.id.ICON); + + if (node.isParent) { + node.open = !node.open; + if (node.iconOpen && node.iconClose) { + icoObj.attr("style", view.makeNodeIcoStyle(setting, node)); + } + + if (node.open) { + view.replaceSwitchClass(node, switchObj, consts.folder.OPEN); + view.replaceIcoClass(node, icoObj, consts.folder.OPEN); + if (animateFlag == false || setting.view.expandSpeed == "") { + ulObj.show(); + tools.apply(callback, []); + } else { + if (node[childKey] && node[childKey].length > 0) { + ulObj.slideDown(setting.view.expandSpeed, callback); + } else { + ulObj.show(); + tools.apply(callback, []); + } + } + } else { + view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE); + view.replaceIcoClass(node, icoObj, consts.folder.CLOSE); + if (animateFlag == false || setting.view.expandSpeed == "" || !(node[childKey] && node[childKey].length > 0)) { + ulObj.hide(); + tools.apply(callback, []); + } else { + ulObj.slideUp(setting.view.expandSpeed, callback); + } + } + } else { + tools.apply(callback, []); + } + }, + expandCollapseParentNode: function(setting, node, expandFlag, animateFlag, callback) { + if (!node) return; + if (!node.parentTId) { + view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback); + return; + } else { + view.expandCollapseNode(setting, node, expandFlag, animateFlag); + } + if (node.parentTId) { + view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback); + } + }, + expandCollapseSonNode: function(setting, node, expandFlag, animateFlag, callback) { + var root = data.getRoot(setting), + childKey = setting.data.key.children, + treeNodes = (node) ? node[childKey]: root[childKey], + selfAnimateSign = (node) ? false : animateFlag, + expandTriggerFlag = data.getRoot(setting).expandTriggerFlag; + data.getRoot(setting).expandTriggerFlag = false; + if (treeNodes) { + for (var i = 0, l = treeNodes.length; i < l; i++) { + if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign); + } + } + data.getRoot(setting).expandTriggerFlag = expandTriggerFlag; + view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback ); + }, + makeDOMNodeIcon: function(html, setting, node) { + var nameStr = data.getNodeName(setting, node), + name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g,'&').replace(//g,'>'); + html.push("",name,""); + }, + makeDOMNodeLine: function(html, setting, node) { + html.push(""); + }, + makeDOMNodeMainAfter: function(html, setting, node) { + html.push("
        • "); + }, + makeDOMNodeMainBefore: function(html, setting, node) { + html.push("
        • "); + }, + makeDOMNodeNameAfter: function(html, setting, node) { + html.push(""); + }, + makeDOMNodeNameBefore: function(html, setting, node) { + var title = data.getNodeTitle(setting, node), + url = view.makeNodeUrl(setting, node), + fontcss = view.makeNodeFontCss(setting, node), + fontStyle = []; + for (var f in fontcss) { + fontStyle.push(f, ":", fontcss[f], ";"); + } + html.push(" 0) ? "href='" + url + "'" : ""), " target='",view.makeNodeTarget(node),"' style='", fontStyle.join(''), + "'"); + if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) {html.push("title='", title.replace(/'/g,"'").replace(//g,'>'),"'");} + html.push(">"); + }, + makeNodeFontCss: function(setting, node) { + var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss); + return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {}; + }, + makeNodeIcoClass: function(setting, node) { + var icoCss = ["ico"]; + if (!node.isAjaxing) { + icoCss[0] = (node.iconSkin ? node.iconSkin + "_" : "") + icoCss[0]; + if (node.isParent) { + icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); + } else { + icoCss.push(consts.folder.DOCU); + } + } + return consts.className.BUTTON + " " + icoCss.join('_'); + }, + makeNodeIcoStyle: function(setting, node) { + var icoStyle = []; + if (!node.isAjaxing) { + var icon = (node.isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node.icon; + if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;"); + if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) { + icoStyle.push("width:0px;height:0px;"); + } + } + return icoStyle.join(''); + }, + makeNodeLineClass: function(setting, node) { + var lineClass = []; + if (setting.view.showLine) { + if (node.level == 0 && node.isFirstNode && node.isLastNode) { + lineClass.push(consts.line.ROOT); + } else if (node.level == 0 && node.isFirstNode) { + lineClass.push(consts.line.ROOTS); + } else if (node.isLastNode) { + lineClass.push(consts.line.BOTTOM); + } else { + lineClass.push(consts.line.CENTER); + } + } else { + lineClass.push(consts.line.NOLINE); + } + if (node.isParent) { + lineClass.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); + } else { + lineClass.push(consts.folder.DOCU); + } + return view.makeNodeLineClassEx(node) + lineClass.join('_'); + }, + makeNodeLineClassEx: function(node) { + return consts.className.BUTTON + " " + consts.className.LEVEL + node.level + " " + consts.className.SWITCH + " "; + }, + makeNodeTarget: function(node) { + return (node.target || "_blank"); + }, + makeNodeUrl: function(setting, node) { + var urlKey = setting.data.key.url; + return node[urlKey] ? node[urlKey] : null; + }, + makeUlHtml: function(setting, node, html, content) { + html.push("
            "); + html.push(content); + html.push("
          "); + }, + makeUlLineClass: function(setting, node) { + return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : ""); + }, + removeChildNodes: function(setting, node) { + if (!node) return; + var childKey = setting.data.key.children, + nodes = node[childKey]; + if (!nodes) return; + + for (var i = 0, l = nodes.length; i < l; i++) { + data.removeNodeCache(setting, nodes[i]); + } + data.removeSelectedNode(setting); + delete node[childKey]; + + if (!setting.data.keep.parent) { + node.isParent = false; + node.open = false; + var tmp_switchObj = $("#" + node.tId + consts.id.SWITCH), + tmp_icoObj = $("#" + node.tId + consts.id.ICON); + view.replaceSwitchClass(node, tmp_switchObj, consts.folder.DOCU); + view.replaceIcoClass(node, tmp_icoObj, consts.folder.DOCU); + $("#" + node.tId + consts.id.UL).remove(); + } else { + $("#" + node.tId + consts.id.UL).empty(); + } + }, + setFirstNode: function(setting, parentNode) { + var childKey = setting.data.key.children, childLength = parentNode[childKey].length; + if ( childLength > 0) { + parentNode[childKey][0].isFirstNode = true; + } + }, + setLastNode: function(setting, parentNode) { + var childKey = setting.data.key.children, childLength = parentNode[childKey].length; + if ( childLength > 0) { + parentNode[childKey][childLength - 1].isLastNode = true; + } + }, + removeNode: function(setting, node) { + var root = data.getRoot(setting), + childKey = setting.data.key.children, + parentNode = (node.parentTId) ? node.getParentNode() : root; + + node.isFirstNode = false; + node.isLastNode = false; + node.getPreNode = function() {return null;}; + node.getNextNode = function() {return null;}; + + if (!data.getNodeCache(setting, node.tId)) { + return; + } + + $("#" + node.tId).remove(); + data.removeNodeCache(setting, node); + data.removeSelectedNode(setting, node); + + for (var i = 0, l = parentNode[childKey].length; i < l; i++) { + if (parentNode[childKey][i].tId == node.tId) { + parentNode[childKey].splice(i, 1); + break; + } + } + view.setFirstNode(setting, parentNode); + view.setLastNode(setting, parentNode); + + var tmp_ulObj,tmp_switchObj,tmp_icoObj, + childLength = parentNode[childKey].length; + + //repair nodes old parent + if (!setting.data.keep.parent && childLength == 0) { + //old parentNode has no child nodes + parentNode.isParent = false; + parentNode.open = false; + tmp_ulObj = $("#" + parentNode.tId + consts.id.UL); + tmp_switchObj = $("#" + parentNode.tId + consts.id.SWITCH); + tmp_icoObj = $("#" + parentNode.tId + consts.id.ICON); + view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU); + view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU); + tmp_ulObj.css("display", "none"); + + } else if (setting.view.showLine && childLength > 0) { + //old parentNode has child nodes + var newLast = parentNode[childKey][childLength - 1]; + tmp_ulObj = $("#" + newLast.tId + consts.id.UL); + tmp_switchObj = $("#" + newLast.tId + consts.id.SWITCH); + tmp_icoObj = $("#" + newLast.tId + consts.id.ICON); + if (parentNode == root) { + if (parentNode[childKey].length == 1) { + //node was root, and ztree has only one root after move node + view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT); + } else { + var tmp_first_switchObj = $("#" + parentNode[childKey][0].tId + consts.id.SWITCH); + view.replaceSwitchClass(parentNode[childKey][0], tmp_first_switchObj, consts.line.ROOTS); + view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); + } + } else { + view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); + } + tmp_ulObj.removeClass(consts.line.LINE); + } + }, + replaceIcoClass: function(node, obj, newName) { + if (!obj || node.isAjaxing) return; + var tmpName = obj.attr("class"); + if (tmpName == undefined) return; + var tmpList = tmpName.split("_"); + switch (newName) { + case consts.folder.OPEN: + case consts.folder.CLOSE: + case consts.folder.DOCU: + tmpList[tmpList.length-1] = newName; + break; + } + obj.attr("class", tmpList.join("_")); + }, + replaceSwitchClass: function(node, obj, newName) { + if (!obj) return; + var tmpName = obj.attr("class"); + if (tmpName == undefined) return; + var tmpList = tmpName.split("_"); + switch (newName) { + case consts.line.ROOT: + case consts.line.ROOTS: + case consts.line.CENTER: + case consts.line.BOTTOM: + case consts.line.NOLINE: + tmpList[0] = view.makeNodeLineClassEx(node) + newName; + break; + case consts.folder.OPEN: + case consts.folder.CLOSE: + case consts.folder.DOCU: + tmpList[1] = newName; + break; + } + obj.attr("class", tmpList.join("_")); + if (newName !== consts.folder.DOCU) { + obj.removeAttr("disabled"); + } else { + obj.attr("disabled", "disabled"); + } + }, + selectNode: function(setting, node, addFlag) { + if (!addFlag) { + view.cancelPreSelectedNode(setting); + } + $("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED); + data.addSelectedNode(setting, node); + }, + setNodeFontCss: function(setting, treeNode) { + var aObj = $("#" + treeNode.tId + consts.id.A), + fontCss = view.makeNodeFontCss(setting, treeNode); + if (fontCss) { + aObj.css(fontCss); + } + }, + setNodeLineIcos: function(setting, node) { + if (!node) return; + var switchObj = $("#" + node.tId + consts.id.SWITCH), + ulObj = $("#" + node.tId + consts.id.UL), + icoObj = $("#" + node.tId + consts.id.ICON), + ulLine = view.makeUlLineClass(setting, node); + if (ulLine.length==0) { + ulObj.removeClass(consts.line.LINE); + } else { + ulObj.addClass(ulLine); + } + switchObj.attr("class", view.makeNodeLineClass(setting, node)); + if (node.isParent) { + switchObj.removeAttr("disabled"); + } else { + switchObj.attr("disabled", "disabled"); + } + icoObj.removeAttr("style"); + icoObj.attr("style", view.makeNodeIcoStyle(setting, node)); + icoObj.attr("class", view.makeNodeIcoClass(setting, node)); + }, + setNodeName: function(setting, node) { + var title = data.getNodeTitle(setting, node), + nObj = $("#" + node.tId + consts.id.SPAN); + nObj.empty(); + if (setting.view.nameIsHTML) { + nObj.html(data.getNodeName(setting, node)); + } else { + nObj.text(data.getNodeName(setting, node)); + } + if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) { + var aObj = $("#" + node.tId + consts.id.A); + aObj.attr("title", !title ? "" : title); + } + }, + setNodeTarget: function(node) { + var aObj = $("#" + node.tId + consts.id.A); + aObj.attr("target", view.makeNodeTarget(node)); + }, + setNodeUrl: function(setting, node) { + var aObj = $("#" + node.tId + consts.id.A), + url = view.makeNodeUrl(setting, node); + if (url == null || url.length == 0) { + aObj.removeAttr("href"); + } else { + aObj.attr("href", url); + } + }, + switchNode: function(setting, node) { + if (node.open || !tools.canAsync(setting, node)) { + view.expandCollapseNode(setting, node, !node.open); + } else if (setting.async.enable) { + if (!view.asyncNode(setting, node)) { + view.expandCollapseNode(setting, node, !node.open); + return; + } + } else if (node) { + view.expandCollapseNode(setting, node, !node.open); + } + } + }; + // zTree defind + $.fn.zTree = { + consts : _consts, + _z : { + tools: tools, + view: view, + event: event, + data: data + }, + getZTreeObj: function(treeId) { + var o = data.getZTreeTools(treeId); + return o ? o : null; + }, + destroy: function(treeId) { + if (!!treeId && treeId.length > 0) { + view.destroy(data.getSetting(treeId)); + } else { + for(var s in settings) { + view.destroy(settings[s]); + } + } + }, + init: function(obj, zSetting, zNodes) { + var setting = tools.clone(_setting); + $.extend(true, setting, zSetting); + setting.treeId = obj.attr("id"); + setting.treeObj = obj; + setting.treeObj.empty(); + settings[setting.treeId] = setting; + //For some older browser,(e.g., ie6) + if(typeof document.body.style.maxHeight === "undefined") { + setting.view.expandSpeed = ""; + } + data.initRoot(setting); + var root = data.getRoot(setting), + childKey = setting.data.key.children; + zNodes = zNodes ? tools.clone(tools.isArray(zNodes)? zNodes : [zNodes]) : []; + if (setting.data.simpleData.enable) { + root[childKey] = data.transformTozTreeFormat(setting, zNodes); + } else { + root[childKey] = zNodes; + } + + data.initCache(setting); + event.unbindTree(setting); + event.bindTree(setting); + event.unbindEvent(setting); + event.bindEvent(setting); + + var zTreeTools = { + setting : setting, + addNodes : function(parentNode, newNodes, isSilent) { + if (!newNodes) return null; + if (!parentNode) parentNode = null; + if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null; + var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]); + function addCallback() { + view.addNodes(setting, parentNode, xNewNodes, (isSilent==true)); + } + + if (tools.canAsync(setting, parentNode)) { + view.asyncNode(setting, parentNode, isSilent, addCallback); + } else { + addCallback(); + } + return xNewNodes; + }, + cancelSelectedNode : function(node) { + view.cancelPreSelectedNode(this.setting, node); + }, + destroy : function() { + view.destroy(this.setting); + }, + expandAll : function(expandFlag) { + expandFlag = !!expandFlag; + view.expandCollapseSonNode(this.setting, null, expandFlag, true); + return expandFlag; + }, + expandNode : function(node, expandFlag, sonSign, focus, callbackFlag) { + if (!node || !node.isParent) return null; + if (expandFlag !== true && expandFlag !== false) { + expandFlag = !node.open; + } + callbackFlag = !!callbackFlag; + + if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) { + return null; + } else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) { + return null; + } + if (expandFlag && node.parentTId) { + view.expandCollapseParentNode(this.setting, node.getParentNode(), expandFlag, false); + } + if (expandFlag === node.open && !sonSign) { + return null; + } + + data.getRoot(setting).expandTriggerFlag = callbackFlag; + if (sonSign) { + view.expandCollapseSonNode(this.setting, node, expandFlag, true, function() { + if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}} + }); + } else { + node.open = !expandFlag; + view.switchNode(this.setting, node); + if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}} + } + return expandFlag; + }, + getNodes : function() { + return data.getNodes(this.setting); + }, + getNodeByParam : function(key, value, parentNode) { + if (!key) return null; + return data.getNodeByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); + }, + getNodeByTId : function(tId) { + return data.getNodeCache(this.setting, tId); + }, + getNodesByParam : function(key, value, parentNode) { + if (!key) return null; + return data.getNodesByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); + }, + getNodesByParamFuzzy : function(key, value, parentNode) { + if (!key) return null; + return data.getNodesByParamFuzzy(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); + }, + getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) { + isSingle = !!isSingle; + if (!filter || (typeof filter != "function")) return (isSingle ? null : []); + return data.getNodesByFilter(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), filter, isSingle, invokeParam); + }, + getNodeIndex : function(node) { + if (!node) return null; + var childKey = setting.data.key.children, + parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(this.setting); + for (var i=0, l = parentNode[childKey].length; i < l; i++) { + if (parentNode[childKey][i] == node) return i; + } + return -1; + }, + getSelectedNodes : function() { + var r = [], list = data.getRoot(this.setting).curSelectedList; + for (var i=0, l=list.length; i 0) { + view.createNodes(setting, 0, root[childKey]); + } else if (setting.async.enable && setting.async.url && setting.async.url !== '') { + view.asyncNode(setting); + } + return zTreeTools; + } + }; + + var zt = $.fn.zTree, + consts = zt.consts; +})(jQuery); +/* + * JQuery zTree excheck 3.5.12 + * http://zTree.me/ + * + * Copyright (c) 2010 Hunter.z + * + * Licensed same as jquery - MIT License + * http://www.opensource.org/licenses/mit-license.php + * + * email: hunter.z@263.net + * Date: 2013-03-11 + */ +(function($){ + //default consts of excheck + var _consts = { + event: { + CHECK: "ztree_check" + }, + id: { + CHECK: "_check" + }, + checkbox: { + STYLE: "checkbox", + DEFAULT: "chk", + DISABLED: "disable", + FALSE: "false", + TRUE: "true", + FULL: "full", + PART: "part", + FOCUS: "focus" + }, + radio: { + STYLE: "radio", + TYPE_ALL: "all", + TYPE_LEVEL: "level" + } + }, + //default setting of excheck + _setting = { + check: { + enable: false, + autoCheckTrigger: false, + chkStyle: _consts.checkbox.STYLE, + nocheckInherit: false, + chkDisabledInherit: false, + radioType: _consts.radio.TYPE_LEVEL, + chkboxType: { + "Y": "ps", + "N": "ps" + } + }, + data: { + key: { + checked: "checked" + } + }, + callback: { + beforeCheck:null, + onCheck:null + } + }, + //default root of excheck + _initRoot = function (setting) { + var r = data.getRoot(setting); + r.radioCheckedList = []; + }, + //default cache of excheck + _initCache = function(treeId) {}, + //default bind event of excheck + _bindEvent = function(setting) { + var o = setting.treeObj, + c = consts.event; + o.bind(c.CHECK, function (event, srcEvent, treeId, node) { + tools.apply(setting.callback.onCheck, [!!srcEvent?srcEvent : event, treeId, node]); + }); + }, + _unbindEvent = function(setting) { + var o = setting.treeObj, + c = consts.event; + o.unbind(c.CHECK); + }, + //default event proxy of excheck + _eventProxy = function(e) { + var target = e.target, + setting = data.getSetting(e.data.treeId), + tId = "", node = null, + nodeEventType = "", treeEventType = "", + nodeEventCallback = null, treeEventCallback = null; + + if (tools.eqs(e.type, "mouseover")) { + if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { + tId = target.parentNode.id; + nodeEventType = "mouseoverCheck"; + } + } else if (tools.eqs(e.type, "mouseout")) { + if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { + tId = target.parentNode.id; + nodeEventType = "mouseoutCheck"; + } + } else if (tools.eqs(e.type, "click")) { + if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { + tId = target.parentNode.id; + nodeEventType = "checkNode"; + } + } + if (tId.length>0) { + node = data.getNodeCache(setting, tId); + switch (nodeEventType) { + case "checkNode" : + nodeEventCallback = _handler.onCheckNode; + break; + case "mouseoverCheck" : + nodeEventCallback = _handler.onMouseoverCheck; + break; + case "mouseoutCheck" : + nodeEventCallback = _handler.onMouseoutCheck; + break; + } + } + var proxyResult = { + stop: false, + node: node, + nodeEventType: nodeEventType, + nodeEventCallback: nodeEventCallback, + treeEventType: treeEventType, + treeEventCallback: treeEventCallback + }; + return proxyResult + }, + //default init node of excheck + _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + if (!n) return; + var checkedKey = setting.data.key.checked; + if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true"); + n[checkedKey] = !!n[checkedKey]; + n.checkedOld = n[checkedKey]; + if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); + n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); + if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); + n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); + if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); + n.halfCheck = !!n.halfCheck; + n.check_Child_State = -1; + n.check_Focus = false; + n.getCheckStatus = function() {return data.getCheckStatus(setting, n);}; + }, + //add dom for check + _beforeA = function(setting, node, html) { + var checkedKey = setting.data.key.checked; + if (setting.check.enable) { + data.makeChkFlag(setting, node); + if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && node[checkedKey] ) { + var r = data.getRoot(setting); + r.radioCheckedList.push(node); + } + html.push(""); + } + }, + //update zTreeObj, add method of check + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) { + var checkedKey = this.setting.data.key.checked; + if (node.chkDisabled === true) return; + if (checked !== true && checked !== false) { + checked = !node[checkedKey]; + } + callbackFlag = !!callbackFlag; + + if (node[checkedKey] === checked && !checkTypeFlag) { + return; + } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) { + return; + } + if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) { + node[checkedKey] = checked; + var checkObj = $("#" + node.tId + consts.id.CHECK); + if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); + view.setChkClass(this.setting, checkObj, node); + view.repairParentChkClassWithSelf(this.setting, node); + if (callbackFlag) { + setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + } + } + } + + zTreeTools.checkAllNodes = function(checked) { + view.repairAllChk(this.setting, !!checked); + } + + zTreeTools.getCheckedNodes = function(checked) { + var childKey = this.setting.data.key.children; + checked = (checked !== false); + return data.getTreeCheckedNodes(this.setting, data.getRoot(setting)[childKey], checked); + } + + zTreeTools.getChangeCheckedNodes = function() { + var childKey = this.setting.data.key.children; + return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(setting)[childKey]); + } + + zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) { + disabled = !!disabled; + inheritParent = !!inheritParent; + inheritChildren = !!inheritChildren; + view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); + view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); + } + + var _updateNode = zTreeTools.updateNode; + zTreeTools.updateNode = function(node, checkTypeFlag) { + if (_updateNode) _updateNode.apply(zTreeTools, arguments); + if (!node || !this.setting.check.enable) return; + var nObj = $("#" + node.tId); + if (nObj.get(0) && tools.uCanDo(this.setting)) { + var checkObj = $("#" + node.tId + consts.id.CHECK); + if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); + view.setChkClass(this.setting, checkObj, node); + view.repairParentChkClassWithSelf(this.setting, node); + } + } + }, + //method of operate data + _data = { + getRadioCheckedList: function(setting) { + var checkedList = data.getRoot(setting).radioCheckedList; + for (var i=0, j=checkedList.length; i -1 && node.check_Child_State < 2) : (node.check_Child_State > 0))) + }; + return r; + }, + getTreeCheckedNodes: function(setting, nodes, checked, results) { + if (!nodes) return []; + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL); + results = !results ? [] : results; + for (var i = 0, l = nodes.length; i < l; i++) { + if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) { + results.push(nodes[i]); + if(onlyOne) { + break; + } + } + data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results); + if(onlyOne && results.length > 0) { + break; + } + } + return results; + }, + getTreeChangeCheckedNodes: function(setting, nodes, results) { + if (!nodes) return []; + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked; + results = !results ? [] : results; + for (var i = 0, l = nodes.length; i < l; i++) { + if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) { + results.push(nodes[i]); + } + data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results); + } + return results; + }, + makeChkFlag: function(setting, node) { + if (!node) return; + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + chkFlag = -1; + if (node[childKey]) { + for (var i = 0, l = node[childKey].length; i < l; i++) { + var cNode = node[childKey][i]; + var tmp = -1; + if (setting.check.chkStyle == consts.radio.STYLE) { + if (cNode.nocheck === true || cNode.chkDisabled === true) { + tmp = cNode.check_Child_State; + } else if (cNode.halfCheck === true) { + tmp = 2; + } else if (cNode[checkedKey]) { + tmp = 2; + } else { + tmp = cNode.check_Child_State > 0 ? 2:0; + } + if (tmp == 2) { + chkFlag = 2; break; + } else if (tmp == 0){ + chkFlag = 0; + } + } else if (setting.check.chkStyle == consts.checkbox.STYLE) { + if (cNode.nocheck === true || cNode.chkDisabled === true) { + tmp = cNode.check_Child_State; + } else if (cNode.halfCheck === true) { + tmp = 1; + } else if (cNode[checkedKey] ) { + tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; + } else { + tmp = (cNode.check_Child_State > 0) ? 1 : 0; + } + if (tmp === 1) { + chkFlag = 1; break; + } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { + chkFlag = 1; break; + } else if (chkFlag === 2 && tmp > -1 && tmp < 2) { + chkFlag = 1; break; + } else if (tmp > -1) { + chkFlag = tmp; + } + } + } + } + node.check_Child_State = chkFlag; + } + }, + //method of event proxy + _event = { + + }, + //method of event handler + _handler = { + onCheckNode: function (event, node) { + if (node.chkDisabled === true) return false; + var setting = data.getSetting(event.data.treeId), + checkedKey = setting.data.key.checked; + if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true; + node[checkedKey] = !node[checkedKey]; + view.checkNodeRelation(setting, node); + var checkObj = $("#" + node.tId + consts.id.CHECK); + view.setChkClass(setting, checkObj, node); + view.repairParentChkClassWithSelf(setting, node); + setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); + return true; + }, + onMouseoverCheck: function(event, node) { + if (node.chkDisabled === true) return false; + var setting = data.getSetting(event.data.treeId), + checkObj = $("#" + node.tId + consts.id.CHECK); + node.check_Focus = true; + view.setChkClass(setting, checkObj, node); + return true; + }, + onMouseoutCheck: function(event, node) { + if (node.chkDisabled === true) return false; + var setting = data.getSetting(event.data.treeId), + checkObj = $("#" + node.tId + consts.id.CHECK); + node.check_Focus = false; + view.setChkClass(setting, checkObj, node); + return true; + } + }, + //method of tools for zTree + _tools = { + + }, + //method of operate ztree dom + _view = { + checkNodeRelation: function(setting, node) { + var pNode, i, l, + childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + r = consts.radio; + if (setting.check.chkStyle == r.STYLE) { + var checkedList = data.getRadioCheckedList(setting); + if (node[checkedKey]) { + if (setting.check.radioType == r.TYPE_ALL) { + for (i = checkedList.length-1; i >= 0; i--) { + pNode = checkedList[i]; + pNode[checkedKey] = false; + checkedList.splice(i, 1); + + view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode); + if (pNode.parentTId != node.parentTId) { + view.repairParentChkClassWithSelf(setting, pNode); + } + } + checkedList.push(node); + } else { + var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); + for (i = 0, l = parentNode[childKey].length; i < l; i++) { + pNode = parentNode[childKey][i]; + if (pNode[checkedKey] && pNode != node) { + pNode[checkedKey] = false; + view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode); + } + } + } + } else if (setting.check.radioType == r.TYPE_ALL) { + for (i = 0, l = checkedList.length; i < l; i++) { + if (node == checkedList[i]) { + checkedList.splice(i, 1); + break; + } + } + } + + } else { + if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { + view.setSonNodeCheckBox(setting, node, true); + } + if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) { + view.setSonNodeCheckBox(setting, node, false); + } + if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) { + view.setParentNodeCheckBox(setting, node, true); + } + if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) { + view.setParentNodeCheckBox(setting, node, false); + } + } + }, + makeChkClass: function(setting, node) { + var checkedKey = setting.data.key.checked, + c = consts.checkbox, r = consts.radio, + fullStyle = ""; + if (node.chkDisabled === true) { + fullStyle = c.DISABLED; + } else if (node.halfCheck) { + fullStyle = c.PART; + } else if (setting.check.chkStyle == r.STYLE) { + fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART; + } else { + fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART); + } + var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle; + chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; + return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; + }, + repairAllChk: function(setting, checked) { + if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { + var checkedKey = setting.data.key.checked, + childKey = setting.data.key.children, + root = data.getRoot(setting); + for (var i = 0, l = root[childKey].length; i 0) { + view.repairParentChkClass(setting, node[childKey][0]); + } else { + view.repairParentChkClass(setting, node); + } + }, + repairSonChkDisabled: function(setting, node, chkDisabled, inherit) { + if (!node) return; + var childKey = setting.data.key.children; + if (node.chkDisabled != chkDisabled) { + node.chkDisabled = chkDisabled; + } + view.repairChkClass(setting, node); + if (node[childKey] && inherit) { + for (var i = 0, l = node[childKey].length; i < l; i++) { + var sNode = node[childKey][i]; + view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit); + } + } + }, + repairParentChkDisabled: function(setting, node, chkDisabled, inherit) { + if (!node) return; + if (node.chkDisabled != chkDisabled && inherit) { + node.chkDisabled = chkDisabled; + } + view.repairChkClass(setting, node); + view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); + }, + setChkClass: function(setting, obj, node) { + if (!obj) return; + if (node.nocheck === true) { + obj.hide(); + } else { + obj.show(); + } + obj.removeClass(); + obj.addClass(view.makeChkClass(setting, node)); + }, + setParentNodeCheckBox: function(setting, node, value, srcNode) { + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + checkObj = $("#" + node.tId + consts.id.CHECK); + if (!srcNode) srcNode = node; + data.makeChkFlag(setting, node); + if (node.nocheck !== true && node.chkDisabled !== true) { + node[checkedKey] = value; + view.setChkClass(setting, checkObj, node); + if (setting.check.autoCheckTrigger && node != srcNode) { + setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + } + } + if (node.parentTId) { + var pSign = true; + if (!value) { + var pNodes = node.getParentNode()[childKey]; + for (var i = 0, l = pNodes.length; i < l; i++) { + if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey]) + || ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) { + pSign = false; + break; + } + } + } + if (pSign) { + view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode); + } + } + }, + setSonNodeCheckBox: function(setting, node, value, srcNode) { + if (!node) return; + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + checkObj = $("#" + node.tId + consts.id.CHECK); + if (!srcNode) srcNode = node; + + var hasDisable = false; + if (node[childKey]) { + for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) { + var sNode = node[childKey][i]; + view.setSonNodeCheckBox(setting, sNode, value, srcNode); + if (sNode.chkDisabled === true) hasDisable = true; + } + } + + if (node != data.getRoot(setting) && node.chkDisabled !== true) { + if (hasDisable && node.nocheck !== true) { + data.makeChkFlag(setting, node); + } + if (node.nocheck !== true && node.chkDisabled !== true) { + node[checkedKey] = value; + if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1; + } else { + node.check_Child_State = -1; + } + view.setChkClass(setting, checkObj, node); + if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) { + setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + } + } + + } + }, + + _z = { + tools: _tools, + view: _view, + event: _event, + data: _data + }; + $.extend(true, $.fn.zTree.consts, _consts); + $.extend(true, $.fn.zTree._z, _z); + + var zt = $.fn.zTree, + tools = zt._z.tools, + consts = zt.consts, + view = zt._z.view, + data = zt._z.data, + event = zt._z.event; + + data.exSetting(_setting); + data.addInitBind(_bindEvent); + data.addInitUnBind(_unbindEvent); + data.addInitCache(_initCache); + data.addInitNode(_initNode); + data.addInitProxy(_eventProxy); + data.addInitRoot(_initRoot); + data.addBeforeA(_beforeA); + data.addZTreeTools(_zTreeTools); + + var _createNodes = view.createNodes; + view.createNodes = function(setting, level, nodes, parentNode) { + if (_createNodes) _createNodes.apply(view, arguments); + if (!nodes) return; + view.repairParentChkClassWithSelf(setting, parentNode); + } + var _removeNode = view.removeNode; + view.removeNode = function(setting, node) { + var parentNode = node.getParentNode(); + if (_removeNode) _removeNode.apply(view, arguments); + if (!node || !parentNode) return; + view.repairChkClass(setting, parentNode); + view.repairParentChkClass(setting, parentNode); + } + + var _appendNodes = view.appendNodes; + view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) { + var html = ""; + if (_appendNodes) { + html = _appendNodes.apply(view, arguments); + } + if (parentNode) { + data.makeChkFlag(setting, parentNode); + } + return html; + } +})(jQuery); +/* + * JQuery zTree exedit 3.5.12 + * http://zTree.me/ + * + * Copyright (c) 2010 Hunter.z + * + * Licensed same as jquery - MIT License + * http://www.opensource.org/licenses/mit-license.php + * + * email: hunter.z@263.net + * Date: 2013-03-11 + */ +(function($){ + //default consts of exedit + var _consts = { + event: { + DRAG: "ztree_drag", + DROP: "ztree_drop", + REMOVE: "ztree_remove", + RENAME: "ztree_rename" + }, + id: { + EDIT: "_edit", + INPUT: "_input", + REMOVE: "_remove" + }, + move: { + TYPE_INNER: "inner", + TYPE_PREV: "prev", + TYPE_NEXT: "next" + }, + node: { + CURSELECTED_EDIT: "curSelectedNode_Edit", + TMPTARGET_TREE: "tmpTargetzTree", + TMPTARGET_NODE: "tmpTargetNode" + } + }, + //default setting of exedit + _setting = { + edit: { + enable: false, + editNameSelectAll: false, + showRemoveBtn: true, + showRenameBtn: true, + removeTitle: "remove", + renameTitle: "rename", + drag: { + autoExpandTrigger: false, + isCopy: true, + isMove: true, + prev: true, + next: true, + inner: true, + minMoveSize: 5, + borderMax: 10, + borderMin: -5, + maxShowNodeNum: 5, + autoOpenTime: 500 + } + }, + view: { + addHoverDom: null, + removeHoverDom: null + }, + callback: { + beforeDrag:null, + beforeDragOpen:null, + beforeDrop:null, + beforeEditName:null, + beforeRename:null, + onDrag:null, + onDrop:null, + onRename:null + } + }, + //default root of exedit + _initRoot = function (setting) { + var r = data.getRoot(setting); + r.curEditNode = null; + r.curEditInput = null; + r.curHoverNode = null; + r.dragFlag = 0; + r.dragNodeShowBefore = []; + r.dragMaskList = new Array(); + r.showHoverDom = true; + }, + //default cache of exedit + _initCache = function(treeId) {}, + //default bind event of exedit + _bindEvent = function(setting) { + var o = setting.treeObj; + var c = consts.event; + o.bind(c.RENAME, function (event, treeId, treeNode) { + tools.apply(setting.callback.onRename, [event, treeId, treeNode]); + }); + + o.bind(c.REMOVE, function (event, treeId, treeNode) { + tools.apply(setting.callback.onRemove, [event, treeId, treeNode]); + }); + + o.bind(c.DRAG, function (event, srcEvent, treeId, treeNodes) { + tools.apply(setting.callback.onDrag, [srcEvent, treeId, treeNodes]); + }); + + o.bind(c.DROP, function (event, srcEvent, treeId, treeNodes, targetNode, moveType, isCopy) { + tools.apply(setting.callback.onDrop, [srcEvent, treeId, treeNodes, targetNode, moveType, isCopy]); + }); + }, + _unbindEvent = function(setting) { + var o = setting.treeObj; + var c = consts.event; + o.unbind(c.RENAME); + o.unbind(c.REMOVE); + o.unbind(c.DRAG); + o.unbind(c.DROP); + }, + //default event proxy of exedit + _eventProxy = function(e) { + var target = e.target, + setting = data.getSetting(e.data.treeId), + relatedTarget = e.relatedTarget, + tId = "", node = null, + nodeEventType = "", treeEventType = "", + nodeEventCallback = null, treeEventCallback = null, + tmp = null; + + if (tools.eqs(e.type, "mouseover")) { + tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (tmp) { + tId = tmp.parentNode.id; + nodeEventType = "hoverOverNode"; + } + } else if (tools.eqs(e.type, "mouseout")) { + tmp = tools.getMDom(setting, relatedTarget, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (!tmp) { + tId = "remove"; + nodeEventType = "hoverOutNode"; + } + } else if (tools.eqs(e.type, "mousedown")) { + tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (tmp) { + tId = tmp.parentNode.id; + nodeEventType = "mousedownNode"; + } + } + if (tId.length>0) { + node = data.getNodeCache(setting, tId); + switch (nodeEventType) { + case "mousedownNode" : + nodeEventCallback = _handler.onMousedownNode; + break; + case "hoverOverNode" : + nodeEventCallback = _handler.onHoverOverNode; + break; + case "hoverOutNode" : + nodeEventCallback = _handler.onHoverOutNode; + break; + } + } + var proxyResult = { + stop: false, + node: node, + nodeEventType: nodeEventType, + nodeEventCallback: nodeEventCallback, + treeEventType: treeEventType, + treeEventCallback: treeEventCallback + }; + return proxyResult + }, + //default init node of exedit + _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + if (!n) return; + n.isHover = false; + n.editNameFlag = false; + }, + //update zTreeObj, add method of edit + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.cancelEditName = function(newName) { + var root = data.getRoot(setting), + nameKey = setting.data.key.name, + node = root.curEditNode; + if (!root.curEditNode) return; + view.cancelCurEditNode(setting, newName?newName:node[nameKey]); + } + zTreeTools.copyNode = function(targetNode, node, moveType, isSilent) { + if (!node) return null; + if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null; + var newNode = tools.clone(node); + if (!targetNode) { + targetNode = null; + moveType = consts.move.TYPE_INNER; + } + if (moveType == consts.move.TYPE_INNER) { + function copyCallback() { + view.addNodes(setting, targetNode, [newNode], isSilent); + } + + if (tools.canAsync(setting, targetNode)) { + view.asyncNode(setting, targetNode, isSilent, copyCallback); + } else { + copyCallback(); + } + } else { + view.addNodes(setting, targetNode.parentNode, [newNode], isSilent); + view.moveNode(setting, targetNode, newNode, moveType, false, isSilent); + } + return newNode; + } + zTreeTools.editName = function(node) { + if (!node || !node.tId || node !== data.getNodeCache(setting, node.tId)) return; + if (node.parentTId) view.expandCollapseParentNode(setting, node.getParentNode(), true); + view.editNode(setting, node) + } + zTreeTools.moveNode = function(targetNode, node, moveType, isSilent) { + if (!node) return node; + if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) { + return null; + } else if (targetNode && ((node.parentTId == targetNode.tId && moveType == consts.move.TYPE_INNER) || $("#" + node.tId).find("#" + targetNode.tId).length > 0)) { + return null; + } else if (!targetNode) { + targetNode = null; + } + function moveCallback() { + view.moveNode(setting, targetNode, node, moveType, false, isSilent); + } + if (tools.canAsync(setting, targetNode) && moveType === consts.move.TYPE_INNER) { + view.asyncNode(setting, targetNode, isSilent, moveCallback); + } else { + moveCallback(); + } + return node; + } + zTreeTools.setEditable = function(editable) { + setting.edit.enable = editable; + return this.refresh(); + } + }, + //method of operate data + _data = { + setSonNodeLevel: function(setting, parentNode, node) { + if (!node) return; + var childKey = setting.data.key.children; + node.level = (parentNode)? parentNode.level + 1 : 0; + if (!node[childKey]) return; + for (var i = 0, l = node[childKey].length; i < l; i++) { + if (node[childKey][i]) data.setSonNodeLevel(setting, node, node[childKey][i]); + } + } + }, + //method of event proxy + _event = { + + }, + //method of event handler + _handler = { + onHoverOverNode: function(event, node) { + var setting = data.getSetting(event.data.treeId), + root = data.getRoot(setting); + if (root.curHoverNode != node) { + _handler.onHoverOutNode(event); + } + root.curHoverNode = node; + view.addHoverDom(setting, node); + }, + onHoverOutNode: function(event, node) { + var setting = data.getSetting(event.data.treeId), + root = data.getRoot(setting); + if (root.curHoverNode && !data.isSelectedNode(setting, root.curHoverNode)) { + view.removeTreeDom(setting, root.curHoverNode); + root.curHoverNode = null; + } + }, + onMousedownNode: function(eventMouseDown, _node) { + var i,l, + setting = data.getSetting(eventMouseDown.data.treeId), + root = data.getRoot(setting); + //right click can't drag & drop + if (eventMouseDown.button == 2 || !setting.edit.enable || (!setting.edit.drag.isCopy && !setting.edit.drag.isMove)) return true; + + //input of edit node name can't drag & drop + var target = eventMouseDown.target, + _nodes = data.getRoot(setting).curSelectedList, + nodes = []; + if (!data.isSelectedNode(setting, _node)) { + nodes = [_node]; + } else { + for (i=0, l=_nodes.length; i1) { + var pNodes = nodes[0].parentTId ? nodes[0].getParentNode()[childKey] : data.getNodes(setting); + tmpNodes = []; + for (i=0, l=pNodes.length; i -1 && (lastIndex+1) !== i) { + isOrder = false; + } + tmpNodes.push(pNodes[i]); + lastIndex = i; + } + if (nodes.length === tmpNodes.length) { + nodes = tmpNodes; + break; + } + } + } + if (isOrder) { + preNode = nodes[0].getPreNode(); + nextNode = nodes[nodes.length-1].getNextNode(); + } + + //set node in selected + curNode = $("
            "); + for (i=0, l=nodes.length; i0); + view.removeTreeDom(setting, tmpNode); + + tmpDom = $("
          • "); + tmpDom.append($("#" + tmpNode.tId + consts.id.A).clone()); + tmpDom.css("padding", "0"); + tmpDom.children("#" + tmpNode.tId + consts.id.A).removeClass(consts.node.CURSELECTED); + curNode.append(tmpDom); + if (i == setting.edit.drag.maxShowNodeNum-1) { + tmpDom = $("
          • ...
          • "); + curNode.append(tmpDom); + break; + } + } + curNode.attr("id", nodes[0].tId + consts.id.UL + "_tmp"); + curNode.addClass(setting.treeObj.attr("class")); + curNode.appendTo("body"); + + tmpArrow = $(""); + tmpArrow.attr("id", "zTreeMove_arrow_tmp"); + tmpArrow.appendTo("body"); + + setting.treeObj.trigger(consts.event.DRAG, [event, setting.treeId, nodes]); + } + + if (root.dragFlag == 1) { + if (tmpTarget && tmpArrow.attr("id") == event.target.id && tmpTargetNodeId && (event.clientX + doc.scrollLeft()+2) > ($("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left)) { + var xT = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget); + event.target = (xT.length > 0) ? xT.get(0) : event.target; + } else if (tmpTarget) { + tmpTarget.removeClass(consts.node.TMPTARGET_TREE); + if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) + .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); + } + tmpTarget = null; + tmpTargetNodeId = null; + + //judge drag & drop in multi ztree + isOtherTree = false; + targetSetting = setting; + var settings = data.getSettings(); + for (var s in settings) { + if (settings[s].treeId && settings[s].edit.enable && settings[s].treeId != setting.treeId + && (event.target.id == settings[s].treeId || $(event.target).parents("#" + settings[s].treeId).length>0)) { + isOtherTree = true; + targetSetting = settings[s]; + } + } + + var docScrollTop = doc.scrollTop(), + docScrollLeft = doc.scrollLeft(), + treeOffset = targetSetting.treeObj.offset(), + scrollHeight = targetSetting.treeObj.get(0).scrollHeight, + scrollWidth = targetSetting.treeObj.get(0).scrollWidth, + dTop = (event.clientY + docScrollTop - treeOffset.top), + dBottom = (targetSetting.treeObj.height() + treeOffset.top - event.clientY - docScrollTop), + dLeft = (event.clientX + docScrollLeft - treeOffset.left), + dRight = (targetSetting.treeObj.width() + treeOffset.left - event.clientX - docScrollLeft), + isTop = (dTop < setting.edit.drag.borderMax && dTop > setting.edit.drag.borderMin), + isBottom = (dBottom < setting.edit.drag.borderMax && dBottom > setting.edit.drag.borderMin), + isLeft = (dLeft < setting.edit.drag.borderMax && dLeft > setting.edit.drag.borderMin), + isRight = (dRight < setting.edit.drag.borderMax && dRight > setting.edit.drag.borderMin), + isTreeInner = dTop > setting.edit.drag.borderMin && dBottom > setting.edit.drag.borderMin && dLeft > setting.edit.drag.borderMin && dRight > setting.edit.drag.borderMin, + isTreeTop = (isTop && targetSetting.treeObj.scrollTop() <= 0), + isTreeBottom = (isBottom && (targetSetting.treeObj.scrollTop() + targetSetting.treeObj.height()+10) >= scrollHeight), + isTreeLeft = (isLeft && targetSetting.treeObj.scrollLeft() <= 0), + isTreeRight = (isRight && (targetSetting.treeObj.scrollLeft() + targetSetting.treeObj.width()+10) >= scrollWidth); + + if (event.target.id && targetSetting.treeObj.find("#" + event.target.id).length > 0) { + //get node
          • dom + var targetObj = event.target; + while (targetObj && targetObj.tagName && !tools.eqs(targetObj.tagName, "li") && targetObj.id != targetSetting.treeId) { + targetObj = targetObj.parentNode; + } + + var canMove = true; + //don't move to self or children of self + for (i=0, l=nodes.length; i 0) { + canMove = false; + break; + } + } + if (canMove) { + if (event.target.id && + (event.target.id == (targetObj.id + consts.id.A) || $(event.target).parents("#" + targetObj.id + consts.id.A).length > 0)) { + tmpTarget = $(targetObj); + tmpTargetNodeId = targetObj.id; + } + } + } + + //the mouse must be in zTree + tmpNode = nodes[0]; + if (isTreeInner && (event.target.id == targetSetting.treeId || $(event.target).parents("#" + targetSetting.treeId).length>0)) { + //judge mouse move in root of ztree + if (!tmpTarget && (event.target.id == targetSetting.treeId || isTreeTop || isTreeBottom || isTreeLeft || isTreeRight) && (isOtherTree || (!isOtherTree && tmpNode.parentTId))) { + tmpTarget = targetSetting.treeObj; + } + //auto scroll top + if (isTop) { + targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()-10); + } else if (isBottom) { + targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()+10); + } + if (isLeft) { + targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()-10); + } else if (isRight) { + targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+10); + } + //auto scroll left + if (tmpTarget && tmpTarget != targetSetting.treeObj && tmpTarget.offset().left < targetSetting.treeObj.offset().left) { + targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+ tmpTarget.offset().left - targetSetting.treeObj.offset().left); + } + } + + curNode.css({ + "top": (event.clientY + docScrollTop + 3) + "px", + "left": (event.clientX + docScrollLeft + 3) + "px" + }); + + var dX = 0; + var dY = 0; + if (tmpTarget && tmpTarget.attr("id")!=targetSetting.treeId) { + var tmpTargetNode = tmpTargetNodeId == null ? null: data.getNodeCache(targetSetting, tmpTargetNodeId), + isCopy = (event.ctrlKey && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy), + isPrev = !!(preNode && tmpTargetNodeId === preNode.tId), + isNext = !!(nextNode && tmpTargetNodeId === nextNode.tId), + isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId), + canPrev = (isCopy || !isNext) && tools.apply(targetSetting.edit.drag.prev, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.prev), + canNext = (isCopy || !isPrev) && tools.apply(targetSetting.edit.drag.next, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.next), + canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !tmpTargetNode.isParent) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner); + if (!canPrev && !canNext && !canInner) { + tmpTarget = null; + tmpTargetNodeId = ""; + moveType = consts.move.TYPE_INNER; + tmpArrow.css({ + "display":"none" + }); + if (window.zTreeMoveTimer) { + clearTimeout(window.zTreeMoveTimer); + window.zTreeMoveTargetNodeTId = null + } + } else { + var tmpTargetA = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget), + tmpNextA = tmpTargetNode.isLastNode ? null : $("#" + tmpTargetNode.getNextNode().tId + consts.id.A, tmpTarget.next()), + tmpTop = tmpTargetA.offset().top, + tmpLeft = tmpTargetA.offset().left, + prevPercent = canPrev ? (canInner ? 0.25 : (canNext ? 0.5 : 1) ) : -1, + nextPercent = canNext ? (canInner ? 0.75 : (canPrev ? 0.5 : 0) ) : -1, + dY_percent = (event.clientY + docScrollTop - tmpTop)/tmpTargetA.height(); + if ((prevPercent==1 ||dY_percent<=prevPercent && dY_percent>=-.2) && canPrev) { + dX = 1 - tmpArrow.width(); + dY = tmpTop - tmpArrow.height()/2; + moveType = consts.move.TYPE_PREV; + } else if ((nextPercent==0 || dY_percent>=nextPercent && dY_percent<=1.2) && canNext) { + dX = 1 - tmpArrow.width(); + dY = (tmpNextA == null || (tmpTargetNode.isParent && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height()/2) : (tmpNextA.offset().top - tmpArrow.height()/2); + moveType = consts.move.TYPE_NEXT; + }else { + dX = 5 - tmpArrow.width(); + dY = tmpTop; + moveType = consts.move.TYPE_INNER; + } + tmpArrow.css({ + "display":"block", + "top": dY + "px", + "left": (tmpLeft + dX) + "px" + }); + tmpTargetA.addClass(consts.node.TMPTARGET_NODE + "_" + moveType); + + if (preTmpTargetNodeId != tmpTargetNodeId || preTmpMoveType != moveType) { + startTime = (new Date()).getTime(); + } + if (tmpTargetNode && tmpTargetNode.isParent && moveType == consts.move.TYPE_INNER) { + var startTimer = true; + if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId) { + clearTimeout(window.zTreeMoveTimer); + window.zTreeMoveTargetNodeTId = null; + } else if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId === tmpTargetNode.tId) { + startTimer = false; + } + if (startTimer) { + window.zTreeMoveTimer = setTimeout(function() { + if (moveType != consts.move.TYPE_INNER) return; + if (tmpTargetNode && tmpTargetNode.isParent && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime + && tools.apply(targetSetting.callback.beforeDragOpen, [targetSetting.treeId, tmpTargetNode], true)) { + view.switchNode(targetSetting, tmpTargetNode); + if (targetSetting.edit.drag.autoExpandTrigger) { + targetSetting.treeObj.trigger(consts.event.EXPAND, [targetSetting.treeId, tmpTargetNode]); + } + } + }, targetSetting.edit.drag.autoOpenTime+50); + window.zTreeMoveTargetNodeTId = tmpTargetNode.tId; + } + } + } + } else { + moveType = consts.move.TYPE_INNER; + if (tmpTarget && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, null], !!targetSetting.edit.drag.inner)) { + tmpTarget.addClass(consts.node.TMPTARGET_TREE); + } else { + tmpTarget = null; + } + tmpArrow.css({ + "display":"none" + }); + if (window.zTreeMoveTimer) { + clearTimeout(window.zTreeMoveTimer); + window.zTreeMoveTargetNodeTId = null; + } + } + preTmpTargetNodeId = tmpTargetNodeId; + preTmpMoveType = moveType; + } + return false; + } + + doc.bind("mouseup", _docMouseUp); + function _docMouseUp(event) { + if (window.zTreeMoveTimer) { + clearTimeout(window.zTreeMoveTimer); + window.zTreeMoveTargetNodeTId = null; + } + preTmpTargetNodeId = null; + preTmpMoveType = null; + doc.unbind("mousemove", _docMouseMove); + doc.unbind("mouseup", _docMouseUp); + doc.unbind("selectstart", _docSelect); + $("body").css("cursor", "auto"); + if (tmpTarget) { + tmpTarget.removeClass(consts.node.TMPTARGET_TREE); + if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) + .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); + } + tools.showIfameMask(setting, false); + + root.showHoverDom = true; + if (root.dragFlag == 0) return; + root.dragFlag = 0; + + var i, l, tmpNode; + for (i=0, l=nodes.length; i0); + } + $("#" + newNodes[0].tId).focus().blur(); + + setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]); + } + + if (moveType == consts.move.TYPE_INNER && tools.canAsync(targetSetting, dragTargetNode)) { + view.asyncNode(targetSetting, dragTargetNode, false, dropCallback); + } else { + dropCallback(); + } + + } else { + for (i=0, l=nodes.length; i0); + } + setting.treeObj.trigger(consts.event.DROP, [event, setting.treeId, nodes, null, null, null]); + } + } + + doc.bind("selectstart", _docSelect); + function _docSelect() { + return false; + } + + //Avoid FireFox's Bug + //If zTree Div CSS set 'overflow', so drag node outside of zTree, and event.target is error. + if(eventMouseDown.preventDefault) { + eventMouseDown.preventDefault(); + } + return true; + } + }, + //method of tools for zTree + _tools = { + getAbs: function (obj) { + var oRect = obj.getBoundingClientRect(); + return [oRect.left,oRect.top] + }, + inputFocus: function(inputObj) { + if (inputObj.get(0)) { + inputObj.focus(); + tools.setCursorPosition(inputObj.get(0), inputObj.val().length); + } + }, + inputSelect: function(inputObj) { + if (inputObj.get(0)) { + inputObj.focus(); + inputObj.select(); + } + }, + setCursorPosition: function(obj, pos){ + if(obj.setSelectionRange) { + obj.focus(); + obj.setSelectionRange(pos,pos); + } else if (obj.createTextRange) { + var range = obj.createTextRange(); + range.collapse(true); + range.moveEnd('character', pos); + range.moveStart('character', pos); + range.select(); + } + }, + showIfameMask: function(setting, showSign) { + var root = data.getRoot(setting); + //clear full mask + while (root.dragMaskList.length > 0) { + root.dragMaskList[0].remove(); + root.dragMaskList.shift(); + } + if (showSign) { + //show mask + var iframeList = $("iframe"); + for (var i = 0, l = iframeList.length; i < l; i++) { + var obj = iframeList.get(i), + r = tools.getAbs(obj), + dragMask = $("
            "); + dragMask.appendTo("body"); + root.dragMaskList.push(dragMask); + } + } + } + }, + //method of operate ztree dom + _view = { + addEditBtn: function(setting, node) { + if (node.editNameFlag || $("#" + node.tId + consts.id.EDIT).length > 0) { + return; + } + if (!tools.apply(setting.edit.showRenameBtn, [setting.treeId, node], setting.edit.showRenameBtn)) { + return; + } + var aObj = $("#" + node.tId + consts.id.A), + editStr = ""; + aObj.append(editStr); + + $("#" + node.tId + consts.id.EDIT).bind('click', + function() { + if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeEditName, [setting.treeId, node], true) == false) return false; + view.editNode(setting, node); + return false; + } + ).show(); + }, + addRemoveBtn: function(setting, node) { + if (node.editNameFlag || $("#" + node.tId + consts.id.REMOVE).length > 0) { + return; + } + if (!tools.apply(setting.edit.showRemoveBtn, [setting.treeId, node], setting.edit.showRemoveBtn)) { + return; + } + var aObj = $("#" + node.tId + consts.id.A), + removeStr = ""; + aObj.append(removeStr); + + $("#" + node.tId + consts.id.REMOVE).bind('click', + function() { + if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return false; + view.removeNode(setting, node); + setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]); + return false; + } + ).bind('mousedown', + function(eventMouseDown) { + return true; + } + ).show(); + }, + addHoverDom: function(setting, node) { + if (data.getRoot(setting).showHoverDom) { + node.isHover = true; + if (setting.edit.enable) { + view.addEditBtn(setting, node); + view.addRemoveBtn(setting, node); + } + tools.apply(setting.view.addHoverDom, [setting.treeId, node]); + } + }, + cancelCurEditNode: function (setting, forceName) { + var root = data.getRoot(setting), + nameKey = setting.data.key.name, + node = root.curEditNode; + + if (node) { + var inputObj = root.curEditInput; + var newName = forceName ? forceName:inputObj.val(); + if (!forceName && tools.apply(setting.callback.beforeRename, [setting.treeId, node, newName], true) === false) { + return false; + } else { + node[nameKey] = newName ? newName:inputObj.val(); + if (!forceName) { + setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node]); + } + } + var aObj = $("#" + node.tId + consts.id.A); + aObj.removeClass(consts.node.CURSELECTED_EDIT); + inputObj.unbind(); + view.setNodeName(setting, node); + node.editNameFlag = false; + root.curEditNode = null; + root.curEditInput = null; + view.selectNode(setting, node, false); + } + root.noSelection = true; + return true; + }, + editNode: function(setting, node) { + var root = data.getRoot(setting); + view.editNodeBlur = false; + if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) { + setTimeout(function() {tools.inputFocus(root.curEditInput);}, 0); + return; + } + var nameKey = setting.data.key.name; + node.editNameFlag = true; + view.removeTreeDom(setting, node); + view.cancelCurEditNode(setting); + view.selectNode(setting, node, false); + $("#" + node.tId + consts.id.SPAN).html(""); + var inputObj = $("#" + node.tId + consts.id.INPUT); + inputObj.attr("value", node[nameKey]); + if (setting.edit.editNameSelectAll) { + tools.inputSelect(inputObj); + } else { + tools.inputFocus(inputObj); + } + + inputObj.bind('blur', function(event) { + if (!view.editNodeBlur) { + view.cancelCurEditNode(setting); + } + }).bind('keydown', function(event) { + if (event.keyCode=="13") { + view.editNodeBlur = true; + view.cancelCurEditNode(setting, null, true); + } else if (event.keyCode=="27") { + view.cancelCurEditNode(setting, node[nameKey]); + } + }).bind('click', function(event) { + return false; + }).bind('dblclick', function(event) { + return false; + }); + + $("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED_EDIT); + root.curEditInput = inputObj; + root.noSelection = false; + root.curEditNode = node; + }, + moveNode: function(setting, targetNode, node, moveType, animateFlag, isSilent) { + var root = data.getRoot(setting), + childKey = setting.data.key.children; + if (targetNode == node) return; + if (setting.data.keep.leaf && targetNode && !targetNode.isParent && moveType == consts.move.TYPE_INNER) return; + var oldParentNode = (node.parentTId ? node.getParentNode(): root), + targetNodeIsRoot = (targetNode === null || targetNode == root); + if (targetNodeIsRoot && targetNode === null) targetNode = root; + if (targetNodeIsRoot) moveType = consts.move.TYPE_INNER; + var targetParentNode = (targetNode.parentTId ? targetNode.getParentNode() : root); + + if (moveType != consts.move.TYPE_PREV && moveType != consts.move.TYPE_NEXT) { + moveType = consts.move.TYPE_INNER; + } + + if (moveType == consts.move.TYPE_INNER) { + if (targetNodeIsRoot) { + //parentTId of root node is null + node.parentTId = null; + } else { + if (!targetNode.isParent) { + targetNode.isParent = true; + targetNode.open = !!targetNode.open; + view.setNodeLineIcos(setting, targetNode); + } + node.parentTId = targetNode.tId; + } + } + + //move node Dom + var targetObj, target_ulObj; + if (targetNodeIsRoot) { + targetObj = setting.treeObj; + target_ulObj = targetObj; + } else { + if (!isSilent && moveType == consts.move.TYPE_INNER) { + view.expandCollapseNode(setting, targetNode, true, false); + } else if (!isSilent) { + view.expandCollapseNode(setting, targetNode.getParentNode(), true, false); + } + targetObj = $("#" + targetNode.tId); + target_ulObj = $("#" + targetNode.tId + consts.id.UL); + if (!!targetObj.get(0) && !target_ulObj.get(0)) { + var ulstr = []; + view.makeUlHtml(setting, targetNode, ulstr, ''); + targetObj.append(ulstr.join('')); + } + target_ulObj = $("#" + targetNode.tId + consts.id.UL); + } + var nodeDom = $("#" + node.tId); + if (!nodeDom.get(0)) { + nodeDom = view.appendNodes(setting, node.level, [node], null, false, true).join(''); + } else if (!targetObj.get(0)) { + nodeDom.remove(); + } + if (target_ulObj.get(0) && moveType == consts.move.TYPE_INNER) { + target_ulObj.append(nodeDom); + } else if (targetObj.get(0) && moveType == consts.move.TYPE_PREV) { + targetObj.before(nodeDom); + } else if (targetObj.get(0) && moveType == consts.move.TYPE_NEXT) { + targetObj.after(nodeDom); + } + + //repair the data after move + var i,l, + tmpSrcIndex = -1, + tmpTargetIndex = 0, + oldNeighbor = null, + newNeighbor = null, + oldLevel = node.level; + if (node.isFirstNode) { + tmpSrcIndex = 0; + if (oldParentNode[childKey].length > 1 ) { + oldNeighbor = oldParentNode[childKey][1]; + oldNeighbor.isFirstNode = true; + } + } else if (node.isLastNode) { + tmpSrcIndex = oldParentNode[childKey].length -1; + oldNeighbor = oldParentNode[childKey][tmpSrcIndex - 1]; + oldNeighbor.isLastNode = true; + } else { + for (i = 0, l = oldParentNode[childKey].length; i < l; i++) { + if (oldParentNode[childKey][i].tId == node.tId) { + tmpSrcIndex = i; + break; + } + } + } + if (tmpSrcIndex >= 0) { + oldParentNode[childKey].splice(tmpSrcIndex, 1); + } + if (moveType != consts.move.TYPE_INNER) { + for (i = 0, l = targetParentNode[childKey].length; i < l; i++) { + if (targetParentNode[childKey][i].tId == targetNode.tId) tmpTargetIndex = i; + } + } + if (moveType == consts.move.TYPE_INNER) { + if (!targetNode[childKey]) targetNode[childKey] = new Array(); + if (targetNode[childKey].length > 0) { + newNeighbor = targetNode[childKey][targetNode[childKey].length - 1]; + newNeighbor.isLastNode = false; + } + targetNode[childKey].splice(targetNode[childKey].length, 0, node); + node.isLastNode = true; + node.isFirstNode = (targetNode[childKey].length == 1); + } else if (targetNode.isFirstNode && moveType == consts.move.TYPE_PREV) { + targetParentNode[childKey].splice(tmpTargetIndex, 0, node); + newNeighbor = targetNode; + newNeighbor.isFirstNode = false; + node.parentTId = targetNode.parentTId; + node.isFirstNode = true; + node.isLastNode = false; + + } else if (targetNode.isLastNode && moveType == consts.move.TYPE_NEXT) { + targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node); + newNeighbor = targetNode; + newNeighbor.isLastNode = false; + node.parentTId = targetNode.parentTId; + node.isFirstNode = false; + node.isLastNode = true; + + } else { + if (moveType == consts.move.TYPE_PREV) { + targetParentNode[childKey].splice(tmpTargetIndex, 0, node); + } else { + targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node); + } + node.parentTId = targetNode.parentTId; + node.isFirstNode = false; + node.isLastNode = false; + } + data.fixPIdKeyValue(setting, node); + data.setSonNodeLevel(setting, node.getParentNode(), node); + + //repair node what been moved + view.setNodeLineIcos(setting, node); + view.repairNodeLevelClass(setting, node, oldLevel) + + //repair node's old parentNode dom + if (!setting.data.keep.parent && oldParentNode[childKey].length < 1) { + //old parentNode has no child nodes + oldParentNode.isParent = false; + oldParentNode.open = false; + var tmp_ulObj = $("#" + oldParentNode.tId + consts.id.UL), + tmp_switchObj = $("#" + oldParentNode.tId + consts.id.SWITCH), + tmp_icoObj = $("#" + oldParentNode.tId + consts.id.ICON); + view.replaceSwitchClass(oldParentNode, tmp_switchObj, consts.folder.DOCU); + view.replaceIcoClass(oldParentNode, tmp_icoObj, consts.folder.DOCU); + tmp_ulObj.css("display", "none"); + + } else if (oldNeighbor) { + //old neigbor node + view.setNodeLineIcos(setting, oldNeighbor); + } + + //new neigbor node + if (newNeighbor) { + view.setNodeLineIcos(setting, newNeighbor); + } + + //repair checkbox / radio + if (!!setting.check && setting.check.enable && view.repairChkClass) { + view.repairChkClass(setting, oldParentNode); + view.repairParentChkClassWithSelf(setting, oldParentNode); + if (oldParentNode != node.parent) + view.repairParentChkClassWithSelf(setting, node); + } + + //expand parents after move + if (!isSilent) { + view.expandCollapseParentNode(setting, node.getParentNode(), true, animateFlag); + } + }, + removeEditBtn: function(node) { + $("#" + node.tId + consts.id.EDIT).unbind().remove(); + }, + removeRemoveBtn: function(node) { + $("#" + node.tId + consts.id.REMOVE).unbind().remove(); + }, + removeTreeDom: function(setting, node) { + node.isHover = false; + view.removeEditBtn(node); + view.removeRemoveBtn(node); + tools.apply(setting.view.removeHoverDom, [setting.treeId, node]); + }, + repairNodeLevelClass: function(setting, node, oldLevel) { + if (oldLevel === node.level) return; + var liObj = $("#" + node.tId), + aObj = $("#" + node.tId + consts.id.A), + ulObj = $("#" + node.tId + consts.id.UL), + oldClass = consts.className.LEVEL + oldLevel, + newClass = consts.className.LEVEL + node.level; + liObj.removeClass(oldClass); + liObj.addClass(newClass); + aObj.removeClass(oldClass); + aObj.addClass(newClass); + ulObj.removeClass(oldClass); + ulObj.addClass(newClass); + } + }, + + _z = { + tools: _tools, + view: _view, + event: _event, + data: _data + }; + $.extend(true, $.fn.zTree.consts, _consts); + $.extend(true, $.fn.zTree._z, _z); + + var zt = $.fn.zTree, + tools = zt._z.tools, + consts = zt.consts, + view = zt._z.view, + data = zt._z.data, + event = zt._z.event; + + data.exSetting(_setting); + data.addInitBind(_bindEvent); + data.addInitUnBind(_unbindEvent); + data.addInitCache(_initCache); + data.addInitNode(_initNode); + data.addInitProxy(_eventProxy); + data.addInitRoot(_initRoot); + data.addZTreeTools(_zTreeTools); + + var _cancelPreSelectedNode = view.cancelPreSelectedNode; + view.cancelPreSelectedNode = function (setting, node) { + var list = data.getRoot(setting).curSelectedList; + for (var i=0, j=list.length; i"); + }, + showNode: function(setting, node, options) { + node.isHidden = false; + data.initShowForExCheck(setting, node); + $("#" + node.tId).show(); + }, + showNodes: function(setting, nodes, options) { + if (!nodes || nodes.length == 0) { + return; + } + var pList = {}, i, j; + for (i=0, j=nodes.length; i 0 && !parentNode[childKey][0].isHidden) { + parentNode[childKey][0].isFirstNode = true; + } else if (childLength > 0) { + view.setFirstNodeForHide(setting, parentNode[childKey]); + } + }, + setLastNode: function(setting, parentNode) { + var childKey = setting.data.key.children, childLength = parentNode[childKey].length; + if (childLength > 0 && !parentNode[childKey][0].isHidden) { + parentNode[childKey][childLength - 1].isLastNode = true; + } else if (childLength > 0) { + view.setLastNodeForHide(setting, parentNode[childKey]); + } + }, + setFirstNodeForHide: function(setting, nodes) { + var n,i,j; + for (i=0, j=nodes.length; i=0; i--) { + n = nodes[i]; + if (n.isLastNode) { + break; + } + if (!n.isHidden && !n.isLastNode) { + n.isLastNode = true; + view.setNodeLineIcos(setting, n); + break; + } else { + n = null; + } + } + return n; + }, + setLastNodeForShow: function(setting, nodes) { + var n,i,j, last, old; + for (i=nodes.length-1; i>=0; i--) { + n = nodes[i]; + if (!last && !n.isHidden && n.isLastNode) { + last = n; + break; + } else if (!last && !n.isHidden && !n.isLastNode) { + n.isLastNode = true; + last = n; + view.setNodeLineIcos(setting, n); + } else if (last && n.isLastNode) { + n.isLastNode = false; + old = n; + view.setNodeLineIcos(setting, n); + break; + } else { + n = null; + } + } + return {"new":last, "old":old}; + } + }, + + _z = { + view: _view, + data: _data + }; + $.extend(true, $.fn.zTree._z, _z); + + var zt = $.fn.zTree, + tools = zt._z.tools, + consts = zt.consts, + view = zt._z.view, + data = zt._z.data, + event = zt._z.event; + + data.addInitNode(_initNode); + data.addBeforeA(_beforeA); + data.addZTreeTools(_zTreeTools); + +// Override method in core + var _dInitNode = data.initNode; + data.tmpHideParent = -1; + data.initNode = function(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag) { + if (data.tmpHideParent !== parentNode) { + data.tmpHideParent = parentNode; + var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting), + children = tmpPNode[setting.data.key.children]; + data.tmpHideFirstNode = view.setFirstNodeForHide(setting, children); + data.tmpHideLastNode = view.setLastNodeForHide(setting, children); + view.setNodeLineIcos(setting, data.tmpHideFirstNode); + view.setNodeLineIcos(setting, data.tmpHideLastNode); + } + isFirstNode = (data.tmpHideFirstNode === node); + isLastNode = (data.tmpHideLastNode === node); + if (_dInitNode) _dInitNode.apply(data, arguments); + if (isLastNode) { + view.clearOldLastNode(setting, node); + } + } + + var _makeChkFlag = data.makeChkFlag; + if (!!_makeChkFlag) { + data.makeChkFlag = function(setting, node) { + if (!!node && !!node.isHidden) { + return; + } + _makeChkFlag.apply(data, arguments); + } + } + + var _getTreeCheckedNodes = data.getTreeCheckedNodes; + if (!!_getTreeCheckedNodes) { + data.getTreeCheckedNodes = function(setting, nodes, checked, results) { + if (!!nodes && nodes.length > 0) { + var p = nodes[0].getParentNode(); + if (!!p && !!p.isHidden) { + return []; + } + } + return _getTreeCheckedNodes.apply(data, arguments); + } + } + + var _getTreeChangeCheckedNodes = data.getTreeChangeCheckedNodes; + if (!!_getTreeChangeCheckedNodes) { + data.getTreeChangeCheckedNodes = function(setting, nodes, results) { + if (!!nodes && nodes.length > 0) { + var p = nodes[0].getParentNode(); + if (!!p && !!p.isHidden) { + return []; + } + } + return _getTreeChangeCheckedNodes.apply(data, arguments); + } + } + + var _expandCollapseSonNode = view.expandCollapseSonNode; + if (!!_expandCollapseSonNode) { + view.expandCollapseSonNode = function(setting, node, expandFlag, animateFlag, callback) { + if (!!node && !!node.isHidden) { + return; + } + _expandCollapseSonNode.apply(view, arguments); + } + } + + var _setSonNodeCheckBox = view.setSonNodeCheckBox; + if (!!_setSonNodeCheckBox) { + view.setSonNodeCheckBox = function(setting, node, value, srcNode) { + if (!!node && !!node.isHidden) { + return; + } + _setSonNodeCheckBox.apply(view, arguments); + } + } + + var _repairParentChkClassWithSelf = view.repairParentChkClassWithSelf; + if (!!_repairParentChkClassWithSelf) { + view.repairParentChkClassWithSelf = function(setting, node) { + if (!!node && !!node.isHidden) { + return; + } + _repairParentChkClassWithSelf.apply(view, arguments); + } + } })(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.core-3.5.js b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.core-3.5.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.core-3.5.js rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.core-3.5.js index a07818e5f..d8bc64f26 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.core-3.5.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.core-3.5.js @@ -1,1650 +1,1650 @@ -/* - * JQuery zTree core 3.5.12 - * http://zTree.me/ - * - * Copyright (c) 2010 Hunter.z - * - * Licensed same as jquery - MIT License - * http://www.opensource.org/licenses/mit-license.php - * - * email: hunter.z@263.net - * Date: 2013-03-11 - */ -(function($){ - var settings = {}, roots = {}, caches = {}, - //default consts of core - _consts = { - className: { - BUTTON: "button", - LEVEL: "level", - ICO_LOADING: "ico_loading", - SWITCH: "switch" - }, - event: { - NODECREATED: "ztree_nodeCreated", - CLICK: "ztree_click", - EXPAND: "ztree_expand", - COLLAPSE: "ztree_collapse", - ASYNC_SUCCESS: "ztree_async_success", - ASYNC_ERROR: "ztree_async_error" - }, - id: { - A: "_a", - ICON: "_ico", - SPAN: "_span", - SWITCH: "_switch", - UL: "_ul" - }, - line: { - ROOT: "root", - ROOTS: "roots", - CENTER: "center", - BOTTOM: "bottom", - NOLINE: "noline", - LINE: "line" - }, - folder: { - OPEN: "open", - CLOSE: "close", - DOCU: "docu" - }, - node: { - CURSELECTED: "curSelectedNode" - } - }, - //default setting of core - _setting = { - treeId: "", - treeObj: null, - view: { - addDiyDom: null, - autoCancelSelected: true, - dblClickExpand: true, - expandSpeed: "fast", - fontCss: {}, - nameIsHTML: false, - selectedMulti: true, - showIcon: true, - showLine: true, - showTitle: true - }, - data: { - key: { - children: "children", - name: "name", - title: "", - url: "url" - }, - simpleData: { - enable: false, - idKey: "id", - pIdKey: "pId", - rootPId: null - }, - keep: { - parent: false, - leaf: false - } - }, - async: { - enable: false, - contentType: "application/x-www-form-urlencoded", - type: "post", - dataType: "text", - url: "", - autoParam: [], - otherParam: [], - dataFilter: null - }, - callback: { - beforeAsync:null, - beforeClick:null, - beforeDblClick:null, - beforeRightClick:null, - beforeMouseDown:null, - beforeMouseUp:null, - beforeExpand:null, - beforeCollapse:null, - beforeRemove:null, - - onAsyncError:null, - onAsyncSuccess:null, - onNodeCreated:null, - onClick:null, - onDblClick:null, - onRightClick:null, - onMouseDown:null, - onMouseUp:null, - onExpand:null, - onCollapse:null, - onRemove:null - } - }, - //default root of core - //zTree use root to save full data - _initRoot = function (setting) { - var r = data.getRoot(setting); - if (!r) { - r = {}; - data.setRoot(setting, r); - } - r[setting.data.key.children] = []; - r.expandTriggerFlag = false; - r.curSelectedList = []; - r.noSelection = true; - r.createdNodes = []; - r.zId = 0; - r._ver = (new Date()).getTime(); - }, - //default cache of core - _initCache = function(setting) { - var c = data.getCache(setting); - if (!c) { - c = {}; - data.setCache(setting, c); - } - c.nodes = []; - c.doms = []; - }, - //default bindEvent of core - _bindEvent = function(setting) { - var o = setting.treeObj, - c = consts.event; - o.bind(c.NODECREATED, function (event, treeId, node) { - tools.apply(setting.callback.onNodeCreated, [event, treeId, node]); - }); - - o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) { - tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]); - }); - - o.bind(c.EXPAND, function (event, treeId, node) { - tools.apply(setting.callback.onExpand, [event, treeId, node]); - }); - - o.bind(c.COLLAPSE, function (event, treeId, node) { - tools.apply(setting.callback.onCollapse, [event, treeId, node]); - }); - - o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) { - tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]); - }); - - o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) { - tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]); - }); - }, - _unbindEvent = function(setting) { - var o = setting.treeObj, - c = consts.event; - o.unbind(c.NODECREATED) - .unbind(c.CLICK) - .unbind(c.EXPAND) - .unbind(c.COLLAPSE) - .unbind(c.ASYNC_SUCCESS) - .unbind(c.ASYNC_ERROR); - }, - //default event proxy of core - _eventProxy = function(event) { - var target = event.target, - setting = data.getSetting(event.data.treeId), - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null, - tmp = null; - - if (tools.eqs(event.type, "mousedown")) { - treeEventType = "mousedown"; - } else if (tools.eqs(event.type, "mouseup")) { - treeEventType = "mouseup"; - } else if (tools.eqs(event.type, "contextmenu")) { - treeEventType = "contextmenu"; - } else if (tools.eqs(event.type, "click")) { - if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.SWITCH) !== null) { - tId = ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)).id; - nodeEventType = "switchNode"; - } else { - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) { - tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id; - nodeEventType = "clickNode"; - } - } - } else if (tools.eqs(event.type, "dblclick")) { - treeEventType = "dblclick"; - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) { - tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id; - nodeEventType = "switchNode"; - } - } - if (treeEventType.length > 0 && tId.length == 0) { - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) {tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;} - } - // event to node - if (tId.length>0) { - node = data.getNodeCache(setting, tId); - switch (nodeEventType) { - case "switchNode" : - if (!node.isParent) { - nodeEventType = ""; - } else if (tools.eqs(event.type, "click") - || (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) { - nodeEventCallback = handler.onSwitchNode; - } else { - nodeEventType = ""; - } - break; - case "clickNode" : - nodeEventCallback = handler.onClickNode; - break; - } - } - // event to zTree - switch (treeEventType) { - case "mousedown" : - treeEventCallback = handler.onZTreeMousedown; - break; - case "mouseup" : - treeEventCallback = handler.onZTreeMouseup; - break; - case "dblclick" : - treeEventCallback = handler.onZTreeDblclick; - break; - case "contextmenu" : - treeEventCallback = handler.onZTreeContextmenu; - break; - } - var proxyResult = { - stop: false, - node: node, - nodeEventType: nodeEventType, - nodeEventCallback: nodeEventCallback, - treeEventType: treeEventType, - treeEventCallback: treeEventCallback - }; - return proxyResult - }, - //default init node of core - _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { - if (!n) return; - var r = data.getRoot(setting), - childKey = setting.data.key.children; - n.level = level; - n.tId = setting.treeId + "_" + (++r.zId); - n.parentTId = parentNode ? parentNode.tId : null; - if (n[childKey] && n[childKey].length > 0) { - if (typeof n.open == "string") n.open = tools.eqs(n.open, "true"); - n.open = !!n.open; - n.isParent = true; - n.zAsync = true; - } else { - n.open = false; - if (typeof n.isParent == "string") n.isParent = tools.eqs(n.isParent, "true"); - n.isParent = !!n.isParent; - n.zAsync = !n.isParent; - } - n.isFirstNode = isFirstNode; - n.isLastNode = isLastNode; - n.getParentNode = function() {return data.getNodeCache(setting, n.parentTId);}; - n.getPreNode = function() {return data.getPreNode(setting, n);}; - n.getNextNode = function() {return data.getNextNode(setting, n);}; - n.isAjaxing = false; - data.fixPIdKeyValue(setting, n); - }, - _init = { - bind: [_bindEvent], - unbind: [_unbindEvent], - caches: [_initCache], - nodes: [_initNode], - proxys: [_eventProxy], - roots: [_initRoot], - beforeA: [], - afterA: [], - innerBeforeA: [], - innerAfterA: [], - zTreeTools: [] - }, - //method of operate data - data = { - addNodeCache: function(setting, node) { - data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node; - }, - getNodeCacheId: function(tId) { - return tId.substring(tId.lastIndexOf("_")+1); - }, - addAfterA: function(afterA) { - _init.afterA.push(afterA); - }, - addBeforeA: function(beforeA) { - _init.beforeA.push(beforeA); - }, - addInnerAfterA: function(innerAfterA) { - _init.innerAfterA.push(innerAfterA); - }, - addInnerBeforeA: function(innerBeforeA) { - _init.innerBeforeA.push(innerBeforeA); - }, - addInitBind: function(bindEvent) { - _init.bind.push(bindEvent); - }, - addInitUnBind: function(unbindEvent) { - _init.unbind.push(unbindEvent); - }, - addInitCache: function(initCache) { - _init.caches.push(initCache); - }, - addInitNode: function(initNode) { - _init.nodes.push(initNode); - }, - addInitProxy: function(initProxy) { - _init.proxys.push(initProxy); - }, - addInitRoot: function(initRoot) { - _init.roots.push(initRoot); - }, - addNodesData: function(setting, parentNode, nodes) { - var childKey = setting.data.key.children; - if (!parentNode[childKey]) parentNode[childKey] = []; - if (parentNode[childKey].length > 0) { - parentNode[childKey][parentNode[childKey].length - 1].isLastNode = false; - view.setNodeLineIcos(setting, parentNode[childKey][parentNode[childKey].length - 1]); - } - parentNode.isParent = true; - parentNode[childKey] = parentNode[childKey].concat(nodes); - }, - addSelectedNode: function(setting, node) { - var root = data.getRoot(setting); - if (!data.isSelectedNode(setting, node)) { - root.curSelectedList.push(node); - } - }, - addCreatedNode: function(setting, node) { - if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { - var root = data.getRoot(setting); - root.createdNodes.push(node); - } - }, - addZTreeTools: function(zTreeTools) { - _init.zTreeTools.push(zTreeTools); - }, - exSetting: function(s) { - $.extend(true, _setting, s); - }, - fixPIdKeyValue: function(setting, node) { - if (setting.data.simpleData.enable) { - node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId; - } - }, - getAfterA: function(setting, node, array) { - for (var i=0, j=_init.afterA.length; i-1) { - result.push(nodes[i]); - } - result = result.concat(data.getNodesByParamFuzzy(setting, nodes[i][childKey], key, value)); - } - return result; - }, - getNodesByFilter: function(setting, nodes, filter, isSingle, invokeParam) { - if (!nodes) return (isSingle ? null : []); - var childKey = setting.data.key.children, - result = isSingle ? null : []; - for (var i = 0, l = nodes.length; i < l; i++) { - if (tools.apply(filter, [nodes[i], invokeParam], false)) { - if (isSingle) {return nodes[i];} - result.push(nodes[i]); - } - var tmpResult = data.getNodesByFilter(setting, nodes[i][childKey], filter, isSingle, invokeParam); - if (isSingle && !!tmpResult) {return tmpResult;} - result = isSingle ? tmpResult : result.concat(tmpResult); - } - return result; - }, - getPreNode: function(setting, node) { - if (!node) return null; - var childKey = setting.data.key.children, - p = node.parentTId ? node.getParentNode() : data.getRoot(setting); - for (var i=0, l=p[childKey].length; i 0))); - }, - clone: function (obj){ - if (obj === null) return null; - var o = obj.constructor === Array ? [] : {}; - for(var i in obj){ - o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? arguments.callee(obj[i]) : obj[i]); - } - return o; - }, - eqs: function(str1, str2) { - return str1.toLowerCase() === str2.toLowerCase(); - }, - isArray: function(arr) { - return Object.prototype.toString.apply(arr) === "[object Array]"; - }, - getMDom: function (setting, curDom, targetExpr) { - if (!curDom) return null; - while (curDom && curDom.id !== setting.treeId) { - for (var i=0, l=targetExpr.length; curDom.tagName && i 0) { - //make child html first, because checkType - childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open); - } - if (openFlag) { - - view.makeDOMNodeMainBefore(html, setting, node); - view.makeDOMNodeLine(html, setting, node); - data.getBeforeA(setting, node, html); - view.makeDOMNodeNameBefore(html, setting, node); - data.getInnerBeforeA(setting, node, html); - view.makeDOMNodeIcon(html, setting, node); - data.getInnerAfterA(setting, node, html); - view.makeDOMNodeNameAfter(html, setting, node); - data.getAfterA(setting, node, html); - if (node.isParent && node.open) { - view.makeUlHtml(setting, node, html, childHtml.join('')); - } - view.makeDOMNodeMainAfter(html, setting, node); - data.addCreatedNode(setting, node); - } - } - return html; - }, - appendParentULDom: function(setting, node) { - var html = [], - nObj = $("#" + node.tId), - ulObj = $("#" + node.tId + consts.id.UL), - childKey = setting.data.key.children, - childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true); - view.makeUlHtml(setting, node, html, childHtml.join('')); - if (!nObj.get(0) && !!node.parentTId) { - view.appendParentULDom(setting, node.getParentNode()); - nObj = $("#" + node.tId); - } - if (ulObj.get(0)) { - ulObj.remove(); - } - nObj.append(html.join('')); - }, - asyncNode: function(setting, node, isSilent, callback) { - var i, l; - if (node && !node.isParent) { - tools.apply(callback); - return false; - } else if (node && node.isAjaxing) { - return false; - } else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) { - tools.apply(callback); - return false; - } - if (node) { - node.isAjaxing = true; - var icoObj = $("#" + node.tId + consts.id.ICON); - icoObj.attr({"style":"", "class":consts.className.BUTTON + " " + consts.className.ICO_LOADING}); - } - - var tmpParam = {}; - for (i = 0, l = setting.async.autoParam.length; node && i < l; i++) { - var pKey = setting.async.autoParam[i].split("="), spKey = pKey; - if (pKey.length>1) { - spKey = pKey[1]; - pKey = pKey[0]; - } - tmpParam[spKey] = node[pKey]; - } - if (tools.isArray(setting.async.otherParam)) { - for (i = 0, l = setting.async.otherParam.length; i < l; i += 2) { - tmpParam[setting.async.otherParam[i]] = setting.async.otherParam[i + 1]; - } - } else { - for (var p in setting.async.otherParam) { - tmpParam[p] = setting.async.otherParam[p]; - } - } - - var _tmpV = data.getRoot(setting)._ver; - $.ajax({ - contentType: setting.async.contentType, - type: setting.async.type, - url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url), - data: tmpParam, - dataType: setting.async.dataType, - success: function(msg) { - if (_tmpV != data.getRoot(setting)._ver) { - return; - } - var newNodes = []; - try { - if (!msg || msg.length == 0) { - newNodes = []; - } else if (typeof msg == "string") { - newNodes = eval("(" + msg + ")"); - } else { - newNodes = msg; - } - } catch(err) { - newNodes = msg; - } - - if (node) { - node.isAjaxing = null; - node.zAsync = true; - } - view.setNodeLineIcos(setting, node); - if (newNodes && newNodes !== "") { - newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes); - view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent); - } else { - view.addNodes(setting, node, [], !!isSilent); - } - setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]); - tools.apply(callback); - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - if (_tmpV != data.getRoot(setting)._ver) { - return; - } - if (node) node.isAjaxing = null; - view.setNodeLineIcos(setting, node); - setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]); - } - }); - return true; - }, - cancelPreSelectedNode: function (setting, node) { - var list = data.getRoot(setting).curSelectedList; - for (var i=0, j=list.length-1; j>=i; j--) { - if (!node || node === list[j]) { - $("#" + list[j].tId + consts.id.A).removeClass(consts.node.CURSELECTED); - if (node) { - data.removeSelectedNode(setting, node); - break; - } - } - } - if (!node) data.getRoot(setting).curSelectedList = []; - }, - createNodeCallback: function(setting) { - if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { - var root = data.getRoot(setting); - while (root.createdNodes.length>0) { - var node = root.createdNodes.shift(); - tools.apply(setting.view.addDiyDom, [setting.treeId, node]); - if (!!setting.callback.onNodeCreated) { - setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]); - } - } - } - }, - createNodes: function(setting, level, nodes, parentNode) { - if (!nodes || nodes.length == 0) return; - var root = data.getRoot(setting), - childKey = setting.data.key.children, - openFlag = !parentNode || parentNode.open || !!$("#" + parentNode[childKey][0].tId).get(0); - root.createdNodes = []; - var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag); - if (!parentNode) { - setting.treeObj.append(zTreeHtml.join('')); - } else { - var ulObj = $("#" + parentNode.tId + consts.id.UL); - if (ulObj.get(0)) { - ulObj.append(zTreeHtml.join('')); - } - } - view.createNodeCallback(setting); - }, - destroy: function(setting) { - if (!setting) return; - data.initCache(setting); - data.initRoot(setting); - event.unbindTree(setting); - event.unbindEvent(setting); - setting.treeObj.empty(); - }, - expandCollapseNode: function(setting, node, expandFlag, animateFlag, callback) { - var root = data.getRoot(setting), - childKey = setting.data.key.children; - if (!node) { - tools.apply(callback, []); - return; - } - if (root.expandTriggerFlag) { - var _callback = callback; - callback = function(){ - if (_callback) _callback(); - if (node.open) { - setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]); - } else { - setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]); - } - }; - root.expandTriggerFlag = false; - } - if (!node.open && node.isParent && ((!$("#" + node.tId + consts.id.UL).get(0)) || (node[childKey] && node[childKey].length>0 && !$("#" + node[childKey][0].tId).get(0)))) { - view.appendParentULDom(setting, node); - view.createNodeCallback(setting); - } - if (node.open == expandFlag) { - tools.apply(callback, []); - return; - } - var ulObj = $("#" + node.tId + consts.id.UL), - switchObj = $("#" + node.tId + consts.id.SWITCH), - icoObj = $("#" + node.tId + consts.id.ICON); - - if (node.isParent) { - node.open = !node.open; - if (node.iconOpen && node.iconClose) { - icoObj.attr("style", view.makeNodeIcoStyle(setting, node)); - } - - if (node.open) { - view.replaceSwitchClass(node, switchObj, consts.folder.OPEN); - view.replaceIcoClass(node, icoObj, consts.folder.OPEN); - if (animateFlag == false || setting.view.expandSpeed == "") { - ulObj.show(); - tools.apply(callback, []); - } else { - if (node[childKey] && node[childKey].length > 0) { - ulObj.slideDown(setting.view.expandSpeed, callback); - } else { - ulObj.show(); - tools.apply(callback, []); - } - } - } else { - view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE); - view.replaceIcoClass(node, icoObj, consts.folder.CLOSE); - if (animateFlag == false || setting.view.expandSpeed == "" || !(node[childKey] && node[childKey].length > 0)) { - ulObj.hide(); - tools.apply(callback, []); - } else { - ulObj.slideUp(setting.view.expandSpeed, callback); - } - } - } else { - tools.apply(callback, []); - } - }, - expandCollapseParentNode: function(setting, node, expandFlag, animateFlag, callback) { - if (!node) return; - if (!node.parentTId) { - view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback); - return; - } else { - view.expandCollapseNode(setting, node, expandFlag, animateFlag); - } - if (node.parentTId) { - view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback); - } - }, - expandCollapseSonNode: function(setting, node, expandFlag, animateFlag, callback) { - var root = data.getRoot(setting), - childKey = setting.data.key.children, - treeNodes = (node) ? node[childKey]: root[childKey], - selfAnimateSign = (node) ? false : animateFlag, - expandTriggerFlag = data.getRoot(setting).expandTriggerFlag; - data.getRoot(setting).expandTriggerFlag = false; - if (treeNodes) { - for (var i = 0, l = treeNodes.length; i < l; i++) { - if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign); - } - } - data.getRoot(setting).expandTriggerFlag = expandTriggerFlag; - view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback ); - }, - makeDOMNodeIcon: function(html, setting, node) { - var nameStr = data.getNodeName(setting, node), - name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g,'&').replace(//g,'>'); - html.push("",name,""); - }, - makeDOMNodeLine: function(html, setting, node) { - html.push(""); - }, - makeDOMNodeMainAfter: function(html, setting, node) { - html.push("
          • "); - }, - makeDOMNodeMainBefore: function(html, setting, node) { - html.push("
          • "); - }, - makeDOMNodeNameAfter: function(html, setting, node) { - html.push(""); - }, - makeDOMNodeNameBefore: function(html, setting, node) { - var title = data.getNodeTitle(setting, node), - url = view.makeNodeUrl(setting, node), - fontcss = view.makeNodeFontCss(setting, node), - fontStyle = []; - for (var f in fontcss) { - fontStyle.push(f, ":", fontcss[f], ";"); - } - html.push(" 0) ? "href='" + url + "'" : ""), " target='",view.makeNodeTarget(node),"' style='", fontStyle.join(''), - "'"); - if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) {html.push("title='", title.replace(/'/g,"'").replace(//g,'>'),"'");} - html.push(">"); - }, - makeNodeFontCss: function(setting, node) { - var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss); - return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {}; - }, - makeNodeIcoClass: function(setting, node) { - var icoCss = ["ico"]; - if (!node.isAjaxing) { - icoCss[0] = (node.iconSkin ? node.iconSkin + "_" : "") + icoCss[0]; - if (node.isParent) { - icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); - } else { - icoCss.push(consts.folder.DOCU); - } - } - return consts.className.BUTTON + " " + icoCss.join('_'); - }, - makeNodeIcoStyle: function(setting, node) { - var icoStyle = []; - if (!node.isAjaxing) { - var icon = (node.isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node.icon; - if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;"); - if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) { - icoStyle.push("width:0px;height:0px;"); - } - } - return icoStyle.join(''); - }, - makeNodeLineClass: function(setting, node) { - var lineClass = []; - if (setting.view.showLine) { - if (node.level == 0 && node.isFirstNode && node.isLastNode) { - lineClass.push(consts.line.ROOT); - } else if (node.level == 0 && node.isFirstNode) { - lineClass.push(consts.line.ROOTS); - } else if (node.isLastNode) { - lineClass.push(consts.line.BOTTOM); - } else { - lineClass.push(consts.line.CENTER); - } - } else { - lineClass.push(consts.line.NOLINE); - } - if (node.isParent) { - lineClass.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); - } else { - lineClass.push(consts.folder.DOCU); - } - return view.makeNodeLineClassEx(node) + lineClass.join('_'); - }, - makeNodeLineClassEx: function(node) { - return consts.className.BUTTON + " " + consts.className.LEVEL + node.level + " " + consts.className.SWITCH + " "; - }, - makeNodeTarget: function(node) { - return (node.target || "_blank"); - }, - makeNodeUrl: function(setting, node) { - var urlKey = setting.data.key.url; - return node[urlKey] ? node[urlKey] : null; - }, - makeUlHtml: function(setting, node, html, content) { - html.push("
              "); - html.push(content); - html.push("
            "); - }, - makeUlLineClass: function(setting, node) { - return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : ""); - }, - removeChildNodes: function(setting, node) { - if (!node) return; - var childKey = setting.data.key.children, - nodes = node[childKey]; - if (!nodes) return; - - for (var i = 0, l = nodes.length; i < l; i++) { - data.removeNodeCache(setting, nodes[i]); - } - data.removeSelectedNode(setting); - delete node[childKey]; - - if (!setting.data.keep.parent) { - node.isParent = false; - node.open = false; - var tmp_switchObj = $("#" + node.tId + consts.id.SWITCH), - tmp_icoObj = $("#" + node.tId + consts.id.ICON); - view.replaceSwitchClass(node, tmp_switchObj, consts.folder.DOCU); - view.replaceIcoClass(node, tmp_icoObj, consts.folder.DOCU); - $("#" + node.tId + consts.id.UL).remove(); - } else { - $("#" + node.tId + consts.id.UL).empty(); - } - }, - setFirstNode: function(setting, parentNode) { - var childKey = setting.data.key.children, childLength = parentNode[childKey].length; - if ( childLength > 0) { - parentNode[childKey][0].isFirstNode = true; - } - }, - setLastNode: function(setting, parentNode) { - var childKey = setting.data.key.children, childLength = parentNode[childKey].length; - if ( childLength > 0) { - parentNode[childKey][childLength - 1].isLastNode = true; - } - }, - removeNode: function(setting, node) { - var root = data.getRoot(setting), - childKey = setting.data.key.children, - parentNode = (node.parentTId) ? node.getParentNode() : root; - - node.isFirstNode = false; - node.isLastNode = false; - node.getPreNode = function() {return null;}; - node.getNextNode = function() {return null;}; - - if (!data.getNodeCache(setting, node.tId)) { - return; - } - - $("#" + node.tId).remove(); - data.removeNodeCache(setting, node); - data.removeSelectedNode(setting, node); - - for (var i = 0, l = parentNode[childKey].length; i < l; i++) { - if (parentNode[childKey][i].tId == node.tId) { - parentNode[childKey].splice(i, 1); - break; - } - } - view.setFirstNode(setting, parentNode); - view.setLastNode(setting, parentNode); - - var tmp_ulObj,tmp_switchObj,tmp_icoObj, - childLength = parentNode[childKey].length; - - //repair nodes old parent - if (!setting.data.keep.parent && childLength == 0) { - //old parentNode has no child nodes - parentNode.isParent = false; - parentNode.open = false; - tmp_ulObj = $("#" + parentNode.tId + consts.id.UL); - tmp_switchObj = $("#" + parentNode.tId + consts.id.SWITCH); - tmp_icoObj = $("#" + parentNode.tId + consts.id.ICON); - view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU); - view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU); - tmp_ulObj.css("display", "none"); - - } else if (setting.view.showLine && childLength > 0) { - //old parentNode has child nodes - var newLast = parentNode[childKey][childLength - 1]; - tmp_ulObj = $("#" + newLast.tId + consts.id.UL); - tmp_switchObj = $("#" + newLast.tId + consts.id.SWITCH); - tmp_icoObj = $("#" + newLast.tId + consts.id.ICON); - if (parentNode == root) { - if (parentNode[childKey].length == 1) { - //node was root, and ztree has only one root after move node - view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT); - } else { - var tmp_first_switchObj = $("#" + parentNode[childKey][0].tId + consts.id.SWITCH); - view.replaceSwitchClass(parentNode[childKey][0], tmp_first_switchObj, consts.line.ROOTS); - view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); - } - } else { - view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); - } - tmp_ulObj.removeClass(consts.line.LINE); - } - }, - replaceIcoClass: function(node, obj, newName) { - if (!obj || node.isAjaxing) return; - var tmpName = obj.attr("class"); - if (tmpName == undefined) return; - var tmpList = tmpName.split("_"); - switch (newName) { - case consts.folder.OPEN: - case consts.folder.CLOSE: - case consts.folder.DOCU: - tmpList[tmpList.length-1] = newName; - break; - } - obj.attr("class", tmpList.join("_")); - }, - replaceSwitchClass: function(node, obj, newName) { - if (!obj) return; - var tmpName = obj.attr("class"); - if (tmpName == undefined) return; - var tmpList = tmpName.split("_"); - switch (newName) { - case consts.line.ROOT: - case consts.line.ROOTS: - case consts.line.CENTER: - case consts.line.BOTTOM: - case consts.line.NOLINE: - tmpList[0] = view.makeNodeLineClassEx(node) + newName; - break; - case consts.folder.OPEN: - case consts.folder.CLOSE: - case consts.folder.DOCU: - tmpList[1] = newName; - break; - } - obj.attr("class", tmpList.join("_")); - if (newName !== consts.folder.DOCU) { - obj.removeAttr("disabled"); - } else { - obj.attr("disabled", "disabled"); - } - }, - selectNode: function(setting, node, addFlag) { - if (!addFlag) { - view.cancelPreSelectedNode(setting); - } - $("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED); - data.addSelectedNode(setting, node); - }, - setNodeFontCss: function(setting, treeNode) { - var aObj = $("#" + treeNode.tId + consts.id.A), - fontCss = view.makeNodeFontCss(setting, treeNode); - if (fontCss) { - aObj.css(fontCss); - } - }, - setNodeLineIcos: function(setting, node) { - if (!node) return; - var switchObj = $("#" + node.tId + consts.id.SWITCH), - ulObj = $("#" + node.tId + consts.id.UL), - icoObj = $("#" + node.tId + consts.id.ICON), - ulLine = view.makeUlLineClass(setting, node); - if (ulLine.length==0) { - ulObj.removeClass(consts.line.LINE); - } else { - ulObj.addClass(ulLine); - } - switchObj.attr("class", view.makeNodeLineClass(setting, node)); - if (node.isParent) { - switchObj.removeAttr("disabled"); - } else { - switchObj.attr("disabled", "disabled"); - } - icoObj.removeAttr("style"); - icoObj.attr("style", view.makeNodeIcoStyle(setting, node)); - icoObj.attr("class", view.makeNodeIcoClass(setting, node)); - }, - setNodeName: function(setting, node) { - var title = data.getNodeTitle(setting, node), - nObj = $("#" + node.tId + consts.id.SPAN); - nObj.empty(); - if (setting.view.nameIsHTML) { - nObj.html(data.getNodeName(setting, node)); - } else { - nObj.text(data.getNodeName(setting, node)); - } - if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) { - var aObj = $("#" + node.tId + consts.id.A); - aObj.attr("title", !title ? "" : title); - } - }, - setNodeTarget: function(node) { - var aObj = $("#" + node.tId + consts.id.A); - aObj.attr("target", view.makeNodeTarget(node)); - }, - setNodeUrl: function(setting, node) { - var aObj = $("#" + node.tId + consts.id.A), - url = view.makeNodeUrl(setting, node); - if (url == null || url.length == 0) { - aObj.removeAttr("href"); - } else { - aObj.attr("href", url); - } - }, - switchNode: function(setting, node) { - if (node.open || !tools.canAsync(setting, node)) { - view.expandCollapseNode(setting, node, !node.open); - } else if (setting.async.enable) { - if (!view.asyncNode(setting, node)) { - view.expandCollapseNode(setting, node, !node.open); - return; - } - } else if (node) { - view.expandCollapseNode(setting, node, !node.open); - } - } - }; - // zTree defind - $.fn.zTree = { - consts : _consts, - _z : { - tools: tools, - view: view, - event: event, - data: data - }, - getZTreeObj: function(treeId) { - var o = data.getZTreeTools(treeId); - return o ? o : null; - }, - destroy: function(treeId) { - if (!!treeId && treeId.length > 0) { - view.destroy(data.getSetting(treeId)); - } else { - for(var s in settings) { - view.destroy(settings[s]); - } - } - }, - init: function(obj, zSetting, zNodes) { - var setting = tools.clone(_setting); - $.extend(true, setting, zSetting); - setting.treeId = obj.attr("id"); - setting.treeObj = obj; - setting.treeObj.empty(); - settings[setting.treeId] = setting; - //For some older browser,(e.g., ie6) - if(typeof document.body.style.maxHeight === "undefined") { - setting.view.expandSpeed = ""; - } - data.initRoot(setting); - var root = data.getRoot(setting), - childKey = setting.data.key.children; - zNodes = zNodes ? tools.clone(tools.isArray(zNodes)? zNodes : [zNodes]) : []; - if (setting.data.simpleData.enable) { - root[childKey] = data.transformTozTreeFormat(setting, zNodes); - } else { - root[childKey] = zNodes; - } - - data.initCache(setting); - event.unbindTree(setting); - event.bindTree(setting); - event.unbindEvent(setting); - event.bindEvent(setting); - - var zTreeTools = { - setting : setting, - addNodes : function(parentNode, newNodes, isSilent) { - if (!newNodes) return null; - if (!parentNode) parentNode = null; - if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null; - var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]); - function addCallback() { - view.addNodes(setting, parentNode, xNewNodes, (isSilent==true)); - } - - if (tools.canAsync(setting, parentNode)) { - view.asyncNode(setting, parentNode, isSilent, addCallback); - } else { - addCallback(); - } - return xNewNodes; - }, - cancelSelectedNode : function(node) { - view.cancelPreSelectedNode(this.setting, node); - }, - destroy : function() { - view.destroy(this.setting); - }, - expandAll : function(expandFlag) { - expandFlag = !!expandFlag; - view.expandCollapseSonNode(this.setting, null, expandFlag, true); - return expandFlag; - }, - expandNode : function(node, expandFlag, sonSign, focus, callbackFlag) { - if (!node || !node.isParent) return null; - if (expandFlag !== true && expandFlag !== false) { - expandFlag = !node.open; - } - callbackFlag = !!callbackFlag; - - if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) { - return null; - } else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) { - return null; - } - if (expandFlag && node.parentTId) { - view.expandCollapseParentNode(this.setting, node.getParentNode(), expandFlag, false); - } - if (expandFlag === node.open && !sonSign) { - return null; - } - - data.getRoot(setting).expandTriggerFlag = callbackFlag; - if (sonSign) { - view.expandCollapseSonNode(this.setting, node, expandFlag, true, function() { - if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}} - }); - } else { - node.open = !expandFlag; - view.switchNode(this.setting, node); - if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}} - } - return expandFlag; - }, - getNodes : function() { - return data.getNodes(this.setting); - }, - getNodeByParam : function(key, value, parentNode) { - if (!key) return null; - return data.getNodeByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); - }, - getNodeByTId : function(tId) { - return data.getNodeCache(this.setting, tId); - }, - getNodesByParam : function(key, value, parentNode) { - if (!key) return null; - return data.getNodesByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); - }, - getNodesByParamFuzzy : function(key, value, parentNode) { - if (!key) return null; - return data.getNodesByParamFuzzy(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); - }, - getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) { - isSingle = !!isSingle; - if (!filter || (typeof filter != "function")) return (isSingle ? null : []); - return data.getNodesByFilter(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), filter, isSingle, invokeParam); - }, - getNodeIndex : function(node) { - if (!node) return null; - var childKey = setting.data.key.children, - parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(this.setting); - for (var i=0, l = parentNode[childKey].length; i < l; i++) { - if (parentNode[childKey][i] == node) return i; - } - return -1; - }, - getSelectedNodes : function() { - var r = [], list = data.getRoot(this.setting).curSelectedList; - for (var i=0, l=list.length; i 0) { - view.createNodes(setting, 0, root[childKey]); - } else if (setting.async.enable && setting.async.url && setting.async.url !== '') { - view.asyncNode(setting); - } - return zTreeTools; - } - }; - - var zt = $.fn.zTree, - consts = zt.consts; +/* + * JQuery zTree core 3.5.12 + * http://zTree.me/ + * + * Copyright (c) 2010 Hunter.z + * + * Licensed same as jquery - MIT License + * http://www.opensource.org/licenses/mit-license.php + * + * email: hunter.z@263.net + * Date: 2013-03-11 + */ +(function($){ + var settings = {}, roots = {}, caches = {}, + //default consts of core + _consts = { + className: { + BUTTON: "button", + LEVEL: "level", + ICO_LOADING: "ico_loading", + SWITCH: "switch" + }, + event: { + NODECREATED: "ztree_nodeCreated", + CLICK: "ztree_click", + EXPAND: "ztree_expand", + COLLAPSE: "ztree_collapse", + ASYNC_SUCCESS: "ztree_async_success", + ASYNC_ERROR: "ztree_async_error" + }, + id: { + A: "_a", + ICON: "_ico", + SPAN: "_span", + SWITCH: "_switch", + UL: "_ul" + }, + line: { + ROOT: "root", + ROOTS: "roots", + CENTER: "center", + BOTTOM: "bottom", + NOLINE: "noline", + LINE: "line" + }, + folder: { + OPEN: "open", + CLOSE: "close", + DOCU: "docu" + }, + node: { + CURSELECTED: "curSelectedNode" + } + }, + //default setting of core + _setting = { + treeId: "", + treeObj: null, + view: { + addDiyDom: null, + autoCancelSelected: true, + dblClickExpand: true, + expandSpeed: "fast", + fontCss: {}, + nameIsHTML: false, + selectedMulti: true, + showIcon: true, + showLine: true, + showTitle: true + }, + data: { + key: { + children: "children", + name: "name", + title: "", + url: "url" + }, + simpleData: { + enable: false, + idKey: "id", + pIdKey: "pId", + rootPId: null + }, + keep: { + parent: false, + leaf: false + } + }, + async: { + enable: false, + contentType: "application/x-www-form-urlencoded", + type: "post", + dataType: "text", + url: "", + autoParam: [], + otherParam: [], + dataFilter: null + }, + callback: { + beforeAsync:null, + beforeClick:null, + beforeDblClick:null, + beforeRightClick:null, + beforeMouseDown:null, + beforeMouseUp:null, + beforeExpand:null, + beforeCollapse:null, + beforeRemove:null, + + onAsyncError:null, + onAsyncSuccess:null, + onNodeCreated:null, + onClick:null, + onDblClick:null, + onRightClick:null, + onMouseDown:null, + onMouseUp:null, + onExpand:null, + onCollapse:null, + onRemove:null + } + }, + //default root of core + //zTree use root to save full data + _initRoot = function (setting) { + var r = data.getRoot(setting); + if (!r) { + r = {}; + data.setRoot(setting, r); + } + r[setting.data.key.children] = []; + r.expandTriggerFlag = false; + r.curSelectedList = []; + r.noSelection = true; + r.createdNodes = []; + r.zId = 0; + r._ver = (new Date()).getTime(); + }, + //default cache of core + _initCache = function(setting) { + var c = data.getCache(setting); + if (!c) { + c = {}; + data.setCache(setting, c); + } + c.nodes = []; + c.doms = []; + }, + //default bindEvent of core + _bindEvent = function(setting) { + var o = setting.treeObj, + c = consts.event; + o.bind(c.NODECREATED, function (event, treeId, node) { + tools.apply(setting.callback.onNodeCreated, [event, treeId, node]); + }); + + o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) { + tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]); + }); + + o.bind(c.EXPAND, function (event, treeId, node) { + tools.apply(setting.callback.onExpand, [event, treeId, node]); + }); + + o.bind(c.COLLAPSE, function (event, treeId, node) { + tools.apply(setting.callback.onCollapse, [event, treeId, node]); + }); + + o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) { + tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]); + }); + + o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) { + tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]); + }); + }, + _unbindEvent = function(setting) { + var o = setting.treeObj, + c = consts.event; + o.unbind(c.NODECREATED) + .unbind(c.CLICK) + .unbind(c.EXPAND) + .unbind(c.COLLAPSE) + .unbind(c.ASYNC_SUCCESS) + .unbind(c.ASYNC_ERROR); + }, + //default event proxy of core + _eventProxy = function(event) { + var target = event.target, + setting = data.getSetting(event.data.treeId), + tId = "", node = null, + nodeEventType = "", treeEventType = "", + nodeEventCallback = null, treeEventCallback = null, + tmp = null; + + if (tools.eqs(event.type, "mousedown")) { + treeEventType = "mousedown"; + } else if (tools.eqs(event.type, "mouseup")) { + treeEventType = "mouseup"; + } else if (tools.eqs(event.type, "contextmenu")) { + treeEventType = "contextmenu"; + } else if (tools.eqs(event.type, "click")) { + if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.SWITCH) !== null) { + tId = ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)).id; + nodeEventType = "switchNode"; + } else { + tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (tmp) { + tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id; + nodeEventType = "clickNode"; + } + } + } else if (tools.eqs(event.type, "dblclick")) { + treeEventType = "dblclick"; + tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (tmp) { + tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id; + nodeEventType = "switchNode"; + } + } + if (treeEventType.length > 0 && tId.length == 0) { + tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); + if (tmp) {tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;} + } + // event to node + if (tId.length>0) { + node = data.getNodeCache(setting, tId); + switch (nodeEventType) { + case "switchNode" : + if (!node.isParent) { + nodeEventType = ""; + } else if (tools.eqs(event.type, "click") + || (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) { + nodeEventCallback = handler.onSwitchNode; + } else { + nodeEventType = ""; + } + break; + case "clickNode" : + nodeEventCallback = handler.onClickNode; + break; + } + } + // event to zTree + switch (treeEventType) { + case "mousedown" : + treeEventCallback = handler.onZTreeMousedown; + break; + case "mouseup" : + treeEventCallback = handler.onZTreeMouseup; + break; + case "dblclick" : + treeEventCallback = handler.onZTreeDblclick; + break; + case "contextmenu" : + treeEventCallback = handler.onZTreeContextmenu; + break; + } + var proxyResult = { + stop: false, + node: node, + nodeEventType: nodeEventType, + nodeEventCallback: nodeEventCallback, + treeEventType: treeEventType, + treeEventCallback: treeEventCallback + }; + return proxyResult + }, + //default init node of core + _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + if (!n) return; + var r = data.getRoot(setting), + childKey = setting.data.key.children; + n.level = level; + n.tId = setting.treeId + "_" + (++r.zId); + n.parentTId = parentNode ? parentNode.tId : null; + if (n[childKey] && n[childKey].length > 0) { + if (typeof n.open == "string") n.open = tools.eqs(n.open, "true"); + n.open = !!n.open; + n.isParent = true; + n.zAsync = true; + } else { + n.open = false; + if (typeof n.isParent == "string") n.isParent = tools.eqs(n.isParent, "true"); + n.isParent = !!n.isParent; + n.zAsync = !n.isParent; + } + n.isFirstNode = isFirstNode; + n.isLastNode = isLastNode; + n.getParentNode = function() {return data.getNodeCache(setting, n.parentTId);}; + n.getPreNode = function() {return data.getPreNode(setting, n);}; + n.getNextNode = function() {return data.getNextNode(setting, n);}; + n.isAjaxing = false; + data.fixPIdKeyValue(setting, n); + }, + _init = { + bind: [_bindEvent], + unbind: [_unbindEvent], + caches: [_initCache], + nodes: [_initNode], + proxys: [_eventProxy], + roots: [_initRoot], + beforeA: [], + afterA: [], + innerBeforeA: [], + innerAfterA: [], + zTreeTools: [] + }, + //method of operate data + data = { + addNodeCache: function(setting, node) { + data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node; + }, + getNodeCacheId: function(tId) { + return tId.substring(tId.lastIndexOf("_")+1); + }, + addAfterA: function(afterA) { + _init.afterA.push(afterA); + }, + addBeforeA: function(beforeA) { + _init.beforeA.push(beforeA); + }, + addInnerAfterA: function(innerAfterA) { + _init.innerAfterA.push(innerAfterA); + }, + addInnerBeforeA: function(innerBeforeA) { + _init.innerBeforeA.push(innerBeforeA); + }, + addInitBind: function(bindEvent) { + _init.bind.push(bindEvent); + }, + addInitUnBind: function(unbindEvent) { + _init.unbind.push(unbindEvent); + }, + addInitCache: function(initCache) { + _init.caches.push(initCache); + }, + addInitNode: function(initNode) { + _init.nodes.push(initNode); + }, + addInitProxy: function(initProxy) { + _init.proxys.push(initProxy); + }, + addInitRoot: function(initRoot) { + _init.roots.push(initRoot); + }, + addNodesData: function(setting, parentNode, nodes) { + var childKey = setting.data.key.children; + if (!parentNode[childKey]) parentNode[childKey] = []; + if (parentNode[childKey].length > 0) { + parentNode[childKey][parentNode[childKey].length - 1].isLastNode = false; + view.setNodeLineIcos(setting, parentNode[childKey][parentNode[childKey].length - 1]); + } + parentNode.isParent = true; + parentNode[childKey] = parentNode[childKey].concat(nodes); + }, + addSelectedNode: function(setting, node) { + var root = data.getRoot(setting); + if (!data.isSelectedNode(setting, node)) { + root.curSelectedList.push(node); + } + }, + addCreatedNode: function(setting, node) { + if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { + var root = data.getRoot(setting); + root.createdNodes.push(node); + } + }, + addZTreeTools: function(zTreeTools) { + _init.zTreeTools.push(zTreeTools); + }, + exSetting: function(s) { + $.extend(true, _setting, s); + }, + fixPIdKeyValue: function(setting, node) { + if (setting.data.simpleData.enable) { + node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId; + } + }, + getAfterA: function(setting, node, array) { + for (var i=0, j=_init.afterA.length; i-1) { + result.push(nodes[i]); + } + result = result.concat(data.getNodesByParamFuzzy(setting, nodes[i][childKey], key, value)); + } + return result; + }, + getNodesByFilter: function(setting, nodes, filter, isSingle, invokeParam) { + if (!nodes) return (isSingle ? null : []); + var childKey = setting.data.key.children, + result = isSingle ? null : []; + for (var i = 0, l = nodes.length; i < l; i++) { + if (tools.apply(filter, [nodes[i], invokeParam], false)) { + if (isSingle) {return nodes[i];} + result.push(nodes[i]); + } + var tmpResult = data.getNodesByFilter(setting, nodes[i][childKey], filter, isSingle, invokeParam); + if (isSingle && !!tmpResult) {return tmpResult;} + result = isSingle ? tmpResult : result.concat(tmpResult); + } + return result; + }, + getPreNode: function(setting, node) { + if (!node) return null; + var childKey = setting.data.key.children, + p = node.parentTId ? node.getParentNode() : data.getRoot(setting); + for (var i=0, l=p[childKey].length; i 0))); + }, + clone: function (obj){ + if (obj === null) return null; + var o = obj.constructor === Array ? [] : {}; + for(var i in obj){ + o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? arguments.callee(obj[i]) : obj[i]); + } + return o; + }, + eqs: function(str1, str2) { + return str1.toLowerCase() === str2.toLowerCase(); + }, + isArray: function(arr) { + return Object.prototype.toString.apply(arr) === "[object Array]"; + }, + getMDom: function (setting, curDom, targetExpr) { + if (!curDom) return null; + while (curDom && curDom.id !== setting.treeId) { + for (var i=0, l=targetExpr.length; curDom.tagName && i 0) { + //make child html first, because checkType + childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open); + } + if (openFlag) { + + view.makeDOMNodeMainBefore(html, setting, node); + view.makeDOMNodeLine(html, setting, node); + data.getBeforeA(setting, node, html); + view.makeDOMNodeNameBefore(html, setting, node); + data.getInnerBeforeA(setting, node, html); + view.makeDOMNodeIcon(html, setting, node); + data.getInnerAfterA(setting, node, html); + view.makeDOMNodeNameAfter(html, setting, node); + data.getAfterA(setting, node, html); + if (node.isParent && node.open) { + view.makeUlHtml(setting, node, html, childHtml.join('')); + } + view.makeDOMNodeMainAfter(html, setting, node); + data.addCreatedNode(setting, node); + } + } + return html; + }, + appendParentULDom: function(setting, node) { + var html = [], + nObj = $("#" + node.tId), + ulObj = $("#" + node.tId + consts.id.UL), + childKey = setting.data.key.children, + childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true); + view.makeUlHtml(setting, node, html, childHtml.join('')); + if (!nObj.get(0) && !!node.parentTId) { + view.appendParentULDom(setting, node.getParentNode()); + nObj = $("#" + node.tId); + } + if (ulObj.get(0)) { + ulObj.remove(); + } + nObj.append(html.join('')); + }, + asyncNode: function(setting, node, isSilent, callback) { + var i, l; + if (node && !node.isParent) { + tools.apply(callback); + return false; + } else if (node && node.isAjaxing) { + return false; + } else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) { + tools.apply(callback); + return false; + } + if (node) { + node.isAjaxing = true; + var icoObj = $("#" + node.tId + consts.id.ICON); + icoObj.attr({"style":"", "class":consts.className.BUTTON + " " + consts.className.ICO_LOADING}); + } + + var tmpParam = {}; + for (i = 0, l = setting.async.autoParam.length; node && i < l; i++) { + var pKey = setting.async.autoParam[i].split("="), spKey = pKey; + if (pKey.length>1) { + spKey = pKey[1]; + pKey = pKey[0]; + } + tmpParam[spKey] = node[pKey]; + } + if (tools.isArray(setting.async.otherParam)) { + for (i = 0, l = setting.async.otherParam.length; i < l; i += 2) { + tmpParam[setting.async.otherParam[i]] = setting.async.otherParam[i + 1]; + } + } else { + for (var p in setting.async.otherParam) { + tmpParam[p] = setting.async.otherParam[p]; + } + } + + var _tmpV = data.getRoot(setting)._ver; + $.ajax({ + contentType: setting.async.contentType, + type: setting.async.type, + url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url), + data: tmpParam, + dataType: setting.async.dataType, + success: function(msg) { + if (_tmpV != data.getRoot(setting)._ver) { + return; + } + var newNodes = []; + try { + if (!msg || msg.length == 0) { + newNodes = []; + } else if (typeof msg == "string") { + newNodes = eval("(" + msg + ")"); + } else { + newNodes = msg; + } + } catch(err) { + newNodes = msg; + } + + if (node) { + node.isAjaxing = null; + node.zAsync = true; + } + view.setNodeLineIcos(setting, node); + if (newNodes && newNodes !== "") { + newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes); + view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent); + } else { + view.addNodes(setting, node, [], !!isSilent); + } + setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]); + tools.apply(callback); + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + if (_tmpV != data.getRoot(setting)._ver) { + return; + } + if (node) node.isAjaxing = null; + view.setNodeLineIcos(setting, node); + setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]); + } + }); + return true; + }, + cancelPreSelectedNode: function (setting, node) { + var list = data.getRoot(setting).curSelectedList; + for (var i=0, j=list.length-1; j>=i; j--) { + if (!node || node === list[j]) { + $("#" + list[j].tId + consts.id.A).removeClass(consts.node.CURSELECTED); + if (node) { + data.removeSelectedNode(setting, node); + break; + } + } + } + if (!node) data.getRoot(setting).curSelectedList = []; + }, + createNodeCallback: function(setting) { + if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) { + var root = data.getRoot(setting); + while (root.createdNodes.length>0) { + var node = root.createdNodes.shift(); + tools.apply(setting.view.addDiyDom, [setting.treeId, node]); + if (!!setting.callback.onNodeCreated) { + setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]); + } + } + } + }, + createNodes: function(setting, level, nodes, parentNode) { + if (!nodes || nodes.length == 0) return; + var root = data.getRoot(setting), + childKey = setting.data.key.children, + openFlag = !parentNode || parentNode.open || !!$("#" + parentNode[childKey][0].tId).get(0); + root.createdNodes = []; + var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag); + if (!parentNode) { + setting.treeObj.append(zTreeHtml.join('')); + } else { + var ulObj = $("#" + parentNode.tId + consts.id.UL); + if (ulObj.get(0)) { + ulObj.append(zTreeHtml.join('')); + } + } + view.createNodeCallback(setting); + }, + destroy: function(setting) { + if (!setting) return; + data.initCache(setting); + data.initRoot(setting); + event.unbindTree(setting); + event.unbindEvent(setting); + setting.treeObj.empty(); + }, + expandCollapseNode: function(setting, node, expandFlag, animateFlag, callback) { + var root = data.getRoot(setting), + childKey = setting.data.key.children; + if (!node) { + tools.apply(callback, []); + return; + } + if (root.expandTriggerFlag) { + var _callback = callback; + callback = function(){ + if (_callback) _callback(); + if (node.open) { + setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]); + } else { + setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]); + } + }; + root.expandTriggerFlag = false; + } + if (!node.open && node.isParent && ((!$("#" + node.tId + consts.id.UL).get(0)) || (node[childKey] && node[childKey].length>0 && !$("#" + node[childKey][0].tId).get(0)))) { + view.appendParentULDom(setting, node); + view.createNodeCallback(setting); + } + if (node.open == expandFlag) { + tools.apply(callback, []); + return; + } + var ulObj = $("#" + node.tId + consts.id.UL), + switchObj = $("#" + node.tId + consts.id.SWITCH), + icoObj = $("#" + node.tId + consts.id.ICON); + + if (node.isParent) { + node.open = !node.open; + if (node.iconOpen && node.iconClose) { + icoObj.attr("style", view.makeNodeIcoStyle(setting, node)); + } + + if (node.open) { + view.replaceSwitchClass(node, switchObj, consts.folder.OPEN); + view.replaceIcoClass(node, icoObj, consts.folder.OPEN); + if (animateFlag == false || setting.view.expandSpeed == "") { + ulObj.show(); + tools.apply(callback, []); + } else { + if (node[childKey] && node[childKey].length > 0) { + ulObj.slideDown(setting.view.expandSpeed, callback); + } else { + ulObj.show(); + tools.apply(callback, []); + } + } + } else { + view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE); + view.replaceIcoClass(node, icoObj, consts.folder.CLOSE); + if (animateFlag == false || setting.view.expandSpeed == "" || !(node[childKey] && node[childKey].length > 0)) { + ulObj.hide(); + tools.apply(callback, []); + } else { + ulObj.slideUp(setting.view.expandSpeed, callback); + } + } + } else { + tools.apply(callback, []); + } + }, + expandCollapseParentNode: function(setting, node, expandFlag, animateFlag, callback) { + if (!node) return; + if (!node.parentTId) { + view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback); + return; + } else { + view.expandCollapseNode(setting, node, expandFlag, animateFlag); + } + if (node.parentTId) { + view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback); + } + }, + expandCollapseSonNode: function(setting, node, expandFlag, animateFlag, callback) { + var root = data.getRoot(setting), + childKey = setting.data.key.children, + treeNodes = (node) ? node[childKey]: root[childKey], + selfAnimateSign = (node) ? false : animateFlag, + expandTriggerFlag = data.getRoot(setting).expandTriggerFlag; + data.getRoot(setting).expandTriggerFlag = false; + if (treeNodes) { + for (var i = 0, l = treeNodes.length; i < l; i++) { + if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign); + } + } + data.getRoot(setting).expandTriggerFlag = expandTriggerFlag; + view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback ); + }, + makeDOMNodeIcon: function(html, setting, node) { + var nameStr = data.getNodeName(setting, node), + name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g,'&').replace(//g,'>'); + html.push("",name,""); + }, + makeDOMNodeLine: function(html, setting, node) { + html.push(""); + }, + makeDOMNodeMainAfter: function(html, setting, node) { + html.push("
          • "); + }, + makeDOMNodeMainBefore: function(html, setting, node) { + html.push("
          • "); + }, + makeDOMNodeNameAfter: function(html, setting, node) { + html.push(""); + }, + makeDOMNodeNameBefore: function(html, setting, node) { + var title = data.getNodeTitle(setting, node), + url = view.makeNodeUrl(setting, node), + fontcss = view.makeNodeFontCss(setting, node), + fontStyle = []; + for (var f in fontcss) { + fontStyle.push(f, ":", fontcss[f], ";"); + } + html.push(" 0) ? "href='" + url + "'" : ""), " target='",view.makeNodeTarget(node),"' style='", fontStyle.join(''), + "'"); + if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) {html.push("title='", title.replace(/'/g,"'").replace(//g,'>'),"'");} + html.push(">"); + }, + makeNodeFontCss: function(setting, node) { + var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss); + return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {}; + }, + makeNodeIcoClass: function(setting, node) { + var icoCss = ["ico"]; + if (!node.isAjaxing) { + icoCss[0] = (node.iconSkin ? node.iconSkin + "_" : "") + icoCss[0]; + if (node.isParent) { + icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); + } else { + icoCss.push(consts.folder.DOCU); + } + } + return consts.className.BUTTON + " " + icoCss.join('_'); + }, + makeNodeIcoStyle: function(setting, node) { + var icoStyle = []; + if (!node.isAjaxing) { + var icon = (node.isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node.icon; + if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;"); + if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) { + icoStyle.push("width:0px;height:0px;"); + } + } + return icoStyle.join(''); + }, + makeNodeLineClass: function(setting, node) { + var lineClass = []; + if (setting.view.showLine) { + if (node.level == 0 && node.isFirstNode && node.isLastNode) { + lineClass.push(consts.line.ROOT); + } else if (node.level == 0 && node.isFirstNode) { + lineClass.push(consts.line.ROOTS); + } else if (node.isLastNode) { + lineClass.push(consts.line.BOTTOM); + } else { + lineClass.push(consts.line.CENTER); + } + } else { + lineClass.push(consts.line.NOLINE); + } + if (node.isParent) { + lineClass.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE); + } else { + lineClass.push(consts.folder.DOCU); + } + return view.makeNodeLineClassEx(node) + lineClass.join('_'); + }, + makeNodeLineClassEx: function(node) { + return consts.className.BUTTON + " " + consts.className.LEVEL + node.level + " " + consts.className.SWITCH + " "; + }, + makeNodeTarget: function(node) { + return (node.target || "_blank"); + }, + makeNodeUrl: function(setting, node) { + var urlKey = setting.data.key.url; + return node[urlKey] ? node[urlKey] : null; + }, + makeUlHtml: function(setting, node, html, content) { + html.push("
              "); + html.push(content); + html.push("
            "); + }, + makeUlLineClass: function(setting, node) { + return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : ""); + }, + removeChildNodes: function(setting, node) { + if (!node) return; + var childKey = setting.data.key.children, + nodes = node[childKey]; + if (!nodes) return; + + for (var i = 0, l = nodes.length; i < l; i++) { + data.removeNodeCache(setting, nodes[i]); + } + data.removeSelectedNode(setting); + delete node[childKey]; + + if (!setting.data.keep.parent) { + node.isParent = false; + node.open = false; + var tmp_switchObj = $("#" + node.tId + consts.id.SWITCH), + tmp_icoObj = $("#" + node.tId + consts.id.ICON); + view.replaceSwitchClass(node, tmp_switchObj, consts.folder.DOCU); + view.replaceIcoClass(node, tmp_icoObj, consts.folder.DOCU); + $("#" + node.tId + consts.id.UL).remove(); + } else { + $("#" + node.tId + consts.id.UL).empty(); + } + }, + setFirstNode: function(setting, parentNode) { + var childKey = setting.data.key.children, childLength = parentNode[childKey].length; + if ( childLength > 0) { + parentNode[childKey][0].isFirstNode = true; + } + }, + setLastNode: function(setting, parentNode) { + var childKey = setting.data.key.children, childLength = parentNode[childKey].length; + if ( childLength > 0) { + parentNode[childKey][childLength - 1].isLastNode = true; + } + }, + removeNode: function(setting, node) { + var root = data.getRoot(setting), + childKey = setting.data.key.children, + parentNode = (node.parentTId) ? node.getParentNode() : root; + + node.isFirstNode = false; + node.isLastNode = false; + node.getPreNode = function() {return null;}; + node.getNextNode = function() {return null;}; + + if (!data.getNodeCache(setting, node.tId)) { + return; + } + + $("#" + node.tId).remove(); + data.removeNodeCache(setting, node); + data.removeSelectedNode(setting, node); + + for (var i = 0, l = parentNode[childKey].length; i < l; i++) { + if (parentNode[childKey][i].tId == node.tId) { + parentNode[childKey].splice(i, 1); + break; + } + } + view.setFirstNode(setting, parentNode); + view.setLastNode(setting, parentNode); + + var tmp_ulObj,tmp_switchObj,tmp_icoObj, + childLength = parentNode[childKey].length; + + //repair nodes old parent + if (!setting.data.keep.parent && childLength == 0) { + //old parentNode has no child nodes + parentNode.isParent = false; + parentNode.open = false; + tmp_ulObj = $("#" + parentNode.tId + consts.id.UL); + tmp_switchObj = $("#" + parentNode.tId + consts.id.SWITCH); + tmp_icoObj = $("#" + parentNode.tId + consts.id.ICON); + view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU); + view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU); + tmp_ulObj.css("display", "none"); + + } else if (setting.view.showLine && childLength > 0) { + //old parentNode has child nodes + var newLast = parentNode[childKey][childLength - 1]; + tmp_ulObj = $("#" + newLast.tId + consts.id.UL); + tmp_switchObj = $("#" + newLast.tId + consts.id.SWITCH); + tmp_icoObj = $("#" + newLast.tId + consts.id.ICON); + if (parentNode == root) { + if (parentNode[childKey].length == 1) { + //node was root, and ztree has only one root after move node + view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT); + } else { + var tmp_first_switchObj = $("#" + parentNode[childKey][0].tId + consts.id.SWITCH); + view.replaceSwitchClass(parentNode[childKey][0], tmp_first_switchObj, consts.line.ROOTS); + view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); + } + } else { + view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM); + } + tmp_ulObj.removeClass(consts.line.LINE); + } + }, + replaceIcoClass: function(node, obj, newName) { + if (!obj || node.isAjaxing) return; + var tmpName = obj.attr("class"); + if (tmpName == undefined) return; + var tmpList = tmpName.split("_"); + switch (newName) { + case consts.folder.OPEN: + case consts.folder.CLOSE: + case consts.folder.DOCU: + tmpList[tmpList.length-1] = newName; + break; + } + obj.attr("class", tmpList.join("_")); + }, + replaceSwitchClass: function(node, obj, newName) { + if (!obj) return; + var tmpName = obj.attr("class"); + if (tmpName == undefined) return; + var tmpList = tmpName.split("_"); + switch (newName) { + case consts.line.ROOT: + case consts.line.ROOTS: + case consts.line.CENTER: + case consts.line.BOTTOM: + case consts.line.NOLINE: + tmpList[0] = view.makeNodeLineClassEx(node) + newName; + break; + case consts.folder.OPEN: + case consts.folder.CLOSE: + case consts.folder.DOCU: + tmpList[1] = newName; + break; + } + obj.attr("class", tmpList.join("_")); + if (newName !== consts.folder.DOCU) { + obj.removeAttr("disabled"); + } else { + obj.attr("disabled", "disabled"); + } + }, + selectNode: function(setting, node, addFlag) { + if (!addFlag) { + view.cancelPreSelectedNode(setting); + } + $("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED); + data.addSelectedNode(setting, node); + }, + setNodeFontCss: function(setting, treeNode) { + var aObj = $("#" + treeNode.tId + consts.id.A), + fontCss = view.makeNodeFontCss(setting, treeNode); + if (fontCss) { + aObj.css(fontCss); + } + }, + setNodeLineIcos: function(setting, node) { + if (!node) return; + var switchObj = $("#" + node.tId + consts.id.SWITCH), + ulObj = $("#" + node.tId + consts.id.UL), + icoObj = $("#" + node.tId + consts.id.ICON), + ulLine = view.makeUlLineClass(setting, node); + if (ulLine.length==0) { + ulObj.removeClass(consts.line.LINE); + } else { + ulObj.addClass(ulLine); + } + switchObj.attr("class", view.makeNodeLineClass(setting, node)); + if (node.isParent) { + switchObj.removeAttr("disabled"); + } else { + switchObj.attr("disabled", "disabled"); + } + icoObj.removeAttr("style"); + icoObj.attr("style", view.makeNodeIcoStyle(setting, node)); + icoObj.attr("class", view.makeNodeIcoClass(setting, node)); + }, + setNodeName: function(setting, node) { + var title = data.getNodeTitle(setting, node), + nObj = $("#" + node.tId + consts.id.SPAN); + nObj.empty(); + if (setting.view.nameIsHTML) { + nObj.html(data.getNodeName(setting, node)); + } else { + nObj.text(data.getNodeName(setting, node)); + } + if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) { + var aObj = $("#" + node.tId + consts.id.A); + aObj.attr("title", !title ? "" : title); + } + }, + setNodeTarget: function(node) { + var aObj = $("#" + node.tId + consts.id.A); + aObj.attr("target", view.makeNodeTarget(node)); + }, + setNodeUrl: function(setting, node) { + var aObj = $("#" + node.tId + consts.id.A), + url = view.makeNodeUrl(setting, node); + if (url == null || url.length == 0) { + aObj.removeAttr("href"); + } else { + aObj.attr("href", url); + } + }, + switchNode: function(setting, node) { + if (node.open || !tools.canAsync(setting, node)) { + view.expandCollapseNode(setting, node, !node.open); + } else if (setting.async.enable) { + if (!view.asyncNode(setting, node)) { + view.expandCollapseNode(setting, node, !node.open); + return; + } + } else if (node) { + view.expandCollapseNode(setting, node, !node.open); + } + } + }; + // zTree defind + $.fn.zTree = { + consts : _consts, + _z : { + tools: tools, + view: view, + event: event, + data: data + }, + getZTreeObj: function(treeId) { + var o = data.getZTreeTools(treeId); + return o ? o : null; + }, + destroy: function(treeId) { + if (!!treeId && treeId.length > 0) { + view.destroy(data.getSetting(treeId)); + } else { + for(var s in settings) { + view.destroy(settings[s]); + } + } + }, + init: function(obj, zSetting, zNodes) { + var setting = tools.clone(_setting); + $.extend(true, setting, zSetting); + setting.treeId = obj.attr("id"); + setting.treeObj = obj; + setting.treeObj.empty(); + settings[setting.treeId] = setting; + //For some older browser,(e.g., ie6) + if(typeof document.body.style.maxHeight === "undefined") { + setting.view.expandSpeed = ""; + } + data.initRoot(setting); + var root = data.getRoot(setting), + childKey = setting.data.key.children; + zNodes = zNodes ? tools.clone(tools.isArray(zNodes)? zNodes : [zNodes]) : []; + if (setting.data.simpleData.enable) { + root[childKey] = data.transformTozTreeFormat(setting, zNodes); + } else { + root[childKey] = zNodes; + } + + data.initCache(setting); + event.unbindTree(setting); + event.bindTree(setting); + event.unbindEvent(setting); + event.bindEvent(setting); + + var zTreeTools = { + setting : setting, + addNodes : function(parentNode, newNodes, isSilent) { + if (!newNodes) return null; + if (!parentNode) parentNode = null; + if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null; + var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]); + function addCallback() { + view.addNodes(setting, parentNode, xNewNodes, (isSilent==true)); + } + + if (tools.canAsync(setting, parentNode)) { + view.asyncNode(setting, parentNode, isSilent, addCallback); + } else { + addCallback(); + } + return xNewNodes; + }, + cancelSelectedNode : function(node) { + view.cancelPreSelectedNode(this.setting, node); + }, + destroy : function() { + view.destroy(this.setting); + }, + expandAll : function(expandFlag) { + expandFlag = !!expandFlag; + view.expandCollapseSonNode(this.setting, null, expandFlag, true); + return expandFlag; + }, + expandNode : function(node, expandFlag, sonSign, focus, callbackFlag) { + if (!node || !node.isParent) return null; + if (expandFlag !== true && expandFlag !== false) { + expandFlag = !node.open; + } + callbackFlag = !!callbackFlag; + + if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) { + return null; + } else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) { + return null; + } + if (expandFlag && node.parentTId) { + view.expandCollapseParentNode(this.setting, node.getParentNode(), expandFlag, false); + } + if (expandFlag === node.open && !sonSign) { + return null; + } + + data.getRoot(setting).expandTriggerFlag = callbackFlag; + if (sonSign) { + view.expandCollapseSonNode(this.setting, node, expandFlag, true, function() { + if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}} + }); + } else { + node.open = !expandFlag; + view.switchNode(this.setting, node); + if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}} + } + return expandFlag; + }, + getNodes : function() { + return data.getNodes(this.setting); + }, + getNodeByParam : function(key, value, parentNode) { + if (!key) return null; + return data.getNodeByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); + }, + getNodeByTId : function(tId) { + return data.getNodeCache(this.setting, tId); + }, + getNodesByParam : function(key, value, parentNode) { + if (!key) return null; + return data.getNodesByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); + }, + getNodesByParamFuzzy : function(key, value, parentNode) { + if (!key) return null; + return data.getNodesByParamFuzzy(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value); + }, + getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) { + isSingle = !!isSingle; + if (!filter || (typeof filter != "function")) return (isSingle ? null : []); + return data.getNodesByFilter(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), filter, isSingle, invokeParam); + }, + getNodeIndex : function(node) { + if (!node) return null; + var childKey = setting.data.key.children, + parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(this.setting); + for (var i=0, l = parentNode[childKey].length; i < l; i++) { + if (parentNode[childKey][i] == node) return i; + } + return -1; + }, + getSelectedNodes : function() { + var r = [], list = data.getRoot(this.setting).curSelectedList; + for (var i=0, l=list.length; i 0) { + view.createNodes(setting, 0, root[childKey]); + } else if (setting.async.enable && setting.async.url && setting.async.url !== '') { + view.asyncNode(setting); + } + return zTreeTools; + } + }; + + var zt = $.fn.zTree, + consts = zt.consts; })(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.excheck-3.5.js b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.excheck-3.5.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.excheck-3.5.js rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.excheck-3.5.js index a7680267b..2605badd3 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.excheck-3.5.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.excheck-3.5.js @@ -1,624 +1,624 @@ -/* - * JQuery zTree excheck 3.5.12 - * http://zTree.me/ - * - * Copyright (c) 2010 Hunter.z - * - * Licensed same as jquery - MIT License - * http://www.opensource.org/licenses/mit-license.php - * - * email: hunter.z@263.net - * Date: 2013-03-11 - */ -(function($){ - //default consts of excheck - var _consts = { - event: { - CHECK: "ztree_check" - }, - id: { - CHECK: "_check" - }, - checkbox: { - STYLE: "checkbox", - DEFAULT: "chk", - DISABLED: "disable", - FALSE: "false", - TRUE: "true", - FULL: "full", - PART: "part", - FOCUS: "focus" - }, - radio: { - STYLE: "radio", - TYPE_ALL: "all", - TYPE_LEVEL: "level" - } - }, - //default setting of excheck - _setting = { - check: { - enable: false, - autoCheckTrigger: false, - chkStyle: _consts.checkbox.STYLE, - nocheckInherit: false, - chkDisabledInherit: false, - radioType: _consts.radio.TYPE_LEVEL, - chkboxType: { - "Y": "ps", - "N": "ps" - } - }, - data: { - key: { - checked: "checked" - } - }, - callback: { - beforeCheck:null, - onCheck:null - } - }, - //default root of excheck - _initRoot = function (setting) { - var r = data.getRoot(setting); - r.radioCheckedList = []; - }, - //default cache of excheck - _initCache = function(treeId) {}, - //default bind event of excheck - _bindEvent = function(setting) { - var o = setting.treeObj, - c = consts.event; - o.bind(c.CHECK, function (event, srcEvent, treeId, node) { - tools.apply(setting.callback.onCheck, [!!srcEvent?srcEvent : event, treeId, node]); - }); - }, - _unbindEvent = function(setting) { - var o = setting.treeObj, - c = consts.event; - o.unbind(c.CHECK); - }, - //default event proxy of excheck - _eventProxy = function(e) { - var target = e.target, - setting = data.getSetting(e.data.treeId), - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null; - - if (tools.eqs(e.type, "mouseover")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { - tId = target.parentNode.id; - nodeEventType = "mouseoverCheck"; - } - } else if (tools.eqs(e.type, "mouseout")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { - tId = target.parentNode.id; - nodeEventType = "mouseoutCheck"; - } - } else if (tools.eqs(e.type, "click")) { - if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { - tId = target.parentNode.id; - nodeEventType = "checkNode"; - } - } - if (tId.length>0) { - node = data.getNodeCache(setting, tId); - switch (nodeEventType) { - case "checkNode" : - nodeEventCallback = _handler.onCheckNode; - break; - case "mouseoverCheck" : - nodeEventCallback = _handler.onMouseoverCheck; - break; - case "mouseoutCheck" : - nodeEventCallback = _handler.onMouseoutCheck; - break; - } - } - var proxyResult = { - stop: false, - node: node, - nodeEventType: nodeEventType, - nodeEventCallback: nodeEventCallback, - treeEventType: treeEventType, - treeEventCallback: treeEventCallback - }; - return proxyResult - }, - //default init node of excheck - _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { - if (!n) return; - var checkedKey = setting.data.key.checked; - if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true"); - n[checkedKey] = !!n[checkedKey]; - n.checkedOld = n[checkedKey]; - if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); - n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); - if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); - n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); - if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); - n.halfCheck = !!n.halfCheck; - n.check_Child_State = -1; - n.check_Focus = false; - n.getCheckStatus = function() {return data.getCheckStatus(setting, n);}; - }, - //add dom for check - _beforeA = function(setting, node, html) { - var checkedKey = setting.data.key.checked; - if (setting.check.enable) { - data.makeChkFlag(setting, node); - if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && node[checkedKey] ) { - var r = data.getRoot(setting); - r.radioCheckedList.push(node); - } - html.push(""); - } - }, - //update zTreeObj, add method of check - _zTreeTools = function(setting, zTreeTools) { - zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) { - var checkedKey = this.setting.data.key.checked; - if (node.chkDisabled === true) return; - if (checked !== true && checked !== false) { - checked = !node[checkedKey]; - } - callbackFlag = !!callbackFlag; - - if (node[checkedKey] === checked && !checkTypeFlag) { - return; - } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) { - return; - } - if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) { - node[checkedKey] = checked; - var checkObj = $("#" + node.tId + consts.id.CHECK); - if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); - view.setChkClass(this.setting, checkObj, node); - view.repairParentChkClassWithSelf(this.setting, node); - if (callbackFlag) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); - } - } - } - - zTreeTools.checkAllNodes = function(checked) { - view.repairAllChk(this.setting, !!checked); - } - - zTreeTools.getCheckedNodes = function(checked) { - var childKey = this.setting.data.key.children; - checked = (checked !== false); - return data.getTreeCheckedNodes(this.setting, data.getRoot(setting)[childKey], checked); - } - - zTreeTools.getChangeCheckedNodes = function() { - var childKey = this.setting.data.key.children; - return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(setting)[childKey]); - } - - zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) { - disabled = !!disabled; - inheritParent = !!inheritParent; - inheritChildren = !!inheritChildren; - view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); - view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); - } - - var _updateNode = zTreeTools.updateNode; - zTreeTools.updateNode = function(node, checkTypeFlag) { - if (_updateNode) _updateNode.apply(zTreeTools, arguments); - if (!node || !this.setting.check.enable) return; - var nObj = $("#" + node.tId); - if (nObj.get(0) && tools.uCanDo(this.setting)) { - var checkObj = $("#" + node.tId + consts.id.CHECK); - if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); - view.setChkClass(this.setting, checkObj, node); - view.repairParentChkClassWithSelf(this.setting, node); - } - } - }, - //method of operate data - _data = { - getRadioCheckedList: function(setting) { - var checkedList = data.getRoot(setting).radioCheckedList; - for (var i=0, j=checkedList.length; i -1 && node.check_Child_State < 2) : (node.check_Child_State > 0))) - }; - return r; - }, - getTreeCheckedNodes: function(setting, nodes, checked, results) { - if (!nodes) return []; - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL); - results = !results ? [] : results; - for (var i = 0, l = nodes.length; i < l; i++) { - if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) { - results.push(nodes[i]); - if(onlyOne) { - break; - } - } - data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results); - if(onlyOne && results.length > 0) { - break; - } - } - return results; - }, - getTreeChangeCheckedNodes: function(setting, nodes, results) { - if (!nodes) return []; - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked; - results = !results ? [] : results; - for (var i = 0, l = nodes.length; i < l; i++) { - if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) { - results.push(nodes[i]); - } - data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results); - } - return results; - }, - makeChkFlag: function(setting, node) { - if (!node) return; - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - chkFlag = -1; - if (node[childKey]) { - for (var i = 0, l = node[childKey].length; i < l; i++) { - var cNode = node[childKey][i]; - var tmp = -1; - if (setting.check.chkStyle == consts.radio.STYLE) { - if (cNode.nocheck === true || cNode.chkDisabled === true) { - tmp = cNode.check_Child_State; - } else if (cNode.halfCheck === true) { - tmp = 2; - } else if (cNode[checkedKey]) { - tmp = 2; - } else { - tmp = cNode.check_Child_State > 0 ? 2:0; - } - if (tmp == 2) { - chkFlag = 2; break; - } else if (tmp == 0){ - chkFlag = 0; - } - } else if (setting.check.chkStyle == consts.checkbox.STYLE) { - if (cNode.nocheck === true || cNode.chkDisabled === true) { - tmp = cNode.check_Child_State; - } else if (cNode.halfCheck === true) { - tmp = 1; - } else if (cNode[checkedKey] ) { - tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; - } else { - tmp = (cNode.check_Child_State > 0) ? 1 : 0; - } - if (tmp === 1) { - chkFlag = 1; break; - } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { - chkFlag = 1; break; - } else if (chkFlag === 2 && tmp > -1 && tmp < 2) { - chkFlag = 1; break; - } else if (tmp > -1) { - chkFlag = tmp; - } - } - } - } - node.check_Child_State = chkFlag; - } - }, - //method of event proxy - _event = { - - }, - //method of event handler - _handler = { - onCheckNode: function (event, node) { - if (node.chkDisabled === true) return false; - var setting = data.getSetting(event.data.treeId), - checkedKey = setting.data.key.checked; - if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true; - node[checkedKey] = !node[checkedKey]; - view.checkNodeRelation(setting, node); - var checkObj = $("#" + node.tId + consts.id.CHECK); - view.setChkClass(setting, checkObj, node); - view.repairParentChkClassWithSelf(setting, node); - setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); - return true; - }, - onMouseoverCheck: function(event, node) { - if (node.chkDisabled === true) return false; - var setting = data.getSetting(event.data.treeId), - checkObj = $("#" + node.tId + consts.id.CHECK); - node.check_Focus = true; - view.setChkClass(setting, checkObj, node); - return true; - }, - onMouseoutCheck: function(event, node) { - if (node.chkDisabled === true) return false; - var setting = data.getSetting(event.data.treeId), - checkObj = $("#" + node.tId + consts.id.CHECK); - node.check_Focus = false; - view.setChkClass(setting, checkObj, node); - return true; - } - }, - //method of tools for zTree - _tools = { - - }, - //method of operate ztree dom - _view = { - checkNodeRelation: function(setting, node) { - var pNode, i, l, - childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - r = consts.radio; - if (setting.check.chkStyle == r.STYLE) { - var checkedList = data.getRadioCheckedList(setting); - if (node[checkedKey]) { - if (setting.check.radioType == r.TYPE_ALL) { - for (i = checkedList.length-1; i >= 0; i--) { - pNode = checkedList[i]; - pNode[checkedKey] = false; - checkedList.splice(i, 1); - - view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode); - if (pNode.parentTId != node.parentTId) { - view.repairParentChkClassWithSelf(setting, pNode); - } - } - checkedList.push(node); - } else { - var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); - for (i = 0, l = parentNode[childKey].length; i < l; i++) { - pNode = parentNode[childKey][i]; - if (pNode[checkedKey] && pNode != node) { - pNode[checkedKey] = false; - view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode); - } - } - } - } else if (setting.check.radioType == r.TYPE_ALL) { - for (i = 0, l = checkedList.length; i < l; i++) { - if (node == checkedList[i]) { - checkedList.splice(i, 1); - break; - } - } - } - - } else { - if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { - view.setSonNodeCheckBox(setting, node, true); - } - if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) { - view.setSonNodeCheckBox(setting, node, false); - } - if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) { - view.setParentNodeCheckBox(setting, node, true); - } - if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) { - view.setParentNodeCheckBox(setting, node, false); - } - } - }, - makeChkClass: function(setting, node) { - var checkedKey = setting.data.key.checked, - c = consts.checkbox, r = consts.radio, - fullStyle = ""; - if (node.chkDisabled === true) { - fullStyle = c.DISABLED; - } else if (node.halfCheck) { - fullStyle = c.PART; - } else if (setting.check.chkStyle == r.STYLE) { - fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART; - } else { - fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART); - } - var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle; - chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; - return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; - }, - repairAllChk: function(setting, checked) { - if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { - var checkedKey = setting.data.key.checked, - childKey = setting.data.key.children, - root = data.getRoot(setting); - for (var i = 0, l = root[childKey].length; i 0) { - view.repairParentChkClass(setting, node[childKey][0]); - } else { - view.repairParentChkClass(setting, node); - } - }, - repairSonChkDisabled: function(setting, node, chkDisabled, inherit) { - if (!node) return; - var childKey = setting.data.key.children; - if (node.chkDisabled != chkDisabled) { - node.chkDisabled = chkDisabled; - } - view.repairChkClass(setting, node); - if (node[childKey] && inherit) { - for (var i = 0, l = node[childKey].length; i < l; i++) { - var sNode = node[childKey][i]; - view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit); - } - } - }, - repairParentChkDisabled: function(setting, node, chkDisabled, inherit) { - if (!node) return; - if (node.chkDisabled != chkDisabled && inherit) { - node.chkDisabled = chkDisabled; - } - view.repairChkClass(setting, node); - view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); - }, - setChkClass: function(setting, obj, node) { - if (!obj) return; - if (node.nocheck === true) { - obj.hide(); - } else { - obj.show(); - } - obj.removeClass(); - obj.addClass(view.makeChkClass(setting, node)); - }, - setParentNodeCheckBox: function(setting, node, value, srcNode) { - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - checkObj = $("#" + node.tId + consts.id.CHECK); - if (!srcNode) srcNode = node; - data.makeChkFlag(setting, node); - if (node.nocheck !== true && node.chkDisabled !== true) { - node[checkedKey] = value; - view.setChkClass(setting, checkObj, node); - if (setting.check.autoCheckTrigger && node != srcNode) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); - } - } - if (node.parentTId) { - var pSign = true; - if (!value) { - var pNodes = node.getParentNode()[childKey]; - for (var i = 0, l = pNodes.length; i < l; i++) { - if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey]) - || ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) { - pSign = false; - break; - } - } - } - if (pSign) { - view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode); - } - } - }, - setSonNodeCheckBox: function(setting, node, value, srcNode) { - if (!node) return; - var childKey = setting.data.key.children, - checkedKey = setting.data.key.checked, - checkObj = $("#" + node.tId + consts.id.CHECK); - if (!srcNode) srcNode = node; - - var hasDisable = false; - if (node[childKey]) { - for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) { - var sNode = node[childKey][i]; - view.setSonNodeCheckBox(setting, sNode, value, srcNode); - if (sNode.chkDisabled === true) hasDisable = true; - } - } - - if (node != data.getRoot(setting) && node.chkDisabled !== true) { - if (hasDisable && node.nocheck !== true) { - data.makeChkFlag(setting, node); - } - if (node.nocheck !== true && node.chkDisabled !== true) { - node[checkedKey] = value; - if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1; - } else { - node.check_Child_State = -1; - } - view.setChkClass(setting, checkObj, node); - if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) { - setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); - } - } - - } - }, - - _z = { - tools: _tools, - view: _view, - event: _event, - data: _data - }; - $.extend(true, $.fn.zTree.consts, _consts); - $.extend(true, $.fn.zTree._z, _z); - - var zt = $.fn.zTree, - tools = zt._z.tools, - consts = zt.consts, - view = zt._z.view, - data = zt._z.data, - event = zt._z.event; - - data.exSetting(_setting); - data.addInitBind(_bindEvent); - data.addInitUnBind(_unbindEvent); - data.addInitCache(_initCache); - data.addInitNode(_initNode); - data.addInitProxy(_eventProxy); - data.addInitRoot(_initRoot); - data.addBeforeA(_beforeA); - data.addZTreeTools(_zTreeTools); - - var _createNodes = view.createNodes; - view.createNodes = function(setting, level, nodes, parentNode) { - if (_createNodes) _createNodes.apply(view, arguments); - if (!nodes) return; - view.repairParentChkClassWithSelf(setting, parentNode); - } - var _removeNode = view.removeNode; - view.removeNode = function(setting, node) { - var parentNode = node.getParentNode(); - if (_removeNode) _removeNode.apply(view, arguments); - if (!node || !parentNode) return; - view.repairChkClass(setting, parentNode); - view.repairParentChkClass(setting, parentNode); - } - - var _appendNodes = view.appendNodes; - view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) { - var html = ""; - if (_appendNodes) { - html = _appendNodes.apply(view, arguments); - } - if (parentNode) { - data.makeChkFlag(setting, parentNode); - } - return html; - } +/* + * JQuery zTree excheck 3.5.12 + * http://zTree.me/ + * + * Copyright (c) 2010 Hunter.z + * + * Licensed same as jquery - MIT License + * http://www.opensource.org/licenses/mit-license.php + * + * email: hunter.z@263.net + * Date: 2013-03-11 + */ +(function($){ + //default consts of excheck + var _consts = { + event: { + CHECK: "ztree_check" + }, + id: { + CHECK: "_check" + }, + checkbox: { + STYLE: "checkbox", + DEFAULT: "chk", + DISABLED: "disable", + FALSE: "false", + TRUE: "true", + FULL: "full", + PART: "part", + FOCUS: "focus" + }, + radio: { + STYLE: "radio", + TYPE_ALL: "all", + TYPE_LEVEL: "level" + } + }, + //default setting of excheck + _setting = { + check: { + enable: false, + autoCheckTrigger: false, + chkStyle: _consts.checkbox.STYLE, + nocheckInherit: false, + chkDisabledInherit: false, + radioType: _consts.radio.TYPE_LEVEL, + chkboxType: { + "Y": "ps", + "N": "ps" + } + }, + data: { + key: { + checked: "checked" + } + }, + callback: { + beforeCheck:null, + onCheck:null + } + }, + //default root of excheck + _initRoot = function (setting) { + var r = data.getRoot(setting); + r.radioCheckedList = []; + }, + //default cache of excheck + _initCache = function(treeId) {}, + //default bind event of excheck + _bindEvent = function(setting) { + var o = setting.treeObj, + c = consts.event; + o.bind(c.CHECK, function (event, srcEvent, treeId, node) { + tools.apply(setting.callback.onCheck, [!!srcEvent?srcEvent : event, treeId, node]); + }); + }, + _unbindEvent = function(setting) { + var o = setting.treeObj, + c = consts.event; + o.unbind(c.CHECK); + }, + //default event proxy of excheck + _eventProxy = function(e) { + var target = e.target, + setting = data.getSetting(e.data.treeId), + tId = "", node = null, + nodeEventType = "", treeEventType = "", + nodeEventCallback = null, treeEventCallback = null; + + if (tools.eqs(e.type, "mouseover")) { + if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { + tId = target.parentNode.id; + nodeEventType = "mouseoverCheck"; + } + } else if (tools.eqs(e.type, "mouseout")) { + if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { + tId = target.parentNode.id; + nodeEventType = "mouseoutCheck"; + } + } else if (tools.eqs(e.type, "click")) { + if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { + tId = target.parentNode.id; + nodeEventType = "checkNode"; + } + } + if (tId.length>0) { + node = data.getNodeCache(setting, tId); + switch (nodeEventType) { + case "checkNode" : + nodeEventCallback = _handler.onCheckNode; + break; + case "mouseoverCheck" : + nodeEventCallback = _handler.onMouseoverCheck; + break; + case "mouseoutCheck" : + nodeEventCallback = _handler.onMouseoutCheck; + break; + } + } + var proxyResult = { + stop: false, + node: node, + nodeEventType: nodeEventType, + nodeEventCallback: nodeEventCallback, + treeEventType: treeEventType, + treeEventCallback: treeEventCallback + }; + return proxyResult + }, + //default init node of excheck + _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + if (!n) return; + var checkedKey = setting.data.key.checked; + if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true"); + n[checkedKey] = !!n[checkedKey]; + n.checkedOld = n[checkedKey]; + if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); + n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); + if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); + n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); + if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); + n.halfCheck = !!n.halfCheck; + n.check_Child_State = -1; + n.check_Focus = false; + n.getCheckStatus = function() {return data.getCheckStatus(setting, n);}; + }, + //add dom for check + _beforeA = function(setting, node, html) { + var checkedKey = setting.data.key.checked; + if (setting.check.enable) { + data.makeChkFlag(setting, node); + if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && node[checkedKey] ) { + var r = data.getRoot(setting); + r.radioCheckedList.push(node); + } + html.push(""); + } + }, + //update zTreeObj, add method of check + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) { + var checkedKey = this.setting.data.key.checked; + if (node.chkDisabled === true) return; + if (checked !== true && checked !== false) { + checked = !node[checkedKey]; + } + callbackFlag = !!callbackFlag; + + if (node[checkedKey] === checked && !checkTypeFlag) { + return; + } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) { + return; + } + if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) { + node[checkedKey] = checked; + var checkObj = $("#" + node.tId + consts.id.CHECK); + if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); + view.setChkClass(this.setting, checkObj, node); + view.repairParentChkClassWithSelf(this.setting, node); + if (callbackFlag) { + setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + } + } + } + + zTreeTools.checkAllNodes = function(checked) { + view.repairAllChk(this.setting, !!checked); + } + + zTreeTools.getCheckedNodes = function(checked) { + var childKey = this.setting.data.key.children; + checked = (checked !== false); + return data.getTreeCheckedNodes(this.setting, data.getRoot(setting)[childKey], checked); + } + + zTreeTools.getChangeCheckedNodes = function() { + var childKey = this.setting.data.key.children; + return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(setting)[childKey]); + } + + zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) { + disabled = !!disabled; + inheritParent = !!inheritParent; + inheritChildren = !!inheritChildren; + view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); + view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); + } + + var _updateNode = zTreeTools.updateNode; + zTreeTools.updateNode = function(node, checkTypeFlag) { + if (_updateNode) _updateNode.apply(zTreeTools, arguments); + if (!node || !this.setting.check.enable) return; + var nObj = $("#" + node.tId); + if (nObj.get(0) && tools.uCanDo(this.setting)) { + var checkObj = $("#" + node.tId + consts.id.CHECK); + if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); + view.setChkClass(this.setting, checkObj, node); + view.repairParentChkClassWithSelf(this.setting, node); + } + } + }, + //method of operate data + _data = { + getRadioCheckedList: function(setting) { + var checkedList = data.getRoot(setting).radioCheckedList; + for (var i=0, j=checkedList.length; i -1 && node.check_Child_State < 2) : (node.check_Child_State > 0))) + }; + return r; + }, + getTreeCheckedNodes: function(setting, nodes, checked, results) { + if (!nodes) return []; + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL); + results = !results ? [] : results; + for (var i = 0, l = nodes.length; i < l; i++) { + if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) { + results.push(nodes[i]); + if(onlyOne) { + break; + } + } + data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results); + if(onlyOne && results.length > 0) { + break; + } + } + return results; + }, + getTreeChangeCheckedNodes: function(setting, nodes, results) { + if (!nodes) return []; + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked; + results = !results ? [] : results; + for (var i = 0, l = nodes.length; i < l; i++) { + if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) { + results.push(nodes[i]); + } + data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results); + } + return results; + }, + makeChkFlag: function(setting, node) { + if (!node) return; + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + chkFlag = -1; + if (node[childKey]) { + for (var i = 0, l = node[childKey].length; i < l; i++) { + var cNode = node[childKey][i]; + var tmp = -1; + if (setting.check.chkStyle == consts.radio.STYLE) { + if (cNode.nocheck === true || cNode.chkDisabled === true) { + tmp = cNode.check_Child_State; + } else if (cNode.halfCheck === true) { + tmp = 2; + } else if (cNode[checkedKey]) { + tmp = 2; + } else { + tmp = cNode.check_Child_State > 0 ? 2:0; + } + if (tmp == 2) { + chkFlag = 2; break; + } else if (tmp == 0){ + chkFlag = 0; + } + } else if (setting.check.chkStyle == consts.checkbox.STYLE) { + if (cNode.nocheck === true || cNode.chkDisabled === true) { + tmp = cNode.check_Child_State; + } else if (cNode.halfCheck === true) { + tmp = 1; + } else if (cNode[checkedKey] ) { + tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; + } else { + tmp = (cNode.check_Child_State > 0) ? 1 : 0; + } + if (tmp === 1) { + chkFlag = 1; break; + } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { + chkFlag = 1; break; + } else if (chkFlag === 2 && tmp > -1 && tmp < 2) { + chkFlag = 1; break; + } else if (tmp > -1) { + chkFlag = tmp; + } + } + } + } + node.check_Child_State = chkFlag; + } + }, + //method of event proxy + _event = { + + }, + //method of event handler + _handler = { + onCheckNode: function (event, node) { + if (node.chkDisabled === true) return false; + var setting = data.getSetting(event.data.treeId), + checkedKey = setting.data.key.checked; + if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true; + node[checkedKey] = !node[checkedKey]; + view.checkNodeRelation(setting, node); + var checkObj = $("#" + node.tId + consts.id.CHECK); + view.setChkClass(setting, checkObj, node); + view.repairParentChkClassWithSelf(setting, node); + setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); + return true; + }, + onMouseoverCheck: function(event, node) { + if (node.chkDisabled === true) return false; + var setting = data.getSetting(event.data.treeId), + checkObj = $("#" + node.tId + consts.id.CHECK); + node.check_Focus = true; + view.setChkClass(setting, checkObj, node); + return true; + }, + onMouseoutCheck: function(event, node) { + if (node.chkDisabled === true) return false; + var setting = data.getSetting(event.data.treeId), + checkObj = $("#" + node.tId + consts.id.CHECK); + node.check_Focus = false; + view.setChkClass(setting, checkObj, node); + return true; + } + }, + //method of tools for zTree + _tools = { + + }, + //method of operate ztree dom + _view = { + checkNodeRelation: function(setting, node) { + var pNode, i, l, + childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + r = consts.radio; + if (setting.check.chkStyle == r.STYLE) { + var checkedList = data.getRadioCheckedList(setting); + if (node[checkedKey]) { + if (setting.check.radioType == r.TYPE_ALL) { + for (i = checkedList.length-1; i >= 0; i--) { + pNode = checkedList[i]; + pNode[checkedKey] = false; + checkedList.splice(i, 1); + + view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode); + if (pNode.parentTId != node.parentTId) { + view.repairParentChkClassWithSelf(setting, pNode); + } + } + checkedList.push(node); + } else { + var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); + for (i = 0, l = parentNode[childKey].length; i < l; i++) { + pNode = parentNode[childKey][i]; + if (pNode[checkedKey] && pNode != node) { + pNode[checkedKey] = false; + view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode); + } + } + } + } else if (setting.check.radioType == r.TYPE_ALL) { + for (i = 0, l = checkedList.length; i < l; i++) { + if (node == checkedList[i]) { + checkedList.splice(i, 1); + break; + } + } + } + + } else { + if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { + view.setSonNodeCheckBox(setting, node, true); + } + if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) { + view.setSonNodeCheckBox(setting, node, false); + } + if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) { + view.setParentNodeCheckBox(setting, node, true); + } + if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) { + view.setParentNodeCheckBox(setting, node, false); + } + } + }, + makeChkClass: function(setting, node) { + var checkedKey = setting.data.key.checked, + c = consts.checkbox, r = consts.radio, + fullStyle = ""; + if (node.chkDisabled === true) { + fullStyle = c.DISABLED; + } else if (node.halfCheck) { + fullStyle = c.PART; + } else if (setting.check.chkStyle == r.STYLE) { + fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART; + } else { + fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART); + } + var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle; + chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; + return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; + }, + repairAllChk: function(setting, checked) { + if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { + var checkedKey = setting.data.key.checked, + childKey = setting.data.key.children, + root = data.getRoot(setting); + for (var i = 0, l = root[childKey].length; i 0) { + view.repairParentChkClass(setting, node[childKey][0]); + } else { + view.repairParentChkClass(setting, node); + } + }, + repairSonChkDisabled: function(setting, node, chkDisabled, inherit) { + if (!node) return; + var childKey = setting.data.key.children; + if (node.chkDisabled != chkDisabled) { + node.chkDisabled = chkDisabled; + } + view.repairChkClass(setting, node); + if (node[childKey] && inherit) { + for (var i = 0, l = node[childKey].length; i < l; i++) { + var sNode = node[childKey][i]; + view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit); + } + } + }, + repairParentChkDisabled: function(setting, node, chkDisabled, inherit) { + if (!node) return; + if (node.chkDisabled != chkDisabled && inherit) { + node.chkDisabled = chkDisabled; + } + view.repairChkClass(setting, node); + view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); + }, + setChkClass: function(setting, obj, node) { + if (!obj) return; + if (node.nocheck === true) { + obj.hide(); + } else { + obj.show(); + } + obj.removeClass(); + obj.addClass(view.makeChkClass(setting, node)); + }, + setParentNodeCheckBox: function(setting, node, value, srcNode) { + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + checkObj = $("#" + node.tId + consts.id.CHECK); + if (!srcNode) srcNode = node; + data.makeChkFlag(setting, node); + if (node.nocheck !== true && node.chkDisabled !== true) { + node[checkedKey] = value; + view.setChkClass(setting, checkObj, node); + if (setting.check.autoCheckTrigger && node != srcNode) { + setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + } + } + if (node.parentTId) { + var pSign = true; + if (!value) { + var pNodes = node.getParentNode()[childKey]; + for (var i = 0, l = pNodes.length; i < l; i++) { + if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey]) + || ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) { + pSign = false; + break; + } + } + } + if (pSign) { + view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode); + } + } + }, + setSonNodeCheckBox: function(setting, node, value, srcNode) { + if (!node) return; + var childKey = setting.data.key.children, + checkedKey = setting.data.key.checked, + checkObj = $("#" + node.tId + consts.id.CHECK); + if (!srcNode) srcNode = node; + + var hasDisable = false; + if (node[childKey]) { + for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) { + var sNode = node[childKey][i]; + view.setSonNodeCheckBox(setting, sNode, value, srcNode); + if (sNode.chkDisabled === true) hasDisable = true; + } + } + + if (node != data.getRoot(setting) && node.chkDisabled !== true) { + if (hasDisable && node.nocheck !== true) { + data.makeChkFlag(setting, node); + } + if (node.nocheck !== true && node.chkDisabled !== true) { + node[checkedKey] = value; + if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1; + } else { + node.check_Child_State = -1; + } + view.setChkClass(setting, checkObj, node); + if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) { + setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); + } + } + + } + }, + + _z = { + tools: _tools, + view: _view, + event: _event, + data: _data + }; + $.extend(true, $.fn.zTree.consts, _consts); + $.extend(true, $.fn.zTree._z, _z); + + var zt = $.fn.zTree, + tools = zt._z.tools, + consts = zt.consts, + view = zt._z.view, + data = zt._z.data, + event = zt._z.event; + + data.exSetting(_setting); + data.addInitBind(_bindEvent); + data.addInitUnBind(_unbindEvent); + data.addInitCache(_initCache); + data.addInitNode(_initNode); + data.addInitProxy(_eventProxy); + data.addInitRoot(_initRoot); + data.addBeforeA(_beforeA); + data.addZTreeTools(_zTreeTools); + + var _createNodes = view.createNodes; + view.createNodes = function(setting, level, nodes, parentNode) { + if (_createNodes) _createNodes.apply(view, arguments); + if (!nodes) return; + view.repairParentChkClassWithSelf(setting, parentNode); + } + var _removeNode = view.removeNode; + view.removeNode = function(setting, node) { + var parentNode = node.getParentNode(); + if (_removeNode) _removeNode.apply(view, arguments); + if (!node || !parentNode) return; + view.repairChkClass(setting, parentNode); + view.repairParentChkClass(setting, parentNode); + } + + var _appendNodes = view.appendNodes; + view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) { + var html = ""; + if (_appendNodes) { + html = _appendNodes.apply(view, arguments); + } + if (parentNode) { + data.makeChkFlag(setting, parentNode); + } + return html; + } })(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.exedit-3.5.js b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.exedit-3.5.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.exedit-3.5.js rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.exedit-3.5.js index 988f28fe7..c6ec3fcda 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.exedit-3.5.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.exedit-3.5.js @@ -1,1178 +1,1178 @@ -/* - * JQuery zTree exedit 3.5.12 - * http://zTree.me/ - * - * Copyright (c) 2010 Hunter.z - * - * Licensed same as jquery - MIT License - * http://www.opensource.org/licenses/mit-license.php - * - * email: hunter.z@263.net - * Date: 2013-03-11 - */ -(function($){ - //default consts of exedit - var _consts = { - event: { - DRAG: "ztree_drag", - DROP: "ztree_drop", - REMOVE: "ztree_remove", - RENAME: "ztree_rename" - }, - id: { - EDIT: "_edit", - INPUT: "_input", - REMOVE: "_remove" - }, - move: { - TYPE_INNER: "inner", - TYPE_PREV: "prev", - TYPE_NEXT: "next" - }, - node: { - CURSELECTED_EDIT: "curSelectedNode_Edit", - TMPTARGET_TREE: "tmpTargetzTree", - TMPTARGET_NODE: "tmpTargetNode" - } - }, - //default setting of exedit - _setting = { - edit: { - enable: false, - editNameSelectAll: false, - showRemoveBtn: true, - showRenameBtn: true, - removeTitle: "remove", - renameTitle: "rename", - drag: { - autoExpandTrigger: false, - isCopy: true, - isMove: true, - prev: true, - next: true, - inner: true, - minMoveSize: 5, - borderMax: 10, - borderMin: -5, - maxShowNodeNum: 5, - autoOpenTime: 500 - } - }, - view: { - addHoverDom: null, - removeHoverDom: null - }, - callback: { - beforeDrag:null, - beforeDragOpen:null, - beforeDrop:null, - beforeEditName:null, - beforeRename:null, - onDrag:null, - onDrop:null, - onRename:null - } - }, - //default root of exedit - _initRoot = function (setting) { - var r = data.getRoot(setting); - r.curEditNode = null; - r.curEditInput = null; - r.curHoverNode = null; - r.dragFlag = 0; - r.dragNodeShowBefore = []; - r.dragMaskList = new Array(); - r.showHoverDom = true; - }, - //default cache of exedit - _initCache = function(treeId) {}, - //default bind event of exedit - _bindEvent = function(setting) { - var o = setting.treeObj; - var c = consts.event; - o.bind(c.RENAME, function (event, treeId, treeNode) { - tools.apply(setting.callback.onRename, [event, treeId, treeNode]); - }); - - o.bind(c.REMOVE, function (event, treeId, treeNode) { - tools.apply(setting.callback.onRemove, [event, treeId, treeNode]); - }); - - o.bind(c.DRAG, function (event, srcEvent, treeId, treeNodes) { - tools.apply(setting.callback.onDrag, [srcEvent, treeId, treeNodes]); - }); - - o.bind(c.DROP, function (event, srcEvent, treeId, treeNodes, targetNode, moveType, isCopy) { - tools.apply(setting.callback.onDrop, [srcEvent, treeId, treeNodes, targetNode, moveType, isCopy]); - }); - }, - _unbindEvent = function(setting) { - var o = setting.treeObj; - var c = consts.event; - o.unbind(c.RENAME); - o.unbind(c.REMOVE); - o.unbind(c.DRAG); - o.unbind(c.DROP); - }, - //default event proxy of exedit - _eventProxy = function(e) { - var target = e.target, - setting = data.getSetting(e.data.treeId), - relatedTarget = e.relatedTarget, - tId = "", node = null, - nodeEventType = "", treeEventType = "", - nodeEventCallback = null, treeEventCallback = null, - tmp = null; - - if (tools.eqs(e.type, "mouseover")) { - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) { - tId = tmp.parentNode.id; - nodeEventType = "hoverOverNode"; - } - } else if (tools.eqs(e.type, "mouseout")) { - tmp = tools.getMDom(setting, relatedTarget, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (!tmp) { - tId = "remove"; - nodeEventType = "hoverOutNode"; - } - } else if (tools.eqs(e.type, "mousedown")) { - tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]); - if (tmp) { - tId = tmp.parentNode.id; - nodeEventType = "mousedownNode"; - } - } - if (tId.length>0) { - node = data.getNodeCache(setting, tId); - switch (nodeEventType) { - case "mousedownNode" : - nodeEventCallback = _handler.onMousedownNode; - break; - case "hoverOverNode" : - nodeEventCallback = _handler.onHoverOverNode; - break; - case "hoverOutNode" : - nodeEventCallback = _handler.onHoverOutNode; - break; - } - } - var proxyResult = { - stop: false, - node: node, - nodeEventType: nodeEventType, - nodeEventCallback: nodeEventCallback, - treeEventType: treeEventType, - treeEventCallback: treeEventCallback - }; - return proxyResult - }, - //default init node of exedit - _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { - if (!n) return; - n.isHover = false; - n.editNameFlag = false; - }, - //update zTreeObj, add method of edit - _zTreeTools = function(setting, zTreeTools) { - zTreeTools.cancelEditName = function(newName) { - var root = data.getRoot(setting), - nameKey = setting.data.key.name, - node = root.curEditNode; - if (!root.curEditNode) return; - view.cancelCurEditNode(setting, newName?newName:node[nameKey]); - } - zTreeTools.copyNode = function(targetNode, node, moveType, isSilent) { - if (!node) return null; - if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null; - var newNode = tools.clone(node); - if (!targetNode) { - targetNode = null; - moveType = consts.move.TYPE_INNER; - } - if (moveType == consts.move.TYPE_INNER) { - function copyCallback() { - view.addNodes(setting, targetNode, [newNode], isSilent); - } - - if (tools.canAsync(setting, targetNode)) { - view.asyncNode(setting, targetNode, isSilent, copyCallback); - } else { - copyCallback(); - } - } else { - view.addNodes(setting, targetNode.parentNode, [newNode], isSilent); - view.moveNode(setting, targetNode, newNode, moveType, false, isSilent); - } - return newNode; - } - zTreeTools.editName = function(node) { - if (!node || !node.tId || node !== data.getNodeCache(setting, node.tId)) return; - if (node.parentTId) view.expandCollapseParentNode(setting, node.getParentNode(), true); - view.editNode(setting, node) - } - zTreeTools.moveNode = function(targetNode, node, moveType, isSilent) { - if (!node) return node; - if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) { - return null; - } else if (targetNode && ((node.parentTId == targetNode.tId && moveType == consts.move.TYPE_INNER) || $("#" + node.tId).find("#" + targetNode.tId).length > 0)) { - return null; - } else if (!targetNode) { - targetNode = null; - } - function moveCallback() { - view.moveNode(setting, targetNode, node, moveType, false, isSilent); - } - if (tools.canAsync(setting, targetNode) && moveType === consts.move.TYPE_INNER) { - view.asyncNode(setting, targetNode, isSilent, moveCallback); - } else { - moveCallback(); - } - return node; - } - zTreeTools.setEditable = function(editable) { - setting.edit.enable = editable; - return this.refresh(); - } - }, - //method of operate data - _data = { - setSonNodeLevel: function(setting, parentNode, node) { - if (!node) return; - var childKey = setting.data.key.children; - node.level = (parentNode)? parentNode.level + 1 : 0; - if (!node[childKey]) return; - for (var i = 0, l = node[childKey].length; i < l; i++) { - if (node[childKey][i]) data.setSonNodeLevel(setting, node, node[childKey][i]); - } - } - }, - //method of event proxy - _event = { - - }, - //method of event handler - _handler = { - onHoverOverNode: function(event, node) { - var setting = data.getSetting(event.data.treeId), - root = data.getRoot(setting); - if (root.curHoverNode != node) { - _handler.onHoverOutNode(event); - } - root.curHoverNode = node; - view.addHoverDom(setting, node); - }, - onHoverOutNode: function(event, node) { - var setting = data.getSetting(event.data.treeId), - root = data.getRoot(setting); - if (root.curHoverNode && !data.isSelectedNode(setting, root.curHoverNode)) { - view.removeTreeDom(setting, root.curHoverNode); - root.curHoverNode = null; - } - }, - onMousedownNode: function(eventMouseDown, _node) { - var i,l, - setting = data.getSetting(eventMouseDown.data.treeId), - root = data.getRoot(setting); - //right click can't drag & drop - if (eventMouseDown.button == 2 || !setting.edit.enable || (!setting.edit.drag.isCopy && !setting.edit.drag.isMove)) return true; - - //input of edit node name can't drag & drop - var target = eventMouseDown.target, - _nodes = data.getRoot(setting).curSelectedList, - nodes = []; - if (!data.isSelectedNode(setting, _node)) { - nodes = [_node]; - } else { - for (i=0, l=_nodes.length; i1) { - var pNodes = nodes[0].parentTId ? nodes[0].getParentNode()[childKey] : data.getNodes(setting); - tmpNodes = []; - for (i=0, l=pNodes.length; i -1 && (lastIndex+1) !== i) { - isOrder = false; - } - tmpNodes.push(pNodes[i]); - lastIndex = i; - } - if (nodes.length === tmpNodes.length) { - nodes = tmpNodes; - break; - } - } - } - if (isOrder) { - preNode = nodes[0].getPreNode(); - nextNode = nodes[nodes.length-1].getNextNode(); - } - - //set node in selected - curNode = $("
              "); - for (i=0, l=nodes.length; i0); - view.removeTreeDom(setting, tmpNode); - - tmpDom = $("
            • "); - tmpDom.append($("#" + tmpNode.tId + consts.id.A).clone()); - tmpDom.css("padding", "0"); - tmpDom.children("#" + tmpNode.tId + consts.id.A).removeClass(consts.node.CURSELECTED); - curNode.append(tmpDom); - if (i == setting.edit.drag.maxShowNodeNum-1) { - tmpDom = $("
            • ...
            • "); - curNode.append(tmpDom); - break; - } - } - curNode.attr("id", nodes[0].tId + consts.id.UL + "_tmp"); - curNode.addClass(setting.treeObj.attr("class")); - curNode.appendTo("body"); - - tmpArrow = $(""); - tmpArrow.attr("id", "zTreeMove_arrow_tmp"); - tmpArrow.appendTo("body"); - - setting.treeObj.trigger(consts.event.DRAG, [event, setting.treeId, nodes]); - } - - if (root.dragFlag == 1) { - if (tmpTarget && tmpArrow.attr("id") == event.target.id && tmpTargetNodeId && (event.clientX + doc.scrollLeft()+2) > ($("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left)) { - var xT = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget); - event.target = (xT.length > 0) ? xT.get(0) : event.target; - } else if (tmpTarget) { - tmpTarget.removeClass(consts.node.TMPTARGET_TREE); - if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) - .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); - } - tmpTarget = null; - tmpTargetNodeId = null; - - //judge drag & drop in multi ztree - isOtherTree = false; - targetSetting = setting; - var settings = data.getSettings(); - for (var s in settings) { - if (settings[s].treeId && settings[s].edit.enable && settings[s].treeId != setting.treeId - && (event.target.id == settings[s].treeId || $(event.target).parents("#" + settings[s].treeId).length>0)) { - isOtherTree = true; - targetSetting = settings[s]; - } - } - - var docScrollTop = doc.scrollTop(), - docScrollLeft = doc.scrollLeft(), - treeOffset = targetSetting.treeObj.offset(), - scrollHeight = targetSetting.treeObj.get(0).scrollHeight, - scrollWidth = targetSetting.treeObj.get(0).scrollWidth, - dTop = (event.clientY + docScrollTop - treeOffset.top), - dBottom = (targetSetting.treeObj.height() + treeOffset.top - event.clientY - docScrollTop), - dLeft = (event.clientX + docScrollLeft - treeOffset.left), - dRight = (targetSetting.treeObj.width() + treeOffset.left - event.clientX - docScrollLeft), - isTop = (dTop < setting.edit.drag.borderMax && dTop > setting.edit.drag.borderMin), - isBottom = (dBottom < setting.edit.drag.borderMax && dBottom > setting.edit.drag.borderMin), - isLeft = (dLeft < setting.edit.drag.borderMax && dLeft > setting.edit.drag.borderMin), - isRight = (dRight < setting.edit.drag.borderMax && dRight > setting.edit.drag.borderMin), - isTreeInner = dTop > setting.edit.drag.borderMin && dBottom > setting.edit.drag.borderMin && dLeft > setting.edit.drag.borderMin && dRight > setting.edit.drag.borderMin, - isTreeTop = (isTop && targetSetting.treeObj.scrollTop() <= 0), - isTreeBottom = (isBottom && (targetSetting.treeObj.scrollTop() + targetSetting.treeObj.height()+10) >= scrollHeight), - isTreeLeft = (isLeft && targetSetting.treeObj.scrollLeft() <= 0), - isTreeRight = (isRight && (targetSetting.treeObj.scrollLeft() + targetSetting.treeObj.width()+10) >= scrollWidth); - - if (event.target.id && targetSetting.treeObj.find("#" + event.target.id).length > 0) { - //get node
            • dom - var targetObj = event.target; - while (targetObj && targetObj.tagName && !tools.eqs(targetObj.tagName, "li") && targetObj.id != targetSetting.treeId) { - targetObj = targetObj.parentNode; - } - - var canMove = true; - //don't move to self or children of self - for (i=0, l=nodes.length; i 0) { - canMove = false; - break; - } - } - if (canMove) { - if (event.target.id && - (event.target.id == (targetObj.id + consts.id.A) || $(event.target).parents("#" + targetObj.id + consts.id.A).length > 0)) { - tmpTarget = $(targetObj); - tmpTargetNodeId = targetObj.id; - } - } - } - - //the mouse must be in zTree - tmpNode = nodes[0]; - if (isTreeInner && (event.target.id == targetSetting.treeId || $(event.target).parents("#" + targetSetting.treeId).length>0)) { - //judge mouse move in root of ztree - if (!tmpTarget && (event.target.id == targetSetting.treeId || isTreeTop || isTreeBottom || isTreeLeft || isTreeRight) && (isOtherTree || (!isOtherTree && tmpNode.parentTId))) { - tmpTarget = targetSetting.treeObj; - } - //auto scroll top - if (isTop) { - targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()-10); - } else if (isBottom) { - targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()+10); - } - if (isLeft) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()-10); - } else if (isRight) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+10); - } - //auto scroll left - if (tmpTarget && tmpTarget != targetSetting.treeObj && tmpTarget.offset().left < targetSetting.treeObj.offset().left) { - targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+ tmpTarget.offset().left - targetSetting.treeObj.offset().left); - } - } - - curNode.css({ - "top": (event.clientY + docScrollTop + 3) + "px", - "left": (event.clientX + docScrollLeft + 3) + "px" - }); - - var dX = 0; - var dY = 0; - if (tmpTarget && tmpTarget.attr("id")!=targetSetting.treeId) { - var tmpTargetNode = tmpTargetNodeId == null ? null: data.getNodeCache(targetSetting, tmpTargetNodeId), - isCopy = (event.ctrlKey && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy), - isPrev = !!(preNode && tmpTargetNodeId === preNode.tId), - isNext = !!(nextNode && tmpTargetNodeId === nextNode.tId), - isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId), - canPrev = (isCopy || !isNext) && tools.apply(targetSetting.edit.drag.prev, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.prev), - canNext = (isCopy || !isPrev) && tools.apply(targetSetting.edit.drag.next, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.next), - canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !tmpTargetNode.isParent) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner); - if (!canPrev && !canNext && !canInner) { - tmpTarget = null; - tmpTargetNodeId = ""; - moveType = consts.move.TYPE_INNER; - tmpArrow.css({ - "display":"none" - }); - if (window.zTreeMoveTimer) { - clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null - } - } else { - var tmpTargetA = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget), - tmpNextA = tmpTargetNode.isLastNode ? null : $("#" + tmpTargetNode.getNextNode().tId + consts.id.A, tmpTarget.next()), - tmpTop = tmpTargetA.offset().top, - tmpLeft = tmpTargetA.offset().left, - prevPercent = canPrev ? (canInner ? 0.25 : (canNext ? 0.5 : 1) ) : -1, - nextPercent = canNext ? (canInner ? 0.75 : (canPrev ? 0.5 : 0) ) : -1, - dY_percent = (event.clientY + docScrollTop - tmpTop)/tmpTargetA.height(); - if ((prevPercent==1 ||dY_percent<=prevPercent && dY_percent>=-.2) && canPrev) { - dX = 1 - tmpArrow.width(); - dY = tmpTop - tmpArrow.height()/2; - moveType = consts.move.TYPE_PREV; - } else if ((nextPercent==0 || dY_percent>=nextPercent && dY_percent<=1.2) && canNext) { - dX = 1 - tmpArrow.width(); - dY = (tmpNextA == null || (tmpTargetNode.isParent && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height()/2) : (tmpNextA.offset().top - tmpArrow.height()/2); - moveType = consts.move.TYPE_NEXT; - }else { - dX = 5 - tmpArrow.width(); - dY = tmpTop; - moveType = consts.move.TYPE_INNER; - } - tmpArrow.css({ - "display":"block", - "top": dY + "px", - "left": (tmpLeft + dX) + "px" - }); - tmpTargetA.addClass(consts.node.TMPTARGET_NODE + "_" + moveType); - - if (preTmpTargetNodeId != tmpTargetNodeId || preTmpMoveType != moveType) { - startTime = (new Date()).getTime(); - } - if (tmpTargetNode && tmpTargetNode.isParent && moveType == consts.move.TYPE_INNER) { - var startTimer = true; - if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId) { - clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null; - } else if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId === tmpTargetNode.tId) { - startTimer = false; - } - if (startTimer) { - window.zTreeMoveTimer = setTimeout(function() { - if (moveType != consts.move.TYPE_INNER) return; - if (tmpTargetNode && tmpTargetNode.isParent && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime - && tools.apply(targetSetting.callback.beforeDragOpen, [targetSetting.treeId, tmpTargetNode], true)) { - view.switchNode(targetSetting, tmpTargetNode); - if (targetSetting.edit.drag.autoExpandTrigger) { - targetSetting.treeObj.trigger(consts.event.EXPAND, [targetSetting.treeId, tmpTargetNode]); - } - } - }, targetSetting.edit.drag.autoOpenTime+50); - window.zTreeMoveTargetNodeTId = tmpTargetNode.tId; - } - } - } - } else { - moveType = consts.move.TYPE_INNER; - if (tmpTarget && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, null], !!targetSetting.edit.drag.inner)) { - tmpTarget.addClass(consts.node.TMPTARGET_TREE); - } else { - tmpTarget = null; - } - tmpArrow.css({ - "display":"none" - }); - if (window.zTreeMoveTimer) { - clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null; - } - } - preTmpTargetNodeId = tmpTargetNodeId; - preTmpMoveType = moveType; - } - return false; - } - - doc.bind("mouseup", _docMouseUp); - function _docMouseUp(event) { - if (window.zTreeMoveTimer) { - clearTimeout(window.zTreeMoveTimer); - window.zTreeMoveTargetNodeTId = null; - } - preTmpTargetNodeId = null; - preTmpMoveType = null; - doc.unbind("mousemove", _docMouseMove); - doc.unbind("mouseup", _docMouseUp); - doc.unbind("selectstart", _docSelect); - $("body").css("cursor", "auto"); - if (tmpTarget) { - tmpTarget.removeClass(consts.node.TMPTARGET_TREE); - if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) - .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); - } - tools.showIfameMask(setting, false); - - root.showHoverDom = true; - if (root.dragFlag == 0) return; - root.dragFlag = 0; - - var i, l, tmpNode; - for (i=0, l=nodes.length; i0); - } - $("#" + newNodes[0].tId).focus().blur(); - - setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]); - } - - if (moveType == consts.move.TYPE_INNER && tools.canAsync(targetSetting, dragTargetNode)) { - view.asyncNode(targetSetting, dragTargetNode, false, dropCallback); - } else { - dropCallback(); - } - - } else { - for (i=0, l=nodes.length; i0); - } - setting.treeObj.trigger(consts.event.DROP, [event, setting.treeId, nodes, null, null, null]); - } - } - - doc.bind("selectstart", _docSelect); - function _docSelect() { - return false; - } - - //Avoid FireFox's Bug - //If zTree Div CSS set 'overflow', so drag node outside of zTree, and event.target is error. - if(eventMouseDown.preventDefault) { - eventMouseDown.preventDefault(); - } - return true; - } - }, - //method of tools for zTree - _tools = { - getAbs: function (obj) { - var oRect = obj.getBoundingClientRect(); - return [oRect.left,oRect.top] - }, - inputFocus: function(inputObj) { - if (inputObj.get(0)) { - inputObj.focus(); - tools.setCursorPosition(inputObj.get(0), inputObj.val().length); - } - }, - inputSelect: function(inputObj) { - if (inputObj.get(0)) { - inputObj.focus(); - inputObj.select(); - } - }, - setCursorPosition: function(obj, pos){ - if(obj.setSelectionRange) { - obj.focus(); - obj.setSelectionRange(pos,pos); - } else if (obj.createTextRange) { - var range = obj.createTextRange(); - range.collapse(true); - range.moveEnd('character', pos); - range.moveStart('character', pos); - range.select(); - } - }, - showIfameMask: function(setting, showSign) { - var root = data.getRoot(setting); - //clear full mask - while (root.dragMaskList.length > 0) { - root.dragMaskList[0].remove(); - root.dragMaskList.shift(); - } - if (showSign) { - //show mask - var iframeList = $("iframe"); - for (var i = 0, l = iframeList.length; i < l; i++) { - var obj = iframeList.get(i), - r = tools.getAbs(obj), - dragMask = $("
              "); - dragMask.appendTo("body"); - root.dragMaskList.push(dragMask); - } - } - } - }, - //method of operate ztree dom - _view = { - addEditBtn: function(setting, node) { - if (node.editNameFlag || $("#" + node.tId + consts.id.EDIT).length > 0) { - return; - } - if (!tools.apply(setting.edit.showRenameBtn, [setting.treeId, node], setting.edit.showRenameBtn)) { - return; - } - var aObj = $("#" + node.tId + consts.id.A), - editStr = ""; - aObj.append(editStr); - - $("#" + node.tId + consts.id.EDIT).bind('click', - function() { - if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeEditName, [setting.treeId, node], true) == false) return false; - view.editNode(setting, node); - return false; - } - ).show(); - }, - addRemoveBtn: function(setting, node) { - if (node.editNameFlag || $("#" + node.tId + consts.id.REMOVE).length > 0) { - return; - } - if (!tools.apply(setting.edit.showRemoveBtn, [setting.treeId, node], setting.edit.showRemoveBtn)) { - return; - } - var aObj = $("#" + node.tId + consts.id.A), - removeStr = ""; - aObj.append(removeStr); - - $("#" + node.tId + consts.id.REMOVE).bind('click', - function() { - if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return false; - view.removeNode(setting, node); - setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]); - return false; - } - ).bind('mousedown', - function(eventMouseDown) { - return true; - } - ).show(); - }, - addHoverDom: function(setting, node) { - if (data.getRoot(setting).showHoverDom) { - node.isHover = true; - if (setting.edit.enable) { - view.addEditBtn(setting, node); - view.addRemoveBtn(setting, node); - } - tools.apply(setting.view.addHoverDom, [setting.treeId, node]); - } - }, - cancelCurEditNode: function (setting, forceName) { - var root = data.getRoot(setting), - nameKey = setting.data.key.name, - node = root.curEditNode; - - if (node) { - var inputObj = root.curEditInput; - var newName = forceName ? forceName:inputObj.val(); - if (!forceName && tools.apply(setting.callback.beforeRename, [setting.treeId, node, newName], true) === false) { - return false; - } else { - node[nameKey] = newName ? newName:inputObj.val(); - if (!forceName) { - setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node]); - } - } - var aObj = $("#" + node.tId + consts.id.A); - aObj.removeClass(consts.node.CURSELECTED_EDIT); - inputObj.unbind(); - view.setNodeName(setting, node); - node.editNameFlag = false; - root.curEditNode = null; - root.curEditInput = null; - view.selectNode(setting, node, false); - } - root.noSelection = true; - return true; - }, - editNode: function(setting, node) { - var root = data.getRoot(setting); - view.editNodeBlur = false; - if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) { - setTimeout(function() {tools.inputFocus(root.curEditInput);}, 0); - return; - } - var nameKey = setting.data.key.name; - node.editNameFlag = true; - view.removeTreeDom(setting, node); - view.cancelCurEditNode(setting); - view.selectNode(setting, node, false); - $("#" + node.tId + consts.id.SPAN).html(""); - var inputObj = $("#" + node.tId + consts.id.INPUT); - inputObj.attr("value", node[nameKey]); - if (setting.edit.editNameSelectAll) { - tools.inputSelect(inputObj); - } else { - tools.inputFocus(inputObj); - } - - inputObj.bind('blur', function(event) { - if (!view.editNodeBlur) { - view.cancelCurEditNode(setting); - } - }).bind('keydown', function(event) { - if (event.keyCode=="13") { - view.editNodeBlur = true; - view.cancelCurEditNode(setting, null, true); - } else if (event.keyCode=="27") { - view.cancelCurEditNode(setting, node[nameKey]); - } - }).bind('click', function(event) { - return false; - }).bind('dblclick', function(event) { - return false; - }); - - $("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED_EDIT); - root.curEditInput = inputObj; - root.noSelection = false; - root.curEditNode = node; - }, - moveNode: function(setting, targetNode, node, moveType, animateFlag, isSilent) { - var root = data.getRoot(setting), - childKey = setting.data.key.children; - if (targetNode == node) return; - if (setting.data.keep.leaf && targetNode && !targetNode.isParent && moveType == consts.move.TYPE_INNER) return; - var oldParentNode = (node.parentTId ? node.getParentNode(): root), - targetNodeIsRoot = (targetNode === null || targetNode == root); - if (targetNodeIsRoot && targetNode === null) targetNode = root; - if (targetNodeIsRoot) moveType = consts.move.TYPE_INNER; - var targetParentNode = (targetNode.parentTId ? targetNode.getParentNode() : root); - - if (moveType != consts.move.TYPE_PREV && moveType != consts.move.TYPE_NEXT) { - moveType = consts.move.TYPE_INNER; - } - - if (moveType == consts.move.TYPE_INNER) { - if (targetNodeIsRoot) { - //parentTId of root node is null - node.parentTId = null; - } else { - if (!targetNode.isParent) { - targetNode.isParent = true; - targetNode.open = !!targetNode.open; - view.setNodeLineIcos(setting, targetNode); - } - node.parentTId = targetNode.tId; - } - } - - //move node Dom - var targetObj, target_ulObj; - if (targetNodeIsRoot) { - targetObj = setting.treeObj; - target_ulObj = targetObj; - } else { - if (!isSilent && moveType == consts.move.TYPE_INNER) { - view.expandCollapseNode(setting, targetNode, true, false); - } else if (!isSilent) { - view.expandCollapseNode(setting, targetNode.getParentNode(), true, false); - } - targetObj = $("#" + targetNode.tId); - target_ulObj = $("#" + targetNode.tId + consts.id.UL); - if (!!targetObj.get(0) && !target_ulObj.get(0)) { - var ulstr = []; - view.makeUlHtml(setting, targetNode, ulstr, ''); - targetObj.append(ulstr.join('')); - } - target_ulObj = $("#" + targetNode.tId + consts.id.UL); - } - var nodeDom = $("#" + node.tId); - if (!nodeDom.get(0)) { - nodeDom = view.appendNodes(setting, node.level, [node], null, false, true).join(''); - } else if (!targetObj.get(0)) { - nodeDom.remove(); - } - if (target_ulObj.get(0) && moveType == consts.move.TYPE_INNER) { - target_ulObj.append(nodeDom); - } else if (targetObj.get(0) && moveType == consts.move.TYPE_PREV) { - targetObj.before(nodeDom); - } else if (targetObj.get(0) && moveType == consts.move.TYPE_NEXT) { - targetObj.after(nodeDom); - } - - //repair the data after move - var i,l, - tmpSrcIndex = -1, - tmpTargetIndex = 0, - oldNeighbor = null, - newNeighbor = null, - oldLevel = node.level; - if (node.isFirstNode) { - tmpSrcIndex = 0; - if (oldParentNode[childKey].length > 1 ) { - oldNeighbor = oldParentNode[childKey][1]; - oldNeighbor.isFirstNode = true; - } - } else if (node.isLastNode) { - tmpSrcIndex = oldParentNode[childKey].length -1; - oldNeighbor = oldParentNode[childKey][tmpSrcIndex - 1]; - oldNeighbor.isLastNode = true; - } else { - for (i = 0, l = oldParentNode[childKey].length; i < l; i++) { - if (oldParentNode[childKey][i].tId == node.tId) { - tmpSrcIndex = i; - break; - } - } - } - if (tmpSrcIndex >= 0) { - oldParentNode[childKey].splice(tmpSrcIndex, 1); - } - if (moveType != consts.move.TYPE_INNER) { - for (i = 0, l = targetParentNode[childKey].length; i < l; i++) { - if (targetParentNode[childKey][i].tId == targetNode.tId) tmpTargetIndex = i; - } - } - if (moveType == consts.move.TYPE_INNER) { - if (!targetNode[childKey]) targetNode[childKey] = new Array(); - if (targetNode[childKey].length > 0) { - newNeighbor = targetNode[childKey][targetNode[childKey].length - 1]; - newNeighbor.isLastNode = false; - } - targetNode[childKey].splice(targetNode[childKey].length, 0, node); - node.isLastNode = true; - node.isFirstNode = (targetNode[childKey].length == 1); - } else if (targetNode.isFirstNode && moveType == consts.move.TYPE_PREV) { - targetParentNode[childKey].splice(tmpTargetIndex, 0, node); - newNeighbor = targetNode; - newNeighbor.isFirstNode = false; - node.parentTId = targetNode.parentTId; - node.isFirstNode = true; - node.isLastNode = false; - - } else if (targetNode.isLastNode && moveType == consts.move.TYPE_NEXT) { - targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node); - newNeighbor = targetNode; - newNeighbor.isLastNode = false; - node.parentTId = targetNode.parentTId; - node.isFirstNode = false; - node.isLastNode = true; - - } else { - if (moveType == consts.move.TYPE_PREV) { - targetParentNode[childKey].splice(tmpTargetIndex, 0, node); - } else { - targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node); - } - node.parentTId = targetNode.parentTId; - node.isFirstNode = false; - node.isLastNode = false; - } - data.fixPIdKeyValue(setting, node); - data.setSonNodeLevel(setting, node.getParentNode(), node); - - //repair node what been moved - view.setNodeLineIcos(setting, node); - view.repairNodeLevelClass(setting, node, oldLevel) - - //repair node's old parentNode dom - if (!setting.data.keep.parent && oldParentNode[childKey].length < 1) { - //old parentNode has no child nodes - oldParentNode.isParent = false; - oldParentNode.open = false; - var tmp_ulObj = $("#" + oldParentNode.tId + consts.id.UL), - tmp_switchObj = $("#" + oldParentNode.tId + consts.id.SWITCH), - tmp_icoObj = $("#" + oldParentNode.tId + consts.id.ICON); - view.replaceSwitchClass(oldParentNode, tmp_switchObj, consts.folder.DOCU); - view.replaceIcoClass(oldParentNode, tmp_icoObj, consts.folder.DOCU); - tmp_ulObj.css("display", "none"); - - } else if (oldNeighbor) { - //old neigbor node - view.setNodeLineIcos(setting, oldNeighbor); - } - - //new neigbor node - if (newNeighbor) { - view.setNodeLineIcos(setting, newNeighbor); - } - - //repair checkbox / radio - if (!!setting.check && setting.check.enable && view.repairChkClass) { - view.repairChkClass(setting, oldParentNode); - view.repairParentChkClassWithSelf(setting, oldParentNode); - if (oldParentNode != node.parent) - view.repairParentChkClassWithSelf(setting, node); - } - - //expand parents after move - if (!isSilent) { - view.expandCollapseParentNode(setting, node.getParentNode(), true, animateFlag); - } - }, - removeEditBtn: function(node) { - $("#" + node.tId + consts.id.EDIT).unbind().remove(); - }, - removeRemoveBtn: function(node) { - $("#" + node.tId + consts.id.REMOVE).unbind().remove(); - }, - removeTreeDom: function(setting, node) { - node.isHover = false; - view.removeEditBtn(node); - view.removeRemoveBtn(node); - tools.apply(setting.view.removeHoverDom, [setting.treeId, node]); - }, - repairNodeLevelClass: function(setting, node, oldLevel) { - if (oldLevel === node.level) return; - var liObj = $("#" + node.tId), - aObj = $("#" + node.tId + consts.id.A), - ulObj = $("#" + node.tId + consts.id.UL), - oldClass = consts.className.LEVEL + oldLevel, - newClass = consts.className.LEVEL + node.level; - liObj.removeClass(oldClass); - liObj.addClass(newClass); - aObj.removeClass(oldClass); - aObj.addClass(newClass); - ulObj.removeClass(oldClass); - ulObj.addClass(newClass); - } - }, - - _z = { - tools: _tools, - view: _view, - event: _event, - data: _data - }; - $.extend(true, $.fn.zTree.consts, _consts); - $.extend(true, $.fn.zTree._z, _z); - - var zt = $.fn.zTree, - tools = zt._z.tools, - consts = zt.consts, - view = zt._z.view, - data = zt._z.data, - event = zt._z.event; - - data.exSetting(_setting); - data.addInitBind(_bindEvent); - data.addInitUnBind(_unbindEvent); - data.addInitCache(_initCache); - data.addInitNode(_initNode); - data.addInitProxy(_eventProxy); - data.addInitRoot(_initRoot); - data.addZTreeTools(_zTreeTools); - - var _cancelPreSelectedNode = view.cancelPreSelectedNode; - view.cancelPreSelectedNode = function (setting, node) { - var list = data.getRoot(setting).curSelectedList; - for (var i=0, j=list.length; i0) { + node = data.getNodeCache(setting, tId); + switch (nodeEventType) { + case "mousedownNode" : + nodeEventCallback = _handler.onMousedownNode; + break; + case "hoverOverNode" : + nodeEventCallback = _handler.onHoverOverNode; + break; + case "hoverOutNode" : + nodeEventCallback = _handler.onHoverOutNode; + break; + } + } + var proxyResult = { + stop: false, + node: node, + nodeEventType: nodeEventType, + nodeEventCallback: nodeEventCallback, + treeEventType: treeEventType, + treeEventCallback: treeEventCallback + }; + return proxyResult + }, + //default init node of exedit + _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + if (!n) return; + n.isHover = false; + n.editNameFlag = false; + }, + //update zTreeObj, add method of edit + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.cancelEditName = function(newName) { + var root = data.getRoot(setting), + nameKey = setting.data.key.name, + node = root.curEditNode; + if (!root.curEditNode) return; + view.cancelCurEditNode(setting, newName?newName:node[nameKey]); + } + zTreeTools.copyNode = function(targetNode, node, moveType, isSilent) { + if (!node) return null; + if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null; + var newNode = tools.clone(node); + if (!targetNode) { + targetNode = null; + moveType = consts.move.TYPE_INNER; + } + if (moveType == consts.move.TYPE_INNER) { + function copyCallback() { + view.addNodes(setting, targetNode, [newNode], isSilent); + } + + if (tools.canAsync(setting, targetNode)) { + view.asyncNode(setting, targetNode, isSilent, copyCallback); + } else { + copyCallback(); + } + } else { + view.addNodes(setting, targetNode.parentNode, [newNode], isSilent); + view.moveNode(setting, targetNode, newNode, moveType, false, isSilent); + } + return newNode; + } + zTreeTools.editName = function(node) { + if (!node || !node.tId || node !== data.getNodeCache(setting, node.tId)) return; + if (node.parentTId) view.expandCollapseParentNode(setting, node.getParentNode(), true); + view.editNode(setting, node) + } + zTreeTools.moveNode = function(targetNode, node, moveType, isSilent) { + if (!node) return node; + if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) { + return null; + } else if (targetNode && ((node.parentTId == targetNode.tId && moveType == consts.move.TYPE_INNER) || $("#" + node.tId).find("#" + targetNode.tId).length > 0)) { + return null; + } else if (!targetNode) { + targetNode = null; + } + function moveCallback() { + view.moveNode(setting, targetNode, node, moveType, false, isSilent); + } + if (tools.canAsync(setting, targetNode) && moveType === consts.move.TYPE_INNER) { + view.asyncNode(setting, targetNode, isSilent, moveCallback); + } else { + moveCallback(); + } + return node; + } + zTreeTools.setEditable = function(editable) { + setting.edit.enable = editable; + return this.refresh(); + } + }, + //method of operate data + _data = { + setSonNodeLevel: function(setting, parentNode, node) { + if (!node) return; + var childKey = setting.data.key.children; + node.level = (parentNode)? parentNode.level + 1 : 0; + if (!node[childKey]) return; + for (var i = 0, l = node[childKey].length; i < l; i++) { + if (node[childKey][i]) data.setSonNodeLevel(setting, node, node[childKey][i]); + } + } + }, + //method of event proxy + _event = { + + }, + //method of event handler + _handler = { + onHoverOverNode: function(event, node) { + var setting = data.getSetting(event.data.treeId), + root = data.getRoot(setting); + if (root.curHoverNode != node) { + _handler.onHoverOutNode(event); + } + root.curHoverNode = node; + view.addHoverDom(setting, node); + }, + onHoverOutNode: function(event, node) { + var setting = data.getSetting(event.data.treeId), + root = data.getRoot(setting); + if (root.curHoverNode && !data.isSelectedNode(setting, root.curHoverNode)) { + view.removeTreeDom(setting, root.curHoverNode); + root.curHoverNode = null; + } + }, + onMousedownNode: function(eventMouseDown, _node) { + var i,l, + setting = data.getSetting(eventMouseDown.data.treeId), + root = data.getRoot(setting); + //right click can't drag & drop + if (eventMouseDown.button == 2 || !setting.edit.enable || (!setting.edit.drag.isCopy && !setting.edit.drag.isMove)) return true; + + //input of edit node name can't drag & drop + var target = eventMouseDown.target, + _nodes = data.getRoot(setting).curSelectedList, + nodes = []; + if (!data.isSelectedNode(setting, _node)) { + nodes = [_node]; + } else { + for (i=0, l=_nodes.length; i1) { + var pNodes = nodes[0].parentTId ? nodes[0].getParentNode()[childKey] : data.getNodes(setting); + tmpNodes = []; + for (i=0, l=pNodes.length; i -1 && (lastIndex+1) !== i) { + isOrder = false; + } + tmpNodes.push(pNodes[i]); + lastIndex = i; + } + if (nodes.length === tmpNodes.length) { + nodes = tmpNodes; + break; + } + } + } + if (isOrder) { + preNode = nodes[0].getPreNode(); + nextNode = nodes[nodes.length-1].getNextNode(); + } + + //set node in selected + curNode = $("
                "); + for (i=0, l=nodes.length; i0); + view.removeTreeDom(setting, tmpNode); + + tmpDom = $("
              • "); + tmpDom.append($("#" + tmpNode.tId + consts.id.A).clone()); + tmpDom.css("padding", "0"); + tmpDom.children("#" + tmpNode.tId + consts.id.A).removeClass(consts.node.CURSELECTED); + curNode.append(tmpDom); + if (i == setting.edit.drag.maxShowNodeNum-1) { + tmpDom = $("
              • ...
              • "); + curNode.append(tmpDom); + break; + } + } + curNode.attr("id", nodes[0].tId + consts.id.UL + "_tmp"); + curNode.addClass(setting.treeObj.attr("class")); + curNode.appendTo("body"); + + tmpArrow = $(""); + tmpArrow.attr("id", "zTreeMove_arrow_tmp"); + tmpArrow.appendTo("body"); + + setting.treeObj.trigger(consts.event.DRAG, [event, setting.treeId, nodes]); + } + + if (root.dragFlag == 1) { + if (tmpTarget && tmpArrow.attr("id") == event.target.id && tmpTargetNodeId && (event.clientX + doc.scrollLeft()+2) > ($("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left)) { + var xT = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget); + event.target = (xT.length > 0) ? xT.get(0) : event.target; + } else if (tmpTarget) { + tmpTarget.removeClass(consts.node.TMPTARGET_TREE); + if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) + .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); + } + tmpTarget = null; + tmpTargetNodeId = null; + + //judge drag & drop in multi ztree + isOtherTree = false; + targetSetting = setting; + var settings = data.getSettings(); + for (var s in settings) { + if (settings[s].treeId && settings[s].edit.enable && settings[s].treeId != setting.treeId + && (event.target.id == settings[s].treeId || $(event.target).parents("#" + settings[s].treeId).length>0)) { + isOtherTree = true; + targetSetting = settings[s]; + } + } + + var docScrollTop = doc.scrollTop(), + docScrollLeft = doc.scrollLeft(), + treeOffset = targetSetting.treeObj.offset(), + scrollHeight = targetSetting.treeObj.get(0).scrollHeight, + scrollWidth = targetSetting.treeObj.get(0).scrollWidth, + dTop = (event.clientY + docScrollTop - treeOffset.top), + dBottom = (targetSetting.treeObj.height() + treeOffset.top - event.clientY - docScrollTop), + dLeft = (event.clientX + docScrollLeft - treeOffset.left), + dRight = (targetSetting.treeObj.width() + treeOffset.left - event.clientX - docScrollLeft), + isTop = (dTop < setting.edit.drag.borderMax && dTop > setting.edit.drag.borderMin), + isBottom = (dBottom < setting.edit.drag.borderMax && dBottom > setting.edit.drag.borderMin), + isLeft = (dLeft < setting.edit.drag.borderMax && dLeft > setting.edit.drag.borderMin), + isRight = (dRight < setting.edit.drag.borderMax && dRight > setting.edit.drag.borderMin), + isTreeInner = dTop > setting.edit.drag.borderMin && dBottom > setting.edit.drag.borderMin && dLeft > setting.edit.drag.borderMin && dRight > setting.edit.drag.borderMin, + isTreeTop = (isTop && targetSetting.treeObj.scrollTop() <= 0), + isTreeBottom = (isBottom && (targetSetting.treeObj.scrollTop() + targetSetting.treeObj.height()+10) >= scrollHeight), + isTreeLeft = (isLeft && targetSetting.treeObj.scrollLeft() <= 0), + isTreeRight = (isRight && (targetSetting.treeObj.scrollLeft() + targetSetting.treeObj.width()+10) >= scrollWidth); + + if (event.target.id && targetSetting.treeObj.find("#" + event.target.id).length > 0) { + //get node
              • dom + var targetObj = event.target; + while (targetObj && targetObj.tagName && !tools.eqs(targetObj.tagName, "li") && targetObj.id != targetSetting.treeId) { + targetObj = targetObj.parentNode; + } + + var canMove = true; + //don't move to self or children of self + for (i=0, l=nodes.length; i 0) { + canMove = false; + break; + } + } + if (canMove) { + if (event.target.id && + (event.target.id == (targetObj.id + consts.id.A) || $(event.target).parents("#" + targetObj.id + consts.id.A).length > 0)) { + tmpTarget = $(targetObj); + tmpTargetNodeId = targetObj.id; + } + } + } + + //the mouse must be in zTree + tmpNode = nodes[0]; + if (isTreeInner && (event.target.id == targetSetting.treeId || $(event.target).parents("#" + targetSetting.treeId).length>0)) { + //judge mouse move in root of ztree + if (!tmpTarget && (event.target.id == targetSetting.treeId || isTreeTop || isTreeBottom || isTreeLeft || isTreeRight) && (isOtherTree || (!isOtherTree && tmpNode.parentTId))) { + tmpTarget = targetSetting.treeObj; + } + //auto scroll top + if (isTop) { + targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()-10); + } else if (isBottom) { + targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()+10); + } + if (isLeft) { + targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()-10); + } else if (isRight) { + targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+10); + } + //auto scroll left + if (tmpTarget && tmpTarget != targetSetting.treeObj && tmpTarget.offset().left < targetSetting.treeObj.offset().left) { + targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+ tmpTarget.offset().left - targetSetting.treeObj.offset().left); + } + } + + curNode.css({ + "top": (event.clientY + docScrollTop + 3) + "px", + "left": (event.clientX + docScrollLeft + 3) + "px" + }); + + var dX = 0; + var dY = 0; + if (tmpTarget && tmpTarget.attr("id")!=targetSetting.treeId) { + var tmpTargetNode = tmpTargetNodeId == null ? null: data.getNodeCache(targetSetting, tmpTargetNodeId), + isCopy = (event.ctrlKey && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy), + isPrev = !!(preNode && tmpTargetNodeId === preNode.tId), + isNext = !!(nextNode && tmpTargetNodeId === nextNode.tId), + isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId), + canPrev = (isCopy || !isNext) && tools.apply(targetSetting.edit.drag.prev, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.prev), + canNext = (isCopy || !isPrev) && tools.apply(targetSetting.edit.drag.next, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.next), + canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !tmpTargetNode.isParent) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner); + if (!canPrev && !canNext && !canInner) { + tmpTarget = null; + tmpTargetNodeId = ""; + moveType = consts.move.TYPE_INNER; + tmpArrow.css({ + "display":"none" + }); + if (window.zTreeMoveTimer) { + clearTimeout(window.zTreeMoveTimer); + window.zTreeMoveTargetNodeTId = null + } + } else { + var tmpTargetA = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget), + tmpNextA = tmpTargetNode.isLastNode ? null : $("#" + tmpTargetNode.getNextNode().tId + consts.id.A, tmpTarget.next()), + tmpTop = tmpTargetA.offset().top, + tmpLeft = tmpTargetA.offset().left, + prevPercent = canPrev ? (canInner ? 0.25 : (canNext ? 0.5 : 1) ) : -1, + nextPercent = canNext ? (canInner ? 0.75 : (canPrev ? 0.5 : 0) ) : -1, + dY_percent = (event.clientY + docScrollTop - tmpTop)/tmpTargetA.height(); + if ((prevPercent==1 ||dY_percent<=prevPercent && dY_percent>=-.2) && canPrev) { + dX = 1 - tmpArrow.width(); + dY = tmpTop - tmpArrow.height()/2; + moveType = consts.move.TYPE_PREV; + } else if ((nextPercent==0 || dY_percent>=nextPercent && dY_percent<=1.2) && canNext) { + dX = 1 - tmpArrow.width(); + dY = (tmpNextA == null || (tmpTargetNode.isParent && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height()/2) : (tmpNextA.offset().top - tmpArrow.height()/2); + moveType = consts.move.TYPE_NEXT; + }else { + dX = 5 - tmpArrow.width(); + dY = tmpTop; + moveType = consts.move.TYPE_INNER; + } + tmpArrow.css({ + "display":"block", + "top": dY + "px", + "left": (tmpLeft + dX) + "px" + }); + tmpTargetA.addClass(consts.node.TMPTARGET_NODE + "_" + moveType); + + if (preTmpTargetNodeId != tmpTargetNodeId || preTmpMoveType != moveType) { + startTime = (new Date()).getTime(); + } + if (tmpTargetNode && tmpTargetNode.isParent && moveType == consts.move.TYPE_INNER) { + var startTimer = true; + if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId) { + clearTimeout(window.zTreeMoveTimer); + window.zTreeMoveTargetNodeTId = null; + } else if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId === tmpTargetNode.tId) { + startTimer = false; + } + if (startTimer) { + window.zTreeMoveTimer = setTimeout(function() { + if (moveType != consts.move.TYPE_INNER) return; + if (tmpTargetNode && tmpTargetNode.isParent && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime + && tools.apply(targetSetting.callback.beforeDragOpen, [targetSetting.treeId, tmpTargetNode], true)) { + view.switchNode(targetSetting, tmpTargetNode); + if (targetSetting.edit.drag.autoExpandTrigger) { + targetSetting.treeObj.trigger(consts.event.EXPAND, [targetSetting.treeId, tmpTargetNode]); + } + } + }, targetSetting.edit.drag.autoOpenTime+50); + window.zTreeMoveTargetNodeTId = tmpTargetNode.tId; + } + } + } + } else { + moveType = consts.move.TYPE_INNER; + if (tmpTarget && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, null], !!targetSetting.edit.drag.inner)) { + tmpTarget.addClass(consts.node.TMPTARGET_TREE); + } else { + tmpTarget = null; + } + tmpArrow.css({ + "display":"none" + }); + if (window.zTreeMoveTimer) { + clearTimeout(window.zTreeMoveTimer); + window.zTreeMoveTargetNodeTId = null; + } + } + preTmpTargetNodeId = tmpTargetNodeId; + preTmpMoveType = moveType; + } + return false; + } + + doc.bind("mouseup", _docMouseUp); + function _docMouseUp(event) { + if (window.zTreeMoveTimer) { + clearTimeout(window.zTreeMoveTimer); + window.zTreeMoveTargetNodeTId = null; + } + preTmpTargetNodeId = null; + preTmpMoveType = null; + doc.unbind("mousemove", _docMouseMove); + doc.unbind("mouseup", _docMouseUp); + doc.unbind("selectstart", _docSelect); + $("body").css("cursor", "auto"); + if (tmpTarget) { + tmpTarget.removeClass(consts.node.TMPTARGET_TREE); + if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV) + .removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER); + } + tools.showIfameMask(setting, false); + + root.showHoverDom = true; + if (root.dragFlag == 0) return; + root.dragFlag = 0; + + var i, l, tmpNode; + for (i=0, l=nodes.length; i0); + } + $("#" + newNodes[0].tId).focus().blur(); + + setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]); + } + + if (moveType == consts.move.TYPE_INNER && tools.canAsync(targetSetting, dragTargetNode)) { + view.asyncNode(targetSetting, dragTargetNode, false, dropCallback); + } else { + dropCallback(); + } + + } else { + for (i=0, l=nodes.length; i0); + } + setting.treeObj.trigger(consts.event.DROP, [event, setting.treeId, nodes, null, null, null]); + } + } + + doc.bind("selectstart", _docSelect); + function _docSelect() { + return false; + } + + //Avoid FireFox's Bug + //If zTree Div CSS set 'overflow', so drag node outside of zTree, and event.target is error. + if(eventMouseDown.preventDefault) { + eventMouseDown.preventDefault(); + } + return true; + } + }, + //method of tools for zTree + _tools = { + getAbs: function (obj) { + var oRect = obj.getBoundingClientRect(); + return [oRect.left,oRect.top] + }, + inputFocus: function(inputObj) { + if (inputObj.get(0)) { + inputObj.focus(); + tools.setCursorPosition(inputObj.get(0), inputObj.val().length); + } + }, + inputSelect: function(inputObj) { + if (inputObj.get(0)) { + inputObj.focus(); + inputObj.select(); + } + }, + setCursorPosition: function(obj, pos){ + if(obj.setSelectionRange) { + obj.focus(); + obj.setSelectionRange(pos,pos); + } else if (obj.createTextRange) { + var range = obj.createTextRange(); + range.collapse(true); + range.moveEnd('character', pos); + range.moveStart('character', pos); + range.select(); + } + }, + showIfameMask: function(setting, showSign) { + var root = data.getRoot(setting); + //clear full mask + while (root.dragMaskList.length > 0) { + root.dragMaskList[0].remove(); + root.dragMaskList.shift(); + } + if (showSign) { + //show mask + var iframeList = $("iframe"); + for (var i = 0, l = iframeList.length; i < l; i++) { + var obj = iframeList.get(i), + r = tools.getAbs(obj), + dragMask = $("
                "); + dragMask.appendTo("body"); + root.dragMaskList.push(dragMask); + } + } + } + }, + //method of operate ztree dom + _view = { + addEditBtn: function(setting, node) { + if (node.editNameFlag || $("#" + node.tId + consts.id.EDIT).length > 0) { + return; + } + if (!tools.apply(setting.edit.showRenameBtn, [setting.treeId, node], setting.edit.showRenameBtn)) { + return; + } + var aObj = $("#" + node.tId + consts.id.A), + editStr = ""; + aObj.append(editStr); + + $("#" + node.tId + consts.id.EDIT).bind('click', + function() { + if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeEditName, [setting.treeId, node], true) == false) return false; + view.editNode(setting, node); + return false; + } + ).show(); + }, + addRemoveBtn: function(setting, node) { + if (node.editNameFlag || $("#" + node.tId + consts.id.REMOVE).length > 0) { + return; + } + if (!tools.apply(setting.edit.showRemoveBtn, [setting.treeId, node], setting.edit.showRemoveBtn)) { + return; + } + var aObj = $("#" + node.tId + consts.id.A), + removeStr = ""; + aObj.append(removeStr); + + $("#" + node.tId + consts.id.REMOVE).bind('click', + function() { + if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return false; + view.removeNode(setting, node); + setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]); + return false; + } + ).bind('mousedown', + function(eventMouseDown) { + return true; + } + ).show(); + }, + addHoverDom: function(setting, node) { + if (data.getRoot(setting).showHoverDom) { + node.isHover = true; + if (setting.edit.enable) { + view.addEditBtn(setting, node); + view.addRemoveBtn(setting, node); + } + tools.apply(setting.view.addHoverDom, [setting.treeId, node]); + } + }, + cancelCurEditNode: function (setting, forceName) { + var root = data.getRoot(setting), + nameKey = setting.data.key.name, + node = root.curEditNode; + + if (node) { + var inputObj = root.curEditInput; + var newName = forceName ? forceName:inputObj.val(); + if (!forceName && tools.apply(setting.callback.beforeRename, [setting.treeId, node, newName], true) === false) { + return false; + } else { + node[nameKey] = newName ? newName:inputObj.val(); + if (!forceName) { + setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node]); + } + } + var aObj = $("#" + node.tId + consts.id.A); + aObj.removeClass(consts.node.CURSELECTED_EDIT); + inputObj.unbind(); + view.setNodeName(setting, node); + node.editNameFlag = false; + root.curEditNode = null; + root.curEditInput = null; + view.selectNode(setting, node, false); + } + root.noSelection = true; + return true; + }, + editNode: function(setting, node) { + var root = data.getRoot(setting); + view.editNodeBlur = false; + if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) { + setTimeout(function() {tools.inputFocus(root.curEditInput);}, 0); + return; + } + var nameKey = setting.data.key.name; + node.editNameFlag = true; + view.removeTreeDom(setting, node); + view.cancelCurEditNode(setting); + view.selectNode(setting, node, false); + $("#" + node.tId + consts.id.SPAN).html(""); + var inputObj = $("#" + node.tId + consts.id.INPUT); + inputObj.attr("value", node[nameKey]); + if (setting.edit.editNameSelectAll) { + tools.inputSelect(inputObj); + } else { + tools.inputFocus(inputObj); + } + + inputObj.bind('blur', function(event) { + if (!view.editNodeBlur) { + view.cancelCurEditNode(setting); + } + }).bind('keydown', function(event) { + if (event.keyCode=="13") { + view.editNodeBlur = true; + view.cancelCurEditNode(setting, null, true); + } else if (event.keyCode=="27") { + view.cancelCurEditNode(setting, node[nameKey]); + } + }).bind('click', function(event) { + return false; + }).bind('dblclick', function(event) { + return false; + }); + + $("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED_EDIT); + root.curEditInput = inputObj; + root.noSelection = false; + root.curEditNode = node; + }, + moveNode: function(setting, targetNode, node, moveType, animateFlag, isSilent) { + var root = data.getRoot(setting), + childKey = setting.data.key.children; + if (targetNode == node) return; + if (setting.data.keep.leaf && targetNode && !targetNode.isParent && moveType == consts.move.TYPE_INNER) return; + var oldParentNode = (node.parentTId ? node.getParentNode(): root), + targetNodeIsRoot = (targetNode === null || targetNode == root); + if (targetNodeIsRoot && targetNode === null) targetNode = root; + if (targetNodeIsRoot) moveType = consts.move.TYPE_INNER; + var targetParentNode = (targetNode.parentTId ? targetNode.getParentNode() : root); + + if (moveType != consts.move.TYPE_PREV && moveType != consts.move.TYPE_NEXT) { + moveType = consts.move.TYPE_INNER; + } + + if (moveType == consts.move.TYPE_INNER) { + if (targetNodeIsRoot) { + //parentTId of root node is null + node.parentTId = null; + } else { + if (!targetNode.isParent) { + targetNode.isParent = true; + targetNode.open = !!targetNode.open; + view.setNodeLineIcos(setting, targetNode); + } + node.parentTId = targetNode.tId; + } + } + + //move node Dom + var targetObj, target_ulObj; + if (targetNodeIsRoot) { + targetObj = setting.treeObj; + target_ulObj = targetObj; + } else { + if (!isSilent && moveType == consts.move.TYPE_INNER) { + view.expandCollapseNode(setting, targetNode, true, false); + } else if (!isSilent) { + view.expandCollapseNode(setting, targetNode.getParentNode(), true, false); + } + targetObj = $("#" + targetNode.tId); + target_ulObj = $("#" + targetNode.tId + consts.id.UL); + if (!!targetObj.get(0) && !target_ulObj.get(0)) { + var ulstr = []; + view.makeUlHtml(setting, targetNode, ulstr, ''); + targetObj.append(ulstr.join('')); + } + target_ulObj = $("#" + targetNode.tId + consts.id.UL); + } + var nodeDom = $("#" + node.tId); + if (!nodeDom.get(0)) { + nodeDom = view.appendNodes(setting, node.level, [node], null, false, true).join(''); + } else if (!targetObj.get(0)) { + nodeDom.remove(); + } + if (target_ulObj.get(0) && moveType == consts.move.TYPE_INNER) { + target_ulObj.append(nodeDom); + } else if (targetObj.get(0) && moveType == consts.move.TYPE_PREV) { + targetObj.before(nodeDom); + } else if (targetObj.get(0) && moveType == consts.move.TYPE_NEXT) { + targetObj.after(nodeDom); + } + + //repair the data after move + var i,l, + tmpSrcIndex = -1, + tmpTargetIndex = 0, + oldNeighbor = null, + newNeighbor = null, + oldLevel = node.level; + if (node.isFirstNode) { + tmpSrcIndex = 0; + if (oldParentNode[childKey].length > 1 ) { + oldNeighbor = oldParentNode[childKey][1]; + oldNeighbor.isFirstNode = true; + } + } else if (node.isLastNode) { + tmpSrcIndex = oldParentNode[childKey].length -1; + oldNeighbor = oldParentNode[childKey][tmpSrcIndex - 1]; + oldNeighbor.isLastNode = true; + } else { + for (i = 0, l = oldParentNode[childKey].length; i < l; i++) { + if (oldParentNode[childKey][i].tId == node.tId) { + tmpSrcIndex = i; + break; + } + } + } + if (tmpSrcIndex >= 0) { + oldParentNode[childKey].splice(tmpSrcIndex, 1); + } + if (moveType != consts.move.TYPE_INNER) { + for (i = 0, l = targetParentNode[childKey].length; i < l; i++) { + if (targetParentNode[childKey][i].tId == targetNode.tId) tmpTargetIndex = i; + } + } + if (moveType == consts.move.TYPE_INNER) { + if (!targetNode[childKey]) targetNode[childKey] = new Array(); + if (targetNode[childKey].length > 0) { + newNeighbor = targetNode[childKey][targetNode[childKey].length - 1]; + newNeighbor.isLastNode = false; + } + targetNode[childKey].splice(targetNode[childKey].length, 0, node); + node.isLastNode = true; + node.isFirstNode = (targetNode[childKey].length == 1); + } else if (targetNode.isFirstNode && moveType == consts.move.TYPE_PREV) { + targetParentNode[childKey].splice(tmpTargetIndex, 0, node); + newNeighbor = targetNode; + newNeighbor.isFirstNode = false; + node.parentTId = targetNode.parentTId; + node.isFirstNode = true; + node.isLastNode = false; + + } else if (targetNode.isLastNode && moveType == consts.move.TYPE_NEXT) { + targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node); + newNeighbor = targetNode; + newNeighbor.isLastNode = false; + node.parentTId = targetNode.parentTId; + node.isFirstNode = false; + node.isLastNode = true; + + } else { + if (moveType == consts.move.TYPE_PREV) { + targetParentNode[childKey].splice(tmpTargetIndex, 0, node); + } else { + targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node); + } + node.parentTId = targetNode.parentTId; + node.isFirstNode = false; + node.isLastNode = false; + } + data.fixPIdKeyValue(setting, node); + data.setSonNodeLevel(setting, node.getParentNode(), node); + + //repair node what been moved + view.setNodeLineIcos(setting, node); + view.repairNodeLevelClass(setting, node, oldLevel) + + //repair node's old parentNode dom + if (!setting.data.keep.parent && oldParentNode[childKey].length < 1) { + //old parentNode has no child nodes + oldParentNode.isParent = false; + oldParentNode.open = false; + var tmp_ulObj = $("#" + oldParentNode.tId + consts.id.UL), + tmp_switchObj = $("#" + oldParentNode.tId + consts.id.SWITCH), + tmp_icoObj = $("#" + oldParentNode.tId + consts.id.ICON); + view.replaceSwitchClass(oldParentNode, tmp_switchObj, consts.folder.DOCU); + view.replaceIcoClass(oldParentNode, tmp_icoObj, consts.folder.DOCU); + tmp_ulObj.css("display", "none"); + + } else if (oldNeighbor) { + //old neigbor node + view.setNodeLineIcos(setting, oldNeighbor); + } + + //new neigbor node + if (newNeighbor) { + view.setNodeLineIcos(setting, newNeighbor); + } + + //repair checkbox / radio + if (!!setting.check && setting.check.enable && view.repairChkClass) { + view.repairChkClass(setting, oldParentNode); + view.repairParentChkClassWithSelf(setting, oldParentNode); + if (oldParentNode != node.parent) + view.repairParentChkClassWithSelf(setting, node); + } + + //expand parents after move + if (!isSilent) { + view.expandCollapseParentNode(setting, node.getParentNode(), true, animateFlag); + } + }, + removeEditBtn: function(node) { + $("#" + node.tId + consts.id.EDIT).unbind().remove(); + }, + removeRemoveBtn: function(node) { + $("#" + node.tId + consts.id.REMOVE).unbind().remove(); + }, + removeTreeDom: function(setting, node) { + node.isHover = false; + view.removeEditBtn(node); + view.removeRemoveBtn(node); + tools.apply(setting.view.removeHoverDom, [setting.treeId, node]); + }, + repairNodeLevelClass: function(setting, node, oldLevel) { + if (oldLevel === node.level) return; + var liObj = $("#" + node.tId), + aObj = $("#" + node.tId + consts.id.A), + ulObj = $("#" + node.tId + consts.id.UL), + oldClass = consts.className.LEVEL + oldLevel, + newClass = consts.className.LEVEL + node.level; + liObj.removeClass(oldClass); + liObj.addClass(newClass); + aObj.removeClass(oldClass); + aObj.addClass(newClass); + ulObj.removeClass(oldClass); + ulObj.addClass(newClass); + } + }, + + _z = { + tools: _tools, + view: _view, + event: _event, + data: _data + }; + $.extend(true, $.fn.zTree.consts, _consts); + $.extend(true, $.fn.zTree._z, _z); + + var zt = $.fn.zTree, + tools = zt._z.tools, + consts = zt.consts, + view = zt._z.view, + data = zt._z.data, + event = zt._z.event; + + data.exSetting(_setting); + data.addInitBind(_bindEvent); + data.addInitUnBind(_unbindEvent); + data.addInitCache(_initCache); + data.addInitNode(_initNode); + data.addInitProxy(_eventProxy); + data.addInitRoot(_initRoot); + data.addZTreeTools(_zTreeTools); + + var _cancelPreSelectedNode = view.cancelPreSelectedNode; + view.cancelPreSelectedNode = function (setting, node) { + var list = data.getRoot(setting).curSelectedList; + for (var i=0, j=list.length; i"); - }, - showNode: function(setting, node, options) { - node.isHidden = false; - data.initShowForExCheck(setting, node); - $("#" + node.tId).show(); - }, - showNodes: function(setting, nodes, options) { - if (!nodes || nodes.length == 0) { - return; - } - var pList = {}, i, j; - for (i=0, j=nodes.length; i 0 && !parentNode[childKey][0].isHidden) { - parentNode[childKey][0].isFirstNode = true; - } else if (childLength > 0) { - view.setFirstNodeForHide(setting, parentNode[childKey]); - } - }, - setLastNode: function(setting, parentNode) { - var childKey = setting.data.key.children, childLength = parentNode[childKey].length; - if (childLength > 0 && !parentNode[childKey][0].isHidden) { - parentNode[childKey][childLength - 1].isLastNode = true; - } else if (childLength > 0) { - view.setLastNodeForHide(setting, parentNode[childKey]); - } - }, - setFirstNodeForHide: function(setting, nodes) { - var n,i,j; - for (i=0, j=nodes.length; i=0; i--) { - n = nodes[i]; - if (n.isLastNode) { - break; - } - if (!n.isHidden && !n.isLastNode) { - n.isLastNode = true; - view.setNodeLineIcos(setting, n); - break; - } else { - n = null; - } - } - return n; - }, - setLastNodeForShow: function(setting, nodes) { - var n,i,j, last, old; - for (i=nodes.length-1; i>=0; i--) { - n = nodes[i]; - if (!last && !n.isHidden && n.isLastNode) { - last = n; - break; - } else if (!last && !n.isHidden && !n.isLastNode) { - n.isLastNode = true; - last = n; - view.setNodeLineIcos(setting, n); - } else if (last && n.isLastNode) { - n.isLastNode = false; - old = n; - view.setNodeLineIcos(setting, n); - break; - } else { - n = null; - } - } - return {"new":last, "old":old}; - } - }, - - _z = { - view: _view, - data: _data - }; - $.extend(true, $.fn.zTree._z, _z); - - var zt = $.fn.zTree, - tools = zt._z.tools, - consts = zt.consts, - view = zt._z.view, - data = zt._z.data, - event = zt._z.event; - - data.addInitNode(_initNode); - data.addBeforeA(_beforeA); - data.addZTreeTools(_zTreeTools); - -// Override method in core - var _dInitNode = data.initNode; - data.tmpHideParent = -1; - data.initNode = function(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag) { - if (data.tmpHideParent !== parentNode) { - data.tmpHideParent = parentNode; - var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting), - children = tmpPNode[setting.data.key.children]; - data.tmpHideFirstNode = view.setFirstNodeForHide(setting, children); - data.tmpHideLastNode = view.setLastNodeForHide(setting, children); - view.setNodeLineIcos(setting, data.tmpHideFirstNode); - view.setNodeLineIcos(setting, data.tmpHideLastNode); - } - isFirstNode = (data.tmpHideFirstNode === node); - isLastNode = (data.tmpHideLastNode === node); - if (_dInitNode) _dInitNode.apply(data, arguments); - if (isLastNode) { - view.clearOldLastNode(setting, node); - } - } - - var _makeChkFlag = data.makeChkFlag; - if (!!_makeChkFlag) { - data.makeChkFlag = function(setting, node) { - if (!!node && !!node.isHidden) { - return; - } - _makeChkFlag.apply(data, arguments); - } - } - - var _getTreeCheckedNodes = data.getTreeCheckedNodes; - if (!!_getTreeCheckedNodes) { - data.getTreeCheckedNodes = function(setting, nodes, checked, results) { - if (!!nodes && nodes.length > 0) { - var p = nodes[0].getParentNode(); - if (!!p && !!p.isHidden) { - return []; - } - } - return _getTreeCheckedNodes.apply(data, arguments); - } - } - - var _getTreeChangeCheckedNodes = data.getTreeChangeCheckedNodes; - if (!!_getTreeChangeCheckedNodes) { - data.getTreeChangeCheckedNodes = function(setting, nodes, results) { - if (!!nodes && nodes.length > 0) { - var p = nodes[0].getParentNode(); - if (!!p && !!p.isHidden) { - return []; - } - } - return _getTreeChangeCheckedNodes.apply(data, arguments); - } - } - - var _expandCollapseSonNode = view.expandCollapseSonNode; - if (!!_expandCollapseSonNode) { - view.expandCollapseSonNode = function(setting, node, expandFlag, animateFlag, callback) { - if (!!node && !!node.isHidden) { - return; - } - _expandCollapseSonNode.apply(view, arguments); - } - } - - var _setSonNodeCheckBox = view.setSonNodeCheckBox; - if (!!_setSonNodeCheckBox) { - view.setSonNodeCheckBox = function(setting, node, value, srcNode) { - if (!!node && !!node.isHidden) { - return; - } - _setSonNodeCheckBox.apply(view, arguments); - } - } - - var _repairParentChkClassWithSelf = view.repairParentChkClassWithSelf; - if (!!_repairParentChkClassWithSelf) { - view.repairParentChkClassWithSelf = function(setting, node) { - if (!!node && !!node.isHidden) { - return; - } - _repairParentChkClassWithSelf.apply(view, arguments); - } - } +/* + * JQuery zTree exHideNodes 3.5.12 + * http://zTree.me/ + * + * Copyright (c) 2010 Hunter.z + * + * Licensed same as jquery - MIT License + * http://www.opensource.org/licenses/mit-license.php + * + * email: hunter.z@263.net + * Date: 2013-03-11 + */ +(function($){ + //default init node of exLib + var _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { + if (typeof n.isHidden == "string") n.isHidden = tools.eqs(n.isHidden, "true"); + n.isHidden = !!n.isHidden; + data.initHideForExCheck(setting, n); + }, + //add dom for check + _beforeA = function(setting, node, html) {}, + //update zTreeObj, add method of exLib + _zTreeTools = function(setting, zTreeTools) { + zTreeTools.showNodes = function(nodes, options) { + view.showNodes(setting, nodes, options); + } + zTreeTools.showNode = function(node, options) { + if (!node) { + return; + } + view.showNodes(setting, [node], options); + } + zTreeTools.hideNodes = function(nodes, options) { + view.hideNodes(setting, nodes, options); + } + zTreeTools.hideNode = function(node, options) { + if (!node) { + return; + } + view.hideNodes(setting, [node], options); + } + + var _checkNode = zTreeTools.checkNode; + if (_checkNode) { + zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) { + if (!!node && !!node.isHidden) { + return; + } + _checkNode.apply(zTreeTools, arguments); + } + } + }, + //method of operate data + _data = { + initHideForExCheck: function(setting, n) { + if (n.isHidden && setting.check && setting.check.enable) { + if(typeof n._nocheck == "undefined") { + n._nocheck = !!n.nocheck + n.nocheck = true; + } + n.check_Child_State = -1; + if (view.repairParentChkClassWithSelf) { + view.repairParentChkClassWithSelf(setting, n); + } + } + }, + initShowForExCheck: function(setting, n) { + if (!n.isHidden && setting.check && setting.check.enable) { + if(typeof n._nocheck != "undefined") { + n.nocheck = n._nocheck; + delete n._nocheck; + } + if (view.setChkClass) { + var checkObj = $("#" + n.tId + consts.id.CHECK); + view.setChkClass(setting, checkObj, n); + } + if (view.repairParentChkClassWithSelf) { + view.repairParentChkClassWithSelf(setting, n); + } + } + } + }, + //method of operate ztree dom + _view = { + clearOldFirstNode: function(setting, node) { + var n = node.getNextNode(); + while(!!n){ + if (n.isFirstNode) { + n.isFirstNode = false; + view.setNodeLineIcos(setting, n); + break; + } + if (n.isLastNode) { + break; + } + n = n.getNextNode(); + } + }, + clearOldLastNode: function(setting, node) { + var n = node.getPreNode(); + while(!!n){ + if (n.isLastNode) { + n.isLastNode = false; + view.setNodeLineIcos(setting, n); + break; + } + if (n.isFirstNode) { + break; + } + n = n.getPreNode(); + } + }, + makeDOMNodeMainBefore: function(html, setting, node) { + html.push("
              • "); + }, + showNode: function(setting, node, options) { + node.isHidden = false; + data.initShowForExCheck(setting, node); + $("#" + node.tId).show(); + }, + showNodes: function(setting, nodes, options) { + if (!nodes || nodes.length == 0) { + return; + } + var pList = {}, i, j; + for (i=0, j=nodes.length; i 0 && !parentNode[childKey][0].isHidden) { + parentNode[childKey][0].isFirstNode = true; + } else if (childLength > 0) { + view.setFirstNodeForHide(setting, parentNode[childKey]); + } + }, + setLastNode: function(setting, parentNode) { + var childKey = setting.data.key.children, childLength = parentNode[childKey].length; + if (childLength > 0 && !parentNode[childKey][0].isHidden) { + parentNode[childKey][childLength - 1].isLastNode = true; + } else if (childLength > 0) { + view.setLastNodeForHide(setting, parentNode[childKey]); + } + }, + setFirstNodeForHide: function(setting, nodes) { + var n,i,j; + for (i=0, j=nodes.length; i=0; i--) { + n = nodes[i]; + if (n.isLastNode) { + break; + } + if (!n.isHidden && !n.isLastNode) { + n.isLastNode = true; + view.setNodeLineIcos(setting, n); + break; + } else { + n = null; + } + } + return n; + }, + setLastNodeForShow: function(setting, nodes) { + var n,i,j, last, old; + for (i=nodes.length-1; i>=0; i--) { + n = nodes[i]; + if (!last && !n.isHidden && n.isLastNode) { + last = n; + break; + } else if (!last && !n.isHidden && !n.isLastNode) { + n.isLastNode = true; + last = n; + view.setNodeLineIcos(setting, n); + } else if (last && n.isLastNode) { + n.isLastNode = false; + old = n; + view.setNodeLineIcos(setting, n); + break; + } else { + n = null; + } + } + return {"new":last, "old":old}; + } + }, + + _z = { + view: _view, + data: _data + }; + $.extend(true, $.fn.zTree._z, _z); + + var zt = $.fn.zTree, + tools = zt._z.tools, + consts = zt.consts, + view = zt._z.view, + data = zt._z.data, + event = zt._z.event; + + data.addInitNode(_initNode); + data.addBeforeA(_beforeA); + data.addZTreeTools(_zTreeTools); + +// Override method in core + var _dInitNode = data.initNode; + data.tmpHideParent = -1; + data.initNode = function(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag) { + if (data.tmpHideParent !== parentNode) { + data.tmpHideParent = parentNode; + var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting), + children = tmpPNode[setting.data.key.children]; + data.tmpHideFirstNode = view.setFirstNodeForHide(setting, children); + data.tmpHideLastNode = view.setLastNodeForHide(setting, children); + view.setNodeLineIcos(setting, data.tmpHideFirstNode); + view.setNodeLineIcos(setting, data.tmpHideLastNode); + } + isFirstNode = (data.tmpHideFirstNode === node); + isLastNode = (data.tmpHideLastNode === node); + if (_dInitNode) _dInitNode.apply(data, arguments); + if (isLastNode) { + view.clearOldLastNode(setting, node); + } + } + + var _makeChkFlag = data.makeChkFlag; + if (!!_makeChkFlag) { + data.makeChkFlag = function(setting, node) { + if (!!node && !!node.isHidden) { + return; + } + _makeChkFlag.apply(data, arguments); + } + } + + var _getTreeCheckedNodes = data.getTreeCheckedNodes; + if (!!_getTreeCheckedNodes) { + data.getTreeCheckedNodes = function(setting, nodes, checked, results) { + if (!!nodes && nodes.length > 0) { + var p = nodes[0].getParentNode(); + if (!!p && !!p.isHidden) { + return []; + } + } + return _getTreeCheckedNodes.apply(data, arguments); + } + } + + var _getTreeChangeCheckedNodes = data.getTreeChangeCheckedNodes; + if (!!_getTreeChangeCheckedNodes) { + data.getTreeChangeCheckedNodes = function(setting, nodes, results) { + if (!!nodes && nodes.length > 0) { + var p = nodes[0].getParentNode(); + if (!!p && !!p.isHidden) { + return []; + } + } + return _getTreeChangeCheckedNodes.apply(data, arguments); + } + } + + var _expandCollapseSonNode = view.expandCollapseSonNode; + if (!!_expandCollapseSonNode) { + view.expandCollapseSonNode = function(setting, node, expandFlag, animateFlag, callback) { + if (!!node && !!node.isHidden) { + return; + } + _expandCollapseSonNode.apply(view, arguments); + } + } + + var _setSonNodeCheckBox = view.setSonNodeCheckBox; + if (!!_setSonNodeCheckBox) { + view.setSonNodeCheckBox = function(setting, node, value, srcNode) { + if (!!node && !!node.isHidden) { + return; + } + _setSonNodeCheckBox.apply(view, arguments); + } + } + + var _repairParentChkClassWithSelf = view.repairParentChkClassWithSelf; + if (!!_repairParentChkClassWithSelf) { + view.repairParentChkClassWithSelf = function(setting, node) { + if (!!node && !!node.isHidden) { + return; + } + _repairParentChkClassWithSelf.apply(view, arguments); + } + } })(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/log v3.x.txt b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/log v3.x.txt similarity index 98% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/log v3.x.txt rename to bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/log v3.x.txt index 491dede4b..371542cc4 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/log v3.x.txt +++ b/bmw-admin/src/main/resources/static/ajax/libs/jquery-ztree/3.5/log v3.x.txt @@ -1,170 +1,170 @@ -=ZTree v3.x (JQuery Tree插件) 更新日志= - -为了更好的优化及扩展zTree, 因此决定升级为v3.x,并且对之前的v2.x不兼容,会有很多结构上的修改,对此深感无奈与抱歉,请大家谅解。 - - -具体修改内容可参考: - - * [http://www.ztree.me/v3/api.php zTree v3.0 API 文档] - - * [http://www.ztree.me/v3/demo.php#_101 zTree v3.0 Demo 演示] - - * [http://www.ztree.me/v3/faq.php#_101 zTree v3.0 常见问题] - - - - -*2013.03.11* v3.5.12 - * 【修改】由于 jquery 1.9 中移除 event.srcElement 导致的 js 报错的bug。 - * 【修改】在异步加载模式下,使用 moveNode 方法,且 moveType != "inner" 时,也会导致 targetNode 自动加载子节点的 bug - * 【修改】对已经显示的节点(nochecked=true)使用 showNodes 或 showNode 方法后,导致勾选框出现的bug。 - * 【修改】对已经隐藏的节点(nochecked=false)使用 hideNodes 或 hideNode 方法后,导致勾选框消失的bug。 - * 【修改】getNodesByParamFuzzy 支持 大小写模糊。 - * 【修改】className 结构,提取 _consts.className.BUTTON / LEVEL / ICO_LOADING / SWITCH,便于快速修改 css 冲突。 - 例如:与 WordPress 产生冲突后,直接修改 core 中的 "button" 和 "level" 即可。 Issue: https://github.com/zTree/zTree_v3/issues/2 - -*2013.01.28* v3.5.02 - * 【增加】setting.check.chkDisabledInherit 属性,用于设置 chkDisabled 在初始化时子节点是否可以继承父节点的 chkDisabled 属性 - * 【删除】内部 noSel 方法,使用 selectstart事件 和 "-moz-user-select"样式 处理禁止 节点文字被选择的功能 - * 【修改】不兼容 jQuery 1.9 的bug - * 【修改】onDrop 的触发规则,保证异步加载模式下,可以在延迟加载结束后触发,避免 onDrop 中被拖拽的节点是已经更新后的数据。 - * 【修改】setChkDisabled 方法,增加 inheritParent, inheritChildren 参数设置是否让父子节点继承 disabled - * 【修改】异步加载时 拼接参数的方法,由 string 修改为 json 对象 - * 【修正】1-2-3 3级节点时,如果 2级节点 全部设置为 nocheck 或 chkDisabled后,勾选3级节点时,1级节点的半勾选状态错误的 bug - * 【修改】Demo: checkbox_nocheck.html & checkbox_chkDisabled.html; - * 【修改】Demo: edit_super.html,增加 showRenameBtn & showRemoveBtn 的演示 - * 【修改】Demo: asyncForAll, 将 post 修改为 get;为了避免由于 IE10 的 bug 造成的客户端 以及 服务端崩溃 - IE10 ajax Post 无法提交参数的bug (http://bugs.jquery.com/ticket/12790) - -*2012.12.21* v3.5.01 - * 【优化】clone 方法 - * 【修正】对于初始化无 children 属性的父节点进行 reAsyncChildNodes 操作时出错的 bug - * 【修正】beforeRename 回调中使用 cancelEditName 方法后,再 return false 导致无法重新进行编辑的 bug - * 【修正】exedit 扩展包让 setting.data.key.url 失效的 bug - * 【修正】setting.check.autoCheckTrigger 设置为 true 时,onCheck 回调缺少 event 参数的 bug - * 【修正】singlepath.html Demo 中的 bug - -*2012.11.20* v3.5 - * 【优化】原先的 clone 方法 (特别感谢:愚人码头) - * 【修改】隐藏父节点后,使用 expandAll 方法导致 父节点展开的 bug - * 【修改】使用 jQuery v1.7 以上时,设置 zTree 容器 ul 隐藏(visibility: hidden;)后, 调用 selectNode 导致 IE 浏览器报错 Can't move focus 的 bug - * 【修改】正在异步加载时,执行 destory 或 init 方法后,异步加载的节点影响新树的 bug - * 【修改】方法 reAsyncChildNodes 在 refresh 的时候未清空内部 cache 导致内存泄露 的 bug - * 【修改】批量节点拖拽到其他父节点内(inner)时,导致顺序反转 的 bug - * 【修改】对于 使用 html格式的 节点无法触发 双击事件 的 bug - * 【修改】onCheck 回调中的 event ,保证与触发事件中的 event 一致 - * 【修改】异步加载时,在 onNodeCreated 中执行 selectNode 后,导致节点折叠的 bug - * 【修改】API 中 dataFilter 的参数名称 childNodes -> responseData - * 【修改】API 中 iconSkin 的 举例内容 - * 【修改】API 中 chkDisabled 的说明 - * 【修改】Demo 中 index.html 内的 loadReady 重复绑定问题 - -*2012.09.03* v3.4 - * 【增加】 Demo —— OutLook 样式的左侧菜单 - * 【增加】清空 zTree 的方法 $.fn.zTree.destory(treeId) & zTree.destory() - - * 【修改】core核心文件内 _eventProxy 方法中获取 tId 的方法,提高 DOM 的灵活性 - * 【修改】初始化时 多层父节点的 checkbox 半选状态计算错误的 bug - * 【修改】同时选中父、子节点后,利用 getSelectedNodes 获取选中节点并利用 removeNode 删除时报错的 bug - * 【修改】treeNode.chkDisabled / nocheck 属性,支持字符串格式的 "false"/"true" - * 【修改】异步加载模式下无法利用 server 返回 xml 并且 在 dataFilter 中继续处理的 bug - * 【修改】title 只允许设置为 string 类型值的问题。 修正后允许设置为 number 类型的值 - * 【修改】zId 计数规则 & Cache 保存,减少 IE9 的 bug 造成的内存泄漏 - * 【修改】API 页面搜索功能导致 IE 崩溃的 bug - -*2012.07.16* v3.3 - * 【增加】扩展库 exhide -- 节点隐藏功能 - - * 【修改】getNodesByFilter 方法,添加 invokeParam 自定义参数 - * 【修改】拖拽中测试代码未删除,导致出现黄颜色的 iframe 遮罩层的 bug - * 【修改】延迟加载方法 对于使用 expandAll 进行全部展开时,导致 onNodeCreated 回调 和 addDiyDom 方法触发过早的 bug - * 【修改】使用 moveNode 移动尚未生成 DOM 的节点时,视图会出现异常的 bug - * 【修改】删除节点后,相关节点的 isFirstNode 属性未重置的 bug - * 【修改】getPreNode(),getNextNode() 方法在对于特殊情况时计算错误的 bug - * 【修改】设置 title 之后,如果重新将 title 内容设置为空后,会导致无法更新 title 的 bug - * 【修改】针对 setting.check.chkStyle=="radio" && setting.check.radioType=="all" 的情况时,getTreeCheckedNodes方法优化,找到一个结果就 break - * 【修改】zTreeObj.getCheckedNodes(false) 在 radioType = "all" 时计算错误的 bug - * 【修改】完善 API 中 beforeDrop / onDrop 的关于 treeId 的说明 - -*2012.05.13* v3.2 - * 【增加】setting.data.key.url 允许修改 treeNode.url 属性 - * 【增加】getNodesByFilter(filter, isSingle) 方法 - * 【增加】"与其他 DOM 拖拽互动" 的 Demo (http://www.ztree.me/v3/demo.php#_511) - * 【增加】"异步加载模式下全部展开" 的 Demo (http://www.ztree.me/v3/demo.php#_512) - - * 【修改】代码结构,将 addNodes、removeNode、removeChildNodes 方法 和 beforeRemove、onRemove 回调 转移到 core 内 - * 【修改】IE7的环境下无子节点的父节点反复展开出现多余空行的 bug - * 【修改】异步加载时,如果出现网络异常等,会导致 图标显示错误的 bug - * 【修改】dataFilter中 return null 导致异常 的 bug - * 【修改】removeChildNodes 方法清空子节点后,无法正常添加节点的 bug - * 【修改】moveNode 后节点中的自定义元素的事件丢失的 bug - * 【修改】moveNode 方法中设置 isSilent = true 时,如果移动到已展开的 父节点后,出现异常的 bug - * 【修改】onClick/onDrag/onDrop 回调中 event 不是原始 event 的 bug - * 【修改】onDrop 回调中 当拖拽无效时,无法获得 treeNodes 的 bug - * 【修改】onDrop 无法判断拖拽是 移动还是复制的问题 - * 【修改】未开启异步加载模式时,拖拽节点到子节点为空的父节点内时 出现异常 的 bug - * 【修改】拖拽过程中,反复在 父节点图标上划动时,会出现停顿的 bug - (需要css 结构—— button -> span.button) - - * 【修改】拖拽操作时箭头 与 targetNode 背景之间的细节现实问题,便于用户拖拽时更容易区分 prev、next 和 inner 操作 - * 【修改】拖拽操作时IE6/7 下 在 节点 右侧 10px 内会导致 targetNode = root 的 bug - * 【修改】编辑模式下 默认的编辑按钮、删除按钮点击后,如果相应的 before 回调 return false 时会触发 onClick 回调的 bug - -*2012.02.14* v3.1 - * 【增加】ajax 的参数 setting.async.contentType ,让提交参数适用于 json 数据提交 (主要适用于 .Net 的开发)。 - * 【增加】setting.edit.editNameSelectAll, 用于设定编辑节点名称时初次显示 input 后 text 内容为全选 - * 【修改】异步加载 规则,不再仅仅依靠父节点的子节点数来判定,增加内部属性 zAsync,保证默认状态下父节点及时无子节点也只能异步加载一次,除非使用 reAsyncChildNodes 方法强行控制异步加载。 - * 【修改】放大浏览器后导致 界面出现多余连接线的bug (需要更新:icon 图标和 css ) - * 【修改】在编辑状态,如果节点名超过编辑框宽度,左右键在框内不起作用的bug(IE 6 7 8 出现) - CSS 中 filter:alpha(opacity=80) 造成的,应该是 ie 的 bug,需要更新 css 文件 - * 【修改】title 设置后,如果属性不存在,则默认为 title 为空,便于数据容错和用户灵活使用 - * 【修改】editName 方法如果针对尚未展开的 父节点,会导致该父节点自动展开的 bug - * 【修改】title 中存在标签时导致 title 显示异常的bug(例如:蓝色字22%"'``) - -*2012.01.10* v3.0 - * 【增加】setting.check.autoCheckTrigger 默认值 false,可以设置联动选中时是否触发事件回调函数 - * 【增加】setting.callback.beforeEditName 回调函数,以保证用户可以捕获点击编辑按钮的事件 - * 【增加】treeNode.chkDisabled 属性,显示 checkbox 但是用户无法修改 checkbox 状态,并且该 checkbox 会影响父节点的 checkbox 的半选状态 - * 【增加】setting.check.nocheckInherit 属性,用户设置子节点继承 nocheck 属性,用于批量初始化节点,不适用于已经显示的节点 - * 【增加】setting.edit.drag.autoExpandTrigger 默认值 false,可以设置自动展开、折叠操作时是否触发事件回调函数 - * 【增加】setting.view.nameIsHTML 默认值 false,允许用户对 name 设置 DOM 对象 - * 【增加】treeNode.click 属性的说明文档 - * 【增加】treeObj.setChkDisabled 方法用于设置 checkbox / radio disabled 状态 - * 【增加】treeNode.halfCheck 属性,用于强制设定节点的半选状态 - - * 【修改】异步加载 & 编辑功能 共存时,拖拽节点 或 增加节点 导致 ie 上报错的 bug (apply 方法引起) - * 【修改】zTreeStyle 样式冲突 - * 【修改】setting.data.key.title 默认值设置为 "",初始化时自动赋值为 setting.data.key.name 这样可避免希望 title 与 name 一致的用户反复设置参数 - * 【修改】点击叶子节点的连接线会触发 expand 事件的 bug - * 【修改】IE 下 点击叶子节点连线会出现虚线框的 bug - * 【修改】updateNode 导致 checkbox 半选状态错误的 bug - * 【修改】checkNode 方法实现 toggle 操作, 取消 expandAll 方法的 toggle 操作 - * 【修改】zTree 内鼠标移动会抢页面上 input 内的焦点的 bug - * 【修改】beforeRename / onRename 的触发方式——即使名称内容未改变也会触发,便于用户配合 beforeEditName 捕获编辑状态的结束,赋予用户更多调整规则的权利 - * 【修改】与 easyUI 共存时无法拖拽的bug - * 【修改】beforeRename 在 Firefox 下如果利用 alert,会触发两次的 bug - * 【修改】checkNode/expandNode/removeNode 方法,默认不触发回调函数,恢复 v2.6 的默认状态,同时增加 callbackFlag 参数,设置为 true 时,可以触发回调函数 - * 【修改】IE9下“根据参数查找节点”的Demo 报错:行14 重新声明常量属性(Demo 自身的问题,定义了history变量) - * 【修改】初始化 zTree 时 onNodeCreated 事件回调函数中无法 用 getZTreeObj 获取 zTree 对象的 bug - * 【修改】setting.edit.drag.prev / next / inner 参数,增加被拖拽的节点集合 - * 【修改】异步加载模式下,otherParam 使用Array数组会出错的 bug。例如: ["id", "1", "name", "test"] - * 【修改】FireFox 下多棵树拖拽异常的 bug - * 【修改】exedit 中调用 excheck库的方法时没有进行容错处理,导致如果只加入 exedit 而没有 excheck的时候,会出现 js 错误 - * 【修改】显示 checkbox 的 zTree 在编辑模式下,移动节点不会更新父节点半选状态的 bug - * 【修改】treeNode.childs --> children; treeObject.removeChilds --> removeChildNodes; setting.data.key.childs --> children(英文不好惹的祸!抱歉了!) - * 【修改】onRemove 回调中得到的 treeNode 还可以查找 preNode、nextNode 的bug。 修正后,getPreNode 和 getNextNode 都返回 null; 为了便于查找父节点,getParentNode 仍保留 - * 【修改】简单数据模式下,如果 id 与 pId 的值相同会导致该节点无法正常加载的 bug - * 【修改】移动或删除中间节点会导致最后一个节点连接线图标变小的 bug - -*2011.09.05* v3.0 beta - * 【修改】zTree 的 js 代码架构全面修改,并且拆分 - * 【修改】zTree 的 css 样式全面修改,对浏览器可以更好地兼容,同时解决了以前1个像素差的问题 - * 【优化】采用延迟加载技术,一次性加载大数据量的节点性能飞速提升 - * 【增加】支持多节点同时选中、拖拽 - * 【增加】checkNode、checkAllNodes 等多种方法 - * 【增加】IE6 自动取消动画展开、折叠的功能 - * 【修正】异步加载 & 编辑模式 能够更完美的共存 - * 【修正】setting 配置更加合理,并且增加了若干项配置参数 - * 【修正】treeNode 节点数据的属性更加合理,并且增加了一些方法 - * 【修正】拖拽操作更加灵活方便,更容易制定自己的规则 - * 【修正】其他若干修改,详细对比请参考 url:[http://www.ztree.me/v3/faq.php#_101 zTree v3.0 常见问题] +=ZTree v3.x (JQuery Tree插件) 更新日志= + +为了更好的优化及扩展zTree, 因此决定升级为v3.x,并且对之前的v2.x不兼容,会有很多结构上的修改,对此深感无奈与抱歉,请大家谅解。 + + +具体修改内容可参考: + + * [http://www.ztree.me/v3/api.php zTree v3.0 API 文档] + + * [http://www.ztree.me/v3/demo.php#_101 zTree v3.0 Demo 演示] + + * [http://www.ztree.me/v3/faq.php#_101 zTree v3.0 常见问题] + + + + +*2013.03.11* v3.5.12 + * 【修改】由于 jquery 1.9 中移除 event.srcElement 导致的 js 报错的bug。 + * 【修改】在异步加载模式下,使用 moveNode 方法,且 moveType != "inner" 时,也会导致 targetNode 自动加载子节点的 bug + * 【修改】对已经显示的节点(nochecked=true)使用 showNodes 或 showNode 方法后,导致勾选框出现的bug。 + * 【修改】对已经隐藏的节点(nochecked=false)使用 hideNodes 或 hideNode 方法后,导致勾选框消失的bug。 + * 【修改】getNodesByParamFuzzy 支持 大小写模糊。 + * 【修改】className 结构,提取 _consts.className.BUTTON / LEVEL / ICO_LOADING / SWITCH,便于快速修改 css 冲突。 + 例如:与 WordPress 产生冲突后,直接修改 core 中的 "button" 和 "level" 即可。 Issue: https://github.com/zTree/zTree_v3/issues/2 + +*2013.01.28* v3.5.02 + * 【增加】setting.check.chkDisabledInherit 属性,用于设置 chkDisabled 在初始化时子节点是否可以继承父节点的 chkDisabled 属性 + * 【删除】内部 noSel 方法,使用 selectstart事件 和 "-moz-user-select"样式 处理禁止 节点文字被选择的功能 + * 【修改】不兼容 jQuery 1.9 的bug + * 【修改】onDrop 的触发规则,保证异步加载模式下,可以在延迟加载结束后触发,避免 onDrop 中被拖拽的节点是已经更新后的数据。 + * 【修改】setChkDisabled 方法,增加 inheritParent, inheritChildren 参数设置是否让父子节点继承 disabled + * 【修改】异步加载时 拼接参数的方法,由 string 修改为 json 对象 + * 【修正】1-2-3 3级节点时,如果 2级节点 全部设置为 nocheck 或 chkDisabled后,勾选3级节点时,1级节点的半勾选状态错误的 bug + * 【修改】Demo: checkbox_nocheck.html & checkbox_chkDisabled.html; + * 【修改】Demo: edit_super.html,增加 showRenameBtn & showRemoveBtn 的演示 + * 【修改】Demo: asyncForAll, 将 post 修改为 get;为了避免由于 IE10 的 bug 造成的客户端 以及 服务端崩溃 + IE10 ajax Post 无法提交参数的bug (http://bugs.jquery.com/ticket/12790) + +*2012.12.21* v3.5.01 + * 【优化】clone 方法 + * 【修正】对于初始化无 children 属性的父节点进行 reAsyncChildNodes 操作时出错的 bug + * 【修正】beforeRename 回调中使用 cancelEditName 方法后,再 return false 导致无法重新进行编辑的 bug + * 【修正】exedit 扩展包让 setting.data.key.url 失效的 bug + * 【修正】setting.check.autoCheckTrigger 设置为 true 时,onCheck 回调缺少 event 参数的 bug + * 【修正】singlepath.html Demo 中的 bug + +*2012.11.20* v3.5 + * 【优化】原先的 clone 方法 (特别感谢:愚人码头) + * 【修改】隐藏父节点后,使用 expandAll 方法导致 父节点展开的 bug + * 【修改】使用 jQuery v1.7 以上时,设置 zTree 容器 ul 隐藏(visibility: hidden;)后, 调用 selectNode 导致 IE 浏览器报错 Can't move focus 的 bug + * 【修改】正在异步加载时,执行 destory 或 init 方法后,异步加载的节点影响新树的 bug + * 【修改】方法 reAsyncChildNodes 在 refresh 的时候未清空内部 cache 导致内存泄露 的 bug + * 【修改】批量节点拖拽到其他父节点内(inner)时,导致顺序反转 的 bug + * 【修改】对于 使用 html格式的 节点无法触发 双击事件 的 bug + * 【修改】onCheck 回调中的 event ,保证与触发事件中的 event 一致 + * 【修改】异步加载时,在 onNodeCreated 中执行 selectNode 后,导致节点折叠的 bug + * 【修改】API 中 dataFilter 的参数名称 childNodes -> responseData + * 【修改】API 中 iconSkin 的 举例内容 + * 【修改】API 中 chkDisabled 的说明 + * 【修改】Demo 中 index.html 内的 loadReady 重复绑定问题 + +*2012.09.03* v3.4 + * 【增加】 Demo —— OutLook 样式的左侧菜单 + * 【增加】清空 zTree 的方法 $.fn.zTree.destory(treeId) & zTree.destory() + + * 【修改】core核心文件内 _eventProxy 方法中获取 tId 的方法,提高 DOM 的灵活性 + * 【修改】初始化时 多层父节点的 checkbox 半选状态计算错误的 bug + * 【修改】同时选中父、子节点后,利用 getSelectedNodes 获取选中节点并利用 removeNode 删除时报错的 bug + * 【修改】treeNode.chkDisabled / nocheck 属性,支持字符串格式的 "false"/"true" + * 【修改】异步加载模式下无法利用 server 返回 xml 并且 在 dataFilter 中继续处理的 bug + * 【修改】title 只允许设置为 string 类型值的问题。 修正后允许设置为 number 类型的值 + * 【修改】zId 计数规则 & Cache 保存,减少 IE9 的 bug 造成的内存泄漏 + * 【修改】API 页面搜索功能导致 IE 崩溃的 bug + +*2012.07.16* v3.3 + * 【增加】扩展库 exhide -- 节点隐藏功能 + + * 【修改】getNodesByFilter 方法,添加 invokeParam 自定义参数 + * 【修改】拖拽中测试代码未删除,导致出现黄颜色的 iframe 遮罩层的 bug + * 【修改】延迟加载方法 对于使用 expandAll 进行全部展开时,导致 onNodeCreated 回调 和 addDiyDom 方法触发过早的 bug + * 【修改】使用 moveNode 移动尚未生成 DOM 的节点时,视图会出现异常的 bug + * 【修改】删除节点后,相关节点的 isFirstNode 属性未重置的 bug + * 【修改】getPreNode(),getNextNode() 方法在对于特殊情况时计算错误的 bug + * 【修改】设置 title 之后,如果重新将 title 内容设置为空后,会导致无法更新 title 的 bug + * 【修改】针对 setting.check.chkStyle=="radio" && setting.check.radioType=="all" 的情况时,getTreeCheckedNodes方法优化,找到一个结果就 break + * 【修改】zTreeObj.getCheckedNodes(false) 在 radioType = "all" 时计算错误的 bug + * 【修改】完善 API 中 beforeDrop / onDrop 的关于 treeId 的说明 + +*2012.05.13* v3.2 + * 【增加】setting.data.key.url 允许修改 treeNode.url 属性 + * 【增加】getNodesByFilter(filter, isSingle) 方法 + * 【增加】"与其他 DOM 拖拽互动" 的 Demo (http://www.ztree.me/v3/demo.php#_511) + * 【增加】"异步加载模式下全部展开" 的 Demo (http://www.ztree.me/v3/demo.php#_512) + + * 【修改】代码结构,将 addNodes、removeNode、removeChildNodes 方法 和 beforeRemove、onRemove 回调 转移到 core 内 + * 【修改】IE7的环境下无子节点的父节点反复展开出现多余空行的 bug + * 【修改】异步加载时,如果出现网络异常等,会导致 图标显示错误的 bug + * 【修改】dataFilter中 return null 导致异常 的 bug + * 【修改】removeChildNodes 方法清空子节点后,无法正常添加节点的 bug + * 【修改】moveNode 后节点中的自定义元素的事件丢失的 bug + * 【修改】moveNode 方法中设置 isSilent = true 时,如果移动到已展开的 父节点后,出现异常的 bug + * 【修改】onClick/onDrag/onDrop 回调中 event 不是原始 event 的 bug + * 【修改】onDrop 回调中 当拖拽无效时,无法获得 treeNodes 的 bug + * 【修改】onDrop 无法判断拖拽是 移动还是复制的问题 + * 【修改】未开启异步加载模式时,拖拽节点到子节点为空的父节点内时 出现异常 的 bug + * 【修改】拖拽过程中,反复在 父节点图标上划动时,会出现停顿的 bug + (需要css 结构—— button -> span.button) + + * 【修改】拖拽操作时箭头 与 targetNode 背景之间的细节现实问题,便于用户拖拽时更容易区分 prev、next 和 inner 操作 + * 【修改】拖拽操作时IE6/7 下 在 节点 右侧 10px 内会导致 targetNode = root 的 bug + * 【修改】编辑模式下 默认的编辑按钮、删除按钮点击后,如果相应的 before 回调 return false 时会触发 onClick 回调的 bug + +*2012.02.14* v3.1 + * 【增加】ajax 的参数 setting.async.contentType ,让提交参数适用于 json 数据提交 (主要适用于 .Net 的开发)。 + * 【增加】setting.edit.editNameSelectAll, 用于设定编辑节点名称时初次显示 input 后 text 内容为全选 + * 【修改】异步加载 规则,不再仅仅依靠父节点的子节点数来判定,增加内部属性 zAsync,保证默认状态下父节点及时无子节点也只能异步加载一次,除非使用 reAsyncChildNodes 方法强行控制异步加载。 + * 【修改】放大浏览器后导致 界面出现多余连接线的bug (需要更新:icon 图标和 css ) + * 【修改】在编辑状态,如果节点名超过编辑框宽度,左右键在框内不起作用的bug(IE 6 7 8 出现) + CSS 中 filter:alpha(opacity=80) 造成的,应该是 ie 的 bug,需要更新 css 文件 + * 【修改】title 设置后,如果属性不存在,则默认为 title 为空,便于数据容错和用户灵活使用 + * 【修改】editName 方法如果针对尚未展开的 父节点,会导致该父节点自动展开的 bug + * 【修改】title 中存在标签时导致 title 显示异常的bug(例如:蓝色字22%"'``) + +*2012.01.10* v3.0 + * 【增加】setting.check.autoCheckTrigger 默认值 false,可以设置联动选中时是否触发事件回调函数 + * 【增加】setting.callback.beforeEditName 回调函数,以保证用户可以捕获点击编辑按钮的事件 + * 【增加】treeNode.chkDisabled 属性,显示 checkbox 但是用户无法修改 checkbox 状态,并且该 checkbox 会影响父节点的 checkbox 的半选状态 + * 【增加】setting.check.nocheckInherit 属性,用户设置子节点继承 nocheck 属性,用于批量初始化节点,不适用于已经显示的节点 + * 【增加】setting.edit.drag.autoExpandTrigger 默认值 false,可以设置自动展开、折叠操作时是否触发事件回调函数 + * 【增加】setting.view.nameIsHTML 默认值 false,允许用户对 name 设置 DOM 对象 + * 【增加】treeNode.click 属性的说明文档 + * 【增加】treeObj.setChkDisabled 方法用于设置 checkbox / radio disabled 状态 + * 【增加】treeNode.halfCheck 属性,用于强制设定节点的半选状态 + + * 【修改】异步加载 & 编辑功能 共存时,拖拽节点 或 增加节点 导致 ie 上报错的 bug (apply 方法引起) + * 【修改】zTreeStyle 样式冲突 + * 【修改】setting.data.key.title 默认值设置为 "",初始化时自动赋值为 setting.data.key.name 这样可避免希望 title 与 name 一致的用户反复设置参数 + * 【修改】点击叶子节点的连接线会触发 expand 事件的 bug + * 【修改】IE 下 点击叶子节点连线会出现虚线框的 bug + * 【修改】updateNode 导致 checkbox 半选状态错误的 bug + * 【修改】checkNode 方法实现 toggle 操作, 取消 expandAll 方法的 toggle 操作 + * 【修改】zTree 内鼠标移动会抢页面上 input 内的焦点的 bug + * 【修改】beforeRename / onRename 的触发方式——即使名称内容未改变也会触发,便于用户配合 beforeEditName 捕获编辑状态的结束,赋予用户更多调整规则的权利 + * 【修改】与 easyUI 共存时无法拖拽的bug + * 【修改】beforeRename 在 Firefox 下如果利用 alert,会触发两次的 bug + * 【修改】checkNode/expandNode/removeNode 方法,默认不触发回调函数,恢复 v2.6 的默认状态,同时增加 callbackFlag 参数,设置为 true 时,可以触发回调函数 + * 【修改】IE9下“根据参数查找节点”的Demo 报错:行14 重新声明常量属性(Demo 自身的问题,定义了history变量) + * 【修改】初始化 zTree 时 onNodeCreated 事件回调函数中无法 用 getZTreeObj 获取 zTree 对象的 bug + * 【修改】setting.edit.drag.prev / next / inner 参数,增加被拖拽的节点集合 + * 【修改】异步加载模式下,otherParam 使用Array数组会出错的 bug。例如: ["id", "1", "name", "test"] + * 【修改】FireFox 下多棵树拖拽异常的 bug + * 【修改】exedit 中调用 excheck库的方法时没有进行容错处理,导致如果只加入 exedit 而没有 excheck的时候,会出现 js 错误 + * 【修改】显示 checkbox 的 zTree 在编辑模式下,移动节点不会更新父节点半选状态的 bug + * 【修改】treeNode.childs --> children; treeObject.removeChilds --> removeChildNodes; setting.data.key.childs --> children(英文不好惹的祸!抱歉了!) + * 【修改】onRemove 回调中得到的 treeNode 还可以查找 preNode、nextNode 的bug。 修正后,getPreNode 和 getNextNode 都返回 null; 为了便于查找父节点,getParentNode 仍保留 + * 【修改】简单数据模式下,如果 id 与 pId 的值相同会导致该节点无法正常加载的 bug + * 【修改】移动或删除中间节点会导致最后一个节点连接线图标变小的 bug + +*2011.09.05* v3.0 beta + * 【修改】zTree 的 js 代码架构全面修改,并且拆分 + * 【修改】zTree 的 css 样式全面修改,对浏览器可以更好地兼容,同时解决了以前1个像素差的问题 + * 【优化】采用延迟加载技术,一次性加载大数据量的节点性能飞速提升 + * 【增加】支持多节点同时选中、拖拽 + * 【增加】checkNode、checkAllNodes 等多种方法 + * 【增加】IE6 自动取消动画展开、折叠的功能 + * 【修正】异步加载 & 编辑模式 能够更完美的共存 + * 【修正】setting 配置更加合理,并且增加了若干项配置参数 + * 【修正】treeNode 节点数据的属性更加合理,并且增加了一些方法 + * 【修正】拖拽操作更加灵活方便,更容易制定自己的规则 + * 【修正】其他若干修改,详细对比请参考 url:[http://www.ztree.me/v3/faq.php#_101 zTree v3.0 常见问题] diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jsonview/jquery.jsonview.css b/bmw-admin/src/main/resources/static/ajax/libs/jsonview/jquery.jsonview.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jsonview/jquery.jsonview.css rename to bmw-admin/src/main/resources/static/ajax/libs/jsonview/jquery.jsonview.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/jsonview/jquery.jsonview.js b/bmw-admin/src/main/resources/static/ajax/libs/jsonview/jquery.jsonview.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/jsonview/jquery.jsonview.js rename to bmw-admin/src/main/resources/static/ajax/libs/jsonview/jquery.jsonview.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/layer.min.js b/bmw-admin/src/main/resources/static/ajax/libs/layer/layer.min.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/layer.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/layer/layer.min.js index c2f009bd0..12cb6b5c0 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/layer.min.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/layer/layer.min.js @@ -1,2 +1,2 @@ -/*! layer-v3.1.1 Web弹层组件 MIT License http://layer.layui.com/ By 贤心 */ +/*! layer-v3.1.1 Web弹层组件 MIT License http://layer.layui.com/ By 贤心 */ ;!function(e,t){"use strict";var i,n,a=e.layui&&layui.define,o={getPath:function(){var e=document.currentScript?document.currentScript.src:function(){for(var e,t=document.scripts,i=t.length-1,n=i;n>0;n--)if("interactive"===t[n].readyState){e=t[n].src;break}return e||t[i].src}();return e.substring(0,e.lastIndexOf("/")+1)}(),config:{},end:{},minIndex:0,minLeft:[],btn:["确定","取消"],type:["dialog","page","iframe","loading","tips"],getStyle:function(t,i){var n=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](i)},link:function(t,i,n){if(r.path){var a=document.getElementsByTagName("head")[0],s=document.createElement("link");"string"==typeof i&&(n=i);var l=(n||t).replace(/\.|\//g,""),f="layuicss-"+l,c=0;s.rel="stylesheet",s.href=r.path+t,s.id=f,document.getElementById(f)||a.appendChild(s),"function"==typeof i&&!function u(){return++c>80?e.console&&console.error("layer.css: Invalid"):void(1989===parseInt(o.getStyle(document.getElementById(f),"width"))?i():setTimeout(u,100))}()}}},r={v:"3.1.1",ie:function(){var t=navigator.userAgent.toLowerCase();return!!(e.ActiveXObject||"ActiveXObject"in e)&&((t.match(/msie\s(\d+)/)||[])[1]||"11")}(),index:e.layer&&e.layer.v?1e5:0,path:o.getPath,config:function(e,t){return e=e||{},r.cache=o.config=i.extend({},o.config,e),r.path=o.config.path||r.path,"string"==typeof e.extend&&(e.extend=[e.extend]),o.config.path&&r.ready(),e.extend?(a?layui.addcss("modules/layer/"+e.extend):o.link("theme/"+e.extend),this):this},ready:function(e){var t="layer",i="",n=(a?"modules/layer/":"theme/")+"default/layer.css?v="+r.v+i;return a?layui.addcss(n,e,t):o.link(n,e,t),this},alert:function(e,t,n){var a="function"==typeof t;return a&&(n=t),r.open(i.extend({content:e,yes:n},a?{}:t))},confirm:function(e,t,n,a){var s="function"==typeof t;return s&&(a=n,n=t),r.open(i.extend({content:e,btn:o.btn,yes:n,btn2:a},s?{}:t))},msg:function(e,n,a){var s="function"==typeof n,f=o.config.skin,c=(f?f+" "+f+"-msg":"")||"layui-layer-msg",u=l.anim.length-1;return s&&(a=n),r.open(i.extend({content:e,time:3e3,shade:!1,skin:c,title:!1,closeBtn:!1,btn:!1,resize:!1,end:a},s&&!o.config.skin?{skin:c+" layui-layer-hui",anim:u}:function(){return n=n||{},(n.icon===-1||n.icon===t&&!o.config.skin)&&(n.skin=c+" "+(n.skin||"layui-layer-hui")),n}()))},load:function(e,t){return r.open(i.extend({type:3,icon:e||0,resize:!1,shade:.01},t))},tips:function(e,t,n){return r.open(i.extend({type:4,content:[e,t],closeBtn:!1,time:3e3,shade:!1,resize:!1,fixed:!1,maxWidth:210},n))}},s=function(e){var t=this;t.index=++r.index,t.config=i.extend({},t.config,o.config,e),document.body?t.creat():setTimeout(function(){t.creat()},30)};s.pt=s.prototype;var l=["layui-layer",".layui-layer-title",".layui-layer-main",".layui-layer-dialog","layui-layer-iframe","layui-layer-content","layui-layer-btn","layui-layer-close"];l.anim=["layer-anim-00","layer-anim-01","layer-anim-02","layer-anim-03","layer-anim-04","layer-anim-05","layer-anim-06"],s.pt.config={type:0,shade:.3,fixed:!0,move:l[1],title:"信息",offset:"auto",area:"auto",closeBtn:1,time:0,zIndex:19891014,maxWidth:360,anim:0,isOutAnim:!0,icon:-1,moveType:1,resize:!0,scrollbar:!0,tips:2},s.pt.vessel=function(e,t){var n=this,a=n.index,r=n.config,s=r.zIndex+a,f="object"==typeof r.title,c=r.maxmin&&(1===r.type||2===r.type),u=r.title?'
                '+(f?r.title[0]:r.title)+"
                ":"";return r.zIndex=s,t([r.shade?'
                ':"",'
                '+(e&&2!=r.type?"":u)+'
                '+(0==r.type&&r.icon!==-1?'':"")+(1==r.type&&e?"":r.content||"")+'
                '+function(){var e=c?'
                ':"";return r.closeBtn&&(e+=''),e}()+""+(r.btn?function(){var e="";"string"==typeof r.btn&&(r.btn=[r.btn]);for(var t=0,i=r.btn.length;t'+r.btn[t]+"";return'
                '+e+"
                "}():"")+(r.resize?'':"")+"
                "],u,i('
                ')),n},s.pt.creat=function(){var e=this,t=e.config,a=e.index,s=t.content,f="object"==typeof s,c=i("body");if(!t.id||!i("#"+t.id)[0]){switch("string"==typeof t.area&&(t.area="auto"===t.area?["",""]:[t.area,""]),t.shift&&(t.anim=t.shift),6==r.ie&&(t.fixed=!1),t.type){case 0:t.btn="btn"in t?t.btn:o.btn[0],r.closeAll("dialog");break;case 2:var s=t.content=f?t.content:[t.content||"http://layer.layui.com","auto"];t.content='';break;case 3:delete t.title,delete t.closeBtn,t.icon===-1&&0===t.icon,r.closeAll("loading");break;case 4:f||(t.content=[t.content,"body"]),t.follow=t.content[1],t.content=t.content[0]+'',delete t.title,t.tips="object"==typeof t.tips?t.tips:[t.tips,!0],t.tipsMore||r.closeAll("tips")}if(e.vessel(f,function(n,r,u){c.append(n[0]),f?function(){2==t.type||4==t.type?function(){i("body").append(n[1])}():function(){s.parents("."+l[0])[0]||(s.data("display",s.css("display")).show().addClass("layui-layer-wrap").wrap(n[1]),i("#"+l[0]+a).find("."+l[5]).before(r))}()}():c.append(n[1]),i(".layui-layer-move")[0]||c.append(o.moveElem=u),e.layero=i("#"+l[0]+a),t.scrollbar||l.html.css("overflow","hidden").attr("layer-full",a)}).auto(a),i("#layui-layer-shade"+e.index).css({"background-color":t.shade[1]||"#000",opacity:t.shade[0]||t.shade}),2==t.type&&6==r.ie&&e.layero.find("iframe").attr("src",s[0]),4==t.type?e.tips():e.offset(),t.fixed&&n.on("resize",function(){e.offset(),(/^\d+%$/.test(t.area[0])||/^\d+%$/.test(t.area[1]))&&e.auto(a),4==t.type&&e.tips()}),t.time<=0||setTimeout(function(){r.close(e.index)},t.time),e.move().callback(),l.anim[t.anim]){var u="layer-anim "+l.anim[t.anim];e.layero.addClass(u).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){i(this).removeClass(u)})}t.isOutAnim&&e.layero.data("isOutAnim",!0)}},s.pt.auto=function(e){var t=this,a=t.config,o=i("#"+l[0]+e);""===a.area[0]&&a.maxWidth>0&&(r.ie&&r.ie<8&&a.btn&&o.width(o.innerWidth()),o.outerWidth()>a.maxWidth&&o.width(a.maxWidth));var s=[o.innerWidth(),o.innerHeight()],f=o.find(l[1]).outerHeight()||0,c=o.find("."+l[6]).outerHeight()||0,u=function(e){e=o.find(e),e.height(s[1]-f-c-2*(0|parseFloat(e.css("padding-top"))))};switch(a.type){case 2:u("iframe");break;default:""===a.area[1]?a.maxHeight>0&&o.outerHeight()>a.maxHeight?(s[1]=a.maxHeight,u("."+l[5])):a.fixed&&s[1]>=n.height()&&(s[1]=n.height(),u("."+l[5])):u("."+l[5])}return t},s.pt.offset=function(){var e=this,t=e.config,i=e.layero,a=[i.outerWidth(),i.outerHeight()],o="object"==typeof t.offset;e.offsetTop=(n.height()-a[1])/2,e.offsetLeft=(n.width()-a[0])/2,o?(e.offsetTop=t.offset[0],e.offsetLeft=t.offset[1]||e.offsetLeft):"auto"!==t.offset&&("t"===t.offset?e.offsetTop=0:"r"===t.offset?e.offsetLeft=n.width()-a[0]:"b"===t.offset?e.offsetTop=n.height()-a[1]:"l"===t.offset?e.offsetLeft=0:"lt"===t.offset?(e.offsetTop=0,e.offsetLeft=0):"lb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=0):"rt"===t.offset?(e.offsetTop=0,e.offsetLeft=n.width()-a[0]):"rb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=n.width()-a[0]):e.offsetTop=t.offset),t.fixed||(e.offsetTop=/%$/.test(e.offsetTop)?n.height()*parseFloat(e.offsetTop)/100:parseFloat(e.offsetTop),e.offsetLeft=/%$/.test(e.offsetLeft)?n.width()*parseFloat(e.offsetLeft)/100:parseFloat(e.offsetLeft),e.offsetTop+=n.scrollTop(),e.offsetLeft+=n.scrollLeft()),i.attr("minLeft")&&(e.offsetTop=n.height()-(i.find(l[1]).outerHeight()||0),e.offsetLeft=i.css("left")),i.css({top:e.offsetTop,left:e.offsetLeft})},s.pt.tips=function(){var e=this,t=e.config,a=e.layero,o=[a.outerWidth(),a.outerHeight()],r=i(t.follow);r[0]||(r=i("body"));var s={width:r.outerWidth(),height:r.outerHeight(),top:r.offset().top,left:r.offset().left},f=a.find(".layui-layer-TipsG"),c=t.tips[0];t.tips[1]||f.remove(),s.autoLeft=function(){s.left+o[0]-n.width()>0?(s.tipLeft=s.left+s.width-o[0],f.css({right:12,left:"auto"})):s.tipLeft=s.left},s.where=[function(){s.autoLeft(),s.tipTop=s.top-o[1]-10,f.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left+s.width+10,s.tipTop=s.top,f.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color",t.tips[1])},function(){s.autoLeft(),s.tipTop=s.top+s.height+10,f.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left-o[0]-10,s.tipTop=s.top,f.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color",t.tips[1])}],s.where[c-1](),1===c?s.top-(n.scrollTop()+o[1]+16)<0&&s.where[2]():2===c?n.width()-(s.left+s.width+o[0]+16)>0||s.where[3]():3===c?s.top-n.scrollTop()+s.height+o[1]+16-n.height()>0&&s.where[0]():4===c&&o[0]+16-s.left>0&&s.where[1](),a.find("."+l[5]).css({"background-color":t.tips[1],"padding-right":t.closeBtn?"30px":""}),a.css({left:s.tipLeft-(t.fixed?n.scrollLeft():0),top:s.tipTop-(t.fixed?n.scrollTop():0)})},s.pt.move=function(){var e=this,t=e.config,a=i(document),s=e.layero,l=s.find(t.move),f=s.find(".layui-layer-resize"),c={};return t.move&&l.css("cursor","move"),l.on("mousedown",function(e){e.preventDefault(),t.move&&(c.moveStart=!0,c.offset=[e.clientX-parseFloat(s.css("left")),e.clientY-parseFloat(s.css("top"))],o.moveElem.css("cursor","move").show())}),f.on("mousedown",function(e){e.preventDefault(),c.resizeStart=!0,c.offset=[e.clientX,e.clientY],c.area=[s.outerWidth(),s.outerHeight()],o.moveElem.css("cursor","se-resize").show()}),a.on("mousemove",function(i){if(c.moveStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1],l="fixed"===s.css("position");if(i.preventDefault(),c.stX=l?0:n.scrollLeft(),c.stY=l?0:n.scrollTop(),!t.moveOut){var f=n.width()-s.outerWidth()+c.stX,u=n.height()-s.outerHeight()+c.stY;af&&(a=f),ou&&(o=u)}s.css({left:a,top:o})}if(t.resize&&c.resizeStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1];i.preventDefault(),r.style(e.index,{width:c.area[0]+a,height:c.area[1]+o}),c.isResize=!0,t.resizing&&t.resizing(s)}}).on("mouseup",function(e){c.moveStart&&(delete c.moveStart,o.moveElem.hide(),t.moveEnd&&t.moveEnd(s)),c.resizeStart&&(delete c.resizeStart,o.moveElem.hide())}),e},s.pt.callback=function(){function e(){var e=a.cancel&&a.cancel(t.index,n);e===!1||r.close(t.index)}var t=this,n=t.layero,a=t.config;t.openLayer(),a.success&&(2==a.type?n.find("iframe").on("load",function(){a.success(n,t.index)}):a.success(n,t.index)),6==r.ie&&t.IE6(n),n.find("."+l[6]).children("a").on("click",function(){var e=i(this).index();if(0===e)a.yes?a.yes(t.index,n):a.btn1?a.btn1(t.index,n):r.close(t.index);else{var o=a["btn"+(e+1)]&&a["btn"+(e+1)](t.index,n);o===!1||r.close(t.index)}}),n.find("."+l[7]).on("click",e),a.shadeClose&&i("#layui-layer-shade"+t.index).on("click",function(){r.close(t.index)}),n.find(".layui-layer-min").on("click",function(){var e=a.min&&a.min(n);e===!1||r.min(t.index,a)}),n.find(".layui-layer-max").on("click",function(){i(this).hasClass("layui-layer-maxmin")?(r.restore(t.index),a.restore&&a.restore(n)):(r.full(t.index,a),setTimeout(function(){a.full&&a.full(n)},100))}),a.end&&(o.end[t.index]=a.end)},o.reselect=function(){i.each(i("select"),function(e,t){var n=i(this);n.parents("."+l[0])[0]||1==n.attr("layer")&&i("."+l[0]).length<1&&n.removeAttr("layer").show(),n=null})},s.pt.IE6=function(e){i("select").each(function(e,t){var n=i(this);n.parents("."+l[0])[0]||"none"===n.css("display")||n.attr({layer:"1"}).hide(),n=null})},s.pt.openLayer=function(){var e=this;r.zIndex=e.config.zIndex,r.setTop=function(e){var t=function(){r.zIndex++,e.css("z-index",r.zIndex+1)};return r.zIndex=parseInt(e[0].style.zIndex),e.on("mousedown",t),r.zIndex}},o.record=function(e){var t=[e.width(),e.height(),e.position().top,e.position().left+parseFloat(e.css("margin-left"))];e.find(".layui-layer-max").addClass("layui-layer-maxmin"),e.attr({area:t})},o.rescollbar=function(e){l.html.attr("layer-full")==e&&(l.html[0].style.removeProperty?l.html[0].style.removeProperty("overflow"):l.html[0].style.removeAttribute("overflow"),l.html.removeAttr("layer-full"))},e.layer=r,r.getChildFrame=function(e,t){return t=t||i("."+l[4]).attr("times"),i("#"+l[0]+t).find("iframe").contents().find(e)},r.getFrameIndex=function(e){return i("#"+e).parents("."+l[4]).attr("times")},r.iframeAuto=function(e){if(e){var t=r.getChildFrame("html",e).outerHeight(),n=i("#"+l[0]+e),a=n.find(l[1]).outerHeight()||0,o=n.find("."+l[6]).outerHeight()||0;n.css({height:t+a+o}),n.find("iframe").css({height:t})}},r.iframeSrc=function(e,t){i("#"+l[0]+e).find("iframe").attr("src",t)},r.style=function(e,t,n){var a=i("#"+l[0]+e),r=a.find(".layui-layer-content"),s=a.attr("type"),f=a.find(l[1]).outerHeight()||0,c=a.find("."+l[6]).outerHeight()||0;a.attr("minLeft");s!==o.type[3]&&s!==o.type[4]&&(n||(parseFloat(t.width)<=260&&(t.width=260),parseFloat(t.height)-f-c<=64&&(t.height=64+f+c)),a.css(t),c=a.find("."+l[6]).outerHeight(),s===o.type[2]?a.find("iframe").css({height:parseFloat(t.height)-f-c}):r.css({height:parseFloat(t.height)-f-c-parseFloat(r.css("padding-top"))-parseFloat(r.css("padding-bottom"))}))},r.min=function(e,t){var a=i("#"+l[0]+e),s=a.find(l[1]).outerHeight()||0,f=a.attr("minLeft")||181*o.minIndex+"px",c=a.css("position");o.record(a),o.minLeft[0]&&(f=o.minLeft[0],o.minLeft.shift()),a.attr("position",c),r.style(e,{width:180,height:s,left:f,top:n.height()-s,position:"fixed",overflow:"hidden"},!0),a.find(".layui-layer-min").hide(),"page"===a.attr("type")&&a.find(l[4]).hide(),o.rescollbar(e),a.attr("minLeft")||o.minIndex++,a.attr("minLeft",f)},r.restore=function(e){var t=i("#"+l[0]+e),n=t.attr("area").split(",");t.attr("type");r.style(e,{width:parseFloat(n[0]),height:parseFloat(n[1]),top:parseFloat(n[2]),left:parseFloat(n[3]),position:t.attr("position"),overflow:"visible"},!0),t.find(".layui-layer-max").removeClass("layui-layer-maxmin"),t.find(".layui-layer-min").show(),"page"===t.attr("type")&&t.find(l[4]).show(),o.rescollbar(e)},r.full=function(e){var t,a=i("#"+l[0]+e);o.record(a),l.html.attr("layer-full")||l.html.css("overflow","hidden").attr("layer-full",e),clearTimeout(t),t=setTimeout(function(){var t="fixed"===a.css("position");r.style(e,{top:t?0:n.scrollTop(),left:t?0:n.scrollLeft(),width:n.width(),height:n.height()},!0),a.find(".layui-layer-min").hide()},100)},r.title=function(e,t){var n=i("#"+l[0]+(t||r.index)).find(l[1]);n.html(e)},r.close=function(e){var t=i("#"+l[0]+e),n=t.attr("type"),a="layer-anim-close";if(t[0]){var s="layui-layer-wrap",f=function(){if(n===o.type[1]&&"object"===t.attr("conType")){t.children(":not(."+l[5]+")").remove();for(var a=t.find("."+s),r=0;r<2;r++)a.unwrap();a.css("display",a.data("display")).removeClass(s)}else{if(n===o.type[2])try{var f=i("#"+l[4]+e)[0];f.contentWindow.document.write(""),f.contentWindow.close(),t.find("."+l[5])[0].removeChild(f)}catch(c){}t[0].innerHTML="",t.remove()}"function"==typeof o.end[e]&&o.end[e](),delete o.end[e]};t.data("isOutAnim")&&t.addClass("layer-anim "+a),i("#layui-layer-moves, #layui-layer-shade"+e).remove(),6==r.ie&&o.reselect(),o.rescollbar(e),t.attr("minLeft")&&(o.minIndex--,o.minLeft.push(t.attr("minLeft"))),r.ie&&r.ie<10||!t.data("isOutAnim")?f():setTimeout(function(){f()},200)}},r.closeAll=function(e){i.each(i("."+l[0]),function(){var t=i(this),n=e?t.attr("type")===e:1;n&&r.close(t.attr("times")),n=null})};var f=r.cache||{},c=function(e){return f.skin?" "+f.skin+" "+f.skin+"-"+e:""};r.prompt=function(e,t){var a="";if(e=e||{},"function"==typeof e&&(t=e),e.area){var o=e.area;a='style="width: '+o[0]+"; height: "+o[1]+';"',delete e.area}var s,l=2==e.formType?'":function(){return''}(),f=e.success;return delete e.success,r.open(i.extend({type:1,btn:["确定","取消"],content:l,skin:"layui-layer-prompt"+c("prompt"),maxWidth:n.width(),success:function(e){s=e.find(".layui-layer-input"),s.focus(),"function"==typeof f&&f(e)},resize:!1,yes:function(i){var n=s.val();""===n?s.focus():n.length>(e.maxlength||500)?r.tips("最多输入"+(e.maxlength||500)+"个字数",s,{tips:1}):t&&t(n,i,s)}},e))},r.tab=function(e){e=e||{};var t=e.tab||{},n="layui-this",a=e.success;return delete e.success,r.open(i.extend({type:1,skin:"layui-layer-tab"+c("tab"),resize:!1,title:function(){var e=t.length,i=1,a="";if(e>0)for(a=''+t[0].title+"";i"+t[i].title+"";return a}(),content:'
                  '+function(){var e=t.length,i=1,a="";if(e>0)for(a='
                • '+(t[0].content||"no content")+"
                • ";i'+(t[i].content||"no content")+"";return a}()+"
                ",success:function(t){var o=t.find(".layui-layer-title").children(),r=t.find(".layui-layer-tabmain").children();o.on("mousedown",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0;var a=i(this),o=a.index();a.addClass(n).siblings().removeClass(n),r.eq(o).show().siblings().hide(),"function"==typeof e.change&&e.change(o)}),"function"==typeof a&&a(t)}},e))},r.photos=function(t,n,a){function o(e,t,i){var n=new Image;return n.src=e,n.complete?t(n):(n.onload=function(){n.onload=null,t(n)},void(n.onerror=function(e){n.onerror=null,i(e)}))}var s={};if(t=t||{},t.photos){var l=t.photos.constructor===Object,f=l?t.photos:{},u=f.data||[],d=f.start||0;s.imgIndex=(0|d)+1,t.img=t.img||"img";var y=t.success;if(delete t.success,l){if(0===u.length)return r.msg("没有图片")}else{var p=i(t.photos),h=function(){u=[],p.find(t.img).each(function(e){var t=i(this);t.attr("layer-index",e),u.push({alt:t.attr("alt"),pid:t.attr("layer-pid"),src:t.attr("layer-src")||t.attr("src"),thumb:t.attr("src")})})};if(h(),0===u.length)return;if(n||p.on("click",t.img,function(){var e=i(this),n=e.attr("layer-index");r.photos(i.extend(t,{photos:{start:n,data:u,tab:t.tab},full:t.full}),!0),h()}),!n)return}s.imgprev=function(e){s.imgIndex--,s.imgIndex<1&&(s.imgIndex=u.length),s.tabimg(e)},s.imgnext=function(e,t){s.imgIndex++,s.imgIndex>u.length&&(s.imgIndex=1,t)||s.tabimg(e)},s.keyup=function(e){if(!s.end){var t=e.keyCode;e.preventDefault(),37===t?s.imgprev(!0):39===t?s.imgnext(!0):27===t&&r.close(s.index)}},s.tabimg=function(e){if(!(u.length<=1))return f.start=s.imgIndex-1,r.close(s.index),r.photos(t,!0,e)},s.event=function(){s.bigimg.hover(function(){s.imgsee.show()},function(){s.imgsee.hide()}),s.bigimg.find(".layui-layer-imgprev").on("click",function(e){e.preventDefault(),s.imgprev()}),s.bigimg.find(".layui-layer-imgnext").on("click",function(e){e.preventDefault(),s.imgnext()}),i(document).on("keyup",s.keyup)},s.loadi=r.load(1,{shade:!("shade"in t)&&.9,scrollbar:!1}),o(u[d].src,function(n){r.close(s.loadi),s.index=r.open(i.extend({type:1,id:"layui-layer-photos",area:function(){var a=[n.width,n.height],o=[i(e).width()-100,i(e).height()-100];if(!t.full&&(a[0]>o[0]||a[1]>o[1])){var r=[a[0]/o[0],a[1]/o[1]];r[0]>r[1]?(a[0]=a[0]/r[0],a[1]=a[1]/r[0]):r[0]'+(u[d].alt||
                '+(u.length>1?'':"")+'
                '+(u[d].alt||"")+""+s.imgIndex+"/"+u.length+"
                ",success:function(e,i){s.bigimg=e.find(".layui-layer-phimg"),s.imgsee=e.find(".layui-layer-imguide,.layui-layer-imgbar"),s.event(e),t.tab&&t.tab(u[d],e),"function"==typeof y&&y(e)},end:function(){s.end=!0,i(document).off("keyup",s.keyup)}},t))},function(){r.close(s.loadi),r.msg("当前图片地址异常
                是否继续查看下一张?",{time:3e4,btn:["下一张","不看了"],yes:function(){u.length>1&&s.imgnext(!0,!0)}})})}},o.run=function(t){i=t,n=i(e),l.html=i("html"),r.open=function(e){var t=new s(e);return t.index}},e.layui&&layui.define?(r.ready(),layui.define("jquery",function(t){r.path=layui.cache.dir,o.run(layui.$),e.layer=r,t("layer",r)})):"function"==typeof define&&define.amd?define(["jquery"],function(){return o.run(e.jQuery),r}):function(){o.run(e.jQuery),r.ready()}()}(window); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/icon-ext.png b/bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/icon-ext.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/icon-ext.png rename to bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/icon-ext.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/icon.png b/bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/icon.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/icon.png rename to bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/icon.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/layer.css b/bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/layer.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/layer.css rename to bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/layer.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-0.gif b/bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-0.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-0.gif rename to bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-0.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-1.gif b/bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-1.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-1.gif rename to bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-1.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-2.gif b/bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-2.gif similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-2.gif rename to bmw-admin/src/main/resources/static/ajax/libs/layer/theme/default/loading-2.gif diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/moon/default.png b/bmw-admin/src/main/resources/static/ajax/libs/layer/theme/moon/default.png similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/moon/default.png rename to bmw-admin/src/main/resources/static/ajax/libs/layer/theme/moon/default.png diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/moon/style.css b/bmw-admin/src/main/resources/static/ajax/libs/layer/theme/moon/style.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layer/theme/moon/style.css rename to bmw-admin/src/main/resources/static/ajax/libs/layer/theme/moon/style.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.eot b/bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.eot similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.eot rename to bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.eot diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.svg b/bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.svg similarity index 98% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.svg rename to bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.svg index 788ecc697..1e04218fe 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.svg +++ b/bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.svg @@ -1,45 +1,45 @@ - - - - - -Created by iconfont - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + +Created by iconfont + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.ttf b/bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.ttf similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.ttf rename to bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.ttf diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.woff b/bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.woff similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.woff rename to bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/font/iconfont.woff diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/laydate.css b/bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/laydate.css similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/laydate.css rename to bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/laydate.css index 407fe7e84..c7e15086b 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/laydate.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/layui/css/modules/laydate/default/laydate.css @@ -1,2 +1,2 @@ -/*! laydate-v5.0.9 日期与时间组件 MIT License http://www.layui.com/laydate/ By 贤心 */ +/*! laydate-v5.0.9 日期与时间组件 MIT License http://www.layui.com/laydate/ By 贤心 */ .laydate-set-ym,.layui-laydate,.layui-laydate *,.layui-laydate-list{box-sizing:border-box}html #layuicss-laydate{display:none;position:absolute;width:1989px}.layui-laydate *{margin:0;padding:0}.layui-laydate{position:absolute;z-index:66666666;margin:5px 0;border-radius:2px;font-size:14px;-webkit-animation-duration:.3s;animation-duration:.3s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-name:laydate-upbit;animation-name:laydate-upbit}.layui-laydate-main{width:272px}.layui-laydate-content td,.layui-laydate-header *,.layui-laydate-list li{transition-duration:.3s;-webkit-transition-duration:.3s}@-webkit-keyframes laydate-upbit{from{-webkit-transform:translate3d(0,20px,0);opacity:.3}to{-webkit-transform:translate3d(0,0,0);opacity:1}}@keyframes laydate-upbit{from{transform:translate3d(0,20px,0);opacity:.3}to{transform:translate3d(0,0,0);opacity:1}}.layui-laydate-static{position:relative;z-index:0;display:inline-block;margin:0;-webkit-animation:none;animation:none}.laydate-ym-show .laydate-next-m,.laydate-ym-show .laydate-prev-m{display:none!important}.laydate-ym-show .laydate-next-y,.laydate-ym-show .laydate-prev-y{display:inline-block!important}.laydate-time-show .laydate-set-ym span[lay-type=month],.laydate-time-show .laydate-set-ym span[lay-type=year],.laydate-time-show .layui-laydate-header .layui-icon,.laydate-ym-show .laydate-set-ym span[lay-type=month]{display:none!important}.layui-laydate-header{position:relative;line-height:30px;padding:10px 70px 5px}.laydate-set-ym span,.layui-laydate-header i{padding:0 5px;cursor:pointer}.layui-laydate-header *{display:inline-block;vertical-align:bottom}.layui-laydate-header i{position:absolute;top:10px;color:#999;font-size:18px}.layui-laydate-header i.laydate-prev-y{left:15px}.layui-laydate-header i.laydate-prev-m{left:45px}.layui-laydate-header i.laydate-next-y{right:15px}.layui-laydate-header i.laydate-next-m{right:45px}.laydate-set-ym{width:100%;text-align:center;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.laydate-time-text{cursor:default!important}.layui-laydate-content{position:relative;padding:10px;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none}.layui-laydate-content table{border-collapse:collapse;border-spacing:0}.layui-laydate-content td,.layui-laydate-content th{width:36px;height:30px;padding:5px;text-align:center}.layui-laydate-content td{position:relative;cursor:pointer}.laydate-day-mark{position:absolute;left:0;top:0;width:100%;height:100%;line-height:30px;font-size:12px;overflow:hidden}.laydate-day-mark::after{position:absolute;content:'';right:2px;top:2px;width:5px;height:5px;border-radius:50%}.layui-laydate-footer{position:relative;height:46px;line-height:26px;padding:10px 20px}.layui-laydate-footer span{margin-right:15px;display:inline-block;cursor:pointer;font-size:12px}.layui-laydate-footer span:hover{color:#5FB878}.laydate-footer-btns{position:absolute;right:10px;top:10px}.laydate-footer-btns span{height:26px;line-height:26px;margin:0 0 0 -1px;padding:0 10px;border:1px solid #C9C9C9;background-color:#fff;white-space:nowrap;vertical-align:top;border-radius:2px}.layui-laydate-list>li,.layui-laydate-range .layui-laydate-main{display:inline-block;vertical-align:middle}.layui-laydate-list{position:absolute;left:0;top:0;width:100%;height:100%;padding:10px;background-color:#fff}.layui-laydate-list>li{position:relative;width:33.3%;height:36px;line-height:36px;margin:3px 0;text-align:center;cursor:pointer}.laydate-month-list>li{width:25%;margin:17px 0}.laydate-time-list>li{height:100%;margin:0;line-height:normal;cursor:default}.laydate-time-list p{position:relative;top:-4px;line-height:29px}.laydate-time-list ol{height:181px;overflow:hidden}.laydate-time-list>li:hover ol{overflow-y:auto}.laydate-time-list ol li{width:130%;padding-left:33px;line-height:30px;text-align:left;cursor:pointer}.layui-laydate-hint{position:absolute;top:115px;left:50%;width:250px;margin-left:-125px;line-height:20px;padding:15px;text-align:center;font-size:12px}.layui-laydate-range{width:546px}.layui-laydate-range .laydate-main-list-0 .laydate-next-m,.layui-laydate-range .laydate-main-list-0 .laydate-next-y,.layui-laydate-range .laydate-main-list-1 .laydate-prev-m,.layui-laydate-range .laydate-main-list-1 .laydate-prev-y{display:none}.layui-laydate-range .laydate-main-list-1 .layui-laydate-content{border-left:1px solid #e2e2e2}.layui-laydate,.layui-laydate-hint{border:1px solid #d2d2d2;box-shadow:0 2px 4px rgba(0,0,0,.12);background-color:#fff;color:#666}.layui-laydate-header{border-bottom:1px solid #e2e2e2}.layui-laydate-header i:hover,.layui-laydate-header span:hover{color:#5FB878}.layui-laydate-content{border-top:none 0;border-bottom:none 0}.layui-laydate-content th{font-weight:400;color:#333}.layui-laydate-content td{color:#666}.layui-laydate-content td.laydate-selected{background-color:#00F7DE}.laydate-selected:hover{background-color:#00F7DE!important}.layui-laydate-content td:hover,.layui-laydate-list li:hover{background-color:#eaeaea;color:#333}.laydate-time-list li ol{margin:0;padding:0;border:1px solid #e2e2e2;border-left-width:0}.laydate-time-list li:first-child ol{border-left-width:1px}.laydate-time-list>li:hover{background:0 0}.layui-laydate-content .laydate-day-next,.layui-laydate-content .laydate-day-prev{color:#d2d2d2}.laydate-selected.laydate-day-next,.laydate-selected.laydate-day-prev{background-color:#f8f8f8!important}.layui-laydate-footer{border-top:1px solid #e2e2e2}.layui-laydate-hint{color:#FF5722}.laydate-day-mark::after{background-color:#5FB878}.layui-laydate-content td.layui-this .laydate-day-mark::after{display:none}.layui-laydate-footer span[lay-type=date]{color:#5FB878}.layui-laydate .layui-this{background-color:#009688!important;color:#fff!important}.layui-laydate .laydate-disabled,.layui-laydate .laydate-disabled:hover{background:0 0!important;color:#d2d2d2!important;cursor:not-allowed!important;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none}.laydate-theme-molv{border:none}.laydate-theme-molv.layui-laydate-range{width:548px}.laydate-theme-molv .layui-laydate-main{width:274px}.laydate-theme-molv .layui-laydate-header{border:none;background-color:#009688}.laydate-theme-molv .layui-laydate-header i,.laydate-theme-molv .layui-laydate-header span{color:#f6f6f6}.laydate-theme-molv .layui-laydate-header i:hover,.laydate-theme-molv .layui-laydate-header span:hover{color:#fff}.laydate-theme-molv .layui-laydate-content{border:1px solid #e2e2e2;border-top:none;border-bottom:none}.laydate-theme-molv .laydate-main-list-1 .layui-laydate-content{border-left:none}.laydate-theme-grid .laydate-month-list>li,.laydate-theme-grid .laydate-year-list>li,.laydate-theme-grid .layui-laydate-content td,.laydate-theme-grid .layui-laydate-content thead,.laydate-theme-molv .layui-laydate-footer{border:1px solid #e2e2e2}.laydate-theme-grid .laydate-selected,.laydate-theme-grid .laydate-selected:hover{background-color:#f2f2f2!important;color:#009688!important}.laydate-theme-grid .laydate-selected.laydate-day-next,.laydate-theme-grid .laydate-selected.laydate-day-prev{color:#d2d2d2!important}.laydate-theme-grid .laydate-month-list,.laydate-theme-grid .laydate-year-list{margin:1px 0 0 1px}.laydate-theme-grid .laydate-month-list>li,.laydate-theme-grid .laydate-year-list>li{margin:0 -1px -1px 0}.laydate-theme-grid .laydate-year-list>li{height:43px;line-height:43px}.laydate-theme-grid .laydate-month-list>li{height:71px;line-height:71px}@font-face{font-family:laydate-icon;src:url(font/iconfont.eot);src:url(font/iconfont.eot#iefix) format('embedded-opentype'),url(font/iconfont.svg#iconfont) format('svg'),url(font/iconfont.woff) format('woff'),url(font/iconfont.ttf) format('truetype')}.laydate-icon{font-family:laydate-icon!important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale} \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/lay/modules/laydate.js b/bmw-admin/src/main/resources/static/ajax/libs/layui/lay/modules/laydate.js similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/layui/lay/modules/laydate.js rename to bmw-admin/src/main/resources/static/ajax/libs/layui/lay/modules/laydate.js index 56fc54c59..cbf203d11 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/layui/lay/modules/laydate.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/layui/lay/modules/laydate.js @@ -1,2 +1,2 @@ -/** layui-v5.0.9 日期与时间组件 MIT License By https://www.layui.com */ - ;!function(){"use strict";var e=window.layui&&layui.define,t={getPath:function(){var e=document.currentScript?document.currentScript.src:function(){for(var e,t=document.scripts,n=t.length-1,a=n;a>0;a--)if("interactive"===t[a].readyState){e=t[a].src;break}return e||t[n].src}();return e.substring(0,e.lastIndexOf("/")+1)}(),getStyle:function(e,t){var n=e.currentStyle?e.currentStyle:window.getComputedStyle(e,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](t)},link:function(e,a,i){if(n.path){var r=document.getElementsByTagName("head")[0],o=document.createElement("link");"string"==typeof a&&(i=a);var s=(i||e).replace(/\.|\//g,""),l="layuicss-"+s,d=0;o.rel="stylesheet",o.href=n.path+e,o.id=l,document.getElementById(l)||r.appendChild(o),"function"==typeof a&&!function c(){return++d>80?window.console&&console.error("laydate.css: Invalid"):void(1989===parseInt(t.getStyle(document.getElementById(l),"width"))?a():setTimeout(c,100))}()}}},n={v:"5.0.9",config:{},index:window.laydate&&window.laydate.v?1e5:0,path:t.getPath,set:function(e){var t=this;return t.config=w.extend({},t.config,e),t},ready:function(a){var i="laydate",r="",o=(e?"modules/laydate/":"theme/")+"default/laydate.css?v="+n.v+r;return e?layui.addcss(o,a,i):t.link(o,a,i),this}},a=function(){var e=this;return{hint:function(t){e.hint.call(e,t)},config:e.config}},i="laydate",r=".layui-laydate",o="layui-this",s="laydate-disabled",l="开始日期超出了结束日期
                建议重新选择",d=[100,2e5],c="layui-laydate-static",m="layui-laydate-list",u="laydate-selected",h="layui-laydate-hint",y="laydate-day-prev",f="laydate-day-next",p="layui-laydate-footer",g=".laydate-btns-confirm",v="laydate-time-text",D=".laydate-btns-time",T=function(e){var t=this;t.index=++n.index,t.config=w.extend({},t.config,n.config,e),n.ready(function(){t.init()})},w=function(e){return new C(e)},C=function(e){for(var t=0,n="object"==typeof e?[e]:(this.selector=e,document.querySelectorAll(e||null));t0)return n[0].getAttribute(e)}():n.each(function(n,a){a.setAttribute(e,t)})},C.prototype.removeAttr=function(e){return this.each(function(t,n){n.removeAttribute(e)})},C.prototype.html=function(e){return this.each(function(t,n){n.innerHTML=e})},C.prototype.val=function(e){return this.each(function(t,n){n.value=e})},C.prototype.append=function(e){return this.each(function(t,n){"object"==typeof e?n.appendChild(e):n.innerHTML=n.innerHTML+e})},C.prototype.remove=function(e){return this.each(function(t,n){e?n.removeChild(e):n.parentNode.removeChild(n)})},C.prototype.on=function(e,t){return this.each(function(n,a){a.attachEvent?a.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(a,e)}):a.addEventListener(e,t,!1)})},C.prototype.off=function(e,t){return this.each(function(n,a){a.detachEvent?a.detachEvent("on"+e,t):a.removeEventListener(e,t,!1)})},T.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0},T.prototype.config={type:"date",range:!1,format:"yyyy-MM-dd",value:null,min:"1900-1-1",max:"2099-12-31",trigger:"focus",show:!1,showBottom:!0,btns:["clear","now","confirm"],lang:"cn",theme:"default",position:null,calendar:!1,mark:{},zIndex:null,done:null,change:null},T.prototype.lang=function(){var e=this,t=e.config,n={cn:{weeks:["日","一","二","三","四","五","六"],time:["时","分","秒"],timeTips:"选择时间",startTime:"开始时间",endTime:"结束时间",dateTips:"返回日期",month:["一","二","三","四","五","六","七","八","九","十","十一","十二"],tools:{confirm:"确定",clear:"清空",now:"现在"}},en:{weeks:["Su","Mo","Tu","We","Th","Fr","Sa"],time:["Hours","Minutes","Seconds"],timeTips:"Select Time",startTime:"Start Time",endTime:"End Time",dateTips:"Select Date",month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tools:{confirm:"Confirm",clear:"Clear",now:"Now"}}};return n[t.lang]||n.cn},T.prototype.init=function(){var e=this,t=e.config,n="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s",a="static"===t.position,i={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};t.elem=w(t.elem),t.eventElem=w(t.eventElem),t.elem[0]&&(t.range===!0&&(t.range="-"),t.format===i.date&&(t.format=i[t.type]),e.format=t.format.match(new RegExp(n+"|.","g"))||[],e.EXP_IF="",e.EXP_SPLIT="",w.each(e.format,function(t,a){var i=new RegExp(n).test(a)?"\\d{"+function(){return new RegExp(n).test(e.format[0===t?t+1:t-1]||"")?/^yyyy|y$/.test(a)?4:a.length:/^yyyy$/.test(a)?"1,4":/^y$/.test(a)?"1,308":"1,2"}()+"}":"\\"+a;e.EXP_IF=e.EXP_IF+i,e.EXP_SPLIT=e.EXP_SPLIT+"("+i+")"}),e.EXP_IF=new RegExp("^"+(t.range?e.EXP_IF+"\\s\\"+t.range+"\\s"+e.EXP_IF:e.EXP_IF)+"$"),e.EXP_SPLIT=new RegExp("^"+e.EXP_SPLIT+"$",""),e.isInput(t.elem[0])||"focus"===t.trigger&&(t.trigger="click"),t.elem.attr("lay-key")||(t.elem.attr("lay-key",e.index),t.eventElem.attr("lay-key",e.index)),t.mark=w.extend({},t.calendar&&"cn"===t.lang?{"0-1-1":"元旦","0-2-14":"情人","0-3-8":"妇女","0-3-12":"植树","0-4-1":"愚人","0-5-1":"劳动","0-5-4":"青年","0-6-1":"儿童","0-9-10":"教师","0-9-18":"国耻","0-10-1":"国庆","0-12-25":"圣诞"}:{},t.mark),w.each(["min","max"],function(e,n){var a=[],i=[];if("number"==typeof t[n]){var r=t[n],o=(new Date).getTime(),s=864e5,l=new Date(r?r0)return!0;var a=w.elem("div",{"class":"layui-laydate-header"}),i=[function(){var e=w.elem("i",{"class":"layui-icon laydate-icon laydate-prev-y"});return e.innerHTML="",e}(),function(){var e=w.elem("i",{"class":"layui-icon laydate-icon laydate-prev-m"});return e.innerHTML="",e}(),function(){var e=w.elem("div",{"class":"laydate-set-ym"}),t=w.elem("span"),n=w.elem("span");return e.appendChild(t),e.appendChild(n),e}(),function(){var e=w.elem("i",{"class":"layui-icon laydate-icon laydate-next-m"});return e.innerHTML="",e}(),function(){var e=w.elem("i",{"class":"layui-icon laydate-icon laydate-next-y"});return e.innerHTML="",e}()],d=w.elem("div",{"class":"layui-laydate-content"}),c=w.elem("table"),m=w.elem("thead"),u=w.elem("tr");w.each(i,function(e,t){a.appendChild(t)}),m.appendChild(u),w.each(new Array(6),function(e){var t=c.insertRow(0);w.each(new Array(7),function(a){if(0===e){var i=w.elem("th");i.innerHTML=n.weeks[a],u.appendChild(i)}t.insertCell(a)})}),c.insertBefore(m,c.children[0]),d.appendChild(c),r[e]=w.elem("div",{"class":"layui-laydate-main laydate-main-list-"+e}),r[e].appendChild(a),r[e].appendChild(d),o.push(i),s.push(d),l.push(c)}),w(d).html(function(){var e=[],i=[];return"datetime"===t.type&&e.push(''+n.timeTips+""),w.each(t.btns,function(e,r){var o=n.tools[r]||"btn";t.range&&"now"===r||(a&&"clear"===r&&(o="cn"===t.lang?"重置":"Reset"),i.push(''+o+""))}),e.push('"),e.join("")}()),w.each(r,function(e,t){i.appendChild(t)}),t.showBottom&&i.appendChild(d),/^#/.test(t.theme)){var m=w.elem("style"),u=["#{{id}} .layui-laydate-header{background-color:{{theme}};}","#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g,e.elemID).replace(/{{theme}}/g,t.theme);"styleSheet"in m?(m.setAttribute("type","text/css"),m.styleSheet.cssText=u):m.innerHTML=u,w(i).addClass("laydate-theme-molv"),i.appendChild(m)}e.remove(T.thisElemDate),a?t.elem.append(i):(document.body.appendChild(i),e.position()),e.checkDate().calendar(),e.changeEvent(),T.thisElemDate=e.elemID,"function"==typeof t.ready&&t.ready(w.extend({},t.dateTime,{month:t.dateTime.month+1}))},T.prototype.remove=function(e){var t=this,n=(t.config,w("#"+(e||t.elemID)));return n.hasClass(c)||t.checkDate(function(){n.remove()}),t},T.prototype.position=function(){var e=this,t=e.config,n=e.bindElem||t.elem[0],a=n.getBoundingClientRect(),i=e.elem.offsetWidth,r=e.elem.offsetHeight,o=function(e){return e=e?"scrollLeft":"scrollTop",document.body[e]|document.documentElement[e]},s=function(e){return document.documentElement[e?"clientWidth":"clientHeight"]},l=5,d=a.left,c=a.bottom;d+i+l>s("width")&&(d=s("width")-i-l),c+r+l>s()&&(c=a.top>r?a.top-r:s()-r,c-=2*l),t.position&&(e.elem.style.position=t.position),e.elem.style.left=d+("fixed"===t.position?0:o(1))+"px",e.elem.style.top=c+("fixed"===t.position?0:o())+"px"},T.prototype.hint=function(e){var t=this,n=(t.config,w.elem("div",{"class":h}));n.innerHTML=e||"",w(t.elem).find("."+h).remove(),t.elem.appendChild(n),clearTimeout(t.hinTimer),t.hinTimer=setTimeout(function(){w(t.elem).find("."+h).remove()},3e3)},T.prototype.getAsYM=function(e,t,n){return n?t--:t++,t<0&&(t=11,e--),t>11&&(t=0,e++),[e,t]},T.prototype.systemDate=function(e){var t=e||new Date;return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),hours:e?e.getHours():0,minutes:e?e.getMinutes():0,seconds:e?e.getSeconds():0}},T.prototype.checkDate=function(e){var t,a,i=this,r=(new Date,i.config),o=r.dateTime=r.dateTime||i.systemDate(),s=i.bindElem||r.elem[0],l=(i.isInput(s)?"val":"html",i.isInput(s)?s.value:"static"===r.position?"":s.innerHTML),c=function(e){e.year>d[1]&&(e.year=d[1],a=!0),e.month>11&&(e.month=11,a=!0),e.hours>23&&(e.hours=0,a=!0),e.minutes>59&&(e.minutes=0,e.hours++,a=!0),e.seconds>59&&(e.seconds=0,e.minutes++,a=!0),t=n.getEndDate(e.month+1,e.year),e.date>t&&(e.date=t,a=!0)},m=function(e,t,n){var o=["startTime","endTime"];t=(t.match(i.EXP_SPLIT)||[]).slice(1),n=n||0,r.range&&(i[o[n]]=i[o[n]]||{}),w.each(i.format,function(s,l){var c=parseFloat(t[s]);t[s].length必须遵循下述格式:
                "+(r.range?r.format+" "+r.range+" "+r.format:r.format)+"
                已为你重置"),a=!0):l&&l.constructor===Date?r.dateTime=i.systemDate(l):(r.dateTime=i.systemDate(),delete i.startState,delete i.endState,delete i.startDate,delete i.endDate,delete i.startTime,delete i.endTime),c(o),a&&l&&i.setValue(r.range?i.endDate?i.parse():"":i.parse()),e&&e(),i)},T.prototype.mark=function(e,t){var n,a=this,i=a.config;return w.each(i.mark,function(e,a){var i=e.split("-");i[0]!=t[0]&&0!=i[0]||i[1]!=t[1]&&0!=i[1]||i[2]!=t[2]||(n=a||t[2])}),n&&e.html(''+n+""),a},T.prototype.limit=function(e,t,n,a){var i,r=this,o=r.config,l={},d=o[n>41?"endDate":"dateTime"],c=w.extend({},d,t||{});return w.each({now:c,min:o.min,max:o.max},function(e,t){l[e]=r.newDate(w.extend({year:t.year,month:t.month,date:t.date},function(){var e={};return w.each(a,function(n,a){e[a]=t[a]}),e}())).getTime()}),i=l.nowl.max,e&&e[i?"addClass":"removeClass"](s),i},T.prototype.calendar=function(e){var t,a,i,r=this,s=r.config,l=e||s.dateTime,c=new Date,m=r.lang(),u="date"!==s.type&&"datetime"!==s.type,h=e?1:0,y=w(r.table[h]).find("td"),f=w(r.elemHeader[h][2]).find("span");if(l.yeard[1]&&(l.year=d[1],r.hint("最高只能支持到公元"+d[1]+"年")),r.firstDate||(r.firstDate=w.extend({},l)),c.setFullYear(l.year,l.month,1),t=c.getDay(),a=n.getEndDate(l.month||12,l.year),i=n.getEndDate(l.month+1,l.year),w.each(y,function(e,n){var d=[l.year,l.month],c=0;n=w(n),n.removeAttr("class"),e=t&&e=n.firstDate.year&&(r.month=a.max.month,r.date=a.max.date),n.limit(w(i),r,t),M++}),w(u[f?0:1]).attr("lay-ym",M-8+"-"+T[1]).html(b+p+" - "+(M-1+p))}else if("month"===e)w.each(new Array(12),function(e){var i=w.elem("li",{"lay-ym":e}),s={year:T[0],month:e};e+1==T[1]&&w(i).addClass(o),i.innerHTML=r.month[e]+(f?"月":""),d.appendChild(i),T[0]=n.firstDate.year&&(s.date=a.max.date),n.limit(w(i),s,t)}),w(u[f?0:1]).attr("lay-ym",T[0]+"-"+T[1]).html(T[0]+p);else if("time"===e){var E=function(){w(d).find("ol").each(function(e,a){w(a).find("li").each(function(a,i){n.limit(w(i),[{hours:a},{hours:n[x].hours,minutes:a},{hours:n[x].hours,minutes:n[x].minutes,seconds:a}][e],t,[["hours"],["hours","minutes"],["hours","minutes","seconds"]][e])})}),a.range||n.limit(w(n.footer).find(g),n[x],0,["hours","minutes","seconds"])};a.range?n[x]||(n[x]={hours:0,minutes:0,seconds:0}):n[x]=i,w.each([24,60,60],function(e,t){var a=w.elem("li"),i=["

                "+r.time[e]+"

                  "];w.each(new Array(t),function(t){i.push(""+w.digit(t,2)+"")}),a.innerHTML=i.join("")+"
                ",d.appendChild(a)}),E()}if(y&&h.removeChild(y),h.appendChild(d),"year"===e||"month"===e)w(n.elemMain[t]).addClass("laydate-ym-show"),w(d).find("li").on("click",function(){var r=0|w(this).attr("lay-ym");if(!w(this).hasClass(s)){if(0===t)i[e]=r,l&&(n.startDate[e]=r),n.limit(w(n.footer).find(g),null,0);else if(l)n.endDate[e]=r;else{var c="year"===e?n.getAsYM(r,T[1]-1,"sub"):n.getAsYM(T[0],r,"sub");w.extend(i,{year:c[0],month:c[1]})}"year"===a.type||"month"===a.type?(w(d).find("."+o).removeClass(o),w(this).addClass(o),"month"===a.type&&"year"===e&&(n.listYM[t][0]=r,l&&(n[["startDate","endDate"][t]].year=r),n.list("month",t))):(n.checkDate("limit").calendar(),n.closeList()),n.setBtnStatus(),a.range||n.done(null,"change"),w(n.footer).find(D).removeClass(s)}});else{var S=w.elem("span",{"class":v}),k=function(){w(d).find("ol").each(function(e){var t=this,a=w(t).find("li");t.scrollTop=30*(n[x][C[e]]-2),t.scrollTop<=0&&a.each(function(e,n){if(!w(this).hasClass(s))return t.scrollTop=30*(e-2),!0})})},H=w(c[2]).find("."+v);k(),S.innerHTML=a.range?[r.startTime,r.endTime][t]:r.timeTips,w(n.elemMain[t]).addClass("laydate-time-show"),H[0]&&H.remove(),c[2].appendChild(S),w(d).find("ol").each(function(e){var t=this;w(t).find("li").on("click",function(){var r=0|this.innerHTML;w(this).hasClass(s)||(a.range?n[x][C[e]]=r:i[C[e]]=r,w(t).find("."+o).removeClass(o),w(this).addClass(o),E(),k(),(n.endDate||"time"===a.type)&&n.done(null,"change"),n.setBtnStatus())})})}return n},T.prototype.listYM=[],T.prototype.closeList=function(){var e=this;e.config;w.each(e.elemCont,function(t,n){w(this).find("."+m).remove(),w(e.elemMain[t]).removeClass("laydate-ym-show laydate-time-show")}),w(e.elem).find("."+v).remove()},T.prototype.setBtnStatus=function(e,t,n){var a,i=this,r=i.config,o=w(i.footer).find(g),d=r.range&&"date"!==r.type&&"time"!==r.type;d&&(t=t||i.startDate,n=n||i.endDate,a=i.newDate(t).getTime()>i.newDate(n).getTime(),i.limit(null,t)||i.limit(null,n)?o.addClass(s):o[a?"addClass":"removeClass"](s),e&&a&&i.hint("string"==typeof e?l.replace(/日期/g,e):l))},T.prototype.parse=function(e,t){var n=this,a=n.config,i=t||(e?w.extend({},n.endDate,n.endTime):a.range?w.extend({},n.startDate,n.startTime):a.dateTime),r=n.format.concat();return w.each(r,function(e,t){/yyyy|y/.test(t)?r[e]=w.digit(i.year,t.length):/MM|M/.test(t)?r[e]=w.digit(i.month+1,t.length):/dd|d/.test(t)?r[e]=w.digit(i.date,t.length):/HH|H/.test(t)?r[e]=w.digit(i.hours,t.length):/mm|m/.test(t)?r[e]=w.digit(i.minutes,t.length):/ss|s/.test(t)&&(r[e]=w.digit(i.seconds,t.length))}),a.range&&!e?r.join("")+" "+a.range+" "+n.parse(1):r.join("")},T.prototype.newDate=function(e){return e=e||{},new Date(e.year||1,e.month||0,e.date||1,e.hours||0,e.minutes||0,e.seconds||0)},T.prototype.setValue=function(e){var t=this,n=t.config,a=t.bindElem||n.elem[0],i=t.isInput(a)?"val":"html";return"static"===n.position||w(a)[i](e||""),this},T.prototype.stampRange=function(){var e,t,n=this,a=n.config,i=w(n.elem).find("td");if(a.range&&!n.endDate&&w(n.footer).find(g).addClass(s),n.endDate)return e=n.newDate({year:n.startDate.year,month:n.startDate.month,date:n.startDate.date}).getTime(),t=n.newDate({year:n.endDate.year,month:n.endDate.month,date:n.endDate.date}).getTime(),e>t?n.hint(l):void w.each(i,function(a,i){var r=w(i).attr("lay-ymd").split("-"),s=n.newDate({year:r[0],month:r[1]-1,date:r[2]}).getTime();w(i).removeClass(u+" "+o),s!==e&&s!==t||w(i).addClass(w(i).hasClass(y)||w(i).hasClass(f)?u:o),s>e&&s0;a--)if("interactive"===t[a].readyState){e=t[a].src;break}return e||t[n].src}();return e.substring(0,e.lastIndexOf("/")+1)}(),getStyle:function(e,t){var n=e.currentStyle?e.currentStyle:window.getComputedStyle(e,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](t)},link:function(e,a,i){if(n.path){var r=document.getElementsByTagName("head")[0],o=document.createElement("link");"string"==typeof a&&(i=a);var s=(i||e).replace(/\.|\//g,""),l="layuicss-"+s,d=0;o.rel="stylesheet",o.href=n.path+e,o.id=l,document.getElementById(l)||r.appendChild(o),"function"==typeof a&&!function c(){return++d>80?window.console&&console.error("laydate.css: Invalid"):void(1989===parseInt(t.getStyle(document.getElementById(l),"width"))?a():setTimeout(c,100))}()}}},n={v:"5.0.9",config:{},index:window.laydate&&window.laydate.v?1e5:0,path:t.getPath,set:function(e){var t=this;return t.config=w.extend({},t.config,e),t},ready:function(a){var i="laydate",r="",o=(e?"modules/laydate/":"theme/")+"default/laydate.css?v="+n.v+r;return e?layui.addcss(o,a,i):t.link(o,a,i),this}},a=function(){var e=this;return{hint:function(t){e.hint.call(e,t)},config:e.config}},i="laydate",r=".layui-laydate",o="layui-this",s="laydate-disabled",l="开始日期超出了结束日期
                建议重新选择",d=[100,2e5],c="layui-laydate-static",m="layui-laydate-list",u="laydate-selected",h="layui-laydate-hint",y="laydate-day-prev",f="laydate-day-next",p="layui-laydate-footer",g=".laydate-btns-confirm",v="laydate-time-text",D=".laydate-btns-time",T=function(e){var t=this;t.index=++n.index,t.config=w.extend({},t.config,n.config,e),n.ready(function(){t.init()})},w=function(e){return new C(e)},C=function(e){for(var t=0,n="object"==typeof e?[e]:(this.selector=e,document.querySelectorAll(e||null));t0)return n[0].getAttribute(e)}():n.each(function(n,a){a.setAttribute(e,t)})},C.prototype.removeAttr=function(e){return this.each(function(t,n){n.removeAttribute(e)})},C.prototype.html=function(e){return this.each(function(t,n){n.innerHTML=e})},C.prototype.val=function(e){return this.each(function(t,n){n.value=e})},C.prototype.append=function(e){return this.each(function(t,n){"object"==typeof e?n.appendChild(e):n.innerHTML=n.innerHTML+e})},C.prototype.remove=function(e){return this.each(function(t,n){e?n.removeChild(e):n.parentNode.removeChild(n)})},C.prototype.on=function(e,t){return this.each(function(n,a){a.attachEvent?a.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(a,e)}):a.addEventListener(e,t,!1)})},C.prototype.off=function(e,t){return this.each(function(n,a){a.detachEvent?a.detachEvent("on"+e,t):a.removeEventListener(e,t,!1)})},T.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0},T.prototype.config={type:"date",range:!1,format:"yyyy-MM-dd",value:null,min:"1900-1-1",max:"2099-12-31",trigger:"focus",show:!1,showBottom:!0,btns:["clear","now","confirm"],lang:"cn",theme:"default",position:null,calendar:!1,mark:{},zIndex:null,done:null,change:null},T.prototype.lang=function(){var e=this,t=e.config,n={cn:{weeks:["日","一","二","三","四","五","六"],time:["时","分","秒"],timeTips:"选择时间",startTime:"开始时间",endTime:"结束时间",dateTips:"返回日期",month:["一","二","三","四","五","六","七","八","九","十","十一","十二"],tools:{confirm:"确定",clear:"清空",now:"现在"}},en:{weeks:["Su","Mo","Tu","We","Th","Fr","Sa"],time:["Hours","Minutes","Seconds"],timeTips:"Select Time",startTime:"Start Time",endTime:"End Time",dateTips:"Select Date",month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tools:{confirm:"Confirm",clear:"Clear",now:"Now"}}};return n[t.lang]||n.cn},T.prototype.init=function(){var e=this,t=e.config,n="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s",a="static"===t.position,i={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};t.elem=w(t.elem),t.eventElem=w(t.eventElem),t.elem[0]&&(t.range===!0&&(t.range="-"),t.format===i.date&&(t.format=i[t.type]),e.format=t.format.match(new RegExp(n+"|.","g"))||[],e.EXP_IF="",e.EXP_SPLIT="",w.each(e.format,function(t,a){var i=new RegExp(n).test(a)?"\\d{"+function(){return new RegExp(n).test(e.format[0===t?t+1:t-1]||"")?/^yyyy|y$/.test(a)?4:a.length:/^yyyy$/.test(a)?"1,4":/^y$/.test(a)?"1,308":"1,2"}()+"}":"\\"+a;e.EXP_IF=e.EXP_IF+i,e.EXP_SPLIT=e.EXP_SPLIT+"("+i+")"}),e.EXP_IF=new RegExp("^"+(t.range?e.EXP_IF+"\\s\\"+t.range+"\\s"+e.EXP_IF:e.EXP_IF)+"$"),e.EXP_SPLIT=new RegExp("^"+e.EXP_SPLIT+"$",""),e.isInput(t.elem[0])||"focus"===t.trigger&&(t.trigger="click"),t.elem.attr("lay-key")||(t.elem.attr("lay-key",e.index),t.eventElem.attr("lay-key",e.index)),t.mark=w.extend({},t.calendar&&"cn"===t.lang?{"0-1-1":"元旦","0-2-14":"情人","0-3-8":"妇女","0-3-12":"植树","0-4-1":"愚人","0-5-1":"劳动","0-5-4":"青年","0-6-1":"儿童","0-9-10":"教师","0-9-18":"国耻","0-10-1":"国庆","0-12-25":"圣诞"}:{},t.mark),w.each(["min","max"],function(e,n){var a=[],i=[];if("number"==typeof t[n]){var r=t[n],o=(new Date).getTime(),s=864e5,l=new Date(r?r0)return!0;var a=w.elem("div",{"class":"layui-laydate-header"}),i=[function(){var e=w.elem("i",{"class":"layui-icon laydate-icon laydate-prev-y"});return e.innerHTML="",e}(),function(){var e=w.elem("i",{"class":"layui-icon laydate-icon laydate-prev-m"});return e.innerHTML="",e}(),function(){var e=w.elem("div",{"class":"laydate-set-ym"}),t=w.elem("span"),n=w.elem("span");return e.appendChild(t),e.appendChild(n),e}(),function(){var e=w.elem("i",{"class":"layui-icon laydate-icon laydate-next-m"});return e.innerHTML="",e}(),function(){var e=w.elem("i",{"class":"layui-icon laydate-icon laydate-next-y"});return e.innerHTML="",e}()],d=w.elem("div",{"class":"layui-laydate-content"}),c=w.elem("table"),m=w.elem("thead"),u=w.elem("tr");w.each(i,function(e,t){a.appendChild(t)}),m.appendChild(u),w.each(new Array(6),function(e){var t=c.insertRow(0);w.each(new Array(7),function(a){if(0===e){var i=w.elem("th");i.innerHTML=n.weeks[a],u.appendChild(i)}t.insertCell(a)})}),c.insertBefore(m,c.children[0]),d.appendChild(c),r[e]=w.elem("div",{"class":"layui-laydate-main laydate-main-list-"+e}),r[e].appendChild(a),r[e].appendChild(d),o.push(i),s.push(d),l.push(c)}),w(d).html(function(){var e=[],i=[];return"datetime"===t.type&&e.push(''+n.timeTips+""),w.each(t.btns,function(e,r){var o=n.tools[r]||"btn";t.range&&"now"===r||(a&&"clear"===r&&(o="cn"===t.lang?"重置":"Reset"),i.push(''+o+""))}),e.push('"),e.join("")}()),w.each(r,function(e,t){i.appendChild(t)}),t.showBottom&&i.appendChild(d),/^#/.test(t.theme)){var m=w.elem("style"),u=["#{{id}} .layui-laydate-header{background-color:{{theme}};}","#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g,e.elemID).replace(/{{theme}}/g,t.theme);"styleSheet"in m?(m.setAttribute("type","text/css"),m.styleSheet.cssText=u):m.innerHTML=u,w(i).addClass("laydate-theme-molv"),i.appendChild(m)}e.remove(T.thisElemDate),a?t.elem.append(i):(document.body.appendChild(i),e.position()),e.checkDate().calendar(),e.changeEvent(),T.thisElemDate=e.elemID,"function"==typeof t.ready&&t.ready(w.extend({},t.dateTime,{month:t.dateTime.month+1}))},T.prototype.remove=function(e){var t=this,n=(t.config,w("#"+(e||t.elemID)));return n.hasClass(c)||t.checkDate(function(){n.remove()}),t},T.prototype.position=function(){var e=this,t=e.config,n=e.bindElem||t.elem[0],a=n.getBoundingClientRect(),i=e.elem.offsetWidth,r=e.elem.offsetHeight,o=function(e){return e=e?"scrollLeft":"scrollTop",document.body[e]|document.documentElement[e]},s=function(e){return document.documentElement[e?"clientWidth":"clientHeight"]},l=5,d=a.left,c=a.bottom;d+i+l>s("width")&&(d=s("width")-i-l),c+r+l>s()&&(c=a.top>r?a.top-r:s()-r,c-=2*l),t.position&&(e.elem.style.position=t.position),e.elem.style.left=d+("fixed"===t.position?0:o(1))+"px",e.elem.style.top=c+("fixed"===t.position?0:o())+"px"},T.prototype.hint=function(e){var t=this,n=(t.config,w.elem("div",{"class":h}));n.innerHTML=e||"",w(t.elem).find("."+h).remove(),t.elem.appendChild(n),clearTimeout(t.hinTimer),t.hinTimer=setTimeout(function(){w(t.elem).find("."+h).remove()},3e3)},T.prototype.getAsYM=function(e,t,n){return n?t--:t++,t<0&&(t=11,e--),t>11&&(t=0,e++),[e,t]},T.prototype.systemDate=function(e){var t=e||new Date;return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),hours:e?e.getHours():0,minutes:e?e.getMinutes():0,seconds:e?e.getSeconds():0}},T.prototype.checkDate=function(e){var t,a,i=this,r=(new Date,i.config),o=r.dateTime=r.dateTime||i.systemDate(),s=i.bindElem||r.elem[0],l=(i.isInput(s)?"val":"html",i.isInput(s)?s.value:"static"===r.position?"":s.innerHTML),c=function(e){e.year>d[1]&&(e.year=d[1],a=!0),e.month>11&&(e.month=11,a=!0),e.hours>23&&(e.hours=0,a=!0),e.minutes>59&&(e.minutes=0,e.hours++,a=!0),e.seconds>59&&(e.seconds=0,e.minutes++,a=!0),t=n.getEndDate(e.month+1,e.year),e.date>t&&(e.date=t,a=!0)},m=function(e,t,n){var o=["startTime","endTime"];t=(t.match(i.EXP_SPLIT)||[]).slice(1),n=n||0,r.range&&(i[o[n]]=i[o[n]]||{}),w.each(i.format,function(s,l){var c=parseFloat(t[s]);t[s].length必须遵循下述格式:
                "+(r.range?r.format+" "+r.range+" "+r.format:r.format)+"
                已为你重置"),a=!0):l&&l.constructor===Date?r.dateTime=i.systemDate(l):(r.dateTime=i.systemDate(),delete i.startState,delete i.endState,delete i.startDate,delete i.endDate,delete i.startTime,delete i.endTime),c(o),a&&l&&i.setValue(r.range?i.endDate?i.parse():"":i.parse()),e&&e(),i)},T.prototype.mark=function(e,t){var n,a=this,i=a.config;return w.each(i.mark,function(e,a){var i=e.split("-");i[0]!=t[0]&&0!=i[0]||i[1]!=t[1]&&0!=i[1]||i[2]!=t[2]||(n=a||t[2])}),n&&e.html(''+n+""),a},T.prototype.limit=function(e,t,n,a){var i,r=this,o=r.config,l={},d=o[n>41?"endDate":"dateTime"],c=w.extend({},d,t||{});return w.each({now:c,min:o.min,max:o.max},function(e,t){l[e]=r.newDate(w.extend({year:t.year,month:t.month,date:t.date},function(){var e={};return w.each(a,function(n,a){e[a]=t[a]}),e}())).getTime()}),i=l.nowl.max,e&&e[i?"addClass":"removeClass"](s),i},T.prototype.calendar=function(e){var t,a,i,r=this,s=r.config,l=e||s.dateTime,c=new Date,m=r.lang(),u="date"!==s.type&&"datetime"!==s.type,h=e?1:0,y=w(r.table[h]).find("td"),f=w(r.elemHeader[h][2]).find("span");if(l.yeard[1]&&(l.year=d[1],r.hint("最高只能支持到公元"+d[1]+"年")),r.firstDate||(r.firstDate=w.extend({},l)),c.setFullYear(l.year,l.month,1),t=c.getDay(),a=n.getEndDate(l.month||12,l.year),i=n.getEndDate(l.month+1,l.year),w.each(y,function(e,n){var d=[l.year,l.month],c=0;n=w(n),n.removeAttr("class"),e=t&&e=n.firstDate.year&&(r.month=a.max.month,r.date=a.max.date),n.limit(w(i),r,t),M++}),w(u[f?0:1]).attr("lay-ym",M-8+"-"+T[1]).html(b+p+" - "+(M-1+p))}else if("month"===e)w.each(new Array(12),function(e){var i=w.elem("li",{"lay-ym":e}),s={year:T[0],month:e};e+1==T[1]&&w(i).addClass(o),i.innerHTML=r.month[e]+(f?"月":""),d.appendChild(i),T[0]=n.firstDate.year&&(s.date=a.max.date),n.limit(w(i),s,t)}),w(u[f?0:1]).attr("lay-ym",T[0]+"-"+T[1]).html(T[0]+p);else if("time"===e){var E=function(){w(d).find("ol").each(function(e,a){w(a).find("li").each(function(a,i){n.limit(w(i),[{hours:a},{hours:n[x].hours,minutes:a},{hours:n[x].hours,minutes:n[x].minutes,seconds:a}][e],t,[["hours"],["hours","minutes"],["hours","minutes","seconds"]][e])})}),a.range||n.limit(w(n.footer).find(g),n[x],0,["hours","minutes","seconds"])};a.range?n[x]||(n[x]={hours:0,minutes:0,seconds:0}):n[x]=i,w.each([24,60,60],function(e,t){var a=w.elem("li"),i=["

                "+r.time[e]+"

                  "];w.each(new Array(t),function(t){i.push(""+w.digit(t,2)+"")}),a.innerHTML=i.join("")+"
                ",d.appendChild(a)}),E()}if(y&&h.removeChild(y),h.appendChild(d),"year"===e||"month"===e)w(n.elemMain[t]).addClass("laydate-ym-show"),w(d).find("li").on("click",function(){var r=0|w(this).attr("lay-ym");if(!w(this).hasClass(s)){if(0===t)i[e]=r,l&&(n.startDate[e]=r),n.limit(w(n.footer).find(g),null,0);else if(l)n.endDate[e]=r;else{var c="year"===e?n.getAsYM(r,T[1]-1,"sub"):n.getAsYM(T[0],r,"sub");w.extend(i,{year:c[0],month:c[1]})}"year"===a.type||"month"===a.type?(w(d).find("."+o).removeClass(o),w(this).addClass(o),"month"===a.type&&"year"===e&&(n.listYM[t][0]=r,l&&(n[["startDate","endDate"][t]].year=r),n.list("month",t))):(n.checkDate("limit").calendar(),n.closeList()),n.setBtnStatus(),a.range||n.done(null,"change"),w(n.footer).find(D).removeClass(s)}});else{var S=w.elem("span",{"class":v}),k=function(){w(d).find("ol").each(function(e){var t=this,a=w(t).find("li");t.scrollTop=30*(n[x][C[e]]-2),t.scrollTop<=0&&a.each(function(e,n){if(!w(this).hasClass(s))return t.scrollTop=30*(e-2),!0})})},H=w(c[2]).find("."+v);k(),S.innerHTML=a.range?[r.startTime,r.endTime][t]:r.timeTips,w(n.elemMain[t]).addClass("laydate-time-show"),H[0]&&H.remove(),c[2].appendChild(S),w(d).find("ol").each(function(e){var t=this;w(t).find("li").on("click",function(){var r=0|this.innerHTML;w(this).hasClass(s)||(a.range?n[x][C[e]]=r:i[C[e]]=r,w(t).find("."+o).removeClass(o),w(this).addClass(o),E(),k(),(n.endDate||"time"===a.type)&&n.done(null,"change"),n.setBtnStatus())})})}return n},T.prototype.listYM=[],T.prototype.closeList=function(){var e=this;e.config;w.each(e.elemCont,function(t,n){w(this).find("."+m).remove(),w(e.elemMain[t]).removeClass("laydate-ym-show laydate-time-show")}),w(e.elem).find("."+v).remove()},T.prototype.setBtnStatus=function(e,t,n){var a,i=this,r=i.config,o=w(i.footer).find(g),d=r.range&&"date"!==r.type&&"time"!==r.type;d&&(t=t||i.startDate,n=n||i.endDate,a=i.newDate(t).getTime()>i.newDate(n).getTime(),i.limit(null,t)||i.limit(null,n)?o.addClass(s):o[a?"addClass":"removeClass"](s),e&&a&&i.hint("string"==typeof e?l.replace(/日期/g,e):l))},T.prototype.parse=function(e,t){var n=this,a=n.config,i=t||(e?w.extend({},n.endDate,n.endTime):a.range?w.extend({},n.startDate,n.startTime):a.dateTime),r=n.format.concat();return w.each(r,function(e,t){/yyyy|y/.test(t)?r[e]=w.digit(i.year,t.length):/MM|M/.test(t)?r[e]=w.digit(i.month+1,t.length):/dd|d/.test(t)?r[e]=w.digit(i.date,t.length):/HH|H/.test(t)?r[e]=w.digit(i.hours,t.length):/mm|m/.test(t)?r[e]=w.digit(i.minutes,t.length):/ss|s/.test(t)&&(r[e]=w.digit(i.seconds,t.length))}),a.range&&!e?r.join("")+" "+a.range+" "+n.parse(1):r.join("")},T.prototype.newDate=function(e){return e=e||{},new Date(e.year||1,e.month||0,e.date||1,e.hours||0,e.minutes||0,e.seconds||0)},T.prototype.setValue=function(e){var t=this,n=t.config,a=t.bindElem||n.elem[0],i=t.isInput(a)?"val":"html";return"static"===n.position||w(a)[i](e||""),this},T.prototype.stampRange=function(){var e,t,n=this,a=n.config,i=w(n.elem).find("td");if(a.range&&!n.endDate&&w(n.footer).find(g).addClass(s),n.endDate)return e=n.newDate({year:n.startDate.year,month:n.startDate.month,date:n.startDate.date}).getTime(),t=n.newDate({year:n.endDate.year,month:n.endDate.month,date:n.endDate.date}).getTime(),e>t?n.hint(l):void w.each(i,function(a,i){var r=w(i).attr("lay-ymd").split("-"),s=n.newDate({year:r[0],month:r[1]-1,date:r[2]}).getTime();w(i).removeClass(u+" "+o),s!==e&&s!==t||w(i).addClass(w(i).hasClass(y)||w(i).hasClass(f)?u:o),s>e&&s0;r--)if("interactive"===n[r].readyState){e=n[r].src;break}return e||n[o].src}();return e.substring(0,e.lastIndexOf("/")+1)}(),a=function(t){e.console&&console.error&&console.error("Layui hint: "+t)},i="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),u={layer:"modules/layer",laydate:"modules/laydate",laypage:"modules/laypage",laytpl:"modules/laytpl",layim:"modules/layim",layedit:"modules/layedit",form:"modules/form",upload:"modules/upload",tree:"modules/tree",table:"modules/table",element:"modules/element",rate:"modules/rate",carousel:"modules/carousel",flow:"modules/flow",util:"modules/util",code:"modules/code",jquery:"modules/jquery",mobile:"modules/mobile","layui.all":"../layui.all"};o.prototype.cache=n,o.prototype.define=function(e,t){var o=this,r="function"==typeof e,a=function(){var e=function(e,t){layui[e]=t,n.status[e]=!0};return"function"==typeof t&&t(function(o,r){e(o,r),n.callback[o]=function(){t(e)}}),this};return r&&(t=e,e=[]),layui["layui.all"]||!layui["layui.all"]&&layui["layui.mobile"]?a.call(o):(o.use(e,a),o)},o.prototype.use=function(e,o,l){function s(e,t){var o="PLaySTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/;("load"===e.type||o.test((e.currentTarget||e.srcElement).readyState))&&(n.modules[d]=t,f.removeChild(v),function r(){return++m>1e3*n.timeout/4?a(d+" is not a valid module"):void(n.status[d]?c():setTimeout(r,4))}())}function c(){l.push(layui[d]),e.length>1?y.use(e.slice(1),o,l):"function"==typeof o&&o.apply(layui,l)}var y=this,p=n.dir=n.dir?n.dir:r,f=t.getElementsByTagName("head")[0];e="string"==typeof e?[e]:e,window.jQuery&&jQuery.fn.on&&(y.each(e,function(t,n){"jquery"===n&&e.splice(t,1)}),layui.jquery=layui.$=jQuery);var d=e[0],m=0;if(l=l||[],n.host=n.host||(p.match(/\/\/([\s\S]+?)\//)||["//"+location.host+"/"])[0],0===e.length||layui["layui.all"]&&u[d]||!layui["layui.all"]&&layui["layui.mobile"]&&u[d])return c(),y;if(n.modules[d])!function g(){return++m>1e3*n.timeout/4?a(d+" is not a valid module"):void("string"==typeof n.modules[d]&&n.status[d]?c():setTimeout(g,4))}();else{var v=t.createElement("script"),h=(u[d]?p+"lay/":/^\{\/\}/.test(y.modules[d])?"":n.base||"")+(y.modules[d]||d)+".js";h=h.replace(/^\{\/\}/,""),v.async=!0,v.charset="utf-8",v.src=h+function(){var e=n.version===!0?n.v||(new Date).getTime():n.version||"";return e?"?v="+e:""}(),f.appendChild(v),!v.attachEvent||v.attachEvent.toString&&v.attachEvent.toString().indexOf("[native code")<0||i?v.addEventListener("load",function(e){s(e,h)},!1):v.attachEvent("onreadystatechange",function(e){s(e,h)}),n.modules[d]=h}return y},o.prototype.getStyle=function(t,n){var o=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return o[o.getPropertyValue?"getPropertyValue":"getAttribute"](n)},o.prototype.link=function(e,o,r){var i=this,u=t.createElement("link"),l=t.getElementsByTagName("head")[0];"string"==typeof o&&(r=o);var s=(r||e).replace(/\.|\//g,""),c=u.id="layuicss-"+s,y=0;return u.rel="stylesheet",u.href=e+(n.debug?"?v="+(new Date).getTime():""),u.media="all",t.getElementById(c)||l.appendChild(u),"function"!=typeof o?i:(function p(){return++y>1e3*n.timeout/100?a(e+" timeout"):void(1989===parseInt(i.getStyle(t.getElementById(c),"width"))?function(){o()}():setTimeout(p,100))}(),i)},n.callback={},o.prototype.factory=function(e){if(layui[e])return"function"==typeof n.callback[e]?n.callback[e]:null},o.prototype.addcss=function(e,t,o){return layui.link(n.dir+"css/"+e,t,o)},o.prototype.img=function(e,t,n){var o=new Image;return o.src=e,o.complete?t(o):(o.onload=function(){o.onload=null,"function"==typeof t&&t(o)},void(o.onerror=function(e){o.onerror=null,"function"==typeof n&&n(e)}))},o.prototype.config=function(e){e=e||{};for(var t in e)n[t]=e[t];return this},o.prototype.modules=function(){var e={};for(var t in u)e[t]=u[t];return e}(),o.prototype.extend=function(e){var t=this;e=e||{};for(var n in e)t[n]||t.modules[n]?a("模块名 "+n+" 已被占用"):t.modules[n]=e[n];return t},o.prototype.router=function(e){var t=this,e=e||location.hash,n={path:[],search:{},hash:(e.match(/[^#](#.*$)/)||[])[1]||""};return/^#\//.test(e)?(e=e.replace(/^#\//,""),n.href="/"+e,e=e.replace(/([^#])(#.*$)/,"$1").split("/")||[],t.each(e,function(e,t){/^\w+=/.test(t)?function(){t=t.split("="),n.search[t[0]]=t[1]}():n.path.push(t)}),n):n},o.prototype.data=function(t,n,o){if(t=t||"layui",o=o||localStorage,e.JSON&&e.JSON.parse){if(null===n)return delete o[t];n="object"==typeof n?n:{key:n};try{var r=JSON.parse(o[t])}catch(a){var r={}}return"value"in n&&(r[n.key]=n.value),n.remove&&delete r[n.key],o[t]=JSON.stringify(r),n.key?r[n.key]:r}},o.prototype.sessionData=function(e,t){return this.data(e,t,sessionStorage)},o.prototype.device=function(t){var n=navigator.userAgent.toLowerCase(),o=function(e){var t=new RegExp(e+"/([^\\s\\_\\-]+)");return e=(n.match(t)||[])[1],e||!1},r={os:function(){return/windows/.test(n)?"windows":/linux/.test(n)?"linux":/iphone|ipod|ipad|ios/.test(n)?"ios":/mac/.test(n)?"mac":void 0}(),ie:function(){return!!(e.ActiveXObject||"ActiveXObject"in e)&&((n.match(/msie\s(\d+)/)||[])[1]||"11")}(),weixin:o("micromessenger")};return t&&!r[t]&&(r[t]=o(t)),r.android=/android/.test(n),r.ios="ios"===r.os,r},o.prototype.hint=function(){return{error:a}},o.prototype.each=function(e,t){var n,o=this;if("function"!=typeof t)return o;if(e=e||[],e.constructor===Object){for(n in e)if(t.call(e[n],n,e[n]))break}else for(n=0;na?1:r.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--bootstrap .select2-selection--single{height:34px;line-height:1.42857143;padding:6px 24px 6px 12px}.select2-container--bootstrap .select2-selection--single .select2-selection__arrow{position:absolute;bottom:0;right:12px;top:0;width:4px}.select2-container--bootstrap .select2-selection--single .select2-selection__arrow b{border-color:#999 transparent transparent;border-style:solid;border-width:4px 4px 0;height:0;left:0;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--bootstrap .select2-selection--single .select2-selection__rendered{color:#555;padding:0}.select2-container--bootstrap .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--bootstrap .select2-selection--multiple{min-height:34px;padding:0;height:auto}.select2-container--bootstrap .select2-selection--multiple .select2-selection__rendered{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;line-height:1.42857143;list-style:none;margin:0;overflow:hidden;padding:0;width:100%;text-overflow:ellipsis;white-space:nowrap}.select2-container--bootstrap .select2-selection--multiple .select2-selection__placeholder{color:#999;float:left;margin-top:5px}.select2-container--bootstrap .select2-selection--multiple .select2-selection__choice{color:#fff;background:#1AB394;border:1px solid #1AB394;border-radius:4px;cursor:default;float:left;margin:5px 0 0 6px;padding:0 6px}.select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field{background:0 0;padding:0 12px;height:32px;line-height:1.42857143;margin-top:0;min-width:5em}.select2-container--bootstrap .select2-selection--multiple .select2-selection__choice__remove{color:#fff;cursor:pointer;display:inline-block;font-weight:700;margin-right:3px}.select2-container--bootstrap .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--bootstrap .select2-selection--multiple .select2-selection__clear{margin-top:6px}.form-group-sm .select2-container--bootstrap .select2-selection--single,.input-group-sm .select2-container--bootstrap .select2-selection--single,.select2-container--bootstrap .select2-selection--single.input-sm{border-radius:3px;font-size:12px;height:30px;line-height:1.5;padding:5px 22px 5px 10px}.form-group-sm .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b,.input-group-sm .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b,.select2-container--bootstrap .select2-selection--single.input-sm .select2-selection__arrow b{margin-left:-5px}.form-group-sm .select2-container--bootstrap .select2-selection--multiple,.input-group-sm .select2-container--bootstrap .select2-selection--multiple,.select2-container--bootstrap .select2-selection--multiple.input-sm{min-height:30px;border-radius:3px}.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice,.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice,.select2-container--bootstrap .select2-selection--multiple.input-sm .select2-selection__choice{font-size:12px;line-height:1.5;margin:4px 0 0 5px;padding:0 5px}.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field,.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field,.select2-container--bootstrap .select2-selection--multiple.input-sm .select2-search--inline .select2-search__field{padding:0 10px;font-size:12px;height:28px;line-height:1.5}.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear,.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear,.select2-container--bootstrap .select2-selection--multiple.input-sm .select2-selection__clear{margin-top:5px}.form-group-lg .select2-container--bootstrap .select2-selection--single,.input-group-lg .select2-container--bootstrap .select2-selection--single,.select2-container--bootstrap .select2-selection--single.input-lg{border-radius:6px;font-size:18px;height:46px;line-height:1.3333333;padding:10px 31px 10px 16px}.form-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow,.input-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow,.select2-container--bootstrap .select2-selection--single.input-lg .select2-selection__arrow{width:5px}.form-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b,.input-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b,.select2-container--bootstrap .select2-selection--single.input-lg .select2-selection__arrow b{border-width:5px 5px 0;margin-left:-10px;margin-top:-2.5px}.form-group-lg .select2-container--bootstrap .select2-selection--multiple,.input-group-lg .select2-container--bootstrap .select2-selection--multiple,.select2-container--bootstrap .select2-selection--multiple.input-lg{min-height:46px;border-radius:6px}.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice,.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice,.select2-container--bootstrap .select2-selection--multiple.input-lg .select2-selection__choice{font-size:18px;line-height:1.3333333;border-radius:4px;margin:9px 0 0 8px;padding:0 10px}.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field,.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field,.select2-container--bootstrap .select2-selection--multiple.input-lg .select2-search--inline .select2-search__field{padding:0 16px;font-size:18px;height:44px;line-height:1.3333333}.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear,.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear,.select2-container--bootstrap .select2-selection--multiple.input-lg .select2-selection__clear{margin-top:10px}.input-group-lg .select2-container--bootstrap .select2-selection.select2-container--open .select2-selection--single .select2-selection__arrow b,.select2-container--bootstrap .select2-selection.input-lg.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #999;border-width:0 5px 5px}.select2-container--bootstrap[dir=rtl] .select2-selection--single{padding-left:24px;padding-right:12px}.select2-container--bootstrap[dir=rtl] .select2-selection--single .select2-selection__rendered{padding-right:0;padding-left:0;text-align:right}.select2-container--bootstrap[dir=rtl] .select2-selection--single .select2-selection__clear{float:left}.select2-container--bootstrap[dir=rtl] .select2-selection--single .select2-selection__arrow{left:12px;right:auto}.select2-container--bootstrap[dir=rtl] .select2-selection--single .select2-selection__arrow b{margin-left:0}.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-search--inline,.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-selection__choice,.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-selection__placeholder{float:right}.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-selection__choice{margin-left:0;margin-right:6px}.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.has-warning .select2-dropdown,.has-warning .select2-selection{border-color:#8a6d3b}.has-warning .select2-container--focus .select2-selection,.has-warning .select2-container--open .select2-selection{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b;border-color:#66512c}.has-warning.select2-drop-active{border-color:#66512c}.has-warning.select2-drop-active.select2-drop.select2-drop-above{border-top-color:#66512c}.has-error .select2-dropdown,.has-error .select2-selection{border-color:#a94442}.has-error .select2-container--focus .select2-selection,.has-error .select2-container--open .select2-selection{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;border-color:#843534}.has-error.select2-drop-active{border-color:#843534}.has-error.select2-drop-active.select2-drop.select2-drop-above{border-top-color:#843534}.has-success .select2-dropdown,.has-success .select2-selection{border-color:#3c763d}.has-success .select2-container--focus .select2-selection,.has-success .select2-container--open .select2-selection{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168;border-color:#2b542c}.has-success.select2-drop-active{border-color:#2b542c}.has-success.select2-drop-active.select2-drop.select2-drop-above{border-top-color:#2b542c}.input-group>.select2-hidden-accessible:first-child+.select2-container--bootstrap>.selection>.select2-selection,.input-group>.select2-hidden-accessible:first-child+.select2-container--bootstrap>.selection>.select2-selection.form-control{border-bottom-right-radius:0;border-top-right-radius:0}.input-group>.select2-hidden-accessible:not(:first-child)+.select2-container--bootstrap:not(:last-child)>.selection>.select2-selection,.input-group>.select2-hidden-accessible:not(:first-child)+.select2-container--bootstrap:not(:last-child)>.selection>.select2-selection.form-control{border-radius:0}.input-group>.select2-hidden-accessible:not(:first-child):not(:last-child)+.select2-container--bootstrap:last-child>.selection>.select2-selection,.input-group>.select2-hidden-accessible:not(:first-child):not(:last-child)+.select2-container--bootstrap:last-child>.selection>.select2-selection.form-control{border-bottom-left-radius:0;border-top-left-radius:0}.input-group>.select2-container--bootstrap{display:table;table-layout:fixed;position:relative;z-index:2;width:100%;margin-bottom:0}.input-group>.select2-container--bootstrap>.selection>.select2-selection.form-control{float:none}.input-group>.select2-container--bootstrap.select2-container--focus,.input-group>.select2-container--bootstrap.select2-container--open{z-index:3}.input-group>.select2-container--bootstrap,.input-group>.select2-container--bootstrap .input-group-btn,.input-group>.select2-container--bootstrap .input-group-btn .btn{vertical-align:top}.form-control.select2-hidden-accessible{position:absolute!important;width:1px!important}@media (min-width:768px){.form-inline .select2-container--bootstrap{display:inline-block}} +/*! + * Select2 Bootstrap Theme v0.1.0-beta.10 (https://select2.github.io/select2-bootstrap-theme) + * Copyright 2015-2017 Florian Kissling and contributors (https://github.com/select2/select2-bootstrap-theme/graphs/contributors) + * Licensed under MIT (https://github.com/select2/select2-bootstrap-theme/blob/master/LICENSE) + */ + +.select2-container--bootstrap{display:block}.select2-container--bootstrap .select2-selection{background-color:#fff;border:1px solid #e5e6e7;border-radius:1px;color:#555;font-size:14px;outline:0}.select2-container--bootstrap .select2-selection.form-control{border-radius:4px}.select2-container--bootstrap .select2-search--dropdown .select2-search__field{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075);background-color:#fff;border:1px solid #ccc;border-radius:4px;color:#555;font-size:14px}.select2-container--bootstrap .select2-search__field{outline:0}.select2-container--bootstrap .select2-search__field::-webkit-input-placeholder{color:#999}.select2-container--bootstrap .select2-search__field:-moz-placeholder{color:#999}.select2-container--bootstrap .select2-search__field::-moz-placeholder{color:#999;opacity:1}.select2-container--bootstrap .select2-search__field:-ms-input-placeholder{color:#999}.select2-container--bootstrap .select2-results__option{padding:6px 12px}.select2-container--bootstrap .select2-results__option[role=group]{padding:0}.select2-container--bootstrap .select2-results__option[aria-disabled=true]{color:#777;cursor:not-allowed}.select2-container--bootstrap .select2-results__option[aria-selected=true]{background-color:#f5f5f5;color:#262626}.select2-container--bootstrap .select2-results__option--highlighted[aria-selected]{background-color:#337ab7;color:#fff}.select2-container--bootstrap .select2-results__option .select2-results__option{padding:6px 12px}.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option{margin-left:-12px;padding-left:24px}.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-24px;padding-left:36px}.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-36px;padding-left:48px}.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-48px;padding-left:60px}.select2-container--bootstrap .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-60px;padding-left:72px}.select2-container--bootstrap .select2-results__group{color:#777;display:block;padding:6px 12px;font-size:12px;line-height:1.42857143;white-space:nowrap}.select2-container--bootstrap.select2-container--focus .select2-selection,.select2-container--bootstrap.select2-container--open .select2-selection{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);-o-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;-webkit-transition:border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;border-color:#66afe9}.select2-container--bootstrap.select2-container--open .select2-selection .select2-selection__arrow b{border-color:transparent transparent #999;border-width:0 4px 4px}.select2-container--bootstrap.select2-container--open.select2-container--below .select2-selection{border-bottom-right-radius:0;border-bottom-left-radius:0;border-bottom-color:transparent}.select2-container--bootstrap.select2-container--open.select2-container--above .select2-selection{border-top-right-radius:0;border-top-left-radius:0;border-top-color:transparent}.select2-container--bootstrap .select2-selection__clear{color:#999;cursor:pointer;float:right;font-weight:700;margin-right:10px}.select2-container--bootstrap .select2-selection__clear:hover{color:#333}.select2-container--bootstrap.select2-container--disabled .select2-selection{border-color:#ccc;-webkit-box-shadow:none;box-shadow:none}.select2-container--bootstrap.select2-container--disabled .select2-search__field,.select2-container--bootstrap.select2-container--disabled .select2-selection{cursor:not-allowed}.select2-container--bootstrap.select2-container--disabled .select2-selection,.select2-container--bootstrap.select2-container--disabled .select2-selection--multiple .select2-selection__choice{background-color:#eee}.select2-container--bootstrap.select2-container--disabled .select2-selection--multiple .select2-selection__choice__remove,.select2-container--bootstrap.select2-container--disabled .select2-selection__clear{display:none}.select2-container--bootstrap .select2-dropdown{-webkit-box-shadow:0 6px 12px rgba(0,0,0,.175);box-shadow:0 6px 12px rgba(0,0,0,.175);border-color:#66afe9;overflow-x:hidden;margin-top:-1px}.select2-container--bootstrap .select2-dropdown--above{-webkit-box-shadow:0 -6px 12px rgba(0,0,0,.175);box-shadow:0 -6px 12px rgba(0,0,0,.175);margin-top:1px}.select2-container--bootstrap .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--bootstrap .select2-selection--single{height:34px;line-height:1.42857143;padding:6px 24px 6px 12px}.select2-container--bootstrap .select2-selection--single .select2-selection__arrow{position:absolute;bottom:0;right:12px;top:0;width:4px}.select2-container--bootstrap .select2-selection--single .select2-selection__arrow b{border-color:#999 transparent transparent;border-style:solid;border-width:4px 4px 0;height:0;left:0;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--bootstrap .select2-selection--single .select2-selection__rendered{color:#555;padding:0}.select2-container--bootstrap .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--bootstrap .select2-selection--multiple{min-height:34px;padding:0;height:auto}.select2-container--bootstrap .select2-selection--multiple .select2-selection__rendered{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;line-height:1.42857143;list-style:none;margin:0;overflow:hidden;padding:0;width:100%;text-overflow:ellipsis;white-space:nowrap}.select2-container--bootstrap .select2-selection--multiple .select2-selection__placeholder{color:#999;float:left;margin-top:5px}.select2-container--bootstrap .select2-selection--multiple .select2-selection__choice{color:#fff;background:#1AB394;border:1px solid #1AB394;border-radius:4px;cursor:default;float:left;margin:5px 0 0 6px;padding:0 6px}.select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field{background:0 0;padding:0 12px;height:32px;line-height:1.42857143;margin-top:0;min-width:5em}.select2-container--bootstrap .select2-selection--multiple .select2-selection__choice__remove{color:#fff;cursor:pointer;display:inline-block;font-weight:700;margin-right:3px}.select2-container--bootstrap .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--bootstrap .select2-selection--multiple .select2-selection__clear{margin-top:6px}.form-group-sm .select2-container--bootstrap .select2-selection--single,.input-group-sm .select2-container--bootstrap .select2-selection--single,.select2-container--bootstrap .select2-selection--single.input-sm{border-radius:3px;font-size:12px;height:30px;line-height:1.5;padding:5px 22px 5px 10px}.form-group-sm .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b,.input-group-sm .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b,.select2-container--bootstrap .select2-selection--single.input-sm .select2-selection__arrow b{margin-left:-5px}.form-group-sm .select2-container--bootstrap .select2-selection--multiple,.input-group-sm .select2-container--bootstrap .select2-selection--multiple,.select2-container--bootstrap .select2-selection--multiple.input-sm{min-height:30px;border-radius:3px}.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice,.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice,.select2-container--bootstrap .select2-selection--multiple.input-sm .select2-selection__choice{font-size:12px;line-height:1.5;margin:4px 0 0 5px;padding:0 5px}.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field,.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field,.select2-container--bootstrap .select2-selection--multiple.input-sm .select2-search--inline .select2-search__field{padding:0 10px;font-size:12px;height:28px;line-height:1.5}.form-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear,.input-group-sm .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear,.select2-container--bootstrap .select2-selection--multiple.input-sm .select2-selection__clear{margin-top:5px}.form-group-lg .select2-container--bootstrap .select2-selection--single,.input-group-lg .select2-container--bootstrap .select2-selection--single,.select2-container--bootstrap .select2-selection--single.input-lg{border-radius:6px;font-size:18px;height:46px;line-height:1.3333333;padding:10px 31px 10px 16px}.form-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow,.input-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow,.select2-container--bootstrap .select2-selection--single.input-lg .select2-selection__arrow{width:5px}.form-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b,.input-group-lg .select2-container--bootstrap .select2-selection--single .select2-selection__arrow b,.select2-container--bootstrap .select2-selection--single.input-lg .select2-selection__arrow b{border-width:5px 5px 0;margin-left:-10px;margin-top:-2.5px}.form-group-lg .select2-container--bootstrap .select2-selection--multiple,.input-group-lg .select2-container--bootstrap .select2-selection--multiple,.select2-container--bootstrap .select2-selection--multiple.input-lg{min-height:46px;border-radius:6px}.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice,.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__choice,.select2-container--bootstrap .select2-selection--multiple.input-lg .select2-selection__choice{font-size:18px;line-height:1.3333333;border-radius:4px;margin:9px 0 0 8px;padding:0 10px}.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field,.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-search--inline .select2-search__field,.select2-container--bootstrap .select2-selection--multiple.input-lg .select2-search--inline .select2-search__field{padding:0 16px;font-size:18px;height:44px;line-height:1.3333333}.form-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear,.input-group-lg .select2-container--bootstrap .select2-selection--multiple .select2-selection__clear,.select2-container--bootstrap .select2-selection--multiple.input-lg .select2-selection__clear{margin-top:10px}.input-group-lg .select2-container--bootstrap .select2-selection.select2-container--open .select2-selection--single .select2-selection__arrow b,.select2-container--bootstrap .select2-selection.input-lg.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #999;border-width:0 5px 5px}.select2-container--bootstrap[dir=rtl] .select2-selection--single{padding-left:24px;padding-right:12px}.select2-container--bootstrap[dir=rtl] .select2-selection--single .select2-selection__rendered{padding-right:0;padding-left:0;text-align:right}.select2-container--bootstrap[dir=rtl] .select2-selection--single .select2-selection__clear{float:left}.select2-container--bootstrap[dir=rtl] .select2-selection--single .select2-selection__arrow{left:12px;right:auto}.select2-container--bootstrap[dir=rtl] .select2-selection--single .select2-selection__arrow b{margin-left:0}.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-search--inline,.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-selection__choice,.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-selection__placeholder{float:right}.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-selection__choice{margin-left:0;margin-right:6px}.select2-container--bootstrap[dir=rtl] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.has-warning .select2-dropdown,.has-warning .select2-selection{border-color:#8a6d3b}.has-warning .select2-container--focus .select2-selection,.has-warning .select2-container--open .select2-selection{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b;border-color:#66512c}.has-warning.select2-drop-active{border-color:#66512c}.has-warning.select2-drop-active.select2-drop.select2-drop-above{border-top-color:#66512c}.has-error .select2-dropdown,.has-error .select2-selection{border-color:#a94442}.has-error .select2-container--focus .select2-selection,.has-error .select2-container--open .select2-selection{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;border-color:#843534}.has-error.select2-drop-active{border-color:#843534}.has-error.select2-drop-active.select2-drop.select2-drop-above{border-top-color:#843534}.has-success .select2-dropdown,.has-success .select2-selection{border-color:#3c763d}.has-success .select2-container--focus .select2-selection,.has-success .select2-container--open .select2-selection{-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168;border-color:#2b542c}.has-success.select2-drop-active{border-color:#2b542c}.has-success.select2-drop-active.select2-drop.select2-drop-above{border-top-color:#2b542c}.input-group>.select2-hidden-accessible:first-child+.select2-container--bootstrap>.selection>.select2-selection,.input-group>.select2-hidden-accessible:first-child+.select2-container--bootstrap>.selection>.select2-selection.form-control{border-bottom-right-radius:0;border-top-right-radius:0}.input-group>.select2-hidden-accessible:not(:first-child)+.select2-container--bootstrap:not(:last-child)>.selection>.select2-selection,.input-group>.select2-hidden-accessible:not(:first-child)+.select2-container--bootstrap:not(:last-child)>.selection>.select2-selection.form-control{border-radius:0}.input-group>.select2-hidden-accessible:not(:first-child):not(:last-child)+.select2-container--bootstrap:last-child>.selection>.select2-selection,.input-group>.select2-hidden-accessible:not(:first-child):not(:last-child)+.select2-container--bootstrap:last-child>.selection>.select2-selection.form-control{border-bottom-left-radius:0;border-top-left-radius:0}.input-group>.select2-container--bootstrap{display:table;table-layout:fixed;position:relative;z-index:2;width:100%;margin-bottom:0}.input-group>.select2-container--bootstrap>.selection>.select2-selection.form-control{float:none}.input-group>.select2-container--bootstrap.select2-container--focus,.input-group>.select2-container--bootstrap.select2-container--open{z-index:3}.input-group>.select2-container--bootstrap,.input-group>.select2-container--bootstrap .input-group-btn,.input-group>.select2-container--bootstrap .input-group-btn .btn{vertical-align:top}.form-control.select2-hidden-accessible{position:absolute!important;width:1px!important}@media (min-width:768px){.form-inline .select2-container--bootstrap{display:inline-block}} diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.css b/bmw-admin/src/main/resources/static/ajax/libs/select2/select2.css similarity index 97% rename from ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.css rename to bmw-admin/src/main/resources/static/ajax/libs/select2/select2.css index 7f791fab0..ce3afd1d5 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/select2/select2.css @@ -1,484 +1,484 @@ -.select2-container { - box-sizing: border-box; - display: inline-block; - margin: 0; - position: relative; - vertical-align: middle; } - .select2-container .select2-selection--single { - box-sizing: border-box; - cursor: pointer; - display: block; - height: 28px; - user-select: none; - -webkit-user-select: none; } - .select2-container .select2-selection--single .select2-selection__rendered { - display: block; - padding-left: 8px; - padding-right: 20px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; } - .select2-container .select2-selection--single .select2-selection__clear { - position: relative; } - .select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered { - padding-right: 8px; - padding-left: 20px; } - .select2-container .select2-selection--multiple { - box-sizing: border-box; - cursor: pointer; - display: block; - min-height: 32px; - user-select: none; - -webkit-user-select: none; } - .select2-container .select2-selection--multiple .select2-selection__rendered { - display: inline-block; - overflow: hidden; - padding-left: 8px; - text-overflow: ellipsis; - white-space: nowrap; } - .select2-container .select2-search--inline { - float: left; } - .select2-container .select2-search--inline .select2-search__field { - box-sizing: border-box; - border: none; - font-size: 100%; - margin-top: 5px; - padding: 0; } - .select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button { - -webkit-appearance: none; } - -.select2-dropdown { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - box-sizing: border-box; - display: block; - position: absolute; - left: -100000px; - width: 100%; - z-index: 1051; } - -.select2-results { - display: block; } - -.select2-results__options { - list-style: none; - margin: 0; - padding: 0; } - -.select2-results__option { - padding: 6px; - user-select: none; - -webkit-user-select: none; } - .select2-results__option[aria-selected] { - cursor: pointer; } - -.select2-container--open .select2-dropdown { - left: 0; } - -.select2-container--open .select2-dropdown--above { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } - -.select2-container--open .select2-dropdown--below { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; } - -.select2-search--dropdown { - display: block; - padding: 4px; } - .select2-search--dropdown .select2-search__field { - padding: 4px; - width: 100%; - box-sizing: border-box; } - .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button { - -webkit-appearance: none; } - .select2-search--dropdown.select2-search--hide { - display: none; } - -.select2-close-mask { - border: 0; - margin: 0; - padding: 0; - display: block; - position: fixed; - left: 0; - top: 0; - min-height: 100%; - min-width: 100%; - height: auto; - width: auto; - opacity: 0; - z-index: 99; - background-color: #fff; - filter: alpha(opacity=0); } - -.select2-hidden-accessible { - border: 0 !important; - clip: rect(0 0 0 0) !important; - -webkit-clip-path: inset(50%) !important; - clip-path: inset(50%) !important; - height: 1px !important; - overflow: hidden !important; - padding: 0 !important; - position: absolute !important; - width: 1px !important; - white-space: nowrap !important; } - -.select2-container--default .select2-selection--single { - background-color: #fff; - border: 1px solid #aaa; - border-radius: 4px; } - .select2-container--default .select2-selection--single .select2-selection__rendered { - color: #444; - line-height: 28px; } - .select2-container--default .select2-selection--single .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; } - .select2-container--default .select2-selection--single .select2-selection__placeholder { - color: #999; } - .select2-container--default .select2-selection--single .select2-selection__arrow { - height: 26px; - position: absolute; - top: 1px; - right: 1px; - width: 20px; } - .select2-container--default .select2-selection--single .select2-selection__arrow b { - border-color: #888 transparent transparent transparent; - border-style: solid; - border-width: 5px 4px 0 4px; - height: 0; - left: 50%; - margin-left: -4px; - margin-top: -2px; - position: absolute; - top: 50%; - width: 0; } - -.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear { - float: left; } - -.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow { - left: 1px; - right: auto; } - -.select2-container--default.select2-container--disabled .select2-selection--single { - background-color: #eee; - cursor: default; } - .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear { - display: none; } - -.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { - border-color: transparent transparent #888 transparent; - border-width: 0 4px 5px 4px; } - -.select2-container--default .select2-selection--multiple { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - cursor: text; } - .select2-container--default .select2-selection--multiple .select2-selection__rendered { - box-sizing: border-box; - list-style: none; - margin: 0; - padding: 0 5px; - width: 100%; } - .select2-container--default .select2-selection--multiple .select2-selection__rendered li { - list-style: none; } - .select2-container--default .select2-selection--multiple .select2-selection__placeholder { - color: #999; - margin-top: 5px; - float: left; } - .select2-container--default .select2-selection--multiple .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; - margin-top: 5px; - margin-right: 10px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice { - background-color: #e4e4e4; - border: 1px solid #aaa; - border-radius: 4px; - cursor: default; - float: left; - margin-right: 5px; - margin-top: 5px; - padding: 0 5px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { - color: #999; - cursor: pointer; - display: inline-block; - font-weight: bold; - margin-right: 2px; } - .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { - color: #333; } - -.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline { - float: right; } - -.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice { - margin-left: 5px; - margin-right: auto; } - -.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { - margin-left: 2px; - margin-right: auto; } - -.select2-container--default.select2-container--focus .select2-selection--multiple { - border: solid black 1px; - outline: 0; } - -.select2-container--default.select2-container--disabled .select2-selection--multiple { - background-color: #eee; - cursor: default; } - -.select2-container--default.select2-container--disabled .select2-selection__choice__remove { - display: none; } - -.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple { - border-top-left-radius: 0; - border-top-right-radius: 0; } - -.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple { - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } - -.select2-container--default .select2-search--dropdown .select2-search__field { - border: 1px solid #aaa; } - -.select2-container--default .select2-search--inline .select2-search__field { - background: transparent; - border: none; - outline: 0; - box-shadow: none; - -webkit-appearance: textfield; } - -.select2-container--default .select2-results > .select2-results__options { - max-height: 200px; - overflow-y: auto; } - -.select2-container--default .select2-results__option[role=group] { - padding: 0; } - -.select2-container--default .select2-results__option[aria-disabled=true] { - color: #999; } - -.select2-container--default .select2-results__option[aria-selected=true] { - background-color: #ddd; } - -.select2-container--default .select2-results__option .select2-results__option { - padding-left: 1em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__group { - padding-left: 0; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option { - margin-left: -1em; - padding-left: 2em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -2em; - padding-left: 3em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -3em; - padding-left: 4em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -4em; - padding-left: 5em; } - .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { - margin-left: -5em; - padding-left: 6em; } - -.select2-container--default .select2-results__option--highlighted[aria-selected] { - background-color: #5897fb; - color: white; } - -.select2-container--default .select2-results__group { - cursor: default; - display: block; - padding: 6px; } - -.select2-container--classic .select2-selection--single { - background-color: #f7f7f7; - border: 1px solid #aaa; - border-radius: 4px; - outline: 0; - background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%); - background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%); - background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } - .select2-container--classic .select2-selection--single:focus { - border: 1px solid #5897fb; } - .select2-container--classic .select2-selection--single .select2-selection__rendered { - color: #444; - line-height: 28px; } - .select2-container--classic .select2-selection--single .select2-selection__clear { - cursor: pointer; - float: right; - font-weight: bold; - margin-right: 10px; } - .select2-container--classic .select2-selection--single .select2-selection__placeholder { - color: #999; } - .select2-container--classic .select2-selection--single .select2-selection__arrow { - background-color: #ddd; - border: none; - border-left: 1px solid #aaa; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; - height: 26px; - position: absolute; - top: 1px; - right: 1px; - width: 20px; - background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%); - background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%); - background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); } - .select2-container--classic .select2-selection--single .select2-selection__arrow b { - border-color: #888 transparent transparent transparent; - border-style: solid; - border-width: 5px 4px 0 4px; - height: 0; - left: 50%; - margin-left: -4px; - margin-top: -2px; - position: absolute; - top: 50%; - width: 0; } - -.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear { - float: left; } - -.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow { - border: none; - border-right: 1px solid #aaa; - border-radius: 0; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; - left: 1px; - right: auto; } - -.select2-container--classic.select2-container--open .select2-selection--single { - border: 1px solid #5897fb; } - .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow { - background: transparent; - border: none; } - .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b { - border-color: transparent transparent #888 transparent; - border-width: 0 4px 5px 4px; } - -.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; - background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%); - background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%); - background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } - -.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; - background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%); - background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%); - background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); } - -.select2-container--classic .select2-selection--multiple { - background-color: white; - border: 1px solid #aaa; - border-radius: 4px; - cursor: text; - outline: 0; } - .select2-container--classic .select2-selection--multiple:focus { - border: 1px solid #5897fb; } - .select2-container--classic .select2-selection--multiple .select2-selection__rendered { - list-style: none; - margin: 0; - padding: 0 5px; } - .select2-container--classic .select2-selection--multiple .select2-selection__clear { - display: none; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice { - background-color: #e4e4e4; - border: 1px solid #aaa; - border-radius: 4px; - cursor: default; - float: left; - margin-right: 5px; - margin-top: 5px; - padding: 0 5px; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove { - color: #888; - cursor: pointer; - display: inline-block; - font-weight: bold; - margin-right: 2px; } - .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover { - color: #555; } - -.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice { - float: right; - margin-left: 5px; - margin-right: auto; } - -.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { - margin-left: 2px; - margin-right: auto; } - -.select2-container--classic.select2-container--open .select2-selection--multiple { - border: 1px solid #5897fb; } - -.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple { - border-top: none; - border-top-left-radius: 0; - border-top-right-radius: 0; } - -.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple { - border-bottom: none; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; } - -.select2-container--classic .select2-search--dropdown .select2-search__field { - border: 1px solid #aaa; - outline: 0; } - -.select2-container--classic .select2-search--inline .select2-search__field { - outline: 0; - box-shadow: none; } - -.select2-container--classic .select2-dropdown { - background-color: white; - border: 1px solid transparent; } - -.select2-container--classic .select2-dropdown--above { - border-bottom: none; } - -.select2-container--classic .select2-dropdown--below { - border-top: none; } - -.select2-container--classic .select2-results > .select2-results__options { - max-height: 200px; - overflow-y: auto; } - -.select2-container--classic .select2-results__option[role=group] { - padding: 0; } - -.select2-container--classic .select2-results__option[aria-disabled=true] { - color: grey; } - -.select2-container--classic .select2-results__option--highlighted[aria-selected] { - background-color: #3875d7; - color: white; } - -.select2-container--classic .select2-results__group { - cursor: default; - display: block; - padding: 6px; } - -.select2-container--classic.select2-container--open .select2-dropdown { - border-color: #5897fb; } +.select2-container { + box-sizing: border-box; + display: inline-block; + margin: 0; + position: relative; + vertical-align: middle; } + .select2-container .select2-selection--single { + box-sizing: border-box; + cursor: pointer; + display: block; + height: 28px; + user-select: none; + -webkit-user-select: none; } + .select2-container .select2-selection--single .select2-selection__rendered { + display: block; + padding-left: 8px; + padding-right: 20px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } + .select2-container .select2-selection--single .select2-selection__clear { + position: relative; } + .select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered { + padding-right: 8px; + padding-left: 20px; } + .select2-container .select2-selection--multiple { + box-sizing: border-box; + cursor: pointer; + display: block; + min-height: 32px; + user-select: none; + -webkit-user-select: none; } + .select2-container .select2-selection--multiple .select2-selection__rendered { + display: inline-block; + overflow: hidden; + padding-left: 8px; + text-overflow: ellipsis; + white-space: nowrap; } + .select2-container .select2-search--inline { + float: left; } + .select2-container .select2-search--inline .select2-search__field { + box-sizing: border-box; + border: none; + font-size: 100%; + margin-top: 5px; + padding: 0; } + .select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button { + -webkit-appearance: none; } + +.select2-dropdown { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + box-sizing: border-box; + display: block; + position: absolute; + left: -100000px; + width: 100%; + z-index: 1051; } + +.select2-results { + display: block; } + +.select2-results__options { + list-style: none; + margin: 0; + padding: 0; } + +.select2-results__option { + padding: 6px; + user-select: none; + -webkit-user-select: none; } + .select2-results__option[aria-selected] { + cursor: pointer; } + +.select2-container--open .select2-dropdown { + left: 0; } + +.select2-container--open .select2-dropdown--above { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } + +.select2-container--open .select2-dropdown--below { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; } + +.select2-search--dropdown { + display: block; + padding: 4px; } + .select2-search--dropdown .select2-search__field { + padding: 4px; + width: 100%; + box-sizing: border-box; } + .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button { + -webkit-appearance: none; } + .select2-search--dropdown.select2-search--hide { + display: none; } + +.select2-close-mask { + border: 0; + margin: 0; + padding: 0; + display: block; + position: fixed; + left: 0; + top: 0; + min-height: 100%; + min-width: 100%; + height: auto; + width: auto; + opacity: 0; + z-index: 99; + background-color: #fff; + filter: alpha(opacity=0); } + +.select2-hidden-accessible { + border: 0 !important; + clip: rect(0 0 0 0) !important; + -webkit-clip-path: inset(50%) !important; + clip-path: inset(50%) !important; + height: 1px !important; + overflow: hidden !important; + padding: 0 !important; + position: absolute !important; + width: 1px !important; + white-space: nowrap !important; } + +.select2-container--default .select2-selection--single { + background-color: #fff; + border: 1px solid #aaa; + border-radius: 4px; } + .select2-container--default .select2-selection--single .select2-selection__rendered { + color: #444; + line-height: 28px; } + .select2-container--default .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; } + .select2-container--default .select2-selection--single .select2-selection__placeholder { + color: #999; } + .select2-container--default .select2-selection--single .select2-selection__arrow { + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; } + .select2-container--default .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; } + +.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear { + float: left; } + +.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow { + left: 1px; + right: auto; } + +.select2-container--default.select2-container--disabled .select2-selection--single { + background-color: #eee; + cursor: default; } + .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear { + display: none; } + +.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; } + +.select2-container--default .select2-selection--multiple { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + cursor: text; } + .select2-container--default .select2-selection--multiple .select2-selection__rendered { + box-sizing: border-box; + list-style: none; + margin: 0; + padding: 0 5px; + width: 100%; } + .select2-container--default .select2-selection--multiple .select2-selection__rendered li { + list-style: none; } + .select2-container--default .select2-selection--multiple .select2-selection__placeholder { + color: #999; + margin-top: 5px; + float: left; } + .select2-container--default .select2-selection--multiple .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin-top: 5px; + margin-right: 10px; } + .select2-container--default .select2-selection--multiple .select2-selection__choice { + background-color: #e4e4e4; + border: 1px solid #aaa; + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; } + .select2-container--default .select2-selection--multiple .select2-selection__choice__remove { + color: #999; + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; } + .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { + color: #333; } + +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline { + float: right; } + +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice { + margin-left: 5px; + margin-right: auto; } + +.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { + margin-left: 2px; + margin-right: auto; } + +.select2-container--default.select2-container--focus .select2-selection--multiple { + border: solid black 1px; + outline: 0; } + +.select2-container--default.select2-container--disabled .select2-selection--multiple { + background-color: #eee; + cursor: default; } + +.select2-container--default.select2-container--disabled .select2-selection__choice__remove { + display: none; } + +.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple { + border-top-left-radius: 0; + border-top-right-radius: 0; } + +.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } + +.select2-container--default .select2-search--dropdown .select2-search__field { + border: 1px solid #aaa; } + +.select2-container--default .select2-search--inline .select2-search__field { + background: transparent; + border: none; + outline: 0; + box-shadow: none; + -webkit-appearance: textfield; } + +.select2-container--default .select2-results > .select2-results__options { + max-height: 200px; + overflow-y: auto; } + +.select2-container--default .select2-results__option[role=group] { + padding: 0; } + +.select2-container--default .select2-results__option[aria-disabled=true] { + color: #999; } + +.select2-container--default .select2-results__option[aria-selected=true] { + background-color: #ddd; } + +.select2-container--default .select2-results__option .select2-results__option { + padding-left: 1em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__group { + padding-left: 0; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option { + margin-left: -1em; + padding-left: 2em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -2em; + padding-left: 3em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -3em; + padding-left: 4em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -4em; + padding-left: 5em; } + .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option { + margin-left: -5em; + padding-left: 6em; } + +.select2-container--default .select2-results__option--highlighted[aria-selected] { + background-color: #5897fb; + color: white; } + +.select2-container--default .select2-results__group { + cursor: default; + display: block; + padding: 6px; } + +.select2-container--classic .select2-selection--single { + background-color: #f7f7f7; + border: 1px solid #aaa; + border-radius: 4px; + outline: 0; + background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%); + background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%); + background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } + .select2-container--classic .select2-selection--single:focus { + border: 1px solid #5897fb; } + .select2-container--classic .select2-selection--single .select2-selection__rendered { + color: #444; + line-height: 28px; } + .select2-container--classic .select2-selection--single .select2-selection__clear { + cursor: pointer; + float: right; + font-weight: bold; + margin-right: 10px; } + .select2-container--classic .select2-selection--single .select2-selection__placeholder { + color: #999; } + .select2-container--classic .select2-selection--single .select2-selection__arrow { + background-color: #ddd; + border: none; + border-left: 1px solid #aaa; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + height: 26px; + position: absolute; + top: 1px; + right: 1px; + width: 20px; + background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%); + background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%); + background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); } + .select2-container--classic .select2-selection--single .select2-selection__arrow b { + border-color: #888 transparent transparent transparent; + border-style: solid; + border-width: 5px 4px 0 4px; + height: 0; + left: 50%; + margin-left: -4px; + margin-top: -2px; + position: absolute; + top: 50%; + width: 0; } + +.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear { + float: left; } + +.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow { + border: none; + border-right: 1px solid #aaa; + border-radius: 0; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + left: 1px; + right: auto; } + +.select2-container--classic.select2-container--open .select2-selection--single { + border: 1px solid #5897fb; } + .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow { + background: transparent; + border: none; } + .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b { + border-color: transparent transparent #888 transparent; + border-width: 0 4px 5px 4px; } + +.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; + background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%); + background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%); + background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); } + +.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%); + background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%); + background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); } + +.select2-container--classic .select2-selection--multiple { + background-color: white; + border: 1px solid #aaa; + border-radius: 4px; + cursor: text; + outline: 0; } + .select2-container--classic .select2-selection--multiple:focus { + border: 1px solid #5897fb; } + .select2-container--classic .select2-selection--multiple .select2-selection__rendered { + list-style: none; + margin: 0; + padding: 0 5px; } + .select2-container--classic .select2-selection--multiple .select2-selection__clear { + display: none; } + .select2-container--classic .select2-selection--multiple .select2-selection__choice { + background-color: #e4e4e4; + border: 1px solid #aaa; + border-radius: 4px; + cursor: default; + float: left; + margin-right: 5px; + margin-top: 5px; + padding: 0 5px; } + .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove { + color: #888; + cursor: pointer; + display: inline-block; + font-weight: bold; + margin-right: 2px; } + .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover { + color: #555; } + +.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice { + float: right; + margin-left: 5px; + margin-right: auto; } + +.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove { + margin-left: 2px; + margin-right: auto; } + +.select2-container--classic.select2-container--open .select2-selection--multiple { + border: 1px solid #5897fb; } + +.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple { + border-top: none; + border-top-left-radius: 0; + border-top-right-radius: 0; } + +.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple { + border-bottom: none; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } + +.select2-container--classic .select2-search--dropdown .select2-search__field { + border: 1px solid #aaa; + outline: 0; } + +.select2-container--classic .select2-search--inline .select2-search__field { + outline: 0; + box-shadow: none; } + +.select2-container--classic .select2-dropdown { + background-color: white; + border: 1px solid transparent; } + +.select2-container--classic .select2-dropdown--above { + border-bottom: none; } + +.select2-container--classic .select2-dropdown--below { + border-top: none; } + +.select2-container--classic .select2-results > .select2-results__options { + max-height: 200px; + overflow-y: auto; } + +.select2-container--classic .select2-results__option[role=group] { + padding: 0; } + +.select2-container--classic .select2-results__option[aria-disabled=true] { + color: grey; } + +.select2-container--classic .select2-results__option--highlighted[aria-selected] { + background-color: #3875d7; + color: white; } + +.select2-container--classic .select2-results__group { + cursor: default; + display: block; + padding: 6px; } + +.select2-container--classic.select2-container--open .select2-dropdown { + border-color: #5897fb; } diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.js b/bmw-admin/src/main/resources/static/ajax/libs/select2/select2.js similarity index 96% rename from ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.js rename to bmw-admin/src/main/resources/static/ajax/libs/select2/select2.js index eebff51e8..12ab4c2b4 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/select2/select2.js @@ -1,5885 +1,5885 @@ -/*! - * Select2 4.0.7 - * https://select2.github.io - * - * Released under the MIT license - * https://github.com/select2/select2/blob/master/LICENSE.md - */ -;(function (factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['jquery'], factory); - } else if (typeof module === 'object' && module.exports) { - // Node/CommonJS - module.exports = function (root, jQuery) { - if (jQuery === undefined) { - // require('jQuery') returns a factory that requires window to - // build a jQuery instance, we normalize how we use modules - // that require this pattern but the window provided is a noop - // if it's defined (how jquery works) - if (typeof window !== 'undefined') { - jQuery = require('jquery'); - } - else { - jQuery = require('jquery')(root); - } - } - factory(jQuery); - return jQuery; - }; - } else { - // Browser globals - factory(jQuery); - } -} (function (jQuery) { - // This is needed so we can catch the AMD loader configuration and use it - // The inner file should be wrapped (by `banner.start.js`) in a function that - // returns the AMD loader references. - var S2 =(function () { - // Restore the Select2 AMD loader so it can be used - // Needed mostly in the language files, where the loader is not inserted - if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) { - var S2 = jQuery.fn.select2.amd; - } -var S2;(function () { if (!S2 || !S2.requirejs) { -if (!S2) { S2 = {}; } else { require = S2; } -/** - * @license almond 0.3.3 Copyright jQuery Foundation and other contributors. - * Released under MIT license, http://github.com/requirejs/almond/LICENSE - */ -//Going sloppy to avoid 'use strict' string cost, but strict practices should -//be followed. -/*global setTimeout: false */ - -var requirejs, require, define; -(function (undef) { - var main, req, makeMap, handlers, - defined = {}, - waiting = {}, - config = {}, - defining = {}, - hasOwn = Object.prototype.hasOwnProperty, - aps = [].slice, - jsSuffixRegExp = /\.js$/; - - function hasProp(obj, prop) { - return hasOwn.call(obj, prop); - } - - /** - * Given a relative module name, like ./something, normalize it to - * a real name that can be mapped to a path. - * @param {String} name the relative name - * @param {String} baseName a real name that the name arg is relative - * to. - * @returns {String} normalized name - */ - function normalize(name, baseName) { - var nameParts, nameSegment, mapValue, foundMap, lastIndex, - foundI, foundStarMap, starI, i, j, part, normalizedBaseParts, - baseParts = baseName && baseName.split("/"), - map = config.map, - starMap = (map && map['*']) || {}; - - //Adjust any relative paths. - if (name) { - name = name.split('/'); - lastIndex = name.length - 1; - - // If wanting node ID compatibility, strip .js from end - // of IDs. Have to do this here, and not in nameToUrl - // because node allows either .js or non .js to map - // to same file. - if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { - name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); - } - - // Starts with a '.' so need the baseName - if (name[0].charAt(0) === '.' && baseParts) { - //Convert baseName to array, and lop off the last part, - //so that . matches that 'directory' and not name of the baseName's - //module. For instance, baseName of 'one/two/three', maps to - //'one/two/three.js', but we want the directory, 'one/two' for - //this normalization. - normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); - name = normalizedBaseParts.concat(name); - } - - //start trimDots - for (i = 0; i < name.length; i++) { - part = name[i]; - if (part === '.') { - name.splice(i, 1); - i -= 1; - } else if (part === '..') { - // If at the start, or previous value is still .., - // keep them so that when converted to a path it may - // still work when converted to a path, even though - // as an ID it is less than ideal. In larger point - // releases, may be better to just kick out an error. - if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') { - continue; - } else if (i > 0) { - name.splice(i - 1, 2); - i -= 2; - } - } - } - //end trimDots - - name = name.join('/'); - } - - //Apply map config if available. - if ((baseParts || starMap) && map) { - nameParts = name.split('/'); - - for (i = nameParts.length; i > 0; i -= 1) { - nameSegment = nameParts.slice(0, i).join("/"); - - if (baseParts) { - //Find the longest baseName segment match in the config. - //So, do joins on the biggest to smallest lengths of baseParts. - for (j = baseParts.length; j > 0; j -= 1) { - mapValue = map[baseParts.slice(0, j).join('/')]; - - //baseName segment has config, find if it has one for - //this name. - if (mapValue) { - mapValue = mapValue[nameSegment]; - if (mapValue) { - //Match, update name to the new value. - foundMap = mapValue; - foundI = i; - break; - } - } - } - } - - if (foundMap) { - break; - } - - //Check for a star map match, but just hold on to it, - //if there is a shorter segment match later in a matching - //config, then favor over this star map. - if (!foundStarMap && starMap && starMap[nameSegment]) { - foundStarMap = starMap[nameSegment]; - starI = i; - } - } - - if (!foundMap && foundStarMap) { - foundMap = foundStarMap; - foundI = starI; - } - - if (foundMap) { - nameParts.splice(0, foundI, foundMap); - name = nameParts.join('/'); - } - } - - return name; - } - - function makeRequire(relName, forceSync) { - return function () { - //A version of a require function that passes a moduleName - //value for items that may need to - //look up paths relative to the moduleName - var args = aps.call(arguments, 0); - - //If first arg is not require('string'), and there is only - //one arg, it is the array form without a callback. Insert - //a null so that the following concat is correct. - if (typeof args[0] !== 'string' && args.length === 1) { - args.push(null); - } - return req.apply(undef, args.concat([relName, forceSync])); - }; - } - - function makeNormalize(relName) { - return function (name) { - return normalize(name, relName); - }; - } - - function makeLoad(depName) { - return function (value) { - defined[depName] = value; - }; - } - - function callDep(name) { - if (hasProp(waiting, name)) { - var args = waiting[name]; - delete waiting[name]; - defining[name] = true; - main.apply(undef, args); - } - - if (!hasProp(defined, name) && !hasProp(defining, name)) { - throw new Error('No ' + name); - } - return defined[name]; - } - - //Turns a plugin!resource to [plugin, resource] - //with the plugin being undefined if the name - //did not have a plugin prefix. - function splitPrefix(name) { - var prefix, - index = name ? name.indexOf('!') : -1; - if (index > -1) { - prefix = name.substring(0, index); - name = name.substring(index + 1, name.length); - } - return [prefix, name]; - } - - //Creates a parts array for a relName where first part is plugin ID, - //second part is resource ID. Assumes relName has already been normalized. - function makeRelParts(relName) { - return relName ? splitPrefix(relName) : []; - } - - /** - * Makes a name map, normalizing the name, and using a plugin - * for normalization if necessary. Grabs a ref to plugin - * too, as an optimization. - */ - makeMap = function (name, relParts) { - var plugin, - parts = splitPrefix(name), - prefix = parts[0], - relResourceName = relParts[1]; - - name = parts[1]; - - if (prefix) { - prefix = normalize(prefix, relResourceName); - plugin = callDep(prefix); - } - - //Normalize according - if (prefix) { - if (plugin && plugin.normalize) { - name = plugin.normalize(name, makeNormalize(relResourceName)); - } else { - name = normalize(name, relResourceName); - } - } else { - name = normalize(name, relResourceName); - parts = splitPrefix(name); - prefix = parts[0]; - name = parts[1]; - if (prefix) { - plugin = callDep(prefix); - } - } - - //Using ridiculous property names for space reasons - return { - f: prefix ? prefix + '!' + name : name, //fullName - n: name, - pr: prefix, - p: plugin - }; - }; - - function makeConfig(name) { - return function () { - return (config && config.config && config.config[name]) || {}; - }; - } - - handlers = { - require: function (name) { - return makeRequire(name); - }, - exports: function (name) { - var e = defined[name]; - if (typeof e !== 'undefined') { - return e; - } else { - return (defined[name] = {}); - } - }, - module: function (name) { - return { - id: name, - uri: '', - exports: defined[name], - config: makeConfig(name) - }; - } - }; - - main = function (name, deps, callback, relName) { - var cjsModule, depName, ret, map, i, relParts, - args = [], - callbackType = typeof callback, - usingExports; - - //Use name if no relName - relName = relName || name; - relParts = makeRelParts(relName); - - //Call the callback to define the module, if necessary. - if (callbackType === 'undefined' || callbackType === 'function') { - //Pull out the defined dependencies and pass the ordered - //values to the callback. - //Default to [require, exports, module] if no deps - deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; - for (i = 0; i < deps.length; i += 1) { - map = makeMap(deps[i], relParts); - depName = map.f; - - //Fast path CommonJS standard dependencies. - if (depName === "require") { - args[i] = handlers.require(name); - } else if (depName === "exports") { - //CommonJS module spec 1.1 - args[i] = handlers.exports(name); - usingExports = true; - } else if (depName === "module") { - //CommonJS module spec 1.1 - cjsModule = args[i] = handlers.module(name); - } else if (hasProp(defined, depName) || - hasProp(waiting, depName) || - hasProp(defining, depName)) { - args[i] = callDep(depName); - } else if (map.p) { - map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); - args[i] = defined[depName]; - } else { - throw new Error(name + ' missing ' + depName); - } - } - - ret = callback ? callback.apply(defined[name], args) : undefined; - - if (name) { - //If setting exports via "module" is in play, - //favor that over return value and exports. After that, - //favor a non-undefined return value over exports use. - if (cjsModule && cjsModule.exports !== undef && - cjsModule.exports !== defined[name]) { - defined[name] = cjsModule.exports; - } else if (ret !== undef || !usingExports) { - //Use the return value from the function. - defined[name] = ret; - } - } - } else if (name) { - //May just be an object definition for the module. Only - //worry about defining if have a module name. - defined[name] = callback; - } - }; - - requirejs = require = req = function (deps, callback, relName, forceSync, alt) { - if (typeof deps === "string") { - if (handlers[deps]) { - //callback in this case is really relName - return handlers[deps](callback); - } - //Just return the module wanted. In this scenario, the - //deps arg is the module name, and second arg (if passed) - //is just the relName. - //Normalize module name, if it contains . or .. - return callDep(makeMap(deps, makeRelParts(callback)).f); - } else if (!deps.splice) { - //deps is a config object, not an array. - config = deps; - if (config.deps) { - req(config.deps, config.callback); - } - if (!callback) { - return; - } - - if (callback.splice) { - //callback is an array, which means it is a dependency list. - //Adjust args if there are dependencies - deps = callback; - callback = relName; - relName = null; - } else { - deps = undef; - } - } - - //Support require(['a']) - callback = callback || function () {}; - - //If relName is a function, it is an errback handler, - //so remove it. - if (typeof relName === 'function') { - relName = forceSync; - forceSync = alt; - } - - //Simulate async callback; - if (forceSync) { - main(undef, deps, callback, relName); - } else { - //Using a non-zero value because of concern for what old browsers - //do, and latest browsers "upgrade" to 4 if lower value is used: - //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: - //If want a value immediately, use require('id') instead -- something - //that works in almond on the global level, but not guaranteed and - //unlikely to work in other AMD implementations. - setTimeout(function () { - main(undef, deps, callback, relName); - }, 4); - } - - return req; - }; - - /** - * Just drops the config on the floor, but returns req in case - * the config return value is used. - */ - req.config = function (cfg) { - return req(cfg); - }; - - /** - * Expose module registry for debugging and tooling - */ - requirejs._defined = defined; - - define = function (name, deps, callback) { - if (typeof name !== 'string') { - throw new Error('See almond README: incorrect module build, no module name'); - } - - //This module may not have dependencies - if (!deps.splice) { - //deps is not an array, so probably means - //an object literal or factory function for - //the value. Adjust args. - callback = deps; - deps = []; - } - - if (!hasProp(defined, name) && !hasProp(waiting, name)) { - waiting[name] = [name, deps, callback]; - } - }; - - define.amd = { - jQuery: true - }; -}()); - -S2.requirejs = requirejs;S2.require = require;S2.define = define; -} -}()); -S2.define("almond", function(){}); - -/* global jQuery:false, $:false */ -S2.define('jquery',[],function () { - var _$ = jQuery || $; - - if (_$ == null && console && console.error) { - console.error( - 'Select2: An instance of jQuery or a jQuery-compatible library was not ' + - 'found. Make sure that you are including jQuery before Select2 on your ' + - 'web page.' - ); - } - - return _$; -}); - -S2.define('select2/utils',[ - 'jquery' -], function ($) { - var Utils = {}; - - Utils.Extend = function (ChildClass, SuperClass) { - var __hasProp = {}.hasOwnProperty; - - function BaseConstructor () { - this.constructor = ChildClass; - } - - for (var key in SuperClass) { - if (__hasProp.call(SuperClass, key)) { - ChildClass[key] = SuperClass[key]; - } - } - - BaseConstructor.prototype = SuperClass.prototype; - ChildClass.prototype = new BaseConstructor(); - ChildClass.__super__ = SuperClass.prototype; - - return ChildClass; - }; - - function getMethods (theClass) { - var proto = theClass.prototype; - - var methods = []; - - for (var methodName in proto) { - var m = proto[methodName]; - - if (typeof m !== 'function') { - continue; - } - - if (methodName === 'constructor') { - continue; - } - - methods.push(methodName); - } - - return methods; - } - - Utils.Decorate = function (SuperClass, DecoratorClass) { - var decoratedMethods = getMethods(DecoratorClass); - var superMethods = getMethods(SuperClass); - - function DecoratedClass () { - var unshift = Array.prototype.unshift; - - var argCount = DecoratorClass.prototype.constructor.length; - - var calledConstructor = SuperClass.prototype.constructor; - - if (argCount > 0) { - unshift.call(arguments, SuperClass.prototype.constructor); - - calledConstructor = DecoratorClass.prototype.constructor; - } - - calledConstructor.apply(this, arguments); - } - - DecoratorClass.displayName = SuperClass.displayName; - - function ctr () { - this.constructor = DecoratedClass; - } - - DecoratedClass.prototype = new ctr(); - - for (var m = 0; m < superMethods.length; m++) { - var superMethod = superMethods[m]; - - DecoratedClass.prototype[superMethod] = - SuperClass.prototype[superMethod]; - } - - var calledMethod = function (methodName) { - // Stub out the original method if it's not decorating an actual method - var originalMethod = function () {}; - - if (methodName in DecoratedClass.prototype) { - originalMethod = DecoratedClass.prototype[methodName]; - } - - var decoratedMethod = DecoratorClass.prototype[methodName]; - - return function () { - var unshift = Array.prototype.unshift; - - unshift.call(arguments, originalMethod); - - return decoratedMethod.apply(this, arguments); - }; - }; - - for (var d = 0; d < decoratedMethods.length; d++) { - var decoratedMethod = decoratedMethods[d]; - - DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod); - } - - return DecoratedClass; - }; - - var Observable = function () { - this.listeners = {}; - }; - - Observable.prototype.on = function (event, callback) { - this.listeners = this.listeners || {}; - - if (event in this.listeners) { - this.listeners[event].push(callback); - } else { - this.listeners[event] = [callback]; - } - }; - - Observable.prototype.trigger = function (event) { - var slice = Array.prototype.slice; - var params = slice.call(arguments, 1); - - this.listeners = this.listeners || {}; - - // Params should always come in as an array - if (params == null) { - params = []; - } - - // If there are no arguments to the event, use a temporary object - if (params.length === 0) { - params.push({}); - } - - // Set the `_type` of the first object to the event - params[0]._type = event; - - if (event in this.listeners) { - this.invoke(this.listeners[event], slice.call(arguments, 1)); - } - - if ('*' in this.listeners) { - this.invoke(this.listeners['*'], arguments); - } - }; - - Observable.prototype.invoke = function (listeners, params) { - for (var i = 0, len = listeners.length; i < len; i++) { - listeners[i].apply(this, params); - } - }; - - Utils.Observable = Observable; - - Utils.generateChars = function (length) { - var chars = ''; - - for (var i = 0; i < length; i++) { - var randomChar = Math.floor(Math.random() * 36); - chars += randomChar.toString(36); - } - - return chars; - }; - - Utils.bind = function (func, context) { - return function () { - func.apply(context, arguments); - }; - }; - - Utils._convertData = function (data) { - for (var originalKey in data) { - var keys = originalKey.split('-'); - - var dataLevel = data; - - if (keys.length === 1) { - continue; - } - - for (var k = 0; k < keys.length; k++) { - var key = keys[k]; - - // Lowercase the first letter - // By default, dash-separated becomes camelCase - key = key.substring(0, 1).toLowerCase() + key.substring(1); - - if (!(key in dataLevel)) { - dataLevel[key] = {}; - } - - if (k == keys.length - 1) { - dataLevel[key] = data[originalKey]; - } - - dataLevel = dataLevel[key]; - } - - delete data[originalKey]; - } - - return data; - }; - - Utils.hasScroll = function (index, el) { - // Adapted from the function created by @ShadowScripter - // and adapted by @BillBarry on the Stack Exchange Code Review website. - // The original code can be found at - // http://codereview.stackexchange.com/q/13338 - // and was designed to be used with the Sizzle selector engine. - - var $el = $(el); - var overflowX = el.style.overflowX; - var overflowY = el.style.overflowY; - - //Check both x and y declarations - if (overflowX === overflowY && - (overflowY === 'hidden' || overflowY === 'visible')) { - return false; - } - - if (overflowX === 'scroll' || overflowY === 'scroll') { - return true; - } - - return ($el.innerHeight() < el.scrollHeight || - $el.innerWidth() < el.scrollWidth); - }; - - Utils.escapeMarkup = function (markup) { - var replaceMap = { - '\\': '\', - '&': '&', - '<': '<', - '>': '>', - '"': '"', - '\'': ''', - '/': '/' - }; - - // Do not try to escape the markup if it's not a string - if (typeof markup !== 'string') { - return markup; - } - - return String(markup).replace(/[&<>"'\/\\]/g, function (match) { - return replaceMap[match]; - }); - }; - - // Append an array of jQuery nodes to a given element. - Utils.appendMany = function ($element, $nodes) { - // jQuery 1.7.x does not support $.fn.append() with an array - // Fall back to a jQuery object collection using $.fn.add() - if ($.fn.jquery.substr(0, 3) === '1.7') { - var $jqNodes = $(); - - $.map($nodes, function (node) { - $jqNodes = $jqNodes.add(node); - }); - - $nodes = $jqNodes; - } - - $element.append($nodes); - }; - - // Cache objects in Utils.__cache instead of $.data (see #4346) - Utils.__cache = {}; - - var id = 0; - Utils.GetUniqueElementId = function (element) { - // Get a unique element Id. If element has no id, - // creates a new unique number, stores it in the id - // attribute and returns the new id. - // If an id already exists, it simply returns it. - - var select2Id = element.getAttribute('data-select2-id'); - if (select2Id == null) { - // If element has id, use it. - if (element.id) { - select2Id = element.id; - element.setAttribute('data-select2-id', select2Id); - } else { - element.setAttribute('data-select2-id', ++id); - select2Id = id.toString(); - } - } - return select2Id; - }; - - Utils.StoreData = function (element, name, value) { - // Stores an item in the cache for a specified element. - // name is the cache key. - var id = Utils.GetUniqueElementId(element); - if (!Utils.__cache[id]) { - Utils.__cache[id] = {}; - } - - Utils.__cache[id][name] = value; - }; - - Utils.GetData = function (element, name) { - // Retrieves a value from the cache by its key (name) - // name is optional. If no name specified, return - // all cache items for the specified element. - // and for a specified element. - var id = Utils.GetUniqueElementId(element); - if (name) { - if (Utils.__cache[id]) { - if (Utils.__cache[id][name] != null) { - return Utils.__cache[id][name]; - } - return $(element).data(name); // Fallback to HTML5 data attribs. - } - return $(element).data(name); // Fallback to HTML5 data attribs. - } else { - return Utils.__cache[id]; - } - }; - - Utils.RemoveData = function (element) { - // Removes all cached items for a specified element. - var id = Utils.GetUniqueElementId(element); - if (Utils.__cache[id] != null) { - delete Utils.__cache[id]; - } - }; - - return Utils; -}); - -S2.define('select2/results',[ - 'jquery', - './utils' -], function ($, Utils) { - function Results ($element, options, dataAdapter) { - this.$element = $element; - this.data = dataAdapter; - this.options = options; - - Results.__super__.constructor.call(this); - } - - Utils.Extend(Results, Utils.Observable); - - Results.prototype.render = function () { - var $results = $( - '
                  ' - ); - - if (this.options.get('multiple')) { - $results.attr('aria-multiselectable', 'true'); - } - - this.$results = $results; - - return $results; - }; - - Results.prototype.clear = function () { - this.$results.empty(); - }; - - Results.prototype.displayMessage = function (params) { - var escapeMarkup = this.options.get('escapeMarkup'); - - this.clear(); - this.hideLoading(); - - var $message = $( - '
                • ' - ); - - var message = this.options.get('translations').get(params.message); - - $message.append( - escapeMarkup( - message(params.args) - ) - ); - - $message[0].className += ' select2-results__message'; - - this.$results.append($message); - }; - - Results.prototype.hideMessages = function () { - this.$results.find('.select2-results__message').remove(); - }; - - Results.prototype.append = function (data) { - this.hideLoading(); - - var $options = []; - - if (data.results == null || data.results.length === 0) { - if (this.$results.children().length === 0) { - this.trigger('results:message', { - message: 'noResults' - }); - } - - return; - } - - data.results = this.sort(data.results); - - for (var d = 0; d < data.results.length; d++) { - var item = data.results[d]; - - var $option = this.option(item); - - $options.push($option); - } - - this.$results.append($options); - }; - - Results.prototype.position = function ($results, $dropdown) { - var $resultsContainer = $dropdown.find('.select2-results'); - $resultsContainer.append($results); - }; - - Results.prototype.sort = function (data) { - var sorter = this.options.get('sorter'); - - return sorter(data); - }; - - Results.prototype.highlightFirstItem = function () { - var $options = this.$results - .find('.select2-results__option[aria-selected]'); - - var $selected = $options.filter('[aria-selected=true]'); - - // Check if there are any selected options - if ($selected.length > 0) { - // If there are selected options, highlight the first - $selected.first().trigger('mouseenter'); - } else { - // If there are no selected options, highlight the first option - // in the dropdown - $options.first().trigger('mouseenter'); - } - - this.ensureHighlightVisible(); - }; - - Results.prototype.setClasses = function () { - var self = this; - - this.data.current(function (selected) { - var selectedIds = $.map(selected, function (s) { - return s.id.toString(); - }); - - var $options = self.$results - .find('.select2-results__option[aria-selected]'); - - $options.each(function () { - var $option = $(this); - - var item = Utils.GetData(this, 'data'); - - // id needs to be converted to a string when comparing - var id = '' + item.id; - - if ((item.element != null && item.element.selected) || - (item.element == null && $.inArray(id, selectedIds) > -1)) { - $option.attr('aria-selected', 'true'); - } else { - $option.attr('aria-selected', 'false'); - } - }); - - }); - }; - - Results.prototype.showLoading = function (params) { - this.hideLoading(); - - var loadingMore = this.options.get('translations').get('searching'); - - var loading = { - disabled: true, - loading: true, - text: loadingMore(params) - }; - var $loading = this.option(loading); - $loading.className += ' loading-results'; - - this.$results.prepend($loading); - }; - - Results.prototype.hideLoading = function () { - this.$results.find('.loading-results').remove(); - }; - - Results.prototype.option = function (data) { - var option = document.createElement('li'); - option.className = 'select2-results__option'; - - var attrs = { - 'role': 'treeitem', - 'aria-selected': 'false' - }; - - if (data.disabled) { - delete attrs['aria-selected']; - attrs['aria-disabled'] = 'true'; - } - - if (data.id == null) { - delete attrs['aria-selected']; - } - - if (data._resultId != null) { - option.id = data._resultId; - } - - if (data.title) { - option.title = data.title; - } - - if (data.children) { - attrs.role = 'group'; - attrs['aria-label'] = data.text; - delete attrs['aria-selected']; - } - - for (var attr in attrs) { - var val = attrs[attr]; - - option.setAttribute(attr, val); - } - - if (data.children) { - var $option = $(option); - - var label = document.createElement('strong'); - label.className = 'select2-results__group'; - - var $label = $(label); - this.template(data, label); - - var $children = []; - - for (var c = 0; c < data.children.length; c++) { - var child = data.children[c]; - - var $child = this.option(child); - - $children.push($child); - } - - var $childrenContainer = $('
                    ', { - 'class': 'select2-results__options select2-results__options--nested' - }); - - $childrenContainer.append($children); - - $option.append(label); - $option.append($childrenContainer); - } else { - this.template(data, option); - } - - Utils.StoreData(option, 'data', data); - - return option; - }; - - Results.prototype.bind = function (container, $container) { - var self = this; - - var id = container.id + '-results'; - - this.$results.attr('id', id); - - container.on('results:all', function (params) { - self.clear(); - self.append(params.data); - - if (container.isOpen()) { - self.setClasses(); - self.highlightFirstItem(); - } - }); - - container.on('results:append', function (params) { - self.append(params.data); - - if (container.isOpen()) { - self.setClasses(); - } - }); - - container.on('query', function (params) { - self.hideMessages(); - self.showLoading(params); - }); - - container.on('select', function () { - if (!container.isOpen()) { - return; - } - - self.setClasses(); - - if (self.options.get('scrollAfterSelect')) { - self.highlightFirstItem(); - } - }); - - container.on('unselect', function () { - if (!container.isOpen()) { - return; - } - - self.setClasses(); - - if (self.options.get('scrollAfterSelect')) { - self.highlightFirstItem(); - } - }); - - container.on('open', function () { - // When the dropdown is open, aria-expended="true" - self.$results.attr('aria-expanded', 'true'); - self.$results.attr('aria-hidden', 'false'); - - self.setClasses(); - self.ensureHighlightVisible(); - }); - - container.on('close', function () { - // When the dropdown is closed, aria-expended="false" - self.$results.attr('aria-expanded', 'false'); - self.$results.attr('aria-hidden', 'true'); - self.$results.removeAttr('aria-activedescendant'); - }); - - container.on('results:toggle', function () { - var $highlighted = self.getHighlightedResults(); - - if ($highlighted.length === 0) { - return; - } - - $highlighted.trigger('mouseup'); - }); - - container.on('results:select', function () { - var $highlighted = self.getHighlightedResults(); - - if ($highlighted.length === 0) { - return; - } - - var data = Utils.GetData($highlighted[0], 'data'); - - if ($highlighted.attr('aria-selected') == 'true') { - self.trigger('close', {}); - } else { - self.trigger('select', { - data: data - }); - } - }); - - container.on('results:previous', function () { - var $highlighted = self.getHighlightedResults(); - - var $options = self.$results.find('[aria-selected]'); - - var currentIndex = $options.index($highlighted); - - // If we are already at the top, don't move further - // If no options, currentIndex will be -1 - if (currentIndex <= 0) { - return; - } - - var nextIndex = currentIndex - 1; - - // If none are highlighted, highlight the first - if ($highlighted.length === 0) { - nextIndex = 0; - } - - var $next = $options.eq(nextIndex); - - $next.trigger('mouseenter'); - - var currentOffset = self.$results.offset().top; - var nextTop = $next.offset().top; - var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset); - - if (nextIndex === 0) { - self.$results.scrollTop(0); - } else if (nextTop - currentOffset < 0) { - self.$results.scrollTop(nextOffset); - } - }); - - container.on('results:next', function () { - var $highlighted = self.getHighlightedResults(); - - var $options = self.$results.find('[aria-selected]'); - - var currentIndex = $options.index($highlighted); - - var nextIndex = currentIndex + 1; - - // If we are at the last option, stay there - if (nextIndex >= $options.length) { - return; - } - - var $next = $options.eq(nextIndex); - - $next.trigger('mouseenter'); - - var currentOffset = self.$results.offset().top + - self.$results.outerHeight(false); - var nextBottom = $next.offset().top + $next.outerHeight(false); - var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset; - - if (nextIndex === 0) { - self.$results.scrollTop(0); - } else if (nextBottom > currentOffset) { - self.$results.scrollTop(nextOffset); - } - }); - - container.on('results:focus', function (params) { - params.element.addClass('select2-results__option--highlighted'); - }); - - container.on('results:message', function (params) { - self.displayMessage(params); - }); - - if ($.fn.mousewheel) { - this.$results.on('mousewheel', function (e) { - var top = self.$results.scrollTop(); - - var bottom = self.$results.get(0).scrollHeight - top + e.deltaY; - - var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0; - var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height(); - - if (isAtTop) { - self.$results.scrollTop(0); - - e.preventDefault(); - e.stopPropagation(); - } else if (isAtBottom) { - self.$results.scrollTop( - self.$results.get(0).scrollHeight - self.$results.height() - ); - - e.preventDefault(); - e.stopPropagation(); - } - }); - } - - this.$results.on('mouseup', '.select2-results__option[aria-selected]', - function (evt) { - var $this = $(this); - - var data = Utils.GetData(this, 'data'); - - if ($this.attr('aria-selected') === 'true') { - if (self.options.get('multiple')) { - self.trigger('unselect', { - originalEvent: evt, - data: data - }); - } else { - self.trigger('close', {}); - } - - return; - } - - self.trigger('select', { - originalEvent: evt, - data: data - }); - }); - - this.$results.on('mouseenter', '.select2-results__option[aria-selected]', - function (evt) { - var data = Utils.GetData(this, 'data'); - - self.getHighlightedResults() - .removeClass('select2-results__option--highlighted'); - - self.trigger('results:focus', { - data: data, - element: $(this) - }); - }); - }; - - Results.prototype.getHighlightedResults = function () { - var $highlighted = this.$results - .find('.select2-results__option--highlighted'); - - return $highlighted; - }; - - Results.prototype.destroy = function () { - this.$results.remove(); - }; - - Results.prototype.ensureHighlightVisible = function () { - var $highlighted = this.getHighlightedResults(); - - if ($highlighted.length === 0) { - return; - } - - var $options = this.$results.find('[aria-selected]'); - - var currentIndex = $options.index($highlighted); - - var currentOffset = this.$results.offset().top; - var nextTop = $highlighted.offset().top; - var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset); - - var offsetDelta = nextTop - currentOffset; - nextOffset -= $highlighted.outerHeight(false) * 2; - - if (currentIndex <= 2) { - this.$results.scrollTop(0); - } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) { - this.$results.scrollTop(nextOffset); - } - }; - - Results.prototype.template = function (result, container) { - var template = this.options.get('templateResult'); - var escapeMarkup = this.options.get('escapeMarkup'); - - var content = template(result, container); - - if (content == null) { - container.style.display = 'none'; - } else if (typeof content === 'string') { - container.innerHTML = escapeMarkup(content); - } else { - $(container).append(content); - } - }; - - return Results; -}); - -S2.define('select2/keys',[ - -], function () { - var KEYS = { - BACKSPACE: 8, - TAB: 9, - ENTER: 13, - SHIFT: 16, - CTRL: 17, - ALT: 18, - ESC: 27, - SPACE: 32, - PAGE_UP: 33, - PAGE_DOWN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - DELETE: 46 - }; - - return KEYS; -}); - -S2.define('select2/selection/base',[ - 'jquery', - '../utils', - '../keys' -], function ($, Utils, KEYS) { - function BaseSelection ($element, options) { - this.$element = $element; - this.options = options; - - BaseSelection.__super__.constructor.call(this); - } - - Utils.Extend(BaseSelection, Utils.Observable); - - BaseSelection.prototype.render = function () { - var $selection = $( - '' - ); - - this._tabindex = 0; - - if (Utils.GetData(this.$element[0], 'old-tabindex') != null) { - this._tabindex = Utils.GetData(this.$element[0], 'old-tabindex'); - } else if (this.$element.attr('tabindex') != null) { - this._tabindex = this.$element.attr('tabindex'); - } - - $selection.attr('title', this.$element.attr('title')); - $selection.attr('tabindex', this._tabindex); - - this.$selection = $selection; - - return $selection; - }; - - BaseSelection.prototype.bind = function (container, $container) { - var self = this; - - var id = container.id + '-container'; - var resultsId = container.id + '-results'; - - this.container = container; - - this.$selection.on('focus', function (evt) { - self.trigger('focus', evt); - }); - - this.$selection.on('blur', function (evt) { - self._handleBlur(evt); - }); - - this.$selection.on('keydown', function (evt) { - self.trigger('keypress', evt); - - if (evt.which === KEYS.SPACE) { - evt.preventDefault(); - } - }); - - container.on('results:focus', function (params) { - self.$selection.attr('aria-activedescendant', params.data._resultId); - }); - - container.on('selection:update', function (params) { - self.update(params.data); - }); - - container.on('open', function () { - // When the dropdown is open, aria-expanded="true" - self.$selection.attr('aria-expanded', 'true'); - self.$selection.attr('aria-owns', resultsId); - - self._attachCloseHandler(container); - }); - - container.on('close', function () { - // When the dropdown is closed, aria-expanded="false" - self.$selection.attr('aria-expanded', 'false'); - self.$selection.removeAttr('aria-activedescendant'); - self.$selection.removeAttr('aria-owns'); - - window.setTimeout(function () { - self.$selection.focus(); - }, 0); - - self._detachCloseHandler(container); - }); - - container.on('enable', function () { - self.$selection.attr('tabindex', self._tabindex); - }); - - container.on('disable', function () { - self.$selection.attr('tabindex', '-1'); - }); - }; - - BaseSelection.prototype._handleBlur = function (evt) { - var self = this; - - // This needs to be delayed as the active element is the body when the tab - // key is pressed, possibly along with others. - window.setTimeout(function () { - // Don't trigger `blur` if the focus is still in the selection - if ( - (document.activeElement == self.$selection[0]) || - ($.contains(self.$selection[0], document.activeElement)) - ) { - return; - } - - self.trigger('blur', evt); - }, 1); - }; - - BaseSelection.prototype._attachCloseHandler = function (container) { - var self = this; - - $(document.body).on('mousedown.select2.' + container.id, function (e) { - var $target = $(e.target); - - var $select = $target.closest('.select2'); - - var $all = $('.select2.select2-container--open'); - - $all.each(function () { - var $this = $(this); - - if (this == $select[0]) { - return; - } - - var $element = Utils.GetData(this, 'element'); - - $element.select2('close'); - }); - }); - }; - - BaseSelection.prototype._detachCloseHandler = function (container) { - $(document.body).off('mousedown.select2.' + container.id); - }; - - BaseSelection.prototype.position = function ($selection, $container) { - var $selectionContainer = $container.find('.selection'); - $selectionContainer.append($selection); - }; - - BaseSelection.prototype.destroy = function () { - this._detachCloseHandler(this.container); - }; - - BaseSelection.prototype.update = function (data) { - throw new Error('The `update` method must be defined in child classes.'); - }; - - return BaseSelection; -}); - -S2.define('select2/selection/single',[ - 'jquery', - './base', - '../utils', - '../keys' -], function ($, BaseSelection, Utils, KEYS) { - function SingleSelection () { - SingleSelection.__super__.constructor.apply(this, arguments); - } - - Utils.Extend(SingleSelection, BaseSelection); - - SingleSelection.prototype.render = function () { - var $selection = SingleSelection.__super__.render.call(this); - - $selection.addClass('select2-selection--single'); - - $selection.html( - '' + - '' + - '' + - '' - ); - - return $selection; - }; - - SingleSelection.prototype.bind = function (container, $container) { - var self = this; - - SingleSelection.__super__.bind.apply(this, arguments); - - var id = container.id + '-container'; - - this.$selection.find('.select2-selection__rendered') - .attr('id', id) - .attr('role', 'textbox') - .attr('aria-readonly', 'true'); - this.$selection.attr('aria-labelledby', id); - - this.$selection.on('mousedown', function (evt) { - // Only respond to left clicks - if (evt.which !== 1) { - return; - } - - self.trigger('toggle', { - originalEvent: evt - }); - }); - - this.$selection.on('focus', function (evt) { - // User focuses on the container - }); - - this.$selection.on('blur', function (evt) { - // User exits the container - }); - - container.on('focus', function (evt) { - if (!container.isOpen()) { - self.$selection.focus(); - } - }); - }; - - SingleSelection.prototype.clear = function () { - var $rendered = this.$selection.find('.select2-selection__rendered'); - $rendered.empty(); - $rendered.removeAttr('title'); // clear tooltip on empty - }; - - SingleSelection.prototype.display = function (data, container) { - var template = this.options.get('templateSelection'); - var escapeMarkup = this.options.get('escapeMarkup'); - - return escapeMarkup(template(data, container)); - }; - - SingleSelection.prototype.selectionContainer = function () { - return $(''); - }; - - SingleSelection.prototype.update = function (data) { - if (data.length === 0) { - this.clear(); - return; - } - - var selection = data[0]; - - var $rendered = this.$selection.find('.select2-selection__rendered'); - var formatted = this.display(selection, $rendered); - - $rendered.empty().append(formatted); - $rendered.attr('title', selection.title || selection.text); - }; - - return SingleSelection; -}); - -S2.define('select2/selection/multiple',[ - 'jquery', - './base', - '../utils' -], function ($, BaseSelection, Utils) { - function MultipleSelection ($element, options) { - MultipleSelection.__super__.constructor.apply(this, arguments); - } - - Utils.Extend(MultipleSelection, BaseSelection); - - MultipleSelection.prototype.render = function () { - var $selection = MultipleSelection.__super__.render.call(this); - - $selection.addClass('select2-selection--multiple'); - - $selection.html( - '
                      ' - ); - - return $selection; - }; - - MultipleSelection.prototype.bind = function (container, $container) { - var self = this; - - MultipleSelection.__super__.bind.apply(this, arguments); - - this.$selection.on('click', function (evt) { - self.trigger('toggle', { - originalEvent: evt - }); - }); - - this.$selection.on( - 'click', - '.select2-selection__choice__remove', - function (evt) { - // Ignore the event if it is disabled - if (self.options.get('disabled')) { - return; - } - - var $remove = $(this); - var $selection = $remove.parent(); - - var data = Utils.GetData($selection[0], 'data'); - - self.trigger('unselect', { - originalEvent: evt, - data: data - }); - } - ); - }; - - MultipleSelection.prototype.clear = function () { - var $rendered = this.$selection.find('.select2-selection__rendered'); - $rendered.empty(); - $rendered.removeAttr('title'); - }; - - MultipleSelection.prototype.display = function (data, container) { - var template = this.options.get('templateSelection'); - var escapeMarkup = this.options.get('escapeMarkup'); - - return escapeMarkup(template(data, container)); - }; - - MultipleSelection.prototype.selectionContainer = function () { - var $container = $( - '
                    • ' + - '' + - '×' + - '' + - '
                    • ' - ); - - return $container; - }; - - MultipleSelection.prototype.update = function (data) { - this.clear(); - - if (data.length === 0) { - return; - } - - var $selections = []; - - for (var d = 0; d < data.length; d++) { - var selection = data[d]; - - var $selection = this.selectionContainer(); - var formatted = this.display(selection, $selection); - - $selection.append(formatted); - $selection.attr('title', selection.title || selection.text); - - Utils.StoreData($selection[0], 'data', selection); - - $selections.push($selection); - } - - var $rendered = this.$selection.find('.select2-selection__rendered'); - - Utils.appendMany($rendered, $selections); - }; - - return MultipleSelection; -}); - -S2.define('select2/selection/placeholder',[ - '../utils' -], function (Utils) { - function Placeholder (decorated, $element, options) { - this.placeholder = this.normalizePlaceholder(options.get('placeholder')); - - decorated.call(this, $element, options); - } - - Placeholder.prototype.normalizePlaceholder = function (_, placeholder) { - if (typeof placeholder === 'string') { - placeholder = { - id: '', - text: placeholder - }; - } - - return placeholder; - }; - - Placeholder.prototype.createPlaceholder = function (decorated, placeholder) { - var $placeholder = this.selectionContainer(); - - $placeholder.html(this.display(placeholder)); - $placeholder.addClass('select2-selection__placeholder') - .removeClass('select2-selection__choice'); - - return $placeholder; - }; - - Placeholder.prototype.update = function (decorated, data) { - var singlePlaceholder = ( - data.length == 1 && data[0].id != this.placeholder.id - ); - var multipleSelections = data.length > 1; - - if (multipleSelections || singlePlaceholder) { - return decorated.call(this, data); - } - - this.clear(); - - var $placeholder = this.createPlaceholder(this.placeholder); - - this.$selection.find('.select2-selection__rendered').append($placeholder); - }; - - return Placeholder; -}); - -S2.define('select2/selection/allowClear',[ - 'jquery', - '../keys', - '../utils' -], function ($, KEYS, Utils) { - function AllowClear () { } - - AllowClear.prototype.bind = function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - if (this.placeholder == null) { - if (this.options.get('debug') && window.console && console.error) { - console.error( - 'Select2: The `allowClear` option should be used in combination ' + - 'with the `placeholder` option.' - ); - } - } - - this.$selection.on('mousedown', '.select2-selection__clear', - function (evt) { - self._handleClear(evt); - }); - - container.on('keypress', function (evt) { - self._handleKeyboardClear(evt, container); - }); - }; - - AllowClear.prototype._handleClear = function (_, evt) { - // Ignore the event if it is disabled - if (this.options.get('disabled')) { - return; - } - - var $clear = this.$selection.find('.select2-selection__clear'); - - // Ignore the event if nothing has been selected - if ($clear.length === 0) { - return; - } - - evt.stopPropagation(); - - var data = Utils.GetData($clear[0], 'data'); - - var previousVal = this.$element.val(); - this.$element.val(this.placeholder.id); - - var unselectData = { - data: data - }; - this.trigger('clear', unselectData); - if (unselectData.prevented) { - this.$element.val(previousVal); - return; - } - - for (var d = 0; d < data.length; d++) { - unselectData = { - data: data[d] - }; - - // Trigger the `unselect` event, so people can prevent it from being - // cleared. - this.trigger('unselect', unselectData); - - // If the event was prevented, don't clear it out. - if (unselectData.prevented) { - this.$element.val(previousVal); - return; - } - } - - this.$element.trigger('change'); - - this.trigger('toggle', {}); - }; - - AllowClear.prototype._handleKeyboardClear = function (_, evt, container) { - if (container.isOpen()) { - return; - } - - if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) { - this._handleClear(evt); - } - }; - - AllowClear.prototype.update = function (decorated, data) { - decorated.call(this, data); - - if (this.$selection.find('.select2-selection__placeholder').length > 0 || - data.length === 0) { - return; - } - - var removeAll = this.options.get('translations').get('removeAllItems'); - - var $remove = $( - '' + - '×' + - '' - ); - Utils.StoreData($remove[0], 'data', data); - - this.$selection.find('.select2-selection__rendered').prepend($remove); - }; - - return AllowClear; -}); - -S2.define('select2/selection/search',[ - 'jquery', - '../utils', - '../keys' -], function ($, Utils, KEYS) { - function Search (decorated, $element, options) { - decorated.call(this, $element, options); - } - - Search.prototype.render = function (decorated) { - var $search = $( - '' - ); - - this.$searchContainer = $search; - this.$search = $search.find('input'); - - var $rendered = decorated.call(this); - - this._transferTabIndex(); - - return $rendered; - }; - - Search.prototype.bind = function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - container.on('open', function () { - self.$search.trigger('focus'); - }); - - container.on('close', function () { - self.$search.val(''); - self.$search.removeAttr('aria-activedescendant'); - self.$search.trigger('focus'); - }); - - container.on('enable', function () { - self.$search.prop('disabled', false); - - self._transferTabIndex(); - }); - - container.on('disable', function () { - self.$search.prop('disabled', true); - }); - - container.on('focus', function (evt) { - self.$search.trigger('focus'); - }); - - container.on('results:focus', function (params) { - self.$search.attr('aria-activedescendant', params.id); - }); - - this.$selection.on('focusin', '.select2-search--inline', function (evt) { - self.trigger('focus', evt); - }); - - this.$selection.on('focusout', '.select2-search--inline', function (evt) { - self._handleBlur(evt); - }); - - this.$selection.on('keydown', '.select2-search--inline', function (evt) { - evt.stopPropagation(); - - self.trigger('keypress', evt); - - self._keyUpPrevented = evt.isDefaultPrevented(); - - var key = evt.which; - - if (key === KEYS.BACKSPACE && self.$search.val() === '') { - var $previousChoice = self.$searchContainer - .prev('.select2-selection__choice'); - - if ($previousChoice.length > 0) { - var item = Utils.GetData($previousChoice[0], 'data'); - - self.searchRemoveChoice(item); - - evt.preventDefault(); - } - } - }); - - // Try to detect the IE version should the `documentMode` property that - // is stored on the document. This is only implemented in IE and is - // slightly cleaner than doing a user agent check. - // This property is not available in Edge, but Edge also doesn't have - // this bug. - var msie = document.documentMode; - var disableInputEvents = msie && msie <= 11; - - // Workaround for browsers which do not support the `input` event - // This will prevent double-triggering of events for browsers which support - // both the `keyup` and `input` events. - this.$selection.on( - 'input.searchcheck', - '.select2-search--inline', - function (evt) { - // IE will trigger the `input` event when a placeholder is used on a - // search box. To get around this issue, we are forced to ignore all - // `input` events in IE and keep using `keyup`. - if (disableInputEvents) { - self.$selection.off('input.search input.searchcheck'); - return; - } - - // Unbind the duplicated `keyup` event - self.$selection.off('keyup.search'); - } - ); - - this.$selection.on( - 'keyup.search input.search', - '.select2-search--inline', - function (evt) { - // IE will trigger the `input` event when a placeholder is used on a - // search box. To get around this issue, we are forced to ignore all - // `input` events in IE and keep using `keyup`. - if (disableInputEvents && evt.type === 'input') { - self.$selection.off('input.search input.searchcheck'); - return; - } - - var key = evt.which; - - // We can freely ignore events from modifier keys - if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) { - return; - } - - // Tabbing will be handled during the `keydown` phase - if (key == KEYS.TAB) { - return; - } - - self.handleSearch(evt); - } - ); - }; - - /** - * This method will transfer the tabindex attribute from the rendered - * selection to the search box. This allows for the search box to be used as - * the primary focus instead of the selection container. - * - * @private - */ - Search.prototype._transferTabIndex = function (decorated) { - this.$search.attr('tabindex', this.$selection.attr('tabindex')); - this.$selection.attr('tabindex', '-1'); - }; - - Search.prototype.createPlaceholder = function (decorated, placeholder) { - this.$search.attr('placeholder', placeholder.text); - }; - - Search.prototype.update = function (decorated, data) { - var searchHadFocus = this.$search[0] == document.activeElement; - - this.$search.attr('placeholder', ''); - - decorated.call(this, data); - - this.$selection.find('.select2-selection__rendered') - .append(this.$searchContainer); - - this.resizeSearch(); - if (searchHadFocus) { - var isTagInput = this.$element.find('[data-select2-tag]').length; - if (isTagInput) { - // fix IE11 bug where tag input lost focus - this.$element.focus(); - } else { - this.$search.focus(); - } - } - }; - - Search.prototype.handleSearch = function () { - this.resizeSearch(); - - if (!this._keyUpPrevented) { - var input = this.$search.val(); - - this.trigger('query', { - term: input - }); - } - - this._keyUpPrevented = false; - }; - - Search.prototype.searchRemoveChoice = function (decorated, item) { - this.trigger('unselect', { - data: item - }); - - this.$search.val(item.text); - this.handleSearch(); - }; - - Search.prototype.resizeSearch = function () { - this.$search.css('width', '25px'); - - var width = ''; - - if (this.$search.attr('placeholder') !== '') { - width = this.$selection.find('.select2-selection__rendered').innerWidth(); - } else { - var minimumWidth = this.$search.val().length + 1; - - width = (minimumWidth * 0.75) + 'em'; - } - - this.$search.css('width', width); - }; - - return Search; -}); - -S2.define('select2/selection/eventRelay',[ - 'jquery' -], function ($) { - function EventRelay () { } - - EventRelay.prototype.bind = function (decorated, container, $container) { - var self = this; - var relayEvents = [ - 'open', 'opening', - 'close', 'closing', - 'select', 'selecting', - 'unselect', 'unselecting', - 'clear', 'clearing' - ]; - - var preventableEvents = [ - 'opening', 'closing', 'selecting', 'unselecting', 'clearing' - ]; - - decorated.call(this, container, $container); - - container.on('*', function (name, params) { - // Ignore events that should not be relayed - if ($.inArray(name, relayEvents) === -1) { - return; - } - - // The parameters should always be an object - params = params || {}; - - // Generate the jQuery event for the Select2 event - var evt = $.Event('select2:' + name, { - params: params - }); - - self.$element.trigger(evt); - - // Only handle preventable events if it was one - if ($.inArray(name, preventableEvents) === -1) { - return; - } - - params.prevented = evt.isDefaultPrevented(); - }); - }; - - return EventRelay; -}); - -S2.define('select2/translation',[ - 'jquery', - 'require' -], function ($, require) { - function Translation (dict) { - this.dict = dict || {}; - } - - Translation.prototype.all = function () { - return this.dict; - }; - - Translation.prototype.get = function (key) { - return this.dict[key]; - }; - - Translation.prototype.extend = function (translation) { - this.dict = $.extend({}, translation.all(), this.dict); - }; - - // Static functions - - Translation._cache = {}; - - Translation.loadPath = function (path) { - if (!(path in Translation._cache)) { - var translations = require(path); - - Translation._cache[path] = translations; - } - - return new Translation(Translation._cache[path]); - }; - - return Translation; -}); - -S2.define('select2/diacritics',[ - -], function () { - var diacritics = { - '\u24B6': 'A', - '\uFF21': 'A', - '\u00C0': 'A', - '\u00C1': 'A', - '\u00C2': 'A', - '\u1EA6': 'A', - '\u1EA4': 'A', - '\u1EAA': 'A', - '\u1EA8': 'A', - '\u00C3': 'A', - '\u0100': 'A', - '\u0102': 'A', - '\u1EB0': 'A', - '\u1EAE': 'A', - '\u1EB4': 'A', - '\u1EB2': 'A', - '\u0226': 'A', - '\u01E0': 'A', - '\u00C4': 'A', - '\u01DE': 'A', - '\u1EA2': 'A', - '\u00C5': 'A', - '\u01FA': 'A', - '\u01CD': 'A', - '\u0200': 'A', - '\u0202': 'A', - '\u1EA0': 'A', - '\u1EAC': 'A', - '\u1EB6': 'A', - '\u1E00': 'A', - '\u0104': 'A', - '\u023A': 'A', - '\u2C6F': 'A', - '\uA732': 'AA', - '\u00C6': 'AE', - '\u01FC': 'AE', - '\u01E2': 'AE', - '\uA734': 'AO', - '\uA736': 'AU', - '\uA738': 'AV', - '\uA73A': 'AV', - '\uA73C': 'AY', - '\u24B7': 'B', - '\uFF22': 'B', - '\u1E02': 'B', - '\u1E04': 'B', - '\u1E06': 'B', - '\u0243': 'B', - '\u0182': 'B', - '\u0181': 'B', - '\u24B8': 'C', - '\uFF23': 'C', - '\u0106': 'C', - '\u0108': 'C', - '\u010A': 'C', - '\u010C': 'C', - '\u00C7': 'C', - '\u1E08': 'C', - '\u0187': 'C', - '\u023B': 'C', - '\uA73E': 'C', - '\u24B9': 'D', - '\uFF24': 'D', - '\u1E0A': 'D', - '\u010E': 'D', - '\u1E0C': 'D', - '\u1E10': 'D', - '\u1E12': 'D', - '\u1E0E': 'D', - '\u0110': 'D', - '\u018B': 'D', - '\u018A': 'D', - '\u0189': 'D', - '\uA779': 'D', - '\u01F1': 'DZ', - '\u01C4': 'DZ', - '\u01F2': 'Dz', - '\u01C5': 'Dz', - '\u24BA': 'E', - '\uFF25': 'E', - '\u00C8': 'E', - '\u00C9': 'E', - '\u00CA': 'E', - '\u1EC0': 'E', - '\u1EBE': 'E', - '\u1EC4': 'E', - '\u1EC2': 'E', - '\u1EBC': 'E', - '\u0112': 'E', - '\u1E14': 'E', - '\u1E16': 'E', - '\u0114': 'E', - '\u0116': 'E', - '\u00CB': 'E', - '\u1EBA': 'E', - '\u011A': 'E', - '\u0204': 'E', - '\u0206': 'E', - '\u1EB8': 'E', - '\u1EC6': 'E', - '\u0228': 'E', - '\u1E1C': 'E', - '\u0118': 'E', - '\u1E18': 'E', - '\u1E1A': 'E', - '\u0190': 'E', - '\u018E': 'E', - '\u24BB': 'F', - '\uFF26': 'F', - '\u1E1E': 'F', - '\u0191': 'F', - '\uA77B': 'F', - '\u24BC': 'G', - '\uFF27': 'G', - '\u01F4': 'G', - '\u011C': 'G', - '\u1E20': 'G', - '\u011E': 'G', - '\u0120': 'G', - '\u01E6': 'G', - '\u0122': 'G', - '\u01E4': 'G', - '\u0193': 'G', - '\uA7A0': 'G', - '\uA77D': 'G', - '\uA77E': 'G', - '\u24BD': 'H', - '\uFF28': 'H', - '\u0124': 'H', - '\u1E22': 'H', - '\u1E26': 'H', - '\u021E': 'H', - '\u1E24': 'H', - '\u1E28': 'H', - '\u1E2A': 'H', - '\u0126': 'H', - '\u2C67': 'H', - '\u2C75': 'H', - '\uA78D': 'H', - '\u24BE': 'I', - '\uFF29': 'I', - '\u00CC': 'I', - '\u00CD': 'I', - '\u00CE': 'I', - '\u0128': 'I', - '\u012A': 'I', - '\u012C': 'I', - '\u0130': 'I', - '\u00CF': 'I', - '\u1E2E': 'I', - '\u1EC8': 'I', - '\u01CF': 'I', - '\u0208': 'I', - '\u020A': 'I', - '\u1ECA': 'I', - '\u012E': 'I', - '\u1E2C': 'I', - '\u0197': 'I', - '\u24BF': 'J', - '\uFF2A': 'J', - '\u0134': 'J', - '\u0248': 'J', - '\u24C0': 'K', - '\uFF2B': 'K', - '\u1E30': 'K', - '\u01E8': 'K', - '\u1E32': 'K', - '\u0136': 'K', - '\u1E34': 'K', - '\u0198': 'K', - '\u2C69': 'K', - '\uA740': 'K', - '\uA742': 'K', - '\uA744': 'K', - '\uA7A2': 'K', - '\u24C1': 'L', - '\uFF2C': 'L', - '\u013F': 'L', - '\u0139': 'L', - '\u013D': 'L', - '\u1E36': 'L', - '\u1E38': 'L', - '\u013B': 'L', - '\u1E3C': 'L', - '\u1E3A': 'L', - '\u0141': 'L', - '\u023D': 'L', - '\u2C62': 'L', - '\u2C60': 'L', - '\uA748': 'L', - '\uA746': 'L', - '\uA780': 'L', - '\u01C7': 'LJ', - '\u01C8': 'Lj', - '\u24C2': 'M', - '\uFF2D': 'M', - '\u1E3E': 'M', - '\u1E40': 'M', - '\u1E42': 'M', - '\u2C6E': 'M', - '\u019C': 'M', - '\u24C3': 'N', - '\uFF2E': 'N', - '\u01F8': 'N', - '\u0143': 'N', - '\u00D1': 'N', - '\u1E44': 'N', - '\u0147': 'N', - '\u1E46': 'N', - '\u0145': 'N', - '\u1E4A': 'N', - '\u1E48': 'N', - '\u0220': 'N', - '\u019D': 'N', - '\uA790': 'N', - '\uA7A4': 'N', - '\u01CA': 'NJ', - '\u01CB': 'Nj', - '\u24C4': 'O', - '\uFF2F': 'O', - '\u00D2': 'O', - '\u00D3': 'O', - '\u00D4': 'O', - '\u1ED2': 'O', - '\u1ED0': 'O', - '\u1ED6': 'O', - '\u1ED4': 'O', - '\u00D5': 'O', - '\u1E4C': 'O', - '\u022C': 'O', - '\u1E4E': 'O', - '\u014C': 'O', - '\u1E50': 'O', - '\u1E52': 'O', - '\u014E': 'O', - '\u022E': 'O', - '\u0230': 'O', - '\u00D6': 'O', - '\u022A': 'O', - '\u1ECE': 'O', - '\u0150': 'O', - '\u01D1': 'O', - '\u020C': 'O', - '\u020E': 'O', - '\u01A0': 'O', - '\u1EDC': 'O', - '\u1EDA': 'O', - '\u1EE0': 'O', - '\u1EDE': 'O', - '\u1EE2': 'O', - '\u1ECC': 'O', - '\u1ED8': 'O', - '\u01EA': 'O', - '\u01EC': 'O', - '\u00D8': 'O', - '\u01FE': 'O', - '\u0186': 'O', - '\u019F': 'O', - '\uA74A': 'O', - '\uA74C': 'O', - '\u0152': 'OE', - '\u01A2': 'OI', - '\uA74E': 'OO', - '\u0222': 'OU', - '\u24C5': 'P', - '\uFF30': 'P', - '\u1E54': 'P', - '\u1E56': 'P', - '\u01A4': 'P', - '\u2C63': 'P', - '\uA750': 'P', - '\uA752': 'P', - '\uA754': 'P', - '\u24C6': 'Q', - '\uFF31': 'Q', - '\uA756': 'Q', - '\uA758': 'Q', - '\u024A': 'Q', - '\u24C7': 'R', - '\uFF32': 'R', - '\u0154': 'R', - '\u1E58': 'R', - '\u0158': 'R', - '\u0210': 'R', - '\u0212': 'R', - '\u1E5A': 'R', - '\u1E5C': 'R', - '\u0156': 'R', - '\u1E5E': 'R', - '\u024C': 'R', - '\u2C64': 'R', - '\uA75A': 'R', - '\uA7A6': 'R', - '\uA782': 'R', - '\u24C8': 'S', - '\uFF33': 'S', - '\u1E9E': 'S', - '\u015A': 'S', - '\u1E64': 'S', - '\u015C': 'S', - '\u1E60': 'S', - '\u0160': 'S', - '\u1E66': 'S', - '\u1E62': 'S', - '\u1E68': 'S', - '\u0218': 'S', - '\u015E': 'S', - '\u2C7E': 'S', - '\uA7A8': 'S', - '\uA784': 'S', - '\u24C9': 'T', - '\uFF34': 'T', - '\u1E6A': 'T', - '\u0164': 'T', - '\u1E6C': 'T', - '\u021A': 'T', - '\u0162': 'T', - '\u1E70': 'T', - '\u1E6E': 'T', - '\u0166': 'T', - '\u01AC': 'T', - '\u01AE': 'T', - '\u023E': 'T', - '\uA786': 'T', - '\uA728': 'TZ', - '\u24CA': 'U', - '\uFF35': 'U', - '\u00D9': 'U', - '\u00DA': 'U', - '\u00DB': 'U', - '\u0168': 'U', - '\u1E78': 'U', - '\u016A': 'U', - '\u1E7A': 'U', - '\u016C': 'U', - '\u00DC': 'U', - '\u01DB': 'U', - '\u01D7': 'U', - '\u01D5': 'U', - '\u01D9': 'U', - '\u1EE6': 'U', - '\u016E': 'U', - '\u0170': 'U', - '\u01D3': 'U', - '\u0214': 'U', - '\u0216': 'U', - '\u01AF': 'U', - '\u1EEA': 'U', - '\u1EE8': 'U', - '\u1EEE': 'U', - '\u1EEC': 'U', - '\u1EF0': 'U', - '\u1EE4': 'U', - '\u1E72': 'U', - '\u0172': 'U', - '\u1E76': 'U', - '\u1E74': 'U', - '\u0244': 'U', - '\u24CB': 'V', - '\uFF36': 'V', - '\u1E7C': 'V', - '\u1E7E': 'V', - '\u01B2': 'V', - '\uA75E': 'V', - '\u0245': 'V', - '\uA760': 'VY', - '\u24CC': 'W', - '\uFF37': 'W', - '\u1E80': 'W', - '\u1E82': 'W', - '\u0174': 'W', - '\u1E86': 'W', - '\u1E84': 'W', - '\u1E88': 'W', - '\u2C72': 'W', - '\u24CD': 'X', - '\uFF38': 'X', - '\u1E8A': 'X', - '\u1E8C': 'X', - '\u24CE': 'Y', - '\uFF39': 'Y', - '\u1EF2': 'Y', - '\u00DD': 'Y', - '\u0176': 'Y', - '\u1EF8': 'Y', - '\u0232': 'Y', - '\u1E8E': 'Y', - '\u0178': 'Y', - '\u1EF6': 'Y', - '\u1EF4': 'Y', - '\u01B3': 'Y', - '\u024E': 'Y', - '\u1EFE': 'Y', - '\u24CF': 'Z', - '\uFF3A': 'Z', - '\u0179': 'Z', - '\u1E90': 'Z', - '\u017B': 'Z', - '\u017D': 'Z', - '\u1E92': 'Z', - '\u1E94': 'Z', - '\u01B5': 'Z', - '\u0224': 'Z', - '\u2C7F': 'Z', - '\u2C6B': 'Z', - '\uA762': 'Z', - '\u24D0': 'a', - '\uFF41': 'a', - '\u1E9A': 'a', - '\u00E0': 'a', - '\u00E1': 'a', - '\u00E2': 'a', - '\u1EA7': 'a', - '\u1EA5': 'a', - '\u1EAB': 'a', - '\u1EA9': 'a', - '\u00E3': 'a', - '\u0101': 'a', - '\u0103': 'a', - '\u1EB1': 'a', - '\u1EAF': 'a', - '\u1EB5': 'a', - '\u1EB3': 'a', - '\u0227': 'a', - '\u01E1': 'a', - '\u00E4': 'a', - '\u01DF': 'a', - '\u1EA3': 'a', - '\u00E5': 'a', - '\u01FB': 'a', - '\u01CE': 'a', - '\u0201': 'a', - '\u0203': 'a', - '\u1EA1': 'a', - '\u1EAD': 'a', - '\u1EB7': 'a', - '\u1E01': 'a', - '\u0105': 'a', - '\u2C65': 'a', - '\u0250': 'a', - '\uA733': 'aa', - '\u00E6': 'ae', - '\u01FD': 'ae', - '\u01E3': 'ae', - '\uA735': 'ao', - '\uA737': 'au', - '\uA739': 'av', - '\uA73B': 'av', - '\uA73D': 'ay', - '\u24D1': 'b', - '\uFF42': 'b', - '\u1E03': 'b', - '\u1E05': 'b', - '\u1E07': 'b', - '\u0180': 'b', - '\u0183': 'b', - '\u0253': 'b', - '\u24D2': 'c', - '\uFF43': 'c', - '\u0107': 'c', - '\u0109': 'c', - '\u010B': 'c', - '\u010D': 'c', - '\u00E7': 'c', - '\u1E09': 'c', - '\u0188': 'c', - '\u023C': 'c', - '\uA73F': 'c', - '\u2184': 'c', - '\u24D3': 'd', - '\uFF44': 'd', - '\u1E0B': 'd', - '\u010F': 'd', - '\u1E0D': 'd', - '\u1E11': 'd', - '\u1E13': 'd', - '\u1E0F': 'd', - '\u0111': 'd', - '\u018C': 'd', - '\u0256': 'd', - '\u0257': 'd', - '\uA77A': 'd', - '\u01F3': 'dz', - '\u01C6': 'dz', - '\u24D4': 'e', - '\uFF45': 'e', - '\u00E8': 'e', - '\u00E9': 'e', - '\u00EA': 'e', - '\u1EC1': 'e', - '\u1EBF': 'e', - '\u1EC5': 'e', - '\u1EC3': 'e', - '\u1EBD': 'e', - '\u0113': 'e', - '\u1E15': 'e', - '\u1E17': 'e', - '\u0115': 'e', - '\u0117': 'e', - '\u00EB': 'e', - '\u1EBB': 'e', - '\u011B': 'e', - '\u0205': 'e', - '\u0207': 'e', - '\u1EB9': 'e', - '\u1EC7': 'e', - '\u0229': 'e', - '\u1E1D': 'e', - '\u0119': 'e', - '\u1E19': 'e', - '\u1E1B': 'e', - '\u0247': 'e', - '\u025B': 'e', - '\u01DD': 'e', - '\u24D5': 'f', - '\uFF46': 'f', - '\u1E1F': 'f', - '\u0192': 'f', - '\uA77C': 'f', - '\u24D6': 'g', - '\uFF47': 'g', - '\u01F5': 'g', - '\u011D': 'g', - '\u1E21': 'g', - '\u011F': 'g', - '\u0121': 'g', - '\u01E7': 'g', - '\u0123': 'g', - '\u01E5': 'g', - '\u0260': 'g', - '\uA7A1': 'g', - '\u1D79': 'g', - '\uA77F': 'g', - '\u24D7': 'h', - '\uFF48': 'h', - '\u0125': 'h', - '\u1E23': 'h', - '\u1E27': 'h', - '\u021F': 'h', - '\u1E25': 'h', - '\u1E29': 'h', - '\u1E2B': 'h', - '\u1E96': 'h', - '\u0127': 'h', - '\u2C68': 'h', - '\u2C76': 'h', - '\u0265': 'h', - '\u0195': 'hv', - '\u24D8': 'i', - '\uFF49': 'i', - '\u00EC': 'i', - '\u00ED': 'i', - '\u00EE': 'i', - '\u0129': 'i', - '\u012B': 'i', - '\u012D': 'i', - '\u00EF': 'i', - '\u1E2F': 'i', - '\u1EC9': 'i', - '\u01D0': 'i', - '\u0209': 'i', - '\u020B': 'i', - '\u1ECB': 'i', - '\u012F': 'i', - '\u1E2D': 'i', - '\u0268': 'i', - '\u0131': 'i', - '\u24D9': 'j', - '\uFF4A': 'j', - '\u0135': 'j', - '\u01F0': 'j', - '\u0249': 'j', - '\u24DA': 'k', - '\uFF4B': 'k', - '\u1E31': 'k', - '\u01E9': 'k', - '\u1E33': 'k', - '\u0137': 'k', - '\u1E35': 'k', - '\u0199': 'k', - '\u2C6A': 'k', - '\uA741': 'k', - '\uA743': 'k', - '\uA745': 'k', - '\uA7A3': 'k', - '\u24DB': 'l', - '\uFF4C': 'l', - '\u0140': 'l', - '\u013A': 'l', - '\u013E': 'l', - '\u1E37': 'l', - '\u1E39': 'l', - '\u013C': 'l', - '\u1E3D': 'l', - '\u1E3B': 'l', - '\u017F': 'l', - '\u0142': 'l', - '\u019A': 'l', - '\u026B': 'l', - '\u2C61': 'l', - '\uA749': 'l', - '\uA781': 'l', - '\uA747': 'l', - '\u01C9': 'lj', - '\u24DC': 'm', - '\uFF4D': 'm', - '\u1E3F': 'm', - '\u1E41': 'm', - '\u1E43': 'm', - '\u0271': 'm', - '\u026F': 'm', - '\u24DD': 'n', - '\uFF4E': 'n', - '\u01F9': 'n', - '\u0144': 'n', - '\u00F1': 'n', - '\u1E45': 'n', - '\u0148': 'n', - '\u1E47': 'n', - '\u0146': 'n', - '\u1E4B': 'n', - '\u1E49': 'n', - '\u019E': 'n', - '\u0272': 'n', - '\u0149': 'n', - '\uA791': 'n', - '\uA7A5': 'n', - '\u01CC': 'nj', - '\u24DE': 'o', - '\uFF4F': 'o', - '\u00F2': 'o', - '\u00F3': 'o', - '\u00F4': 'o', - '\u1ED3': 'o', - '\u1ED1': 'o', - '\u1ED7': 'o', - '\u1ED5': 'o', - '\u00F5': 'o', - '\u1E4D': 'o', - '\u022D': 'o', - '\u1E4F': 'o', - '\u014D': 'o', - '\u1E51': 'o', - '\u1E53': 'o', - '\u014F': 'o', - '\u022F': 'o', - '\u0231': 'o', - '\u00F6': 'o', - '\u022B': 'o', - '\u1ECF': 'o', - '\u0151': 'o', - '\u01D2': 'o', - '\u020D': 'o', - '\u020F': 'o', - '\u01A1': 'o', - '\u1EDD': 'o', - '\u1EDB': 'o', - '\u1EE1': 'o', - '\u1EDF': 'o', - '\u1EE3': 'o', - '\u1ECD': 'o', - '\u1ED9': 'o', - '\u01EB': 'o', - '\u01ED': 'o', - '\u00F8': 'o', - '\u01FF': 'o', - '\u0254': 'o', - '\uA74B': 'o', - '\uA74D': 'o', - '\u0275': 'o', - '\u0153': 'oe', - '\u01A3': 'oi', - '\u0223': 'ou', - '\uA74F': 'oo', - '\u24DF': 'p', - '\uFF50': 'p', - '\u1E55': 'p', - '\u1E57': 'p', - '\u01A5': 'p', - '\u1D7D': 'p', - '\uA751': 'p', - '\uA753': 'p', - '\uA755': 'p', - '\u24E0': 'q', - '\uFF51': 'q', - '\u024B': 'q', - '\uA757': 'q', - '\uA759': 'q', - '\u24E1': 'r', - '\uFF52': 'r', - '\u0155': 'r', - '\u1E59': 'r', - '\u0159': 'r', - '\u0211': 'r', - '\u0213': 'r', - '\u1E5B': 'r', - '\u1E5D': 'r', - '\u0157': 'r', - '\u1E5F': 'r', - '\u024D': 'r', - '\u027D': 'r', - '\uA75B': 'r', - '\uA7A7': 'r', - '\uA783': 'r', - '\u24E2': 's', - '\uFF53': 's', - '\u00DF': 's', - '\u015B': 's', - '\u1E65': 's', - '\u015D': 's', - '\u1E61': 's', - '\u0161': 's', - '\u1E67': 's', - '\u1E63': 's', - '\u1E69': 's', - '\u0219': 's', - '\u015F': 's', - '\u023F': 's', - '\uA7A9': 's', - '\uA785': 's', - '\u1E9B': 's', - '\u24E3': 't', - '\uFF54': 't', - '\u1E6B': 't', - '\u1E97': 't', - '\u0165': 't', - '\u1E6D': 't', - '\u021B': 't', - '\u0163': 't', - '\u1E71': 't', - '\u1E6F': 't', - '\u0167': 't', - '\u01AD': 't', - '\u0288': 't', - '\u2C66': 't', - '\uA787': 't', - '\uA729': 'tz', - '\u24E4': 'u', - '\uFF55': 'u', - '\u00F9': 'u', - '\u00FA': 'u', - '\u00FB': 'u', - '\u0169': 'u', - '\u1E79': 'u', - '\u016B': 'u', - '\u1E7B': 'u', - '\u016D': 'u', - '\u00FC': 'u', - '\u01DC': 'u', - '\u01D8': 'u', - '\u01D6': 'u', - '\u01DA': 'u', - '\u1EE7': 'u', - '\u016F': 'u', - '\u0171': 'u', - '\u01D4': 'u', - '\u0215': 'u', - '\u0217': 'u', - '\u01B0': 'u', - '\u1EEB': 'u', - '\u1EE9': 'u', - '\u1EEF': 'u', - '\u1EED': 'u', - '\u1EF1': 'u', - '\u1EE5': 'u', - '\u1E73': 'u', - '\u0173': 'u', - '\u1E77': 'u', - '\u1E75': 'u', - '\u0289': 'u', - '\u24E5': 'v', - '\uFF56': 'v', - '\u1E7D': 'v', - '\u1E7F': 'v', - '\u028B': 'v', - '\uA75F': 'v', - '\u028C': 'v', - '\uA761': 'vy', - '\u24E6': 'w', - '\uFF57': 'w', - '\u1E81': 'w', - '\u1E83': 'w', - '\u0175': 'w', - '\u1E87': 'w', - '\u1E85': 'w', - '\u1E98': 'w', - '\u1E89': 'w', - '\u2C73': 'w', - '\u24E7': 'x', - '\uFF58': 'x', - '\u1E8B': 'x', - '\u1E8D': 'x', - '\u24E8': 'y', - '\uFF59': 'y', - '\u1EF3': 'y', - '\u00FD': 'y', - '\u0177': 'y', - '\u1EF9': 'y', - '\u0233': 'y', - '\u1E8F': 'y', - '\u00FF': 'y', - '\u1EF7': 'y', - '\u1E99': 'y', - '\u1EF5': 'y', - '\u01B4': 'y', - '\u024F': 'y', - '\u1EFF': 'y', - '\u24E9': 'z', - '\uFF5A': 'z', - '\u017A': 'z', - '\u1E91': 'z', - '\u017C': 'z', - '\u017E': 'z', - '\u1E93': 'z', - '\u1E95': 'z', - '\u01B6': 'z', - '\u0225': 'z', - '\u0240': 'z', - '\u2C6C': 'z', - '\uA763': 'z', - '\u0386': '\u0391', - '\u0388': '\u0395', - '\u0389': '\u0397', - '\u038A': '\u0399', - '\u03AA': '\u0399', - '\u038C': '\u039F', - '\u038E': '\u03A5', - '\u03AB': '\u03A5', - '\u038F': '\u03A9', - '\u03AC': '\u03B1', - '\u03AD': '\u03B5', - '\u03AE': '\u03B7', - '\u03AF': '\u03B9', - '\u03CA': '\u03B9', - '\u0390': '\u03B9', - '\u03CC': '\u03BF', - '\u03CD': '\u03C5', - '\u03CB': '\u03C5', - '\u03B0': '\u03C5', - '\u03CE': '\u03C9', - '\u03C2': '\u03C3', - '\u2019': '\'' - }; - - return diacritics; -}); - -S2.define('select2/data/base',[ - '../utils' -], function (Utils) { - function BaseAdapter ($element, options) { - BaseAdapter.__super__.constructor.call(this); - } - - Utils.Extend(BaseAdapter, Utils.Observable); - - BaseAdapter.prototype.current = function (callback) { - throw new Error('The `current` method must be defined in child classes.'); - }; - - BaseAdapter.prototype.query = function (params, callback) { - throw new Error('The `query` method must be defined in child classes.'); - }; - - BaseAdapter.prototype.bind = function (container, $container) { - // Can be implemented in subclasses - }; - - BaseAdapter.prototype.destroy = function () { - // Can be implemented in subclasses - }; - - BaseAdapter.prototype.generateResultId = function (container, data) { - var id = container.id + '-result-'; - - id += Utils.generateChars(4); - - if (data.id != null) { - id += '-' + data.id.toString(); - } else { - id += '-' + Utils.generateChars(4); - } - return id; - }; - - return BaseAdapter; -}); - -S2.define('select2/data/select',[ - './base', - '../utils', - 'jquery' -], function (BaseAdapter, Utils, $) { - function SelectAdapter ($element, options) { - this.$element = $element; - this.options = options; - - SelectAdapter.__super__.constructor.call(this); - } - - Utils.Extend(SelectAdapter, BaseAdapter); - - SelectAdapter.prototype.current = function (callback) { - var data = []; - var self = this; - - this.$element.find(':selected').each(function () { - var $option = $(this); - - var option = self.item($option); - - data.push(option); - }); - - callback(data); - }; - - SelectAdapter.prototype.select = function (data) { - var self = this; - - data.selected = true; - - // If data.element is a DOM node, use it instead - if ($(data.element).is('option')) { - data.element.selected = true; - - this.$element.trigger('change'); - - return; - } - - if (this.$element.prop('multiple')) { - this.current(function (currentData) { - var val = []; - - data = [data]; - data.push.apply(data, currentData); - - for (var d = 0; d < data.length; d++) { - var id = data[d].id; - - if ($.inArray(id, val) === -1) { - val.push(id); - } - } - - self.$element.val(val); - self.$element.trigger('change'); - }); - } else { - var val = data.id; - - this.$element.val(val); - this.$element.trigger('change'); - } - }; - - SelectAdapter.prototype.unselect = function (data) { - var self = this; - - if (!this.$element.prop('multiple')) { - return; - } - - data.selected = false; - - if ($(data.element).is('option')) { - data.element.selected = false; - - this.$element.trigger('change'); - - return; - } - - this.current(function (currentData) { - var val = []; - - for (var d = 0; d < currentData.length; d++) { - var id = currentData[d].id; - - if (id !== data.id && $.inArray(id, val) === -1) { - val.push(id); - } - } - - self.$element.val(val); - - self.$element.trigger('change'); - }); - }; - - SelectAdapter.prototype.bind = function (container, $container) { - var self = this; - - this.container = container; - - container.on('select', function (params) { - self.select(params.data); - }); - - container.on('unselect', function (params) { - self.unselect(params.data); - }); - }; - - SelectAdapter.prototype.destroy = function () { - // Remove anything added to child elements - this.$element.find('*').each(function () { - // Remove any custom data set by Select2 - Utils.RemoveData(this); - }); - }; - - SelectAdapter.prototype.query = function (params, callback) { - var data = []; - var self = this; - - var $options = this.$element.children(); - - $options.each(function () { - var $option = $(this); - - if (!$option.is('option') && !$option.is('optgroup')) { - return; - } - - var option = self.item($option); - - var matches = self.matches(params, option); - - if (matches !== null) { - data.push(matches); - } - }); - - callback({ - results: data - }); - }; - - SelectAdapter.prototype.addOptions = function ($options) { - Utils.appendMany(this.$element, $options); - }; - - SelectAdapter.prototype.option = function (data) { - var option; - - if (data.children) { - option = document.createElement('optgroup'); - option.label = data.text; - } else { - option = document.createElement('option'); - - if (option.textContent !== undefined) { - option.textContent = data.text; - } else { - option.innerText = data.text; - } - } - - if (data.id !== undefined) { - option.value = data.id; - } - - if (data.disabled) { - option.disabled = true; - } - - if (data.selected) { - option.selected = true; - } - - if (data.title) { - option.title = data.title; - } - - var $option = $(option); - - var normalizedData = this._normalizeItem(data); - normalizedData.element = option; - - // Override the option's data with the combined data - Utils.StoreData(option, 'data', normalizedData); - - return $option; - }; - - SelectAdapter.prototype.item = function ($option) { - var data = {}; - - data = Utils.GetData($option[0], 'data'); - - if (data != null) { - return data; - } - - if ($option.is('option')) { - data = { - id: $option.val(), - text: $option.text(), - disabled: $option.prop('disabled'), - selected: $option.prop('selected'), - title: $option.prop('title') - }; - } else if ($option.is('optgroup')) { - data = { - text: $option.prop('label'), - children: [], - title: $option.prop('title') - }; - - var $children = $option.children('option'); - var children = []; - - for (var c = 0; c < $children.length; c++) { - var $child = $($children[c]); - - var child = this.item($child); - - children.push(child); - } - - data.children = children; - } - - data = this._normalizeItem(data); - data.element = $option[0]; - - Utils.StoreData($option[0], 'data', data); - - return data; - }; - - SelectAdapter.prototype._normalizeItem = function (item) { - if (item !== Object(item)) { - item = { - id: item, - text: item - }; - } - - item = $.extend({}, { - text: '' - }, item); - - var defaults = { - selected: false, - disabled: false - }; - - if (item.id != null) { - item.id = item.id.toString(); - } - - if (item.text != null) { - item.text = item.text.toString(); - } - - if (item._resultId == null && item.id && this.container != null) { - item._resultId = this.generateResultId(this.container, item); - } - - return $.extend({}, defaults, item); - }; - - SelectAdapter.prototype.matches = function (params, data) { - var matcher = this.options.get('matcher'); - - return matcher(params, data); - }; - - return SelectAdapter; -}); - -S2.define('select2/data/array',[ - './select', - '../utils', - 'jquery' -], function (SelectAdapter, Utils, $) { - function ArrayAdapter ($element, options) { - var data = options.get('data') || []; - - ArrayAdapter.__super__.constructor.call(this, $element, options); - - this.addOptions(this.convertToOptions(data)); - } - - Utils.Extend(ArrayAdapter, SelectAdapter); - - ArrayAdapter.prototype.select = function (data) { - var $option = this.$element.find('option').filter(function (i, elm) { - return elm.value == data.id.toString(); - }); - - if ($option.length === 0) { - $option = this.option(data); - - this.addOptions($option); - } - - ArrayAdapter.__super__.select.call(this, data); - }; - - ArrayAdapter.prototype.convertToOptions = function (data) { - var self = this; - - var $existing = this.$element.find('option'); - var existingIds = $existing.map(function () { - return self.item($(this)).id; - }).get(); - - var $options = []; - - // Filter out all items except for the one passed in the argument - function onlyItem (item) { - return function () { - return $(this).val() == item.id; - }; - } - - for (var d = 0; d < data.length; d++) { - var item = this._normalizeItem(data[d]); - - // Skip items which were pre-loaded, only merge the data - if ($.inArray(item.id, existingIds) >= 0) { - var $existingOption = $existing.filter(onlyItem(item)); - - var existingData = this.item($existingOption); - var newData = $.extend(true, {}, item, existingData); - - var $newOption = this.option(newData); - - $existingOption.replaceWith($newOption); - - continue; - } - - var $option = this.option(item); - - if (item.children) { - var $children = this.convertToOptions(item.children); - - Utils.appendMany($option, $children); - } - - $options.push($option); - } - - return $options; - }; - - return ArrayAdapter; -}); - -S2.define('select2/data/ajax',[ - './array', - '../utils', - 'jquery' -], function (ArrayAdapter, Utils, $) { - function AjaxAdapter ($element, options) { - this.ajaxOptions = this._applyDefaults(options.get('ajax')); - - if (this.ajaxOptions.processResults != null) { - this.processResults = this.ajaxOptions.processResults; - } - - AjaxAdapter.__super__.constructor.call(this, $element, options); - } - - Utils.Extend(AjaxAdapter, ArrayAdapter); - - AjaxAdapter.prototype._applyDefaults = function (options) { - var defaults = { - data: function (params) { - return $.extend({}, params, { - q: params.term - }); - }, - transport: function (params, success, failure) { - var $request = $.ajax(params); - - $request.then(success); - $request.fail(failure); - - return $request; - } - }; - - return $.extend({}, defaults, options, true); - }; - - AjaxAdapter.prototype.processResults = function (results) { - return results; - }; - - AjaxAdapter.prototype.query = function (params, callback) { - var matches = []; - var self = this; - - if (this._request != null) { - // JSONP requests cannot always be aborted - if ($.isFunction(this._request.abort)) { - this._request.abort(); - } - - this._request = null; - } - - var options = $.extend({ - type: 'GET' - }, this.ajaxOptions); - - if (typeof options.url === 'function') { - options.url = options.url.call(this.$element, params); - } - - if (typeof options.data === 'function') { - options.data = options.data.call(this.$element, params); - } - - function request () { - var $request = options.transport(options, function (data) { - var results = self.processResults(data, params); - - if (self.options.get('debug') && window.console && console.error) { - // Check to make sure that the response included a `results` key. - if (!results || !results.results || !$.isArray(results.results)) { - console.error( - 'Select2: The AJAX results did not return an array in the ' + - '`results` key of the response.' - ); - } - } - - callback(results); - }, function () { - // Attempt to detect if a request was aborted - // Only works if the transport exposes a status property - if ('status' in $request && - ($request.status === 0 || $request.status === '0')) { - return; - } - - self.trigger('results:message', { - message: 'errorLoading' - }); - }); - - self._request = $request; - } - - if (this.ajaxOptions.delay && params.term != null) { - if (this._queryTimeout) { - window.clearTimeout(this._queryTimeout); - } - - this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay); - } else { - request(); - } - }; - - return AjaxAdapter; -}); - -S2.define('select2/data/tags',[ - 'jquery' -], function ($) { - function Tags (decorated, $element, options) { - var tags = options.get('tags'); - - var createTag = options.get('createTag'); - - if (createTag !== undefined) { - this.createTag = createTag; - } - - var insertTag = options.get('insertTag'); - - if (insertTag !== undefined) { - this.insertTag = insertTag; - } - - decorated.call(this, $element, options); - - if ($.isArray(tags)) { - for (var t = 0; t < tags.length; t++) { - var tag = tags[t]; - var item = this._normalizeItem(tag); - - var $option = this.option(item); - - this.$element.append($option); - } - } - } - - Tags.prototype.query = function (decorated, params, callback) { - var self = this; - - this._removeOldTags(); - - if (params.term == null || params.page != null) { - decorated.call(this, params, callback); - return; - } - - function wrapper (obj, child) { - var data = obj.results; - - for (var i = 0; i < data.length; i++) { - var option = data[i]; - - var checkChildren = ( - option.children != null && - !wrapper({ - results: option.children - }, true) - ); - - var optionText = (option.text || '').toUpperCase(); - var paramsTerm = (params.term || '').toUpperCase(); - - var checkText = optionText === paramsTerm; - - if (checkText || checkChildren) { - if (child) { - return false; - } - - obj.data = data; - callback(obj); - - return; - } - } - - if (child) { - return true; - } - - var tag = self.createTag(params); - - if (tag != null) { - var $option = self.option(tag); - $option.attr('data-select2-tag', true); - - self.addOptions([$option]); - - self.insertTag(data, tag); - } - - obj.results = data; - - callback(obj); - } - - decorated.call(this, params, wrapper); - }; - - Tags.prototype.createTag = function (decorated, params) { - var term = $.trim(params.term); - - if (term === '') { - return null; - } - - return { - id: term, - text: term - }; - }; - - Tags.prototype.insertTag = function (_, data, tag) { - data.unshift(tag); - }; - - Tags.prototype._removeOldTags = function (_) { - var tag = this._lastTag; - - var $options = this.$element.find('option[data-select2-tag]'); - - $options.each(function () { - if (this.selected) { - return; - } - - $(this).remove(); - }); - }; - - return Tags; -}); - -S2.define('select2/data/tokenizer',[ - 'jquery' -], function ($) { - function Tokenizer (decorated, $element, options) { - var tokenizer = options.get('tokenizer'); - - if (tokenizer !== undefined) { - this.tokenizer = tokenizer; - } - - decorated.call(this, $element, options); - } - - Tokenizer.prototype.bind = function (decorated, container, $container) { - decorated.call(this, container, $container); - - this.$search = container.dropdown.$search || container.selection.$search || - $container.find('.select2-search__field'); - }; - - Tokenizer.prototype.query = function (decorated, params, callback) { - var self = this; - - function createAndSelect (data) { - // Normalize the data object so we can use it for checks - var item = self._normalizeItem(data); - - // Check if the data object already exists as a tag - // Select it if it doesn't - var $existingOptions = self.$element.find('option').filter(function () { - return $(this).val() === item.id; - }); - - // If an existing option wasn't found for it, create the option - if (!$existingOptions.length) { - var $option = self.option(item); - $option.attr('data-select2-tag', true); - - self._removeOldTags(); - self.addOptions([$option]); - } - - // Select the item, now that we know there is an option for it - select(item); - } - - function select (data) { - self.trigger('select', { - data: data - }); - } - - params.term = params.term || ''; - - var tokenData = this.tokenizer(params, this.options, createAndSelect); - - if (tokenData.term !== params.term) { - // Replace the search term if we have the search box - if (this.$search.length) { - this.$search.val(tokenData.term); - this.$search.focus(); - } - - params.term = tokenData.term; - } - - decorated.call(this, params, callback); - }; - - Tokenizer.prototype.tokenizer = function (_, params, options, callback) { - var separators = options.get('tokenSeparators') || []; - var term = params.term; - var i = 0; - - var createTag = this.createTag || function (params) { - return { - id: params.term, - text: params.term - }; - }; - - while (i < term.length) { - var termChar = term[i]; - - if ($.inArray(termChar, separators) === -1) { - i++; - - continue; - } - - var part = term.substr(0, i); - var partParams = $.extend({}, params, { - term: part - }); - - var data = createTag(partParams); - - if (data == null) { - i++; - continue; - } - - callback(data); - - // Reset the term to not include the tokenized portion - term = term.substr(i + 1) || ''; - i = 0; - } - - return { - term: term - }; - }; - - return Tokenizer; -}); - -S2.define('select2/data/minimumInputLength',[ - -], function () { - function MinimumInputLength (decorated, $e, options) { - this.minimumInputLength = options.get('minimumInputLength'); - - decorated.call(this, $e, options); - } - - MinimumInputLength.prototype.query = function (decorated, params, callback) { - params.term = params.term || ''; - - if (params.term.length < this.minimumInputLength) { - this.trigger('results:message', { - message: 'inputTooShort', - args: { - minimum: this.minimumInputLength, - input: params.term, - params: params - } - }); - - return; - } - - decorated.call(this, params, callback); - }; - - return MinimumInputLength; -}); - -S2.define('select2/data/maximumInputLength',[ - -], function () { - function MaximumInputLength (decorated, $e, options) { - this.maximumInputLength = options.get('maximumInputLength'); - - decorated.call(this, $e, options); - } - - MaximumInputLength.prototype.query = function (decorated, params, callback) { - params.term = params.term || ''; - - if (this.maximumInputLength > 0 && - params.term.length > this.maximumInputLength) { - this.trigger('results:message', { - message: 'inputTooLong', - args: { - maximum: this.maximumInputLength, - input: params.term, - params: params - } - }); - - return; - } - - decorated.call(this, params, callback); - }; - - return MaximumInputLength; -}); - -S2.define('select2/data/maximumSelectionLength',[ - -], function (){ - function MaximumSelectionLength (decorated, $e, options) { - this.maximumSelectionLength = options.get('maximumSelectionLength'); - - decorated.call(this, $e, options); - } - - MaximumSelectionLength.prototype.query = - function (decorated, params, callback) { - var self = this; - - this.current(function (currentData) { - var count = currentData != null ? currentData.length : 0; - if (self.maximumSelectionLength > 0 && - count >= self.maximumSelectionLength) { - self.trigger('results:message', { - message: 'maximumSelected', - args: { - maximum: self.maximumSelectionLength - } - }); - return; - } - decorated.call(self, params, callback); - }); - }; - - return MaximumSelectionLength; -}); - -S2.define('select2/dropdown',[ - 'jquery', - './utils' -], function ($, Utils) { - function Dropdown ($element, options) { - this.$element = $element; - this.options = options; - - Dropdown.__super__.constructor.call(this); - } - - Utils.Extend(Dropdown, Utils.Observable); - - Dropdown.prototype.render = function () { - var $dropdown = $( - '' + - '' + - '' - ); - - $dropdown.attr('dir', this.options.get('dir')); - - this.$dropdown = $dropdown; - - return $dropdown; - }; - - Dropdown.prototype.bind = function () { - // Should be implemented in subclasses - }; - - Dropdown.prototype.position = function ($dropdown, $container) { - // Should be implemented in subclasses - }; - - Dropdown.prototype.destroy = function () { - // Remove the dropdown from the DOM - this.$dropdown.remove(); - }; - - return Dropdown; -}); - -S2.define('select2/dropdown/search',[ - 'jquery', - '../utils' -], function ($, Utils) { - function Search () { } - - Search.prototype.render = function (decorated) { - var $rendered = decorated.call(this); - - var $search = $( - '' + - '' + - '' - ); - - this.$searchContainer = $search; - this.$search = $search.find('input'); - - $rendered.prepend($search); - - return $rendered; - }; - - Search.prototype.bind = function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - this.$search.on('keydown', function (evt) { - self.trigger('keypress', evt); - - self._keyUpPrevented = evt.isDefaultPrevented(); - }); - - // Workaround for browsers which do not support the `input` event - // This will prevent double-triggering of events for browsers which support - // both the `keyup` and `input` events. - this.$search.on('input', function (evt) { - // Unbind the duplicated `keyup` event - $(this).off('keyup'); - }); - - this.$search.on('keyup input', function (evt) { - self.handleSearch(evt); - }); - - container.on('open', function () { - self.$search.attr('tabindex', 0); - - self.$search.focus(); - - window.setTimeout(function () { - self.$search.focus(); - }, 0); - }); - - container.on('close', function () { - self.$search.attr('tabindex', -1); - - self.$search.val(''); - self.$search.blur(); - }); - - container.on('focus', function () { - if (!container.isOpen()) { - self.$search.focus(); - } - }); - - container.on('results:all', function (params) { - if (params.query.term == null || params.query.term === '') { - var showSearch = self.showSearch(params); - - if (showSearch) { - self.$searchContainer.removeClass('select2-search--hide'); - } else { - self.$searchContainer.addClass('select2-search--hide'); - } - } - }); - }; - - Search.prototype.handleSearch = function (evt) { - if (!this._keyUpPrevented) { - var input = this.$search.val(); - - this.trigger('query', { - term: input - }); - } - - this._keyUpPrevented = false; - }; - - Search.prototype.showSearch = function (_, params) { - return true; - }; - - return Search; -}); - -S2.define('select2/dropdown/hidePlaceholder',[ - -], function () { - function HidePlaceholder (decorated, $element, options, dataAdapter) { - this.placeholder = this.normalizePlaceholder(options.get('placeholder')); - - decorated.call(this, $element, options, dataAdapter); - } - - HidePlaceholder.prototype.append = function (decorated, data) { - data.results = this.removePlaceholder(data.results); - - decorated.call(this, data); - }; - - HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) { - if (typeof placeholder === 'string') { - placeholder = { - id: '', - text: placeholder - }; - } - - return placeholder; - }; - - HidePlaceholder.prototype.removePlaceholder = function (_, data) { - var modifiedData = data.slice(0); - - for (var d = data.length - 1; d >= 0; d--) { - var item = data[d]; - - if (this.placeholder.id === item.id) { - modifiedData.splice(d, 1); - } - } - - return modifiedData; - }; - - return HidePlaceholder; -}); - -S2.define('select2/dropdown/infiniteScroll',[ - 'jquery' -], function ($) { - function InfiniteScroll (decorated, $element, options, dataAdapter) { - this.lastParams = {}; - - decorated.call(this, $element, options, dataAdapter); - - this.$loadingMore = this.createLoadingMore(); - this.loading = false; - } - - InfiniteScroll.prototype.append = function (decorated, data) { - this.$loadingMore.remove(); - this.loading = false; - - decorated.call(this, data); - - if (this.showLoadingMore(data)) { - this.$results.append(this.$loadingMore); - } - }; - - InfiniteScroll.prototype.bind = function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - container.on('query', function (params) { - self.lastParams = params; - self.loading = true; - }); - - container.on('query:append', function (params) { - self.lastParams = params; - self.loading = true; - }); - - this.$results.on('scroll', function () { - var isLoadMoreVisible = $.contains( - document.documentElement, - self.$loadingMore[0] - ); - - if (self.loading || !isLoadMoreVisible) { - return; - } - - var currentOffset = self.$results.offset().top + - self.$results.outerHeight(false); - var loadingMoreOffset = self.$loadingMore.offset().top + - self.$loadingMore.outerHeight(false); - - if (currentOffset + 50 >= loadingMoreOffset) { - self.loadMore(); - } - }); - }; - - InfiniteScroll.prototype.loadMore = function () { - this.loading = true; - - var params = $.extend({}, {page: 1}, this.lastParams); - - params.page++; - - this.trigger('query:append', params); - }; - - InfiniteScroll.prototype.showLoadingMore = function (_, data) { - return data.pagination && data.pagination.more; - }; - - InfiniteScroll.prototype.createLoadingMore = function () { - var $option = $( - '
                    • ' - ); - - var message = this.options.get('translations').get('loadingMore'); - - $option.html(message(this.lastParams)); - - return $option; - }; - - return InfiniteScroll; -}); - -S2.define('select2/dropdown/attachBody',[ - 'jquery', - '../utils' -], function ($, Utils) { - function AttachBody (decorated, $element, options) { - this.$dropdownParent = options.get('dropdownParent') || $(document.body); - - decorated.call(this, $element, options); - } - - AttachBody.prototype.bind = function (decorated, container, $container) { - var self = this; - - var setupResultsEvents = false; - - decorated.call(this, container, $container); - - container.on('open', function () { - self._showDropdown(); - self._attachPositioningHandler(container); - - if (!setupResultsEvents) { - setupResultsEvents = true; - - container.on('results:all', function () { - self._positionDropdown(); - self._resizeDropdown(); - }); - - container.on('results:append', function () { - self._positionDropdown(); - self._resizeDropdown(); - }); - } - }); - - container.on('close', function () { - self._hideDropdown(); - self._detachPositioningHandler(container); - }); - - this.$dropdownContainer.on('mousedown', function (evt) { - evt.stopPropagation(); - }); - }; - - AttachBody.prototype.destroy = function (decorated) { - decorated.call(this); - - this.$dropdownContainer.remove(); - }; - - AttachBody.prototype.position = function (decorated, $dropdown, $container) { - // Clone all of the container classes - $dropdown.attr('class', $container.attr('class')); - - $dropdown.removeClass('select2'); - $dropdown.addClass('select2-container--open'); - - $dropdown.css({ - position: 'absolute', - top: -999999 - }); - - this.$container = $container; - }; - - AttachBody.prototype.render = function (decorated) { - var $container = $(''); - - var $dropdown = decorated.call(this); - $container.append($dropdown); - - this.$dropdownContainer = $container; - - return $container; - }; - - AttachBody.prototype._hideDropdown = function (decorated) { - this.$dropdownContainer.detach(); - }; - - AttachBody.prototype._attachPositioningHandler = - function (decorated, container) { - var self = this; - - var scrollEvent = 'scroll.select2.' + container.id; - var resizeEvent = 'resize.select2.' + container.id; - var orientationEvent = 'orientationchange.select2.' + container.id; - - var $watchers = this.$container.parents().filter(Utils.hasScroll); - $watchers.each(function () { - Utils.StoreData(this, 'select2-scroll-position', { - x: $(this).scrollLeft(), - y: $(this).scrollTop() - }); - }); - - $watchers.on(scrollEvent, function (ev) { - var position = Utils.GetData(this, 'select2-scroll-position'); - $(this).scrollTop(position.y); - }); - - $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent, - function (e) { - self._positionDropdown(); - self._resizeDropdown(); - }); - }; - - AttachBody.prototype._detachPositioningHandler = - function (decorated, container) { - var scrollEvent = 'scroll.select2.' + container.id; - var resizeEvent = 'resize.select2.' + container.id; - var orientationEvent = 'orientationchange.select2.' + container.id; - - var $watchers = this.$container.parents().filter(Utils.hasScroll); - $watchers.off(scrollEvent); - - $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent); - }; - - AttachBody.prototype._positionDropdown = function () { - var $window = $(window); - - var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above'); - var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below'); - - var newDirection = null; - - var offset = this.$container.offset(); - - offset.bottom = offset.top + this.$container.outerHeight(false); - - var container = { - height: this.$container.outerHeight(false) - }; - - container.top = offset.top; - container.bottom = offset.top + container.height; - - var dropdown = { - height: this.$dropdown.outerHeight(false) - }; - - var viewport = { - top: $window.scrollTop(), - bottom: $window.scrollTop() + $window.height() - }; - - var enoughRoomAbove = viewport.top < (offset.top - dropdown.height); - var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height); - - var css = { - left: offset.left, - top: container.bottom - }; - - // Determine what the parent element is to use for calculating the offset - var $offsetParent = this.$dropdownParent; - - // For statically positioned elements, we need to get the element - // that is determining the offset - if ($offsetParent.css('position') === 'static') { - $offsetParent = $offsetParent.offsetParent(); - } - - var parentOffset = $offsetParent.offset(); - - css.top -= parentOffset.top; - css.left -= parentOffset.left; - - if (!isCurrentlyAbove && !isCurrentlyBelow) { - newDirection = 'below'; - } - - if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) { - newDirection = 'above'; - } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) { - newDirection = 'below'; - } - - if (newDirection == 'above' || - (isCurrentlyAbove && newDirection !== 'below')) { - css.top = container.top - parentOffset.top - dropdown.height; - } - - if (newDirection != null) { - this.$dropdown - .removeClass('select2-dropdown--below select2-dropdown--above') - .addClass('select2-dropdown--' + newDirection); - this.$container - .removeClass('select2-container--below select2-container--above') - .addClass('select2-container--' + newDirection); - } - - this.$dropdownContainer.css(css); - }; - - AttachBody.prototype._resizeDropdown = function () { - var css = { - width: this.$container.outerWidth(false) + 'px' - }; - - if (this.options.get('dropdownAutoWidth')) { - css.minWidth = css.width; - css.position = 'relative'; - css.width = 'auto'; - } - - this.$dropdown.css(css); - }; - - AttachBody.prototype._showDropdown = function (decorated) { - this.$dropdownContainer.appendTo(this.$dropdownParent); - - this._positionDropdown(); - this._resizeDropdown(); - }; - - return AttachBody; -}); - -S2.define('select2/dropdown/minimumResultsForSearch',[ - -], function () { - function countResults (data) { - var count = 0; - - for (var d = 0; d < data.length; d++) { - var item = data[d]; - - if (item.children) { - count += countResults(item.children); - } else { - count++; - } - } - - return count; - } - - function MinimumResultsForSearch (decorated, $element, options, dataAdapter) { - this.minimumResultsForSearch = options.get('minimumResultsForSearch'); - - if (this.minimumResultsForSearch < 0) { - this.minimumResultsForSearch = Infinity; - } - - decorated.call(this, $element, options, dataAdapter); - } - - MinimumResultsForSearch.prototype.showSearch = function (decorated, params) { - if (countResults(params.data.results) < this.minimumResultsForSearch) { - return false; - } - - return decorated.call(this, params); - }; - - return MinimumResultsForSearch; -}); - -S2.define('select2/dropdown/selectOnClose',[ - '../utils' -], function (Utils) { - function SelectOnClose () { } - - SelectOnClose.prototype.bind = function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - container.on('close', function (params) { - self._handleSelectOnClose(params); - }); - }; - - SelectOnClose.prototype._handleSelectOnClose = function (_, params) { - if (params && params.originalSelect2Event != null) { - var event = params.originalSelect2Event; - - // Don't select an item if the close event was triggered from a select or - // unselect event - if (event._type === 'select' || event._type === 'unselect') { - return; - } - } - - var $highlightedResults = this.getHighlightedResults(); - - // Only select highlighted results - if ($highlightedResults.length < 1) { - return; - } - - var data = Utils.GetData($highlightedResults[0], 'data'); - - // Don't re-select already selected resulte - if ( - (data.element != null && data.element.selected) || - (data.element == null && data.selected) - ) { - return; - } - - this.trigger('select', { - data: data - }); - }; - - return SelectOnClose; -}); - -S2.define('select2/dropdown/closeOnSelect',[ - -], function () { - function CloseOnSelect () { } - - CloseOnSelect.prototype.bind = function (decorated, container, $container) { - var self = this; - - decorated.call(this, container, $container); - - container.on('select', function (evt) { - self._selectTriggered(evt); - }); - - container.on('unselect', function (evt) { - self._selectTriggered(evt); - }); - }; - - CloseOnSelect.prototype._selectTriggered = function (_, evt) { - var originalEvent = evt.originalEvent; - - // Don't close if the control key is being held - if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) { - return; - } - - this.trigger('close', { - originalEvent: originalEvent, - originalSelect2Event: evt - }); - }; - - return CloseOnSelect; -}); - -S2.define('select2/i18n/en',[],function () { - // English - return { - errorLoading: function () { - return 'The results could not be loaded.'; - }, - inputTooLong: function (args) { - var overChars = args.input.length - args.maximum; - - var message = 'Please delete ' + overChars + ' character'; - - if (overChars != 1) { - message += 's'; - } - - return message; - }, - inputTooShort: function (args) { - var remainingChars = args.minimum - args.input.length; - - var message = 'Please enter ' + remainingChars + ' or more characters'; - - return message; - }, - loadingMore: function () { - return 'Loading more results…'; - }, - maximumSelected: function (args) { - var message = 'You can only select ' + args.maximum + ' item'; - - if (args.maximum != 1) { - message += 's'; - } - - return message; - }, - noResults: function () { - return 'No results found'; - }, - searching: function () { - return 'Searching…'; - }, - removeAllItems: function () { - return 'Remove all items'; - } - }; -}); - -S2.define('select2/defaults',[ - 'jquery', - 'require', - - './results', - - './selection/single', - './selection/multiple', - './selection/placeholder', - './selection/allowClear', - './selection/search', - './selection/eventRelay', - - './utils', - './translation', - './diacritics', - - './data/select', - './data/array', - './data/ajax', - './data/tags', - './data/tokenizer', - './data/minimumInputLength', - './data/maximumInputLength', - './data/maximumSelectionLength', - - './dropdown', - './dropdown/search', - './dropdown/hidePlaceholder', - './dropdown/infiniteScroll', - './dropdown/attachBody', - './dropdown/minimumResultsForSearch', - './dropdown/selectOnClose', - './dropdown/closeOnSelect', - - './i18n/en' -], function ($, require, - - ResultsList, - - SingleSelection, MultipleSelection, Placeholder, AllowClear, - SelectionSearch, EventRelay, - - Utils, Translation, DIACRITICS, - - SelectData, ArrayData, AjaxData, Tags, Tokenizer, - MinimumInputLength, MaximumInputLength, MaximumSelectionLength, - - Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll, - AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect, - - EnglishTranslation) { - function Defaults () { - this.reset(); - } - - Defaults.prototype.apply = function (options) { - options = $.extend(true, {}, this.defaults, options); - - if (options.dataAdapter == null) { - if (options.ajax != null) { - options.dataAdapter = AjaxData; - } else if (options.data != null) { - options.dataAdapter = ArrayData; - } else { - options.dataAdapter = SelectData; - } - - if (options.minimumInputLength > 0) { - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - MinimumInputLength - ); - } - - if (options.maximumInputLength > 0) { - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - MaximumInputLength - ); - } - - if (options.maximumSelectionLength > 0) { - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - MaximumSelectionLength - ); - } - - if (options.tags) { - options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags); - } - - if (options.tokenSeparators != null || options.tokenizer != null) { - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - Tokenizer - ); - } - - if (options.query != null) { - var Query = require(options.amdBase + 'compat/query'); - - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - Query - ); - } - - if (options.initSelection != null) { - var InitSelection = require(options.amdBase + 'compat/initSelection'); - - options.dataAdapter = Utils.Decorate( - options.dataAdapter, - InitSelection - ); - } - } - - if (options.resultsAdapter == null) { - options.resultsAdapter = ResultsList; - - if (options.ajax != null) { - options.resultsAdapter = Utils.Decorate( - options.resultsAdapter, - InfiniteScroll - ); - } - - if (options.placeholder != null) { - options.resultsAdapter = Utils.Decorate( - options.resultsAdapter, - HidePlaceholder - ); - } - - if (options.selectOnClose) { - options.resultsAdapter = Utils.Decorate( - options.resultsAdapter, - SelectOnClose - ); - } - } - - if (options.dropdownAdapter == null) { - if (options.multiple) { - options.dropdownAdapter = Dropdown; - } else { - var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch); - - options.dropdownAdapter = SearchableDropdown; - } - - if (options.minimumResultsForSearch !== 0) { - options.dropdownAdapter = Utils.Decorate( - options.dropdownAdapter, - MinimumResultsForSearch - ); - } - - if (options.closeOnSelect) { - options.dropdownAdapter = Utils.Decorate( - options.dropdownAdapter, - CloseOnSelect - ); - } - - if ( - options.dropdownCssClass != null || - options.dropdownCss != null || - options.adaptDropdownCssClass != null - ) { - var DropdownCSS = require(options.amdBase + 'compat/dropdownCss'); - - options.dropdownAdapter = Utils.Decorate( - options.dropdownAdapter, - DropdownCSS - ); - } - - options.dropdownAdapter = Utils.Decorate( - options.dropdownAdapter, - AttachBody - ); - } - - if (options.selectionAdapter == null) { - if (options.multiple) { - options.selectionAdapter = MultipleSelection; - } else { - options.selectionAdapter = SingleSelection; - } - - // Add the placeholder mixin if a placeholder was specified - if (options.placeholder != null) { - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - Placeholder - ); - } - - if (options.allowClear) { - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - AllowClear - ); - } - - if (options.multiple) { - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - SelectionSearch - ); - } - - if ( - options.containerCssClass != null || - options.containerCss != null || - options.adaptContainerCssClass != null - ) { - var ContainerCSS = require(options.amdBase + 'compat/containerCss'); - - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - ContainerCSS - ); - } - - options.selectionAdapter = Utils.Decorate( - options.selectionAdapter, - EventRelay - ); - } - - if (typeof options.language === 'string') { - // Check if the language is specified with a region - if (options.language.indexOf('-') > 0) { - // Extract the region information if it is included - var languageParts = options.language.split('-'); - var baseLanguage = languageParts[0]; - - options.language = [options.language, baseLanguage]; - } else { - options.language = [options.language]; - } - } - - if ($.isArray(options.language)) { - var languages = new Translation(); - options.language.push('en'); - - var languageNames = options.language; - - for (var l = 0; l < languageNames.length; l++) { - var name = languageNames[l]; - var language = {}; - - try { - // Try to load it with the original name - language = Translation.loadPath(name); - } catch (e) { - try { - // If we couldn't load it, check if it wasn't the full path - name = this.defaults.amdLanguageBase + name; - language = Translation.loadPath(name); - } catch (ex) { - // The translation could not be loaded at all. Sometimes this is - // because of a configuration problem, other times this can be - // because of how Select2 helps load all possible translation files. - if (options.debug && window.console && console.warn) { - console.warn( - 'Select2: The language file for "' + name + '" could not be ' + - 'automatically loaded. A fallback will be used instead.' - ); - } - - continue; - } - } - - languages.extend(language); - } - - options.translations = languages; - } else { - var baseTranslation = Translation.loadPath( - this.defaults.amdLanguageBase + 'en' - ); - var customTranslation = new Translation(options.language); - - customTranslation.extend(baseTranslation); - - options.translations = customTranslation; - } - - return options; - }; - - Defaults.prototype.reset = function () { - function stripDiacritics (text) { - // Used 'uni range + named function' from http://jsperf.com/diacritics/18 - function match(a) { - return DIACRITICS[a] || a; - } - - return text.replace(/[^\u0000-\u007E]/g, match); - } - - function matcher (params, data) { - // Always return the object if there is nothing to compare - if ($.trim(params.term) === '') { - return data; - } - - // Do a recursive check for options with children - if (data.children && data.children.length > 0) { - // Clone the data object if there are children - // This is required as we modify the object to remove any non-matches - var match = $.extend(true, {}, data); - - // Check each child of the option - for (var c = data.children.length - 1; c >= 0; c--) { - var child = data.children[c]; - - var matches = matcher(params, child); - - // If there wasn't a match, remove the object in the array - if (matches == null) { - match.children.splice(c, 1); - } - } - - // If any children matched, return the new object - if (match.children.length > 0) { - return match; - } - - // If there were no matching children, check just the plain object - return matcher(params, match); - } - - var original = stripDiacritics(data.text).toUpperCase(); - var term = stripDiacritics(params.term).toUpperCase(); - - // Check if the text contains the term - if (original.indexOf(term) > -1) { - return data; - } - - // If it doesn't contain the term, don't return anything - return null; - } - - this.defaults = { - amdBase: './', - amdLanguageBase: './i18n/', - closeOnSelect: true, - debug: false, - dropdownAutoWidth: false, - escapeMarkup: Utils.escapeMarkup, - language: EnglishTranslation, - matcher: matcher, - minimumInputLength: 0, - maximumInputLength: 0, - maximumSelectionLength: 0, - minimumResultsForSearch: 0, - selectOnClose: false, - scrollAfterSelect: false, - sorter: function (data) { - return data; - }, - templateResult: function (result) { - return result.text; - }, - templateSelection: function (selection) { - return selection.text; - }, - theme: 'default', - width: 'resolve' - }; - }; - - Defaults.prototype.set = function (key, value) { - var camelKey = $.camelCase(key); - - var data = {}; - data[camelKey] = value; - - var convertedData = Utils._convertData(data); - - $.extend(true, this.defaults, convertedData); - }; - - var defaults = new Defaults(); - - return defaults; -}); - -S2.define('select2/options',[ - 'require', - 'jquery', - './defaults', - './utils' -], function (require, $, Defaults, Utils) { - function Options (options, $element) { - this.options = options; - - if ($element != null) { - this.fromElement($element); - } - - this.options = Defaults.apply(this.options); - - if ($element && $element.is('input')) { - var InputCompat = require(this.get('amdBase') + 'compat/inputData'); - - this.options.dataAdapter = Utils.Decorate( - this.options.dataAdapter, - InputCompat - ); - } - } - - Options.prototype.fromElement = function ($e) { - var excludedData = ['select2']; - - if (this.options.multiple == null) { - this.options.multiple = $e.prop('multiple'); - } - - if (this.options.disabled == null) { - this.options.disabled = $e.prop('disabled'); - } - - if (this.options.language == null) { - if ($e.prop('lang')) { - this.options.language = $e.prop('lang').toLowerCase(); - } else if ($e.closest('[lang]').prop('lang')) { - this.options.language = $e.closest('[lang]').prop('lang'); - } - } - - if (this.options.dir == null) { - if ($e.prop('dir')) { - this.options.dir = $e.prop('dir'); - } else if ($e.closest('[dir]').prop('dir')) { - this.options.dir = $e.closest('[dir]').prop('dir'); - } else { - this.options.dir = 'ltr'; - } - } - - $e.prop('disabled', this.options.disabled); - $e.prop('multiple', this.options.multiple); - - if (Utils.GetData($e[0], 'select2Tags')) { - if (this.options.debug && window.console && console.warn) { - console.warn( - 'Select2: The `data-select2-tags` attribute has been changed to ' + - 'use the `data-data` and `data-tags="true"` attributes and will be ' + - 'removed in future versions of Select2.' - ); - } - - Utils.StoreData($e[0], 'data', Utils.GetData($e[0], 'select2Tags')); - Utils.StoreData($e[0], 'tags', true); - } - - if (Utils.GetData($e[0], 'ajaxUrl')) { - if (this.options.debug && window.console && console.warn) { - console.warn( - 'Select2: The `data-ajax-url` attribute has been changed to ' + - '`data-ajax--url` and support for the old attribute will be removed' + - ' in future versions of Select2.' - ); - } - - $e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl')); - Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl')); - } - - var dataset = {}; - - function upperCaseLetter(_, letter) { - return letter.toUpperCase(); - } - - // Pre-load all of the attributes which are prefixed with `data-` - for (var attr = 0; attr < $e[0].attributes.length; attr++) { - var attributeName = $e[0].attributes[attr].name; - var prefix = 'data-'; - - if (attributeName.substr(0, prefix.length) == prefix) { - // Get the contents of the attribute after `data-` - var dataName = attributeName.substring(prefix.length); - - // Get the data contents from the consistent source - // This is more than likely the jQuery data helper - var dataValue = Utils.GetData($e[0], dataName); - - // camelCase the attribute name to match the spec - var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter); - - // Store the data attribute contents into the dataset since - dataset[camelDataName] = dataValue; - } - } - - // Prefer the element's `dataset` attribute if it exists - // jQuery 1.x does not correctly handle data attributes with multiple dashes - if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) { - dataset = $.extend(true, {}, $e[0].dataset, dataset); - } - - // Prefer our internal data cache if it exists - var data = $.extend(true, {}, Utils.GetData($e[0]), dataset); - - data = Utils._convertData(data); - - for (var key in data) { - if ($.inArray(key, excludedData) > -1) { - continue; - } - - if ($.isPlainObject(this.options[key])) { - $.extend(this.options[key], data[key]); - } else { - this.options[key] = data[key]; - } - } - - return this; - }; - - Options.prototype.get = function (key) { - return this.options[key]; - }; - - Options.prototype.set = function (key, val) { - this.options[key] = val; - }; - - return Options; -}); - -S2.define('select2/core',[ - 'jquery', - './options', - './utils', - './keys' -], function ($, Options, Utils, KEYS) { - var Select2 = function ($element, options) { - if (Utils.GetData($element[0], 'select2') != null) { - Utils.GetData($element[0], 'select2').destroy(); - } - - this.$element = $element; - - this.id = this._generateId($element); - - options = options || {}; - - this.options = new Options(options, $element); - - Select2.__super__.constructor.call(this); - - // Set up the tabindex - - var tabindex = $element.attr('tabindex') || 0; - Utils.StoreData($element[0], 'old-tabindex', tabindex); - $element.attr('tabindex', '-1'); - - // Set up containers and adapters - - var DataAdapter = this.options.get('dataAdapter'); - this.dataAdapter = new DataAdapter($element, this.options); - - var $container = this.render(); - - this._placeContainer($container); - - var SelectionAdapter = this.options.get('selectionAdapter'); - this.selection = new SelectionAdapter($element, this.options); - this.$selection = this.selection.render(); - - this.selection.position(this.$selection, $container); - - var DropdownAdapter = this.options.get('dropdownAdapter'); - this.dropdown = new DropdownAdapter($element, this.options); - this.$dropdown = this.dropdown.render(); - - this.dropdown.position(this.$dropdown, $container); - - var ResultsAdapter = this.options.get('resultsAdapter'); - this.results = new ResultsAdapter($element, this.options, this.dataAdapter); - this.$results = this.results.render(); - - this.results.position(this.$results, this.$dropdown); - - // Bind events - - var self = this; - - // Bind the container to all of the adapters - this._bindAdapters(); - - // Register any DOM event handlers - this._registerDomEvents(); - - // Register any internal event handlers - this._registerDataEvents(); - this._registerSelectionEvents(); - this._registerDropdownEvents(); - this._registerResultsEvents(); - this._registerEvents(); - - // Set the initial state - this.dataAdapter.current(function (initialData) { - self.trigger('selection:update', { - data: initialData - }); - }); - - // Hide the original select - $element.addClass('select2-hidden-accessible'); - $element.attr('aria-hidden', 'true'); - - // Synchronize any monitored attributes - this._syncAttributes(); - - Utils.StoreData($element[0], 'select2', this); - - // Ensure backwards compatibility with $element.data('select2'). - $element.data('select2', this); - }; - - Utils.Extend(Select2, Utils.Observable); - - Select2.prototype._generateId = function ($element) { - var id = ''; - - if ($element.attr('id') != null) { - id = $element.attr('id'); - } else if ($element.attr('name') != null) { - id = $element.attr('name') + '-' + Utils.generateChars(2); - } else { - id = Utils.generateChars(4); - } - - id = id.replace(/(:|\.|\[|\]|,)/g, ''); - id = 'select2-' + id; - - return id; - }; - - Select2.prototype._placeContainer = function ($container) { - $container.insertAfter(this.$element); - - var width = this._resolveWidth(this.$element, this.options.get('width')); - - if (width != null) { - $container.css('width', width); - } - }; - - Select2.prototype._resolveWidth = function ($element, method) { - var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i; - - if (method == 'resolve') { - var styleWidth = this._resolveWidth($element, 'style'); - - if (styleWidth != null) { - return styleWidth; - } - - return this._resolveWidth($element, 'element'); - } - - if (method == 'element') { - var elementWidth = $element.outerWidth(false); - - if (elementWidth <= 0) { - return 'auto'; - } - - return elementWidth + 'px'; - } - - if (method == 'style') { - var style = $element.attr('style'); - - if (typeof(style) !== 'string') { - return null; - } - - var attrs = style.split(';'); - - for (var i = 0, l = attrs.length; i < l; i = i + 1) { - var attr = attrs[i].replace(/\s/g, ''); - var matches = attr.match(WIDTH); - - if (matches !== null && matches.length >= 1) { - return matches[1]; - } - } - - return null; - } - - return method; - }; - - Select2.prototype._bindAdapters = function () { - this.dataAdapter.bind(this, this.$container); - this.selection.bind(this, this.$container); - - this.dropdown.bind(this, this.$container); - this.results.bind(this, this.$container); - }; - - Select2.prototype._registerDomEvents = function () { - var self = this; - - this.$element.on('change.select2', function () { - self.dataAdapter.current(function (data) { - self.trigger('selection:update', { - data: data - }); - }); - }); - - this.$element.on('focus.select2', function (evt) { - self.trigger('focus', evt); - }); - - this._syncA = Utils.bind(this._syncAttributes, this); - this._syncS = Utils.bind(this._syncSubtree, this); - - if (this.$element[0].attachEvent) { - this.$element[0].attachEvent('onpropertychange', this._syncA); - } - - var observer = window.MutationObserver || - window.WebKitMutationObserver || - window.MozMutationObserver - ; - - if (observer != null) { - this._observer = new observer(function (mutations) { - $.each(mutations, self._syncA); - $.each(mutations, self._syncS); - }); - this._observer.observe(this.$element[0], { - attributes: true, - childList: true, - subtree: false - }); - } else if (this.$element[0].addEventListener) { - this.$element[0].addEventListener( - 'DOMAttrModified', - self._syncA, - false - ); - this.$element[0].addEventListener( - 'DOMNodeInserted', - self._syncS, - false - ); - this.$element[0].addEventListener( - 'DOMNodeRemoved', - self._syncS, - false - ); - } - }; - - Select2.prototype._registerDataEvents = function () { - var self = this; - - this.dataAdapter.on('*', function (name, params) { - self.trigger(name, params); - }); - }; - - Select2.prototype._registerSelectionEvents = function () { - var self = this; - var nonRelayEvents = ['toggle', 'focus']; - - this.selection.on('toggle', function () { - self.toggleDropdown(); - }); - - this.selection.on('focus', function (params) { - self.focus(params); - }); - - this.selection.on('*', function (name, params) { - if ($.inArray(name, nonRelayEvents) !== -1) { - return; - } - - self.trigger(name, params); - }); - }; - - Select2.prototype._registerDropdownEvents = function () { - var self = this; - - this.dropdown.on('*', function (name, params) { - self.trigger(name, params); - }); - }; - - Select2.prototype._registerResultsEvents = function () { - var self = this; - - this.results.on('*', function (name, params) { - self.trigger(name, params); - }); - }; - - Select2.prototype._registerEvents = function () { - var self = this; - - this.on('open', function () { - self.$container.addClass('select2-container--open'); - }); - - this.on('close', function () { - self.$container.removeClass('select2-container--open'); - }); - - this.on('enable', function () { - self.$container.removeClass('select2-container--disabled'); - }); - - this.on('disable', function () { - self.$container.addClass('select2-container--disabled'); - }); - - this.on('blur', function () { - self.$container.removeClass('select2-container--focus'); - }); - - this.on('query', function (params) { - if (!self.isOpen()) { - self.trigger('open', {}); - } - - this.dataAdapter.query(params, function (data) { - self.trigger('results:all', { - data: data, - query: params - }); - }); - }); - - this.on('query:append', function (params) { - this.dataAdapter.query(params, function (data) { - self.trigger('results:append', { - data: data, - query: params - }); - }); - }); - - this.on('keypress', function (evt) { - var key = evt.which; - - if (self.isOpen()) { - if (key === KEYS.ESC || key === KEYS.TAB || - (key === KEYS.UP && evt.altKey)) { - self.close(); - - evt.preventDefault(); - } else if (key === KEYS.ENTER) { - self.trigger('results:select', {}); - - evt.preventDefault(); - } else if ((key === KEYS.SPACE && evt.ctrlKey)) { - self.trigger('results:toggle', {}); - - evt.preventDefault(); - } else if (key === KEYS.UP) { - self.trigger('results:previous', {}); - - evt.preventDefault(); - } else if (key === KEYS.DOWN) { - self.trigger('results:next', {}); - - evt.preventDefault(); - } - } else { - if (key === KEYS.ENTER || key === KEYS.SPACE || - (key === KEYS.DOWN && evt.altKey)) { - self.open(); - - evt.preventDefault(); - } - } - }); - }; - - Select2.prototype._syncAttributes = function () { - this.options.set('disabled', this.$element.prop('disabled')); - - if (this.options.get('disabled')) { - if (this.isOpen()) { - this.close(); - } - - this.trigger('disable', {}); - } else { - this.trigger('enable', {}); - } - }; - - Select2.prototype._syncSubtree = function (evt, mutations) { - var changed = false; - var self = this; - - // Ignore any mutation events raised for elements that aren't options or - // optgroups. This handles the case when the select element is destroyed - if ( - evt && evt.target && ( - evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP' - ) - ) { - return; - } - - if (!mutations) { - // If mutation events aren't supported, then we can only assume that the - // change affected the selections - changed = true; - } else if (mutations.addedNodes && mutations.addedNodes.length > 0) { - for (var n = 0; n < mutations.addedNodes.length; n++) { - var node = mutations.addedNodes[n]; - - if (node.selected) { - changed = true; - } - } - } else if (mutations.removedNodes && mutations.removedNodes.length > 0) { - changed = true; - } - - // Only re-pull the data if we think there is a change - if (changed) { - this.dataAdapter.current(function (currentData) { - self.trigger('selection:update', { - data: currentData - }); - }); - } - }; - - /** - * Override the trigger method to automatically trigger pre-events when - * there are events that can be prevented. - */ - Select2.prototype.trigger = function (name, args) { - var actualTrigger = Select2.__super__.trigger; - var preTriggerMap = { - 'open': 'opening', - 'close': 'closing', - 'select': 'selecting', - 'unselect': 'unselecting', - 'clear': 'clearing' - }; - - if (args === undefined) { - args = {}; - } - - if (name in preTriggerMap) { - var preTriggerName = preTriggerMap[name]; - var preTriggerArgs = { - prevented: false, - name: name, - args: args - }; - - actualTrigger.call(this, preTriggerName, preTriggerArgs); - - if (preTriggerArgs.prevented) { - args.prevented = true; - - return; - } - } - - actualTrigger.call(this, name, args); - }; - - Select2.prototype.toggleDropdown = function () { - if (this.options.get('disabled')) { - return; - } - - if (this.isOpen()) { - this.close(); - } else { - this.open(); - } - }; - - Select2.prototype.open = function () { - if (this.isOpen()) { - return; - } - - this.trigger('query', {}); - }; - - Select2.prototype.close = function () { - if (!this.isOpen()) { - return; - } - - this.trigger('close', {}); - }; - - Select2.prototype.isOpen = function () { - return this.$container.hasClass('select2-container--open'); - }; - - Select2.prototype.hasFocus = function () { - return this.$container.hasClass('select2-container--focus'); - }; - - Select2.prototype.focus = function (data) { - // No need to re-trigger focus events if we are already focused - if (this.hasFocus()) { - return; - } - - this.$container.addClass('select2-container--focus'); - this.trigger('focus', {}); - }; - - Select2.prototype.enable = function (args) { - if (this.options.get('debug') && window.console && console.warn) { - console.warn( - 'Select2: The `select2("enable")` method has been deprecated and will' + - ' be removed in later Select2 versions. Use $element.prop("disabled")' + - ' instead.' - ); - } - - if (args == null || args.length === 0) { - args = [true]; - } - - var disabled = !args[0]; - - this.$element.prop('disabled', disabled); - }; - - Select2.prototype.data = function () { - if (this.options.get('debug') && - arguments.length > 0 && window.console && console.warn) { - console.warn( - 'Select2: Data can no longer be set using `select2("data")`. You ' + - 'should consider setting the value instead using `$element.val()`.' - ); - } - - var data = []; - - this.dataAdapter.current(function (currentData) { - data = currentData; - }); - - return data; - }; - - Select2.prototype.val = function (args) { - if (this.options.get('debug') && window.console && console.warn) { - console.warn( - 'Select2: The `select2("val")` method has been deprecated and will be' + - ' removed in later Select2 versions. Use $element.val() instead.' - ); - } - - if (args == null || args.length === 0) { - return this.$element.val(); - } - - var newVal = args[0]; - - if ($.isArray(newVal)) { - newVal = $.map(newVal, function (obj) { - return obj.toString(); - }); - } - - this.$element.val(newVal).trigger('change'); - }; - - Select2.prototype.destroy = function () { - this.$container.remove(); - - if (this.$element[0].detachEvent) { - this.$element[0].detachEvent('onpropertychange', this._syncA); - } - - if (this._observer != null) { - this._observer.disconnect(); - this._observer = null; - } else if (this.$element[0].removeEventListener) { - this.$element[0] - .removeEventListener('DOMAttrModified', this._syncA, false); - this.$element[0] - .removeEventListener('DOMNodeInserted', this._syncS, false); - this.$element[0] - .removeEventListener('DOMNodeRemoved', this._syncS, false); - } - - this._syncA = null; - this._syncS = null; - - this.$element.off('.select2'); - this.$element.attr('tabindex', - Utils.GetData(this.$element[0], 'old-tabindex')); - - this.$element.removeClass('select2-hidden-accessible'); - this.$element.attr('aria-hidden', 'false'); - Utils.RemoveData(this.$element[0]); - this.$element.removeData('select2'); - - this.dataAdapter.destroy(); - this.selection.destroy(); - this.dropdown.destroy(); - this.results.destroy(); - - this.dataAdapter = null; - this.selection = null; - this.dropdown = null; - this.results = null; - }; - - Select2.prototype.render = function () { - var $container = $( - '' + - '' + - '' + - '' - ); - - $container.attr('dir', this.options.get('dir')); - - this.$container = $container; - - this.$container.addClass('select2-container--' + this.options.get('theme')); - - Utils.StoreData($container[0], 'element', this.$element); - - return $container; - }; - - return Select2; -}); - -S2.define('jquery-mousewheel',[ - 'jquery' -], function ($) { - // Used to shim jQuery.mousewheel for non-full builds. - return $; -}); - -S2.define('jquery.select2',[ - 'jquery', - 'jquery-mousewheel', - - './select2/core', - './select2/defaults', - './select2/utils' -], function ($, _, Select2, Defaults, Utils) { - if ($.fn.select2 == null) { - // All methods that should return the element - var thisMethods = ['open', 'close', 'destroy']; - - $.fn.select2 = function (options) { - options = options || {}; - - if (typeof options === 'object') { - this.each(function () { - var instanceOptions = $.extend(true, {}, options); - - var instance = new Select2($(this), instanceOptions); - }); - - return this; - } else if (typeof options === 'string') { - var ret; - var args = Array.prototype.slice.call(arguments, 1); - - this.each(function () { - var instance = Utils.GetData(this, 'select2'); - - if (instance == null && window.console && console.error) { - console.error( - 'The select2(\'' + options + '\') method was called on an ' + - 'element that is not using Select2.' - ); - } - - ret = instance[options].apply(instance, args); - }); - - // Check if we should be returning `this` - if ($.inArray(options, thisMethods) > -1) { - return this; - } - - return ret; - } else { - throw new Error('Invalid arguments for Select2: ' + options); - } - }; - } - - if ($.fn.select2.defaults == null) { - $.fn.select2.defaults = Defaults; - } - - return Select2; -}); - - // Return the AMD loader configuration so it can be used outside of this file - return { - define: S2.define, - require: S2.require - }; -}()); - - // Autoload the jQuery bindings - // We know that all of the modules exist above this, so we're safe - var select2 = S2.require('jquery.select2'); - - // Hold the AMD module references on the jQuery function that was just loaded - // This allows Select2 to use the internal loader outside of this file, such - // as in the language files. - jQuery.fn.select2.amd = S2; - - // Return the Select2 instance for anyone who is importing it. - return select2; -})); +/*! + * Select2 4.0.7 + * https://select2.github.io + * + * Released under the MIT license + * https://github.com/select2/select2/blob/master/LICENSE.md + */ +;(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof module === 'object' && module.exports) { + // Node/CommonJS + module.exports = function (root, jQuery) { + if (jQuery === undefined) { + // require('jQuery') returns a factory that requires window to + // build a jQuery instance, we normalize how we use modules + // that require this pattern but the window provided is a noop + // if it's defined (how jquery works) + if (typeof window !== 'undefined') { + jQuery = require('jquery'); + } + else { + jQuery = require('jquery')(root); + } + } + factory(jQuery); + return jQuery; + }; + } else { + // Browser globals + factory(jQuery); + } +} (function (jQuery) { + // This is needed so we can catch the AMD loader configuration and use it + // The inner file should be wrapped (by `banner.start.js`) in a function that + // returns the AMD loader references. + var S2 =(function () { + // Restore the Select2 AMD loader so it can be used + // Needed mostly in the language files, where the loader is not inserted + if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) { + var S2 = jQuery.fn.select2.amd; + } +var S2;(function () { if (!S2 || !S2.requirejs) { +if (!S2) { S2 = {}; } else { require = S2; } +/** + * @license almond 0.3.3 Copyright jQuery Foundation and other contributors. + * Released under MIT license, http://github.com/requirejs/almond/LICENSE + */ +//Going sloppy to avoid 'use strict' string cost, but strict practices should +//be followed. +/*global setTimeout: false */ + +var requirejs, require, define; +(function (undef) { + var main, req, makeMap, handlers, + defined = {}, + waiting = {}, + config = {}, + defining = {}, + hasOwn = Object.prototype.hasOwnProperty, + aps = [].slice, + jsSuffixRegExp = /\.js$/; + + function hasProp(obj, prop) { + return hasOwn.call(obj, prop); + } + + /** + * Given a relative module name, like ./something, normalize it to + * a real name that can be mapped to a path. + * @param {String} name the relative name + * @param {String} baseName a real name that the name arg is relative + * to. + * @returns {String} normalized name + */ + function normalize(name, baseName) { + var nameParts, nameSegment, mapValue, foundMap, lastIndex, + foundI, foundStarMap, starI, i, j, part, normalizedBaseParts, + baseParts = baseName && baseName.split("/"), + map = config.map, + starMap = (map && map['*']) || {}; + + //Adjust any relative paths. + if (name) { + name = name.split('/'); + lastIndex = name.length - 1; + + // If wanting node ID compatibility, strip .js from end + // of IDs. Have to do this here, and not in nameToUrl + // because node allows either .js or non .js to map + // to same file. + if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { + name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); + } + + // Starts with a '.' so need the baseName + if (name[0].charAt(0) === '.' && baseParts) { + //Convert baseName to array, and lop off the last part, + //so that . matches that 'directory' and not name of the baseName's + //module. For instance, baseName of 'one/two/three', maps to + //'one/two/three.js', but we want the directory, 'one/two' for + //this normalization. + normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); + name = normalizedBaseParts.concat(name); + } + + //start trimDots + for (i = 0; i < name.length; i++) { + part = name[i]; + if (part === '.') { + name.splice(i, 1); + i -= 1; + } else if (part === '..') { + // If at the start, or previous value is still .., + // keep them so that when converted to a path it may + // still work when converted to a path, even though + // as an ID it is less than ideal. In larger point + // releases, may be better to just kick out an error. + if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') { + continue; + } else if (i > 0) { + name.splice(i - 1, 2); + i -= 2; + } + } + } + //end trimDots + + name = name.join('/'); + } + + //Apply map config if available. + if ((baseParts || starMap) && map) { + nameParts = name.split('/'); + + for (i = nameParts.length; i > 0; i -= 1) { + nameSegment = nameParts.slice(0, i).join("/"); + + if (baseParts) { + //Find the longest baseName segment match in the config. + //So, do joins on the biggest to smallest lengths of baseParts. + for (j = baseParts.length; j > 0; j -= 1) { + mapValue = map[baseParts.slice(0, j).join('/')]; + + //baseName segment has config, find if it has one for + //this name. + if (mapValue) { + mapValue = mapValue[nameSegment]; + if (mapValue) { + //Match, update name to the new value. + foundMap = mapValue; + foundI = i; + break; + } + } + } + } + + if (foundMap) { + break; + } + + //Check for a star map match, but just hold on to it, + //if there is a shorter segment match later in a matching + //config, then favor over this star map. + if (!foundStarMap && starMap && starMap[nameSegment]) { + foundStarMap = starMap[nameSegment]; + starI = i; + } + } + + if (!foundMap && foundStarMap) { + foundMap = foundStarMap; + foundI = starI; + } + + if (foundMap) { + nameParts.splice(0, foundI, foundMap); + name = nameParts.join('/'); + } + } + + return name; + } + + function makeRequire(relName, forceSync) { + return function () { + //A version of a require function that passes a moduleName + //value for items that may need to + //look up paths relative to the moduleName + var args = aps.call(arguments, 0); + + //If first arg is not require('string'), and there is only + //one arg, it is the array form without a callback. Insert + //a null so that the following concat is correct. + if (typeof args[0] !== 'string' && args.length === 1) { + args.push(null); + } + return req.apply(undef, args.concat([relName, forceSync])); + }; + } + + function makeNormalize(relName) { + return function (name) { + return normalize(name, relName); + }; + } + + function makeLoad(depName) { + return function (value) { + defined[depName] = value; + }; + } + + function callDep(name) { + if (hasProp(waiting, name)) { + var args = waiting[name]; + delete waiting[name]; + defining[name] = true; + main.apply(undef, args); + } + + if (!hasProp(defined, name) && !hasProp(defining, name)) { + throw new Error('No ' + name); + } + return defined[name]; + } + + //Turns a plugin!resource to [plugin, resource] + //with the plugin being undefined if the name + //did not have a plugin prefix. + function splitPrefix(name) { + var prefix, + index = name ? name.indexOf('!') : -1; + if (index > -1) { + prefix = name.substring(0, index); + name = name.substring(index + 1, name.length); + } + return [prefix, name]; + } + + //Creates a parts array for a relName where first part is plugin ID, + //second part is resource ID. Assumes relName has already been normalized. + function makeRelParts(relName) { + return relName ? splitPrefix(relName) : []; + } + + /** + * Makes a name map, normalizing the name, and using a plugin + * for normalization if necessary. Grabs a ref to plugin + * too, as an optimization. + */ + makeMap = function (name, relParts) { + var plugin, + parts = splitPrefix(name), + prefix = parts[0], + relResourceName = relParts[1]; + + name = parts[1]; + + if (prefix) { + prefix = normalize(prefix, relResourceName); + plugin = callDep(prefix); + } + + //Normalize according + if (prefix) { + if (plugin && plugin.normalize) { + name = plugin.normalize(name, makeNormalize(relResourceName)); + } else { + name = normalize(name, relResourceName); + } + } else { + name = normalize(name, relResourceName); + parts = splitPrefix(name); + prefix = parts[0]; + name = parts[1]; + if (prefix) { + plugin = callDep(prefix); + } + } + + //Using ridiculous property names for space reasons + return { + f: prefix ? prefix + '!' + name : name, //fullName + n: name, + pr: prefix, + p: plugin + }; + }; + + function makeConfig(name) { + return function () { + return (config && config.config && config.config[name]) || {}; + }; + } + + handlers = { + require: function (name) { + return makeRequire(name); + }, + exports: function (name) { + var e = defined[name]; + if (typeof e !== 'undefined') { + return e; + } else { + return (defined[name] = {}); + } + }, + module: function (name) { + return { + id: name, + uri: '', + exports: defined[name], + config: makeConfig(name) + }; + } + }; + + main = function (name, deps, callback, relName) { + var cjsModule, depName, ret, map, i, relParts, + args = [], + callbackType = typeof callback, + usingExports; + + //Use name if no relName + relName = relName || name; + relParts = makeRelParts(relName); + + //Call the callback to define the module, if necessary. + if (callbackType === 'undefined' || callbackType === 'function') { + //Pull out the defined dependencies and pass the ordered + //values to the callback. + //Default to [require, exports, module] if no deps + deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; + for (i = 0; i < deps.length; i += 1) { + map = makeMap(deps[i], relParts); + depName = map.f; + + //Fast path CommonJS standard dependencies. + if (depName === "require") { + args[i] = handlers.require(name); + } else if (depName === "exports") { + //CommonJS module spec 1.1 + args[i] = handlers.exports(name); + usingExports = true; + } else if (depName === "module") { + //CommonJS module spec 1.1 + cjsModule = args[i] = handlers.module(name); + } else if (hasProp(defined, depName) || + hasProp(waiting, depName) || + hasProp(defining, depName)) { + args[i] = callDep(depName); + } else if (map.p) { + map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); + args[i] = defined[depName]; + } else { + throw new Error(name + ' missing ' + depName); + } + } + + ret = callback ? callback.apply(defined[name], args) : undefined; + + if (name) { + //If setting exports via "module" is in play, + //favor that over return value and exports. After that, + //favor a non-undefined return value over exports use. + if (cjsModule && cjsModule.exports !== undef && + cjsModule.exports !== defined[name]) { + defined[name] = cjsModule.exports; + } else if (ret !== undef || !usingExports) { + //Use the return value from the function. + defined[name] = ret; + } + } + } else if (name) { + //May just be an object definition for the module. Only + //worry about defining if have a module name. + defined[name] = callback; + } + }; + + requirejs = require = req = function (deps, callback, relName, forceSync, alt) { + if (typeof deps === "string") { + if (handlers[deps]) { + //callback in this case is really relName + return handlers[deps](callback); + } + //Just return the module wanted. In this scenario, the + //deps arg is the module name, and second arg (if passed) + //is just the relName. + //Normalize module name, if it contains . or .. + return callDep(makeMap(deps, makeRelParts(callback)).f); + } else if (!deps.splice) { + //deps is a config object, not an array. + config = deps; + if (config.deps) { + req(config.deps, config.callback); + } + if (!callback) { + return; + } + + if (callback.splice) { + //callback is an array, which means it is a dependency list. + //Adjust args if there are dependencies + deps = callback; + callback = relName; + relName = null; + } else { + deps = undef; + } + } + + //Support require(['a']) + callback = callback || function () {}; + + //If relName is a function, it is an errback handler, + //so remove it. + if (typeof relName === 'function') { + relName = forceSync; + forceSync = alt; + } + + //Simulate async callback; + if (forceSync) { + main(undef, deps, callback, relName); + } else { + //Using a non-zero value because of concern for what old browsers + //do, and latest browsers "upgrade" to 4 if lower value is used: + //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: + //If want a value immediately, use require('id') instead -- something + //that works in almond on the global level, but not guaranteed and + //unlikely to work in other AMD implementations. + setTimeout(function () { + main(undef, deps, callback, relName); + }, 4); + } + + return req; + }; + + /** + * Just drops the config on the floor, but returns req in case + * the config return value is used. + */ + req.config = function (cfg) { + return req(cfg); + }; + + /** + * Expose module registry for debugging and tooling + */ + requirejs._defined = defined; + + define = function (name, deps, callback) { + if (typeof name !== 'string') { + throw new Error('See almond README: incorrect module build, no module name'); + } + + //This module may not have dependencies + if (!deps.splice) { + //deps is not an array, so probably means + //an object literal or factory function for + //the value. Adjust args. + callback = deps; + deps = []; + } + + if (!hasProp(defined, name) && !hasProp(waiting, name)) { + waiting[name] = [name, deps, callback]; + } + }; + + define.amd = { + jQuery: true + }; +}()); + +S2.requirejs = requirejs;S2.require = require;S2.define = define; +} +}()); +S2.define("almond", function(){}); + +/* global jQuery:false, $:false */ +S2.define('jquery',[],function () { + var _$ = jQuery || $; + + if (_$ == null && console && console.error) { + console.error( + 'Select2: An instance of jQuery or a jQuery-compatible library was not ' + + 'found. Make sure that you are including jQuery before Select2 on your ' + + 'web page.' + ); + } + + return _$; +}); + +S2.define('select2/utils',[ + 'jquery' +], function ($) { + var Utils = {}; + + Utils.Extend = function (ChildClass, SuperClass) { + var __hasProp = {}.hasOwnProperty; + + function BaseConstructor () { + this.constructor = ChildClass; + } + + for (var key in SuperClass) { + if (__hasProp.call(SuperClass, key)) { + ChildClass[key] = SuperClass[key]; + } + } + + BaseConstructor.prototype = SuperClass.prototype; + ChildClass.prototype = new BaseConstructor(); + ChildClass.__super__ = SuperClass.prototype; + + return ChildClass; + }; + + function getMethods (theClass) { + var proto = theClass.prototype; + + var methods = []; + + for (var methodName in proto) { + var m = proto[methodName]; + + if (typeof m !== 'function') { + continue; + } + + if (methodName === 'constructor') { + continue; + } + + methods.push(methodName); + } + + return methods; + } + + Utils.Decorate = function (SuperClass, DecoratorClass) { + var decoratedMethods = getMethods(DecoratorClass); + var superMethods = getMethods(SuperClass); + + function DecoratedClass () { + var unshift = Array.prototype.unshift; + + var argCount = DecoratorClass.prototype.constructor.length; + + var calledConstructor = SuperClass.prototype.constructor; + + if (argCount > 0) { + unshift.call(arguments, SuperClass.prototype.constructor); + + calledConstructor = DecoratorClass.prototype.constructor; + } + + calledConstructor.apply(this, arguments); + } + + DecoratorClass.displayName = SuperClass.displayName; + + function ctr () { + this.constructor = DecoratedClass; + } + + DecoratedClass.prototype = new ctr(); + + for (var m = 0; m < superMethods.length; m++) { + var superMethod = superMethods[m]; + + DecoratedClass.prototype[superMethod] = + SuperClass.prototype[superMethod]; + } + + var calledMethod = function (methodName) { + // Stub out the original method if it's not decorating an actual method + var originalMethod = function () {}; + + if (methodName in DecoratedClass.prototype) { + originalMethod = DecoratedClass.prototype[methodName]; + } + + var decoratedMethod = DecoratorClass.prototype[methodName]; + + return function () { + var unshift = Array.prototype.unshift; + + unshift.call(arguments, originalMethod); + + return decoratedMethod.apply(this, arguments); + }; + }; + + for (var d = 0; d < decoratedMethods.length; d++) { + var decoratedMethod = decoratedMethods[d]; + + DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod); + } + + return DecoratedClass; + }; + + var Observable = function () { + this.listeners = {}; + }; + + Observable.prototype.on = function (event, callback) { + this.listeners = this.listeners || {}; + + if (event in this.listeners) { + this.listeners[event].push(callback); + } else { + this.listeners[event] = [callback]; + } + }; + + Observable.prototype.trigger = function (event) { + var slice = Array.prototype.slice; + var params = slice.call(arguments, 1); + + this.listeners = this.listeners || {}; + + // Params should always come in as an array + if (params == null) { + params = []; + } + + // If there are no arguments to the event, use a temporary object + if (params.length === 0) { + params.push({}); + } + + // Set the `_type` of the first object to the event + params[0]._type = event; + + if (event in this.listeners) { + this.invoke(this.listeners[event], slice.call(arguments, 1)); + } + + if ('*' in this.listeners) { + this.invoke(this.listeners['*'], arguments); + } + }; + + Observable.prototype.invoke = function (listeners, params) { + for (var i = 0, len = listeners.length; i < len; i++) { + listeners[i].apply(this, params); + } + }; + + Utils.Observable = Observable; + + Utils.generateChars = function (length) { + var chars = ''; + + for (var i = 0; i < length; i++) { + var randomChar = Math.floor(Math.random() * 36); + chars += randomChar.toString(36); + } + + return chars; + }; + + Utils.bind = function (func, context) { + return function () { + func.apply(context, arguments); + }; + }; + + Utils._convertData = function (data) { + for (var originalKey in data) { + var keys = originalKey.split('-'); + + var dataLevel = data; + + if (keys.length === 1) { + continue; + } + + for (var k = 0; k < keys.length; k++) { + var key = keys[k]; + + // Lowercase the first letter + // By default, dash-separated becomes camelCase + key = key.substring(0, 1).toLowerCase() + key.substring(1); + + if (!(key in dataLevel)) { + dataLevel[key] = {}; + } + + if (k == keys.length - 1) { + dataLevel[key] = data[originalKey]; + } + + dataLevel = dataLevel[key]; + } + + delete data[originalKey]; + } + + return data; + }; + + Utils.hasScroll = function (index, el) { + // Adapted from the function created by @ShadowScripter + // and adapted by @BillBarry on the Stack Exchange Code Review website. + // The original code can be found at + // http://codereview.stackexchange.com/q/13338 + // and was designed to be used with the Sizzle selector engine. + + var $el = $(el); + var overflowX = el.style.overflowX; + var overflowY = el.style.overflowY; + + //Check both x and y declarations + if (overflowX === overflowY && + (overflowY === 'hidden' || overflowY === 'visible')) { + return false; + } + + if (overflowX === 'scroll' || overflowY === 'scroll') { + return true; + } + + return ($el.innerHeight() < el.scrollHeight || + $el.innerWidth() < el.scrollWidth); + }; + + Utils.escapeMarkup = function (markup) { + var replaceMap = { + '\\': '\', + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''', + '/': '/' + }; + + // Do not try to escape the markup if it's not a string + if (typeof markup !== 'string') { + return markup; + } + + return String(markup).replace(/[&<>"'\/\\]/g, function (match) { + return replaceMap[match]; + }); + }; + + // Append an array of jQuery nodes to a given element. + Utils.appendMany = function ($element, $nodes) { + // jQuery 1.7.x does not support $.fn.append() with an array + // Fall back to a jQuery object collection using $.fn.add() + if ($.fn.jquery.substr(0, 3) === '1.7') { + var $jqNodes = $(); + + $.map($nodes, function (node) { + $jqNodes = $jqNodes.add(node); + }); + + $nodes = $jqNodes; + } + + $element.append($nodes); + }; + + // Cache objects in Utils.__cache instead of $.data (see #4346) + Utils.__cache = {}; + + var id = 0; + Utils.GetUniqueElementId = function (element) { + // Get a unique element Id. If element has no id, + // creates a new unique number, stores it in the id + // attribute and returns the new id. + // If an id already exists, it simply returns it. + + var select2Id = element.getAttribute('data-select2-id'); + if (select2Id == null) { + // If element has id, use it. + if (element.id) { + select2Id = element.id; + element.setAttribute('data-select2-id', select2Id); + } else { + element.setAttribute('data-select2-id', ++id); + select2Id = id.toString(); + } + } + return select2Id; + }; + + Utils.StoreData = function (element, name, value) { + // Stores an item in the cache for a specified element. + // name is the cache key. + var id = Utils.GetUniqueElementId(element); + if (!Utils.__cache[id]) { + Utils.__cache[id] = {}; + } + + Utils.__cache[id][name] = value; + }; + + Utils.GetData = function (element, name) { + // Retrieves a value from the cache by its key (name) + // name is optional. If no name specified, return + // all cache items for the specified element. + // and for a specified element. + var id = Utils.GetUniqueElementId(element); + if (name) { + if (Utils.__cache[id]) { + if (Utils.__cache[id][name] != null) { + return Utils.__cache[id][name]; + } + return $(element).data(name); // Fallback to HTML5 data attribs. + } + return $(element).data(name); // Fallback to HTML5 data attribs. + } else { + return Utils.__cache[id]; + } + }; + + Utils.RemoveData = function (element) { + // Removes all cached items for a specified element. + var id = Utils.GetUniqueElementId(element); + if (Utils.__cache[id] != null) { + delete Utils.__cache[id]; + } + }; + + return Utils; +}); + +S2.define('select2/results',[ + 'jquery', + './utils' +], function ($, Utils) { + function Results ($element, options, dataAdapter) { + this.$element = $element; + this.data = dataAdapter; + this.options = options; + + Results.__super__.constructor.call(this); + } + + Utils.Extend(Results, Utils.Observable); + + Results.prototype.render = function () { + var $results = $( + '
                        ' + ); + + if (this.options.get('multiple')) { + $results.attr('aria-multiselectable', 'true'); + } + + this.$results = $results; + + return $results; + }; + + Results.prototype.clear = function () { + this.$results.empty(); + }; + + Results.prototype.displayMessage = function (params) { + var escapeMarkup = this.options.get('escapeMarkup'); + + this.clear(); + this.hideLoading(); + + var $message = $( + '
                      • ' + ); + + var message = this.options.get('translations').get(params.message); + + $message.append( + escapeMarkup( + message(params.args) + ) + ); + + $message[0].className += ' select2-results__message'; + + this.$results.append($message); + }; + + Results.prototype.hideMessages = function () { + this.$results.find('.select2-results__message').remove(); + }; + + Results.prototype.append = function (data) { + this.hideLoading(); + + var $options = []; + + if (data.results == null || data.results.length === 0) { + if (this.$results.children().length === 0) { + this.trigger('results:message', { + message: 'noResults' + }); + } + + return; + } + + data.results = this.sort(data.results); + + for (var d = 0; d < data.results.length; d++) { + var item = data.results[d]; + + var $option = this.option(item); + + $options.push($option); + } + + this.$results.append($options); + }; + + Results.prototype.position = function ($results, $dropdown) { + var $resultsContainer = $dropdown.find('.select2-results'); + $resultsContainer.append($results); + }; + + Results.prototype.sort = function (data) { + var sorter = this.options.get('sorter'); + + return sorter(data); + }; + + Results.prototype.highlightFirstItem = function () { + var $options = this.$results + .find('.select2-results__option[aria-selected]'); + + var $selected = $options.filter('[aria-selected=true]'); + + // Check if there are any selected options + if ($selected.length > 0) { + // If there are selected options, highlight the first + $selected.first().trigger('mouseenter'); + } else { + // If there are no selected options, highlight the first option + // in the dropdown + $options.first().trigger('mouseenter'); + } + + this.ensureHighlightVisible(); + }; + + Results.prototype.setClasses = function () { + var self = this; + + this.data.current(function (selected) { + var selectedIds = $.map(selected, function (s) { + return s.id.toString(); + }); + + var $options = self.$results + .find('.select2-results__option[aria-selected]'); + + $options.each(function () { + var $option = $(this); + + var item = Utils.GetData(this, 'data'); + + // id needs to be converted to a string when comparing + var id = '' + item.id; + + if ((item.element != null && item.element.selected) || + (item.element == null && $.inArray(id, selectedIds) > -1)) { + $option.attr('aria-selected', 'true'); + } else { + $option.attr('aria-selected', 'false'); + } + }); + + }); + }; + + Results.prototype.showLoading = function (params) { + this.hideLoading(); + + var loadingMore = this.options.get('translations').get('searching'); + + var loading = { + disabled: true, + loading: true, + text: loadingMore(params) + }; + var $loading = this.option(loading); + $loading.className += ' loading-results'; + + this.$results.prepend($loading); + }; + + Results.prototype.hideLoading = function () { + this.$results.find('.loading-results').remove(); + }; + + Results.prototype.option = function (data) { + var option = document.createElement('li'); + option.className = 'select2-results__option'; + + var attrs = { + 'role': 'treeitem', + 'aria-selected': 'false' + }; + + if (data.disabled) { + delete attrs['aria-selected']; + attrs['aria-disabled'] = 'true'; + } + + if (data.id == null) { + delete attrs['aria-selected']; + } + + if (data._resultId != null) { + option.id = data._resultId; + } + + if (data.title) { + option.title = data.title; + } + + if (data.children) { + attrs.role = 'group'; + attrs['aria-label'] = data.text; + delete attrs['aria-selected']; + } + + for (var attr in attrs) { + var val = attrs[attr]; + + option.setAttribute(attr, val); + } + + if (data.children) { + var $option = $(option); + + var label = document.createElement('strong'); + label.className = 'select2-results__group'; + + var $label = $(label); + this.template(data, label); + + var $children = []; + + for (var c = 0; c < data.children.length; c++) { + var child = data.children[c]; + + var $child = this.option(child); + + $children.push($child); + } + + var $childrenContainer = $('
                          ', { + 'class': 'select2-results__options select2-results__options--nested' + }); + + $childrenContainer.append($children); + + $option.append(label); + $option.append($childrenContainer); + } else { + this.template(data, option); + } + + Utils.StoreData(option, 'data', data); + + return option; + }; + + Results.prototype.bind = function (container, $container) { + var self = this; + + var id = container.id + '-results'; + + this.$results.attr('id', id); + + container.on('results:all', function (params) { + self.clear(); + self.append(params.data); + + if (container.isOpen()) { + self.setClasses(); + self.highlightFirstItem(); + } + }); + + container.on('results:append', function (params) { + self.append(params.data); + + if (container.isOpen()) { + self.setClasses(); + } + }); + + container.on('query', function (params) { + self.hideMessages(); + self.showLoading(params); + }); + + container.on('select', function () { + if (!container.isOpen()) { + return; + } + + self.setClasses(); + + if (self.options.get('scrollAfterSelect')) { + self.highlightFirstItem(); + } + }); + + container.on('unselect', function () { + if (!container.isOpen()) { + return; + } + + self.setClasses(); + + if (self.options.get('scrollAfterSelect')) { + self.highlightFirstItem(); + } + }); + + container.on('open', function () { + // When the dropdown is open, aria-expended="true" + self.$results.attr('aria-expanded', 'true'); + self.$results.attr('aria-hidden', 'false'); + + self.setClasses(); + self.ensureHighlightVisible(); + }); + + container.on('close', function () { + // When the dropdown is closed, aria-expended="false" + self.$results.attr('aria-expanded', 'false'); + self.$results.attr('aria-hidden', 'true'); + self.$results.removeAttr('aria-activedescendant'); + }); + + container.on('results:toggle', function () { + var $highlighted = self.getHighlightedResults(); + + if ($highlighted.length === 0) { + return; + } + + $highlighted.trigger('mouseup'); + }); + + container.on('results:select', function () { + var $highlighted = self.getHighlightedResults(); + + if ($highlighted.length === 0) { + return; + } + + var data = Utils.GetData($highlighted[0], 'data'); + + if ($highlighted.attr('aria-selected') == 'true') { + self.trigger('close', {}); + } else { + self.trigger('select', { + data: data + }); + } + }); + + container.on('results:previous', function () { + var $highlighted = self.getHighlightedResults(); + + var $options = self.$results.find('[aria-selected]'); + + var currentIndex = $options.index($highlighted); + + // If we are already at the top, don't move further + // If no options, currentIndex will be -1 + if (currentIndex <= 0) { + return; + } + + var nextIndex = currentIndex - 1; + + // If none are highlighted, highlight the first + if ($highlighted.length === 0) { + nextIndex = 0; + } + + var $next = $options.eq(nextIndex); + + $next.trigger('mouseenter'); + + var currentOffset = self.$results.offset().top; + var nextTop = $next.offset().top; + var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset); + + if (nextIndex === 0) { + self.$results.scrollTop(0); + } else if (nextTop - currentOffset < 0) { + self.$results.scrollTop(nextOffset); + } + }); + + container.on('results:next', function () { + var $highlighted = self.getHighlightedResults(); + + var $options = self.$results.find('[aria-selected]'); + + var currentIndex = $options.index($highlighted); + + var nextIndex = currentIndex + 1; + + // If we are at the last option, stay there + if (nextIndex >= $options.length) { + return; + } + + var $next = $options.eq(nextIndex); + + $next.trigger('mouseenter'); + + var currentOffset = self.$results.offset().top + + self.$results.outerHeight(false); + var nextBottom = $next.offset().top + $next.outerHeight(false); + var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset; + + if (nextIndex === 0) { + self.$results.scrollTop(0); + } else if (nextBottom > currentOffset) { + self.$results.scrollTop(nextOffset); + } + }); + + container.on('results:focus', function (params) { + params.element.addClass('select2-results__option--highlighted'); + }); + + container.on('results:message', function (params) { + self.displayMessage(params); + }); + + if ($.fn.mousewheel) { + this.$results.on('mousewheel', function (e) { + var top = self.$results.scrollTop(); + + var bottom = self.$results.get(0).scrollHeight - top + e.deltaY; + + var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0; + var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height(); + + if (isAtTop) { + self.$results.scrollTop(0); + + e.preventDefault(); + e.stopPropagation(); + } else if (isAtBottom) { + self.$results.scrollTop( + self.$results.get(0).scrollHeight - self.$results.height() + ); + + e.preventDefault(); + e.stopPropagation(); + } + }); + } + + this.$results.on('mouseup', '.select2-results__option[aria-selected]', + function (evt) { + var $this = $(this); + + var data = Utils.GetData(this, 'data'); + + if ($this.attr('aria-selected') === 'true') { + if (self.options.get('multiple')) { + self.trigger('unselect', { + originalEvent: evt, + data: data + }); + } else { + self.trigger('close', {}); + } + + return; + } + + self.trigger('select', { + originalEvent: evt, + data: data + }); + }); + + this.$results.on('mouseenter', '.select2-results__option[aria-selected]', + function (evt) { + var data = Utils.GetData(this, 'data'); + + self.getHighlightedResults() + .removeClass('select2-results__option--highlighted'); + + self.trigger('results:focus', { + data: data, + element: $(this) + }); + }); + }; + + Results.prototype.getHighlightedResults = function () { + var $highlighted = this.$results + .find('.select2-results__option--highlighted'); + + return $highlighted; + }; + + Results.prototype.destroy = function () { + this.$results.remove(); + }; + + Results.prototype.ensureHighlightVisible = function () { + var $highlighted = this.getHighlightedResults(); + + if ($highlighted.length === 0) { + return; + } + + var $options = this.$results.find('[aria-selected]'); + + var currentIndex = $options.index($highlighted); + + var currentOffset = this.$results.offset().top; + var nextTop = $highlighted.offset().top; + var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset); + + var offsetDelta = nextTop - currentOffset; + nextOffset -= $highlighted.outerHeight(false) * 2; + + if (currentIndex <= 2) { + this.$results.scrollTop(0); + } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) { + this.$results.scrollTop(nextOffset); + } + }; + + Results.prototype.template = function (result, container) { + var template = this.options.get('templateResult'); + var escapeMarkup = this.options.get('escapeMarkup'); + + var content = template(result, container); + + if (content == null) { + container.style.display = 'none'; + } else if (typeof content === 'string') { + container.innerHTML = escapeMarkup(content); + } else { + $(container).append(content); + } + }; + + return Results; +}); + +S2.define('select2/keys',[ + +], function () { + var KEYS = { + BACKSPACE: 8, + TAB: 9, + ENTER: 13, + SHIFT: 16, + CTRL: 17, + ALT: 18, + ESC: 27, + SPACE: 32, + PAGE_UP: 33, + PAGE_DOWN: 34, + END: 35, + HOME: 36, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46 + }; + + return KEYS; +}); + +S2.define('select2/selection/base',[ + 'jquery', + '../utils', + '../keys' +], function ($, Utils, KEYS) { + function BaseSelection ($element, options) { + this.$element = $element; + this.options = options; + + BaseSelection.__super__.constructor.call(this); + } + + Utils.Extend(BaseSelection, Utils.Observable); + + BaseSelection.prototype.render = function () { + var $selection = $( + '' + ); + + this._tabindex = 0; + + if (Utils.GetData(this.$element[0], 'old-tabindex') != null) { + this._tabindex = Utils.GetData(this.$element[0], 'old-tabindex'); + } else if (this.$element.attr('tabindex') != null) { + this._tabindex = this.$element.attr('tabindex'); + } + + $selection.attr('title', this.$element.attr('title')); + $selection.attr('tabindex', this._tabindex); + + this.$selection = $selection; + + return $selection; + }; + + BaseSelection.prototype.bind = function (container, $container) { + var self = this; + + var id = container.id + '-container'; + var resultsId = container.id + '-results'; + + this.container = container; + + this.$selection.on('focus', function (evt) { + self.trigger('focus', evt); + }); + + this.$selection.on('blur', function (evt) { + self._handleBlur(evt); + }); + + this.$selection.on('keydown', function (evt) { + self.trigger('keypress', evt); + + if (evt.which === KEYS.SPACE) { + evt.preventDefault(); + } + }); + + container.on('results:focus', function (params) { + self.$selection.attr('aria-activedescendant', params.data._resultId); + }); + + container.on('selection:update', function (params) { + self.update(params.data); + }); + + container.on('open', function () { + // When the dropdown is open, aria-expanded="true" + self.$selection.attr('aria-expanded', 'true'); + self.$selection.attr('aria-owns', resultsId); + + self._attachCloseHandler(container); + }); + + container.on('close', function () { + // When the dropdown is closed, aria-expanded="false" + self.$selection.attr('aria-expanded', 'false'); + self.$selection.removeAttr('aria-activedescendant'); + self.$selection.removeAttr('aria-owns'); + + window.setTimeout(function () { + self.$selection.focus(); + }, 0); + + self._detachCloseHandler(container); + }); + + container.on('enable', function () { + self.$selection.attr('tabindex', self._tabindex); + }); + + container.on('disable', function () { + self.$selection.attr('tabindex', '-1'); + }); + }; + + BaseSelection.prototype._handleBlur = function (evt) { + var self = this; + + // This needs to be delayed as the active element is the body when the tab + // key is pressed, possibly along with others. + window.setTimeout(function () { + // Don't trigger `blur` if the focus is still in the selection + if ( + (document.activeElement == self.$selection[0]) || + ($.contains(self.$selection[0], document.activeElement)) + ) { + return; + } + + self.trigger('blur', evt); + }, 1); + }; + + BaseSelection.prototype._attachCloseHandler = function (container) { + var self = this; + + $(document.body).on('mousedown.select2.' + container.id, function (e) { + var $target = $(e.target); + + var $select = $target.closest('.select2'); + + var $all = $('.select2.select2-container--open'); + + $all.each(function () { + var $this = $(this); + + if (this == $select[0]) { + return; + } + + var $element = Utils.GetData(this, 'element'); + + $element.select2('close'); + }); + }); + }; + + BaseSelection.prototype._detachCloseHandler = function (container) { + $(document.body).off('mousedown.select2.' + container.id); + }; + + BaseSelection.prototype.position = function ($selection, $container) { + var $selectionContainer = $container.find('.selection'); + $selectionContainer.append($selection); + }; + + BaseSelection.prototype.destroy = function () { + this._detachCloseHandler(this.container); + }; + + BaseSelection.prototype.update = function (data) { + throw new Error('The `update` method must be defined in child classes.'); + }; + + return BaseSelection; +}); + +S2.define('select2/selection/single',[ + 'jquery', + './base', + '../utils', + '../keys' +], function ($, BaseSelection, Utils, KEYS) { + function SingleSelection () { + SingleSelection.__super__.constructor.apply(this, arguments); + } + + Utils.Extend(SingleSelection, BaseSelection); + + SingleSelection.prototype.render = function () { + var $selection = SingleSelection.__super__.render.call(this); + + $selection.addClass('select2-selection--single'); + + $selection.html( + '' + + '' + + '' + + '' + ); + + return $selection; + }; + + SingleSelection.prototype.bind = function (container, $container) { + var self = this; + + SingleSelection.__super__.bind.apply(this, arguments); + + var id = container.id + '-container'; + + this.$selection.find('.select2-selection__rendered') + .attr('id', id) + .attr('role', 'textbox') + .attr('aria-readonly', 'true'); + this.$selection.attr('aria-labelledby', id); + + this.$selection.on('mousedown', function (evt) { + // Only respond to left clicks + if (evt.which !== 1) { + return; + } + + self.trigger('toggle', { + originalEvent: evt + }); + }); + + this.$selection.on('focus', function (evt) { + // User focuses on the container + }); + + this.$selection.on('blur', function (evt) { + // User exits the container + }); + + container.on('focus', function (evt) { + if (!container.isOpen()) { + self.$selection.focus(); + } + }); + }; + + SingleSelection.prototype.clear = function () { + var $rendered = this.$selection.find('.select2-selection__rendered'); + $rendered.empty(); + $rendered.removeAttr('title'); // clear tooltip on empty + }; + + SingleSelection.prototype.display = function (data, container) { + var template = this.options.get('templateSelection'); + var escapeMarkup = this.options.get('escapeMarkup'); + + return escapeMarkup(template(data, container)); + }; + + SingleSelection.prototype.selectionContainer = function () { + return $(''); + }; + + SingleSelection.prototype.update = function (data) { + if (data.length === 0) { + this.clear(); + return; + } + + var selection = data[0]; + + var $rendered = this.$selection.find('.select2-selection__rendered'); + var formatted = this.display(selection, $rendered); + + $rendered.empty().append(formatted); + $rendered.attr('title', selection.title || selection.text); + }; + + return SingleSelection; +}); + +S2.define('select2/selection/multiple',[ + 'jquery', + './base', + '../utils' +], function ($, BaseSelection, Utils) { + function MultipleSelection ($element, options) { + MultipleSelection.__super__.constructor.apply(this, arguments); + } + + Utils.Extend(MultipleSelection, BaseSelection); + + MultipleSelection.prototype.render = function () { + var $selection = MultipleSelection.__super__.render.call(this); + + $selection.addClass('select2-selection--multiple'); + + $selection.html( + '
                            ' + ); + + return $selection; + }; + + MultipleSelection.prototype.bind = function (container, $container) { + var self = this; + + MultipleSelection.__super__.bind.apply(this, arguments); + + this.$selection.on('click', function (evt) { + self.trigger('toggle', { + originalEvent: evt + }); + }); + + this.$selection.on( + 'click', + '.select2-selection__choice__remove', + function (evt) { + // Ignore the event if it is disabled + if (self.options.get('disabled')) { + return; + } + + var $remove = $(this); + var $selection = $remove.parent(); + + var data = Utils.GetData($selection[0], 'data'); + + self.trigger('unselect', { + originalEvent: evt, + data: data + }); + } + ); + }; + + MultipleSelection.prototype.clear = function () { + var $rendered = this.$selection.find('.select2-selection__rendered'); + $rendered.empty(); + $rendered.removeAttr('title'); + }; + + MultipleSelection.prototype.display = function (data, container) { + var template = this.options.get('templateSelection'); + var escapeMarkup = this.options.get('escapeMarkup'); + + return escapeMarkup(template(data, container)); + }; + + MultipleSelection.prototype.selectionContainer = function () { + var $container = $( + '
                          • ' + + '' + + '×' + + '' + + '
                          • ' + ); + + return $container; + }; + + MultipleSelection.prototype.update = function (data) { + this.clear(); + + if (data.length === 0) { + return; + } + + var $selections = []; + + for (var d = 0; d < data.length; d++) { + var selection = data[d]; + + var $selection = this.selectionContainer(); + var formatted = this.display(selection, $selection); + + $selection.append(formatted); + $selection.attr('title', selection.title || selection.text); + + Utils.StoreData($selection[0], 'data', selection); + + $selections.push($selection); + } + + var $rendered = this.$selection.find('.select2-selection__rendered'); + + Utils.appendMany($rendered, $selections); + }; + + return MultipleSelection; +}); + +S2.define('select2/selection/placeholder',[ + '../utils' +], function (Utils) { + function Placeholder (decorated, $element, options) { + this.placeholder = this.normalizePlaceholder(options.get('placeholder')); + + decorated.call(this, $element, options); + } + + Placeholder.prototype.normalizePlaceholder = function (_, placeholder) { + if (typeof placeholder === 'string') { + placeholder = { + id: '', + text: placeholder + }; + } + + return placeholder; + }; + + Placeholder.prototype.createPlaceholder = function (decorated, placeholder) { + var $placeholder = this.selectionContainer(); + + $placeholder.html(this.display(placeholder)); + $placeholder.addClass('select2-selection__placeholder') + .removeClass('select2-selection__choice'); + + return $placeholder; + }; + + Placeholder.prototype.update = function (decorated, data) { + var singlePlaceholder = ( + data.length == 1 && data[0].id != this.placeholder.id + ); + var multipleSelections = data.length > 1; + + if (multipleSelections || singlePlaceholder) { + return decorated.call(this, data); + } + + this.clear(); + + var $placeholder = this.createPlaceholder(this.placeholder); + + this.$selection.find('.select2-selection__rendered').append($placeholder); + }; + + return Placeholder; +}); + +S2.define('select2/selection/allowClear',[ + 'jquery', + '../keys', + '../utils' +], function ($, KEYS, Utils) { + function AllowClear () { } + + AllowClear.prototype.bind = function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + if (this.placeholder == null) { + if (this.options.get('debug') && window.console && console.error) { + console.error( + 'Select2: The `allowClear` option should be used in combination ' + + 'with the `placeholder` option.' + ); + } + } + + this.$selection.on('mousedown', '.select2-selection__clear', + function (evt) { + self._handleClear(evt); + }); + + container.on('keypress', function (evt) { + self._handleKeyboardClear(evt, container); + }); + }; + + AllowClear.prototype._handleClear = function (_, evt) { + // Ignore the event if it is disabled + if (this.options.get('disabled')) { + return; + } + + var $clear = this.$selection.find('.select2-selection__clear'); + + // Ignore the event if nothing has been selected + if ($clear.length === 0) { + return; + } + + evt.stopPropagation(); + + var data = Utils.GetData($clear[0], 'data'); + + var previousVal = this.$element.val(); + this.$element.val(this.placeholder.id); + + var unselectData = { + data: data + }; + this.trigger('clear', unselectData); + if (unselectData.prevented) { + this.$element.val(previousVal); + return; + } + + for (var d = 0; d < data.length; d++) { + unselectData = { + data: data[d] + }; + + // Trigger the `unselect` event, so people can prevent it from being + // cleared. + this.trigger('unselect', unselectData); + + // If the event was prevented, don't clear it out. + if (unselectData.prevented) { + this.$element.val(previousVal); + return; + } + } + + this.$element.trigger('change'); + + this.trigger('toggle', {}); + }; + + AllowClear.prototype._handleKeyboardClear = function (_, evt, container) { + if (container.isOpen()) { + return; + } + + if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) { + this._handleClear(evt); + } + }; + + AllowClear.prototype.update = function (decorated, data) { + decorated.call(this, data); + + if (this.$selection.find('.select2-selection__placeholder').length > 0 || + data.length === 0) { + return; + } + + var removeAll = this.options.get('translations').get('removeAllItems'); + + var $remove = $( + '' + + '×' + + '' + ); + Utils.StoreData($remove[0], 'data', data); + + this.$selection.find('.select2-selection__rendered').prepend($remove); + }; + + return AllowClear; +}); + +S2.define('select2/selection/search',[ + 'jquery', + '../utils', + '../keys' +], function ($, Utils, KEYS) { + function Search (decorated, $element, options) { + decorated.call(this, $element, options); + } + + Search.prototype.render = function (decorated) { + var $search = $( + '' + ); + + this.$searchContainer = $search; + this.$search = $search.find('input'); + + var $rendered = decorated.call(this); + + this._transferTabIndex(); + + return $rendered; + }; + + Search.prototype.bind = function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + container.on('open', function () { + self.$search.trigger('focus'); + }); + + container.on('close', function () { + self.$search.val(''); + self.$search.removeAttr('aria-activedescendant'); + self.$search.trigger('focus'); + }); + + container.on('enable', function () { + self.$search.prop('disabled', false); + + self._transferTabIndex(); + }); + + container.on('disable', function () { + self.$search.prop('disabled', true); + }); + + container.on('focus', function (evt) { + self.$search.trigger('focus'); + }); + + container.on('results:focus', function (params) { + self.$search.attr('aria-activedescendant', params.id); + }); + + this.$selection.on('focusin', '.select2-search--inline', function (evt) { + self.trigger('focus', evt); + }); + + this.$selection.on('focusout', '.select2-search--inline', function (evt) { + self._handleBlur(evt); + }); + + this.$selection.on('keydown', '.select2-search--inline', function (evt) { + evt.stopPropagation(); + + self.trigger('keypress', evt); + + self._keyUpPrevented = evt.isDefaultPrevented(); + + var key = evt.which; + + if (key === KEYS.BACKSPACE && self.$search.val() === '') { + var $previousChoice = self.$searchContainer + .prev('.select2-selection__choice'); + + if ($previousChoice.length > 0) { + var item = Utils.GetData($previousChoice[0], 'data'); + + self.searchRemoveChoice(item); + + evt.preventDefault(); + } + } + }); + + // Try to detect the IE version should the `documentMode` property that + // is stored on the document. This is only implemented in IE and is + // slightly cleaner than doing a user agent check. + // This property is not available in Edge, but Edge also doesn't have + // this bug. + var msie = document.documentMode; + var disableInputEvents = msie && msie <= 11; + + // Workaround for browsers which do not support the `input` event + // This will prevent double-triggering of events for browsers which support + // both the `keyup` and `input` events. + this.$selection.on( + 'input.searchcheck', + '.select2-search--inline', + function (evt) { + // IE will trigger the `input` event when a placeholder is used on a + // search box. To get around this issue, we are forced to ignore all + // `input` events in IE and keep using `keyup`. + if (disableInputEvents) { + self.$selection.off('input.search input.searchcheck'); + return; + } + + // Unbind the duplicated `keyup` event + self.$selection.off('keyup.search'); + } + ); + + this.$selection.on( + 'keyup.search input.search', + '.select2-search--inline', + function (evt) { + // IE will trigger the `input` event when a placeholder is used on a + // search box. To get around this issue, we are forced to ignore all + // `input` events in IE and keep using `keyup`. + if (disableInputEvents && evt.type === 'input') { + self.$selection.off('input.search input.searchcheck'); + return; + } + + var key = evt.which; + + // We can freely ignore events from modifier keys + if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) { + return; + } + + // Tabbing will be handled during the `keydown` phase + if (key == KEYS.TAB) { + return; + } + + self.handleSearch(evt); + } + ); + }; + + /** + * This method will transfer the tabindex attribute from the rendered + * selection to the search box. This allows for the search box to be used as + * the primary focus instead of the selection container. + * + * @private + */ + Search.prototype._transferTabIndex = function (decorated) { + this.$search.attr('tabindex', this.$selection.attr('tabindex')); + this.$selection.attr('tabindex', '-1'); + }; + + Search.prototype.createPlaceholder = function (decorated, placeholder) { + this.$search.attr('placeholder', placeholder.text); + }; + + Search.prototype.update = function (decorated, data) { + var searchHadFocus = this.$search[0] == document.activeElement; + + this.$search.attr('placeholder', ''); + + decorated.call(this, data); + + this.$selection.find('.select2-selection__rendered') + .append(this.$searchContainer); + + this.resizeSearch(); + if (searchHadFocus) { + var isTagInput = this.$element.find('[data-select2-tag]').length; + if (isTagInput) { + // fix IE11 bug where tag input lost focus + this.$element.focus(); + } else { + this.$search.focus(); + } + } + }; + + Search.prototype.handleSearch = function () { + this.resizeSearch(); + + if (!this._keyUpPrevented) { + var input = this.$search.val(); + + this.trigger('query', { + term: input + }); + } + + this._keyUpPrevented = false; + }; + + Search.prototype.searchRemoveChoice = function (decorated, item) { + this.trigger('unselect', { + data: item + }); + + this.$search.val(item.text); + this.handleSearch(); + }; + + Search.prototype.resizeSearch = function () { + this.$search.css('width', '25px'); + + var width = ''; + + if (this.$search.attr('placeholder') !== '') { + width = this.$selection.find('.select2-selection__rendered').innerWidth(); + } else { + var minimumWidth = this.$search.val().length + 1; + + width = (minimumWidth * 0.75) + 'em'; + } + + this.$search.css('width', width); + }; + + return Search; +}); + +S2.define('select2/selection/eventRelay',[ + 'jquery' +], function ($) { + function EventRelay () { } + + EventRelay.prototype.bind = function (decorated, container, $container) { + var self = this; + var relayEvents = [ + 'open', 'opening', + 'close', 'closing', + 'select', 'selecting', + 'unselect', 'unselecting', + 'clear', 'clearing' + ]; + + var preventableEvents = [ + 'opening', 'closing', 'selecting', 'unselecting', 'clearing' + ]; + + decorated.call(this, container, $container); + + container.on('*', function (name, params) { + // Ignore events that should not be relayed + if ($.inArray(name, relayEvents) === -1) { + return; + } + + // The parameters should always be an object + params = params || {}; + + // Generate the jQuery event for the Select2 event + var evt = $.Event('select2:' + name, { + params: params + }); + + self.$element.trigger(evt); + + // Only handle preventable events if it was one + if ($.inArray(name, preventableEvents) === -1) { + return; + } + + params.prevented = evt.isDefaultPrevented(); + }); + }; + + return EventRelay; +}); + +S2.define('select2/translation',[ + 'jquery', + 'require' +], function ($, require) { + function Translation (dict) { + this.dict = dict || {}; + } + + Translation.prototype.all = function () { + return this.dict; + }; + + Translation.prototype.get = function (key) { + return this.dict[key]; + }; + + Translation.prototype.extend = function (translation) { + this.dict = $.extend({}, translation.all(), this.dict); + }; + + // Static functions + + Translation._cache = {}; + + Translation.loadPath = function (path) { + if (!(path in Translation._cache)) { + var translations = require(path); + + Translation._cache[path] = translations; + } + + return new Translation(Translation._cache[path]); + }; + + return Translation; +}); + +S2.define('select2/diacritics',[ + +], function () { + var diacritics = { + '\u24B6': 'A', + '\uFF21': 'A', + '\u00C0': 'A', + '\u00C1': 'A', + '\u00C2': 'A', + '\u1EA6': 'A', + '\u1EA4': 'A', + '\u1EAA': 'A', + '\u1EA8': 'A', + '\u00C3': 'A', + '\u0100': 'A', + '\u0102': 'A', + '\u1EB0': 'A', + '\u1EAE': 'A', + '\u1EB4': 'A', + '\u1EB2': 'A', + '\u0226': 'A', + '\u01E0': 'A', + '\u00C4': 'A', + '\u01DE': 'A', + '\u1EA2': 'A', + '\u00C5': 'A', + '\u01FA': 'A', + '\u01CD': 'A', + '\u0200': 'A', + '\u0202': 'A', + '\u1EA0': 'A', + '\u1EAC': 'A', + '\u1EB6': 'A', + '\u1E00': 'A', + '\u0104': 'A', + '\u023A': 'A', + '\u2C6F': 'A', + '\uA732': 'AA', + '\u00C6': 'AE', + '\u01FC': 'AE', + '\u01E2': 'AE', + '\uA734': 'AO', + '\uA736': 'AU', + '\uA738': 'AV', + '\uA73A': 'AV', + '\uA73C': 'AY', + '\u24B7': 'B', + '\uFF22': 'B', + '\u1E02': 'B', + '\u1E04': 'B', + '\u1E06': 'B', + '\u0243': 'B', + '\u0182': 'B', + '\u0181': 'B', + '\u24B8': 'C', + '\uFF23': 'C', + '\u0106': 'C', + '\u0108': 'C', + '\u010A': 'C', + '\u010C': 'C', + '\u00C7': 'C', + '\u1E08': 'C', + '\u0187': 'C', + '\u023B': 'C', + '\uA73E': 'C', + '\u24B9': 'D', + '\uFF24': 'D', + '\u1E0A': 'D', + '\u010E': 'D', + '\u1E0C': 'D', + '\u1E10': 'D', + '\u1E12': 'D', + '\u1E0E': 'D', + '\u0110': 'D', + '\u018B': 'D', + '\u018A': 'D', + '\u0189': 'D', + '\uA779': 'D', + '\u01F1': 'DZ', + '\u01C4': 'DZ', + '\u01F2': 'Dz', + '\u01C5': 'Dz', + '\u24BA': 'E', + '\uFF25': 'E', + '\u00C8': 'E', + '\u00C9': 'E', + '\u00CA': 'E', + '\u1EC0': 'E', + '\u1EBE': 'E', + '\u1EC4': 'E', + '\u1EC2': 'E', + '\u1EBC': 'E', + '\u0112': 'E', + '\u1E14': 'E', + '\u1E16': 'E', + '\u0114': 'E', + '\u0116': 'E', + '\u00CB': 'E', + '\u1EBA': 'E', + '\u011A': 'E', + '\u0204': 'E', + '\u0206': 'E', + '\u1EB8': 'E', + '\u1EC6': 'E', + '\u0228': 'E', + '\u1E1C': 'E', + '\u0118': 'E', + '\u1E18': 'E', + '\u1E1A': 'E', + '\u0190': 'E', + '\u018E': 'E', + '\u24BB': 'F', + '\uFF26': 'F', + '\u1E1E': 'F', + '\u0191': 'F', + '\uA77B': 'F', + '\u24BC': 'G', + '\uFF27': 'G', + '\u01F4': 'G', + '\u011C': 'G', + '\u1E20': 'G', + '\u011E': 'G', + '\u0120': 'G', + '\u01E6': 'G', + '\u0122': 'G', + '\u01E4': 'G', + '\u0193': 'G', + '\uA7A0': 'G', + '\uA77D': 'G', + '\uA77E': 'G', + '\u24BD': 'H', + '\uFF28': 'H', + '\u0124': 'H', + '\u1E22': 'H', + '\u1E26': 'H', + '\u021E': 'H', + '\u1E24': 'H', + '\u1E28': 'H', + '\u1E2A': 'H', + '\u0126': 'H', + '\u2C67': 'H', + '\u2C75': 'H', + '\uA78D': 'H', + '\u24BE': 'I', + '\uFF29': 'I', + '\u00CC': 'I', + '\u00CD': 'I', + '\u00CE': 'I', + '\u0128': 'I', + '\u012A': 'I', + '\u012C': 'I', + '\u0130': 'I', + '\u00CF': 'I', + '\u1E2E': 'I', + '\u1EC8': 'I', + '\u01CF': 'I', + '\u0208': 'I', + '\u020A': 'I', + '\u1ECA': 'I', + '\u012E': 'I', + '\u1E2C': 'I', + '\u0197': 'I', + '\u24BF': 'J', + '\uFF2A': 'J', + '\u0134': 'J', + '\u0248': 'J', + '\u24C0': 'K', + '\uFF2B': 'K', + '\u1E30': 'K', + '\u01E8': 'K', + '\u1E32': 'K', + '\u0136': 'K', + '\u1E34': 'K', + '\u0198': 'K', + '\u2C69': 'K', + '\uA740': 'K', + '\uA742': 'K', + '\uA744': 'K', + '\uA7A2': 'K', + '\u24C1': 'L', + '\uFF2C': 'L', + '\u013F': 'L', + '\u0139': 'L', + '\u013D': 'L', + '\u1E36': 'L', + '\u1E38': 'L', + '\u013B': 'L', + '\u1E3C': 'L', + '\u1E3A': 'L', + '\u0141': 'L', + '\u023D': 'L', + '\u2C62': 'L', + '\u2C60': 'L', + '\uA748': 'L', + '\uA746': 'L', + '\uA780': 'L', + '\u01C7': 'LJ', + '\u01C8': 'Lj', + '\u24C2': 'M', + '\uFF2D': 'M', + '\u1E3E': 'M', + '\u1E40': 'M', + '\u1E42': 'M', + '\u2C6E': 'M', + '\u019C': 'M', + '\u24C3': 'N', + '\uFF2E': 'N', + '\u01F8': 'N', + '\u0143': 'N', + '\u00D1': 'N', + '\u1E44': 'N', + '\u0147': 'N', + '\u1E46': 'N', + '\u0145': 'N', + '\u1E4A': 'N', + '\u1E48': 'N', + '\u0220': 'N', + '\u019D': 'N', + '\uA790': 'N', + '\uA7A4': 'N', + '\u01CA': 'NJ', + '\u01CB': 'Nj', + '\u24C4': 'O', + '\uFF2F': 'O', + '\u00D2': 'O', + '\u00D3': 'O', + '\u00D4': 'O', + '\u1ED2': 'O', + '\u1ED0': 'O', + '\u1ED6': 'O', + '\u1ED4': 'O', + '\u00D5': 'O', + '\u1E4C': 'O', + '\u022C': 'O', + '\u1E4E': 'O', + '\u014C': 'O', + '\u1E50': 'O', + '\u1E52': 'O', + '\u014E': 'O', + '\u022E': 'O', + '\u0230': 'O', + '\u00D6': 'O', + '\u022A': 'O', + '\u1ECE': 'O', + '\u0150': 'O', + '\u01D1': 'O', + '\u020C': 'O', + '\u020E': 'O', + '\u01A0': 'O', + '\u1EDC': 'O', + '\u1EDA': 'O', + '\u1EE0': 'O', + '\u1EDE': 'O', + '\u1EE2': 'O', + '\u1ECC': 'O', + '\u1ED8': 'O', + '\u01EA': 'O', + '\u01EC': 'O', + '\u00D8': 'O', + '\u01FE': 'O', + '\u0186': 'O', + '\u019F': 'O', + '\uA74A': 'O', + '\uA74C': 'O', + '\u0152': 'OE', + '\u01A2': 'OI', + '\uA74E': 'OO', + '\u0222': 'OU', + '\u24C5': 'P', + '\uFF30': 'P', + '\u1E54': 'P', + '\u1E56': 'P', + '\u01A4': 'P', + '\u2C63': 'P', + '\uA750': 'P', + '\uA752': 'P', + '\uA754': 'P', + '\u24C6': 'Q', + '\uFF31': 'Q', + '\uA756': 'Q', + '\uA758': 'Q', + '\u024A': 'Q', + '\u24C7': 'R', + '\uFF32': 'R', + '\u0154': 'R', + '\u1E58': 'R', + '\u0158': 'R', + '\u0210': 'R', + '\u0212': 'R', + '\u1E5A': 'R', + '\u1E5C': 'R', + '\u0156': 'R', + '\u1E5E': 'R', + '\u024C': 'R', + '\u2C64': 'R', + '\uA75A': 'R', + '\uA7A6': 'R', + '\uA782': 'R', + '\u24C8': 'S', + '\uFF33': 'S', + '\u1E9E': 'S', + '\u015A': 'S', + '\u1E64': 'S', + '\u015C': 'S', + '\u1E60': 'S', + '\u0160': 'S', + '\u1E66': 'S', + '\u1E62': 'S', + '\u1E68': 'S', + '\u0218': 'S', + '\u015E': 'S', + '\u2C7E': 'S', + '\uA7A8': 'S', + '\uA784': 'S', + '\u24C9': 'T', + '\uFF34': 'T', + '\u1E6A': 'T', + '\u0164': 'T', + '\u1E6C': 'T', + '\u021A': 'T', + '\u0162': 'T', + '\u1E70': 'T', + '\u1E6E': 'T', + '\u0166': 'T', + '\u01AC': 'T', + '\u01AE': 'T', + '\u023E': 'T', + '\uA786': 'T', + '\uA728': 'TZ', + '\u24CA': 'U', + '\uFF35': 'U', + '\u00D9': 'U', + '\u00DA': 'U', + '\u00DB': 'U', + '\u0168': 'U', + '\u1E78': 'U', + '\u016A': 'U', + '\u1E7A': 'U', + '\u016C': 'U', + '\u00DC': 'U', + '\u01DB': 'U', + '\u01D7': 'U', + '\u01D5': 'U', + '\u01D9': 'U', + '\u1EE6': 'U', + '\u016E': 'U', + '\u0170': 'U', + '\u01D3': 'U', + '\u0214': 'U', + '\u0216': 'U', + '\u01AF': 'U', + '\u1EEA': 'U', + '\u1EE8': 'U', + '\u1EEE': 'U', + '\u1EEC': 'U', + '\u1EF0': 'U', + '\u1EE4': 'U', + '\u1E72': 'U', + '\u0172': 'U', + '\u1E76': 'U', + '\u1E74': 'U', + '\u0244': 'U', + '\u24CB': 'V', + '\uFF36': 'V', + '\u1E7C': 'V', + '\u1E7E': 'V', + '\u01B2': 'V', + '\uA75E': 'V', + '\u0245': 'V', + '\uA760': 'VY', + '\u24CC': 'W', + '\uFF37': 'W', + '\u1E80': 'W', + '\u1E82': 'W', + '\u0174': 'W', + '\u1E86': 'W', + '\u1E84': 'W', + '\u1E88': 'W', + '\u2C72': 'W', + '\u24CD': 'X', + '\uFF38': 'X', + '\u1E8A': 'X', + '\u1E8C': 'X', + '\u24CE': 'Y', + '\uFF39': 'Y', + '\u1EF2': 'Y', + '\u00DD': 'Y', + '\u0176': 'Y', + '\u1EF8': 'Y', + '\u0232': 'Y', + '\u1E8E': 'Y', + '\u0178': 'Y', + '\u1EF6': 'Y', + '\u1EF4': 'Y', + '\u01B3': 'Y', + '\u024E': 'Y', + '\u1EFE': 'Y', + '\u24CF': 'Z', + '\uFF3A': 'Z', + '\u0179': 'Z', + '\u1E90': 'Z', + '\u017B': 'Z', + '\u017D': 'Z', + '\u1E92': 'Z', + '\u1E94': 'Z', + '\u01B5': 'Z', + '\u0224': 'Z', + '\u2C7F': 'Z', + '\u2C6B': 'Z', + '\uA762': 'Z', + '\u24D0': 'a', + '\uFF41': 'a', + '\u1E9A': 'a', + '\u00E0': 'a', + '\u00E1': 'a', + '\u00E2': 'a', + '\u1EA7': 'a', + '\u1EA5': 'a', + '\u1EAB': 'a', + '\u1EA9': 'a', + '\u00E3': 'a', + '\u0101': 'a', + '\u0103': 'a', + '\u1EB1': 'a', + '\u1EAF': 'a', + '\u1EB5': 'a', + '\u1EB3': 'a', + '\u0227': 'a', + '\u01E1': 'a', + '\u00E4': 'a', + '\u01DF': 'a', + '\u1EA3': 'a', + '\u00E5': 'a', + '\u01FB': 'a', + '\u01CE': 'a', + '\u0201': 'a', + '\u0203': 'a', + '\u1EA1': 'a', + '\u1EAD': 'a', + '\u1EB7': 'a', + '\u1E01': 'a', + '\u0105': 'a', + '\u2C65': 'a', + '\u0250': 'a', + '\uA733': 'aa', + '\u00E6': 'ae', + '\u01FD': 'ae', + '\u01E3': 'ae', + '\uA735': 'ao', + '\uA737': 'au', + '\uA739': 'av', + '\uA73B': 'av', + '\uA73D': 'ay', + '\u24D1': 'b', + '\uFF42': 'b', + '\u1E03': 'b', + '\u1E05': 'b', + '\u1E07': 'b', + '\u0180': 'b', + '\u0183': 'b', + '\u0253': 'b', + '\u24D2': 'c', + '\uFF43': 'c', + '\u0107': 'c', + '\u0109': 'c', + '\u010B': 'c', + '\u010D': 'c', + '\u00E7': 'c', + '\u1E09': 'c', + '\u0188': 'c', + '\u023C': 'c', + '\uA73F': 'c', + '\u2184': 'c', + '\u24D3': 'd', + '\uFF44': 'd', + '\u1E0B': 'd', + '\u010F': 'd', + '\u1E0D': 'd', + '\u1E11': 'd', + '\u1E13': 'd', + '\u1E0F': 'd', + '\u0111': 'd', + '\u018C': 'd', + '\u0256': 'd', + '\u0257': 'd', + '\uA77A': 'd', + '\u01F3': 'dz', + '\u01C6': 'dz', + '\u24D4': 'e', + '\uFF45': 'e', + '\u00E8': 'e', + '\u00E9': 'e', + '\u00EA': 'e', + '\u1EC1': 'e', + '\u1EBF': 'e', + '\u1EC5': 'e', + '\u1EC3': 'e', + '\u1EBD': 'e', + '\u0113': 'e', + '\u1E15': 'e', + '\u1E17': 'e', + '\u0115': 'e', + '\u0117': 'e', + '\u00EB': 'e', + '\u1EBB': 'e', + '\u011B': 'e', + '\u0205': 'e', + '\u0207': 'e', + '\u1EB9': 'e', + '\u1EC7': 'e', + '\u0229': 'e', + '\u1E1D': 'e', + '\u0119': 'e', + '\u1E19': 'e', + '\u1E1B': 'e', + '\u0247': 'e', + '\u025B': 'e', + '\u01DD': 'e', + '\u24D5': 'f', + '\uFF46': 'f', + '\u1E1F': 'f', + '\u0192': 'f', + '\uA77C': 'f', + '\u24D6': 'g', + '\uFF47': 'g', + '\u01F5': 'g', + '\u011D': 'g', + '\u1E21': 'g', + '\u011F': 'g', + '\u0121': 'g', + '\u01E7': 'g', + '\u0123': 'g', + '\u01E5': 'g', + '\u0260': 'g', + '\uA7A1': 'g', + '\u1D79': 'g', + '\uA77F': 'g', + '\u24D7': 'h', + '\uFF48': 'h', + '\u0125': 'h', + '\u1E23': 'h', + '\u1E27': 'h', + '\u021F': 'h', + '\u1E25': 'h', + '\u1E29': 'h', + '\u1E2B': 'h', + '\u1E96': 'h', + '\u0127': 'h', + '\u2C68': 'h', + '\u2C76': 'h', + '\u0265': 'h', + '\u0195': 'hv', + '\u24D8': 'i', + '\uFF49': 'i', + '\u00EC': 'i', + '\u00ED': 'i', + '\u00EE': 'i', + '\u0129': 'i', + '\u012B': 'i', + '\u012D': 'i', + '\u00EF': 'i', + '\u1E2F': 'i', + '\u1EC9': 'i', + '\u01D0': 'i', + '\u0209': 'i', + '\u020B': 'i', + '\u1ECB': 'i', + '\u012F': 'i', + '\u1E2D': 'i', + '\u0268': 'i', + '\u0131': 'i', + '\u24D9': 'j', + '\uFF4A': 'j', + '\u0135': 'j', + '\u01F0': 'j', + '\u0249': 'j', + '\u24DA': 'k', + '\uFF4B': 'k', + '\u1E31': 'k', + '\u01E9': 'k', + '\u1E33': 'k', + '\u0137': 'k', + '\u1E35': 'k', + '\u0199': 'k', + '\u2C6A': 'k', + '\uA741': 'k', + '\uA743': 'k', + '\uA745': 'k', + '\uA7A3': 'k', + '\u24DB': 'l', + '\uFF4C': 'l', + '\u0140': 'l', + '\u013A': 'l', + '\u013E': 'l', + '\u1E37': 'l', + '\u1E39': 'l', + '\u013C': 'l', + '\u1E3D': 'l', + '\u1E3B': 'l', + '\u017F': 'l', + '\u0142': 'l', + '\u019A': 'l', + '\u026B': 'l', + '\u2C61': 'l', + '\uA749': 'l', + '\uA781': 'l', + '\uA747': 'l', + '\u01C9': 'lj', + '\u24DC': 'm', + '\uFF4D': 'm', + '\u1E3F': 'm', + '\u1E41': 'm', + '\u1E43': 'm', + '\u0271': 'm', + '\u026F': 'm', + '\u24DD': 'n', + '\uFF4E': 'n', + '\u01F9': 'n', + '\u0144': 'n', + '\u00F1': 'n', + '\u1E45': 'n', + '\u0148': 'n', + '\u1E47': 'n', + '\u0146': 'n', + '\u1E4B': 'n', + '\u1E49': 'n', + '\u019E': 'n', + '\u0272': 'n', + '\u0149': 'n', + '\uA791': 'n', + '\uA7A5': 'n', + '\u01CC': 'nj', + '\u24DE': 'o', + '\uFF4F': 'o', + '\u00F2': 'o', + '\u00F3': 'o', + '\u00F4': 'o', + '\u1ED3': 'o', + '\u1ED1': 'o', + '\u1ED7': 'o', + '\u1ED5': 'o', + '\u00F5': 'o', + '\u1E4D': 'o', + '\u022D': 'o', + '\u1E4F': 'o', + '\u014D': 'o', + '\u1E51': 'o', + '\u1E53': 'o', + '\u014F': 'o', + '\u022F': 'o', + '\u0231': 'o', + '\u00F6': 'o', + '\u022B': 'o', + '\u1ECF': 'o', + '\u0151': 'o', + '\u01D2': 'o', + '\u020D': 'o', + '\u020F': 'o', + '\u01A1': 'o', + '\u1EDD': 'o', + '\u1EDB': 'o', + '\u1EE1': 'o', + '\u1EDF': 'o', + '\u1EE3': 'o', + '\u1ECD': 'o', + '\u1ED9': 'o', + '\u01EB': 'o', + '\u01ED': 'o', + '\u00F8': 'o', + '\u01FF': 'o', + '\u0254': 'o', + '\uA74B': 'o', + '\uA74D': 'o', + '\u0275': 'o', + '\u0153': 'oe', + '\u01A3': 'oi', + '\u0223': 'ou', + '\uA74F': 'oo', + '\u24DF': 'p', + '\uFF50': 'p', + '\u1E55': 'p', + '\u1E57': 'p', + '\u01A5': 'p', + '\u1D7D': 'p', + '\uA751': 'p', + '\uA753': 'p', + '\uA755': 'p', + '\u24E0': 'q', + '\uFF51': 'q', + '\u024B': 'q', + '\uA757': 'q', + '\uA759': 'q', + '\u24E1': 'r', + '\uFF52': 'r', + '\u0155': 'r', + '\u1E59': 'r', + '\u0159': 'r', + '\u0211': 'r', + '\u0213': 'r', + '\u1E5B': 'r', + '\u1E5D': 'r', + '\u0157': 'r', + '\u1E5F': 'r', + '\u024D': 'r', + '\u027D': 'r', + '\uA75B': 'r', + '\uA7A7': 'r', + '\uA783': 'r', + '\u24E2': 's', + '\uFF53': 's', + '\u00DF': 's', + '\u015B': 's', + '\u1E65': 's', + '\u015D': 's', + '\u1E61': 's', + '\u0161': 's', + '\u1E67': 's', + '\u1E63': 's', + '\u1E69': 's', + '\u0219': 's', + '\u015F': 's', + '\u023F': 's', + '\uA7A9': 's', + '\uA785': 's', + '\u1E9B': 's', + '\u24E3': 't', + '\uFF54': 't', + '\u1E6B': 't', + '\u1E97': 't', + '\u0165': 't', + '\u1E6D': 't', + '\u021B': 't', + '\u0163': 't', + '\u1E71': 't', + '\u1E6F': 't', + '\u0167': 't', + '\u01AD': 't', + '\u0288': 't', + '\u2C66': 't', + '\uA787': 't', + '\uA729': 'tz', + '\u24E4': 'u', + '\uFF55': 'u', + '\u00F9': 'u', + '\u00FA': 'u', + '\u00FB': 'u', + '\u0169': 'u', + '\u1E79': 'u', + '\u016B': 'u', + '\u1E7B': 'u', + '\u016D': 'u', + '\u00FC': 'u', + '\u01DC': 'u', + '\u01D8': 'u', + '\u01D6': 'u', + '\u01DA': 'u', + '\u1EE7': 'u', + '\u016F': 'u', + '\u0171': 'u', + '\u01D4': 'u', + '\u0215': 'u', + '\u0217': 'u', + '\u01B0': 'u', + '\u1EEB': 'u', + '\u1EE9': 'u', + '\u1EEF': 'u', + '\u1EED': 'u', + '\u1EF1': 'u', + '\u1EE5': 'u', + '\u1E73': 'u', + '\u0173': 'u', + '\u1E77': 'u', + '\u1E75': 'u', + '\u0289': 'u', + '\u24E5': 'v', + '\uFF56': 'v', + '\u1E7D': 'v', + '\u1E7F': 'v', + '\u028B': 'v', + '\uA75F': 'v', + '\u028C': 'v', + '\uA761': 'vy', + '\u24E6': 'w', + '\uFF57': 'w', + '\u1E81': 'w', + '\u1E83': 'w', + '\u0175': 'w', + '\u1E87': 'w', + '\u1E85': 'w', + '\u1E98': 'w', + '\u1E89': 'w', + '\u2C73': 'w', + '\u24E7': 'x', + '\uFF58': 'x', + '\u1E8B': 'x', + '\u1E8D': 'x', + '\u24E8': 'y', + '\uFF59': 'y', + '\u1EF3': 'y', + '\u00FD': 'y', + '\u0177': 'y', + '\u1EF9': 'y', + '\u0233': 'y', + '\u1E8F': 'y', + '\u00FF': 'y', + '\u1EF7': 'y', + '\u1E99': 'y', + '\u1EF5': 'y', + '\u01B4': 'y', + '\u024F': 'y', + '\u1EFF': 'y', + '\u24E9': 'z', + '\uFF5A': 'z', + '\u017A': 'z', + '\u1E91': 'z', + '\u017C': 'z', + '\u017E': 'z', + '\u1E93': 'z', + '\u1E95': 'z', + '\u01B6': 'z', + '\u0225': 'z', + '\u0240': 'z', + '\u2C6C': 'z', + '\uA763': 'z', + '\u0386': '\u0391', + '\u0388': '\u0395', + '\u0389': '\u0397', + '\u038A': '\u0399', + '\u03AA': '\u0399', + '\u038C': '\u039F', + '\u038E': '\u03A5', + '\u03AB': '\u03A5', + '\u038F': '\u03A9', + '\u03AC': '\u03B1', + '\u03AD': '\u03B5', + '\u03AE': '\u03B7', + '\u03AF': '\u03B9', + '\u03CA': '\u03B9', + '\u0390': '\u03B9', + '\u03CC': '\u03BF', + '\u03CD': '\u03C5', + '\u03CB': '\u03C5', + '\u03B0': '\u03C5', + '\u03CE': '\u03C9', + '\u03C2': '\u03C3', + '\u2019': '\'' + }; + + return diacritics; +}); + +S2.define('select2/data/base',[ + '../utils' +], function (Utils) { + function BaseAdapter ($element, options) { + BaseAdapter.__super__.constructor.call(this); + } + + Utils.Extend(BaseAdapter, Utils.Observable); + + BaseAdapter.prototype.current = function (callback) { + throw new Error('The `current` method must be defined in child classes.'); + }; + + BaseAdapter.prototype.query = function (params, callback) { + throw new Error('The `query` method must be defined in child classes.'); + }; + + BaseAdapter.prototype.bind = function (container, $container) { + // Can be implemented in subclasses + }; + + BaseAdapter.prototype.destroy = function () { + // Can be implemented in subclasses + }; + + BaseAdapter.prototype.generateResultId = function (container, data) { + var id = container.id + '-result-'; + + id += Utils.generateChars(4); + + if (data.id != null) { + id += '-' + data.id.toString(); + } else { + id += '-' + Utils.generateChars(4); + } + return id; + }; + + return BaseAdapter; +}); + +S2.define('select2/data/select',[ + './base', + '../utils', + 'jquery' +], function (BaseAdapter, Utils, $) { + function SelectAdapter ($element, options) { + this.$element = $element; + this.options = options; + + SelectAdapter.__super__.constructor.call(this); + } + + Utils.Extend(SelectAdapter, BaseAdapter); + + SelectAdapter.prototype.current = function (callback) { + var data = []; + var self = this; + + this.$element.find(':selected').each(function () { + var $option = $(this); + + var option = self.item($option); + + data.push(option); + }); + + callback(data); + }; + + SelectAdapter.prototype.select = function (data) { + var self = this; + + data.selected = true; + + // If data.element is a DOM node, use it instead + if ($(data.element).is('option')) { + data.element.selected = true; + + this.$element.trigger('change'); + + return; + } + + if (this.$element.prop('multiple')) { + this.current(function (currentData) { + var val = []; + + data = [data]; + data.push.apply(data, currentData); + + for (var d = 0; d < data.length; d++) { + var id = data[d].id; + + if ($.inArray(id, val) === -1) { + val.push(id); + } + } + + self.$element.val(val); + self.$element.trigger('change'); + }); + } else { + var val = data.id; + + this.$element.val(val); + this.$element.trigger('change'); + } + }; + + SelectAdapter.prototype.unselect = function (data) { + var self = this; + + if (!this.$element.prop('multiple')) { + return; + } + + data.selected = false; + + if ($(data.element).is('option')) { + data.element.selected = false; + + this.$element.trigger('change'); + + return; + } + + this.current(function (currentData) { + var val = []; + + for (var d = 0; d < currentData.length; d++) { + var id = currentData[d].id; + + if (id !== data.id && $.inArray(id, val) === -1) { + val.push(id); + } + } + + self.$element.val(val); + + self.$element.trigger('change'); + }); + }; + + SelectAdapter.prototype.bind = function (container, $container) { + var self = this; + + this.container = container; + + container.on('select', function (params) { + self.select(params.data); + }); + + container.on('unselect', function (params) { + self.unselect(params.data); + }); + }; + + SelectAdapter.prototype.destroy = function () { + // Remove anything added to child elements + this.$element.find('*').each(function () { + // Remove any custom data set by Select2 + Utils.RemoveData(this); + }); + }; + + SelectAdapter.prototype.query = function (params, callback) { + var data = []; + var self = this; + + var $options = this.$element.children(); + + $options.each(function () { + var $option = $(this); + + if (!$option.is('option') && !$option.is('optgroup')) { + return; + } + + var option = self.item($option); + + var matches = self.matches(params, option); + + if (matches !== null) { + data.push(matches); + } + }); + + callback({ + results: data + }); + }; + + SelectAdapter.prototype.addOptions = function ($options) { + Utils.appendMany(this.$element, $options); + }; + + SelectAdapter.prototype.option = function (data) { + var option; + + if (data.children) { + option = document.createElement('optgroup'); + option.label = data.text; + } else { + option = document.createElement('option'); + + if (option.textContent !== undefined) { + option.textContent = data.text; + } else { + option.innerText = data.text; + } + } + + if (data.id !== undefined) { + option.value = data.id; + } + + if (data.disabled) { + option.disabled = true; + } + + if (data.selected) { + option.selected = true; + } + + if (data.title) { + option.title = data.title; + } + + var $option = $(option); + + var normalizedData = this._normalizeItem(data); + normalizedData.element = option; + + // Override the option's data with the combined data + Utils.StoreData(option, 'data', normalizedData); + + return $option; + }; + + SelectAdapter.prototype.item = function ($option) { + var data = {}; + + data = Utils.GetData($option[0], 'data'); + + if (data != null) { + return data; + } + + if ($option.is('option')) { + data = { + id: $option.val(), + text: $option.text(), + disabled: $option.prop('disabled'), + selected: $option.prop('selected'), + title: $option.prop('title') + }; + } else if ($option.is('optgroup')) { + data = { + text: $option.prop('label'), + children: [], + title: $option.prop('title') + }; + + var $children = $option.children('option'); + var children = []; + + for (var c = 0; c < $children.length; c++) { + var $child = $($children[c]); + + var child = this.item($child); + + children.push(child); + } + + data.children = children; + } + + data = this._normalizeItem(data); + data.element = $option[0]; + + Utils.StoreData($option[0], 'data', data); + + return data; + }; + + SelectAdapter.prototype._normalizeItem = function (item) { + if (item !== Object(item)) { + item = { + id: item, + text: item + }; + } + + item = $.extend({}, { + text: '' + }, item); + + var defaults = { + selected: false, + disabled: false + }; + + if (item.id != null) { + item.id = item.id.toString(); + } + + if (item.text != null) { + item.text = item.text.toString(); + } + + if (item._resultId == null && item.id && this.container != null) { + item._resultId = this.generateResultId(this.container, item); + } + + return $.extend({}, defaults, item); + }; + + SelectAdapter.prototype.matches = function (params, data) { + var matcher = this.options.get('matcher'); + + return matcher(params, data); + }; + + return SelectAdapter; +}); + +S2.define('select2/data/array',[ + './select', + '../utils', + 'jquery' +], function (SelectAdapter, Utils, $) { + function ArrayAdapter ($element, options) { + var data = options.get('data') || []; + + ArrayAdapter.__super__.constructor.call(this, $element, options); + + this.addOptions(this.convertToOptions(data)); + } + + Utils.Extend(ArrayAdapter, SelectAdapter); + + ArrayAdapter.prototype.select = function (data) { + var $option = this.$element.find('option').filter(function (i, elm) { + return elm.value == data.id.toString(); + }); + + if ($option.length === 0) { + $option = this.option(data); + + this.addOptions($option); + } + + ArrayAdapter.__super__.select.call(this, data); + }; + + ArrayAdapter.prototype.convertToOptions = function (data) { + var self = this; + + var $existing = this.$element.find('option'); + var existingIds = $existing.map(function () { + return self.item($(this)).id; + }).get(); + + var $options = []; + + // Filter out all items except for the one passed in the argument + function onlyItem (item) { + return function () { + return $(this).val() == item.id; + }; + } + + for (var d = 0; d < data.length; d++) { + var item = this._normalizeItem(data[d]); + + // Skip items which were pre-loaded, only merge the data + if ($.inArray(item.id, existingIds) >= 0) { + var $existingOption = $existing.filter(onlyItem(item)); + + var existingData = this.item($existingOption); + var newData = $.extend(true, {}, item, existingData); + + var $newOption = this.option(newData); + + $existingOption.replaceWith($newOption); + + continue; + } + + var $option = this.option(item); + + if (item.children) { + var $children = this.convertToOptions(item.children); + + Utils.appendMany($option, $children); + } + + $options.push($option); + } + + return $options; + }; + + return ArrayAdapter; +}); + +S2.define('select2/data/ajax',[ + './array', + '../utils', + 'jquery' +], function (ArrayAdapter, Utils, $) { + function AjaxAdapter ($element, options) { + this.ajaxOptions = this._applyDefaults(options.get('ajax')); + + if (this.ajaxOptions.processResults != null) { + this.processResults = this.ajaxOptions.processResults; + } + + AjaxAdapter.__super__.constructor.call(this, $element, options); + } + + Utils.Extend(AjaxAdapter, ArrayAdapter); + + AjaxAdapter.prototype._applyDefaults = function (options) { + var defaults = { + data: function (params) { + return $.extend({}, params, { + q: params.term + }); + }, + transport: function (params, success, failure) { + var $request = $.ajax(params); + + $request.then(success); + $request.fail(failure); + + return $request; + } + }; + + return $.extend({}, defaults, options, true); + }; + + AjaxAdapter.prototype.processResults = function (results) { + return results; + }; + + AjaxAdapter.prototype.query = function (params, callback) { + var matches = []; + var self = this; + + if (this._request != null) { + // JSONP requests cannot always be aborted + if ($.isFunction(this._request.abort)) { + this._request.abort(); + } + + this._request = null; + } + + var options = $.extend({ + type: 'GET' + }, this.ajaxOptions); + + if (typeof options.url === 'function') { + options.url = options.url.call(this.$element, params); + } + + if (typeof options.data === 'function') { + options.data = options.data.call(this.$element, params); + } + + function request () { + var $request = options.transport(options, function (data) { + var results = self.processResults(data, params); + + if (self.options.get('debug') && window.console && console.error) { + // Check to make sure that the response included a `results` key. + if (!results || !results.results || !$.isArray(results.results)) { + console.error( + 'Select2: The AJAX results did not return an array in the ' + + '`results` key of the response.' + ); + } + } + + callback(results); + }, function () { + // Attempt to detect if a request was aborted + // Only works if the transport exposes a status property + if ('status' in $request && + ($request.status === 0 || $request.status === '0')) { + return; + } + + self.trigger('results:message', { + message: 'errorLoading' + }); + }); + + self._request = $request; + } + + if (this.ajaxOptions.delay && params.term != null) { + if (this._queryTimeout) { + window.clearTimeout(this._queryTimeout); + } + + this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay); + } else { + request(); + } + }; + + return AjaxAdapter; +}); + +S2.define('select2/data/tags',[ + 'jquery' +], function ($) { + function Tags (decorated, $element, options) { + var tags = options.get('tags'); + + var createTag = options.get('createTag'); + + if (createTag !== undefined) { + this.createTag = createTag; + } + + var insertTag = options.get('insertTag'); + + if (insertTag !== undefined) { + this.insertTag = insertTag; + } + + decorated.call(this, $element, options); + + if ($.isArray(tags)) { + for (var t = 0; t < tags.length; t++) { + var tag = tags[t]; + var item = this._normalizeItem(tag); + + var $option = this.option(item); + + this.$element.append($option); + } + } + } + + Tags.prototype.query = function (decorated, params, callback) { + var self = this; + + this._removeOldTags(); + + if (params.term == null || params.page != null) { + decorated.call(this, params, callback); + return; + } + + function wrapper (obj, child) { + var data = obj.results; + + for (var i = 0; i < data.length; i++) { + var option = data[i]; + + var checkChildren = ( + option.children != null && + !wrapper({ + results: option.children + }, true) + ); + + var optionText = (option.text || '').toUpperCase(); + var paramsTerm = (params.term || '').toUpperCase(); + + var checkText = optionText === paramsTerm; + + if (checkText || checkChildren) { + if (child) { + return false; + } + + obj.data = data; + callback(obj); + + return; + } + } + + if (child) { + return true; + } + + var tag = self.createTag(params); + + if (tag != null) { + var $option = self.option(tag); + $option.attr('data-select2-tag', true); + + self.addOptions([$option]); + + self.insertTag(data, tag); + } + + obj.results = data; + + callback(obj); + } + + decorated.call(this, params, wrapper); + }; + + Tags.prototype.createTag = function (decorated, params) { + var term = $.trim(params.term); + + if (term === '') { + return null; + } + + return { + id: term, + text: term + }; + }; + + Tags.prototype.insertTag = function (_, data, tag) { + data.unshift(tag); + }; + + Tags.prototype._removeOldTags = function (_) { + var tag = this._lastTag; + + var $options = this.$element.find('option[data-select2-tag]'); + + $options.each(function () { + if (this.selected) { + return; + } + + $(this).remove(); + }); + }; + + return Tags; +}); + +S2.define('select2/data/tokenizer',[ + 'jquery' +], function ($) { + function Tokenizer (decorated, $element, options) { + var tokenizer = options.get('tokenizer'); + + if (tokenizer !== undefined) { + this.tokenizer = tokenizer; + } + + decorated.call(this, $element, options); + } + + Tokenizer.prototype.bind = function (decorated, container, $container) { + decorated.call(this, container, $container); + + this.$search = container.dropdown.$search || container.selection.$search || + $container.find('.select2-search__field'); + }; + + Tokenizer.prototype.query = function (decorated, params, callback) { + var self = this; + + function createAndSelect (data) { + // Normalize the data object so we can use it for checks + var item = self._normalizeItem(data); + + // Check if the data object already exists as a tag + // Select it if it doesn't + var $existingOptions = self.$element.find('option').filter(function () { + return $(this).val() === item.id; + }); + + // If an existing option wasn't found for it, create the option + if (!$existingOptions.length) { + var $option = self.option(item); + $option.attr('data-select2-tag', true); + + self._removeOldTags(); + self.addOptions([$option]); + } + + // Select the item, now that we know there is an option for it + select(item); + } + + function select (data) { + self.trigger('select', { + data: data + }); + } + + params.term = params.term || ''; + + var tokenData = this.tokenizer(params, this.options, createAndSelect); + + if (tokenData.term !== params.term) { + // Replace the search term if we have the search box + if (this.$search.length) { + this.$search.val(tokenData.term); + this.$search.focus(); + } + + params.term = tokenData.term; + } + + decorated.call(this, params, callback); + }; + + Tokenizer.prototype.tokenizer = function (_, params, options, callback) { + var separators = options.get('tokenSeparators') || []; + var term = params.term; + var i = 0; + + var createTag = this.createTag || function (params) { + return { + id: params.term, + text: params.term + }; + }; + + while (i < term.length) { + var termChar = term[i]; + + if ($.inArray(termChar, separators) === -1) { + i++; + + continue; + } + + var part = term.substr(0, i); + var partParams = $.extend({}, params, { + term: part + }); + + var data = createTag(partParams); + + if (data == null) { + i++; + continue; + } + + callback(data); + + // Reset the term to not include the tokenized portion + term = term.substr(i + 1) || ''; + i = 0; + } + + return { + term: term + }; + }; + + return Tokenizer; +}); + +S2.define('select2/data/minimumInputLength',[ + +], function () { + function MinimumInputLength (decorated, $e, options) { + this.minimumInputLength = options.get('minimumInputLength'); + + decorated.call(this, $e, options); + } + + MinimumInputLength.prototype.query = function (decorated, params, callback) { + params.term = params.term || ''; + + if (params.term.length < this.minimumInputLength) { + this.trigger('results:message', { + message: 'inputTooShort', + args: { + minimum: this.minimumInputLength, + input: params.term, + params: params + } + }); + + return; + } + + decorated.call(this, params, callback); + }; + + return MinimumInputLength; +}); + +S2.define('select2/data/maximumInputLength',[ + +], function () { + function MaximumInputLength (decorated, $e, options) { + this.maximumInputLength = options.get('maximumInputLength'); + + decorated.call(this, $e, options); + } + + MaximumInputLength.prototype.query = function (decorated, params, callback) { + params.term = params.term || ''; + + if (this.maximumInputLength > 0 && + params.term.length > this.maximumInputLength) { + this.trigger('results:message', { + message: 'inputTooLong', + args: { + maximum: this.maximumInputLength, + input: params.term, + params: params + } + }); + + return; + } + + decorated.call(this, params, callback); + }; + + return MaximumInputLength; +}); + +S2.define('select2/data/maximumSelectionLength',[ + +], function (){ + function MaximumSelectionLength (decorated, $e, options) { + this.maximumSelectionLength = options.get('maximumSelectionLength'); + + decorated.call(this, $e, options); + } + + MaximumSelectionLength.prototype.query = + function (decorated, params, callback) { + var self = this; + + this.current(function (currentData) { + var count = currentData != null ? currentData.length : 0; + if (self.maximumSelectionLength > 0 && + count >= self.maximumSelectionLength) { + self.trigger('results:message', { + message: 'maximumSelected', + args: { + maximum: self.maximumSelectionLength + } + }); + return; + } + decorated.call(self, params, callback); + }); + }; + + return MaximumSelectionLength; +}); + +S2.define('select2/dropdown',[ + 'jquery', + './utils' +], function ($, Utils) { + function Dropdown ($element, options) { + this.$element = $element; + this.options = options; + + Dropdown.__super__.constructor.call(this); + } + + Utils.Extend(Dropdown, Utils.Observable); + + Dropdown.prototype.render = function () { + var $dropdown = $( + '' + + '' + + '' + ); + + $dropdown.attr('dir', this.options.get('dir')); + + this.$dropdown = $dropdown; + + return $dropdown; + }; + + Dropdown.prototype.bind = function () { + // Should be implemented in subclasses + }; + + Dropdown.prototype.position = function ($dropdown, $container) { + // Should be implemented in subclasses + }; + + Dropdown.prototype.destroy = function () { + // Remove the dropdown from the DOM + this.$dropdown.remove(); + }; + + return Dropdown; +}); + +S2.define('select2/dropdown/search',[ + 'jquery', + '../utils' +], function ($, Utils) { + function Search () { } + + Search.prototype.render = function (decorated) { + var $rendered = decorated.call(this); + + var $search = $( + '' + + '' + + '' + ); + + this.$searchContainer = $search; + this.$search = $search.find('input'); + + $rendered.prepend($search); + + return $rendered; + }; + + Search.prototype.bind = function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + this.$search.on('keydown', function (evt) { + self.trigger('keypress', evt); + + self._keyUpPrevented = evt.isDefaultPrevented(); + }); + + // Workaround for browsers which do not support the `input` event + // This will prevent double-triggering of events for browsers which support + // both the `keyup` and `input` events. + this.$search.on('input', function (evt) { + // Unbind the duplicated `keyup` event + $(this).off('keyup'); + }); + + this.$search.on('keyup input', function (evt) { + self.handleSearch(evt); + }); + + container.on('open', function () { + self.$search.attr('tabindex', 0); + + self.$search.focus(); + + window.setTimeout(function () { + self.$search.focus(); + }, 0); + }); + + container.on('close', function () { + self.$search.attr('tabindex', -1); + + self.$search.val(''); + self.$search.blur(); + }); + + container.on('focus', function () { + if (!container.isOpen()) { + self.$search.focus(); + } + }); + + container.on('results:all', function (params) { + if (params.query.term == null || params.query.term === '') { + var showSearch = self.showSearch(params); + + if (showSearch) { + self.$searchContainer.removeClass('select2-search--hide'); + } else { + self.$searchContainer.addClass('select2-search--hide'); + } + } + }); + }; + + Search.prototype.handleSearch = function (evt) { + if (!this._keyUpPrevented) { + var input = this.$search.val(); + + this.trigger('query', { + term: input + }); + } + + this._keyUpPrevented = false; + }; + + Search.prototype.showSearch = function (_, params) { + return true; + }; + + return Search; +}); + +S2.define('select2/dropdown/hidePlaceholder',[ + +], function () { + function HidePlaceholder (decorated, $element, options, dataAdapter) { + this.placeholder = this.normalizePlaceholder(options.get('placeholder')); + + decorated.call(this, $element, options, dataAdapter); + } + + HidePlaceholder.prototype.append = function (decorated, data) { + data.results = this.removePlaceholder(data.results); + + decorated.call(this, data); + }; + + HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) { + if (typeof placeholder === 'string') { + placeholder = { + id: '', + text: placeholder + }; + } + + return placeholder; + }; + + HidePlaceholder.prototype.removePlaceholder = function (_, data) { + var modifiedData = data.slice(0); + + for (var d = data.length - 1; d >= 0; d--) { + var item = data[d]; + + if (this.placeholder.id === item.id) { + modifiedData.splice(d, 1); + } + } + + return modifiedData; + }; + + return HidePlaceholder; +}); + +S2.define('select2/dropdown/infiniteScroll',[ + 'jquery' +], function ($) { + function InfiniteScroll (decorated, $element, options, dataAdapter) { + this.lastParams = {}; + + decorated.call(this, $element, options, dataAdapter); + + this.$loadingMore = this.createLoadingMore(); + this.loading = false; + } + + InfiniteScroll.prototype.append = function (decorated, data) { + this.$loadingMore.remove(); + this.loading = false; + + decorated.call(this, data); + + if (this.showLoadingMore(data)) { + this.$results.append(this.$loadingMore); + } + }; + + InfiniteScroll.prototype.bind = function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + container.on('query', function (params) { + self.lastParams = params; + self.loading = true; + }); + + container.on('query:append', function (params) { + self.lastParams = params; + self.loading = true; + }); + + this.$results.on('scroll', function () { + var isLoadMoreVisible = $.contains( + document.documentElement, + self.$loadingMore[0] + ); + + if (self.loading || !isLoadMoreVisible) { + return; + } + + var currentOffset = self.$results.offset().top + + self.$results.outerHeight(false); + var loadingMoreOffset = self.$loadingMore.offset().top + + self.$loadingMore.outerHeight(false); + + if (currentOffset + 50 >= loadingMoreOffset) { + self.loadMore(); + } + }); + }; + + InfiniteScroll.prototype.loadMore = function () { + this.loading = true; + + var params = $.extend({}, {page: 1}, this.lastParams); + + params.page++; + + this.trigger('query:append', params); + }; + + InfiniteScroll.prototype.showLoadingMore = function (_, data) { + return data.pagination && data.pagination.more; + }; + + InfiniteScroll.prototype.createLoadingMore = function () { + var $option = $( + '
                          • ' + ); + + var message = this.options.get('translations').get('loadingMore'); + + $option.html(message(this.lastParams)); + + return $option; + }; + + return InfiniteScroll; +}); + +S2.define('select2/dropdown/attachBody',[ + 'jquery', + '../utils' +], function ($, Utils) { + function AttachBody (decorated, $element, options) { + this.$dropdownParent = options.get('dropdownParent') || $(document.body); + + decorated.call(this, $element, options); + } + + AttachBody.prototype.bind = function (decorated, container, $container) { + var self = this; + + var setupResultsEvents = false; + + decorated.call(this, container, $container); + + container.on('open', function () { + self._showDropdown(); + self._attachPositioningHandler(container); + + if (!setupResultsEvents) { + setupResultsEvents = true; + + container.on('results:all', function () { + self._positionDropdown(); + self._resizeDropdown(); + }); + + container.on('results:append', function () { + self._positionDropdown(); + self._resizeDropdown(); + }); + } + }); + + container.on('close', function () { + self._hideDropdown(); + self._detachPositioningHandler(container); + }); + + this.$dropdownContainer.on('mousedown', function (evt) { + evt.stopPropagation(); + }); + }; + + AttachBody.prototype.destroy = function (decorated) { + decorated.call(this); + + this.$dropdownContainer.remove(); + }; + + AttachBody.prototype.position = function (decorated, $dropdown, $container) { + // Clone all of the container classes + $dropdown.attr('class', $container.attr('class')); + + $dropdown.removeClass('select2'); + $dropdown.addClass('select2-container--open'); + + $dropdown.css({ + position: 'absolute', + top: -999999 + }); + + this.$container = $container; + }; + + AttachBody.prototype.render = function (decorated) { + var $container = $(''); + + var $dropdown = decorated.call(this); + $container.append($dropdown); + + this.$dropdownContainer = $container; + + return $container; + }; + + AttachBody.prototype._hideDropdown = function (decorated) { + this.$dropdownContainer.detach(); + }; + + AttachBody.prototype._attachPositioningHandler = + function (decorated, container) { + var self = this; + + var scrollEvent = 'scroll.select2.' + container.id; + var resizeEvent = 'resize.select2.' + container.id; + var orientationEvent = 'orientationchange.select2.' + container.id; + + var $watchers = this.$container.parents().filter(Utils.hasScroll); + $watchers.each(function () { + Utils.StoreData(this, 'select2-scroll-position', { + x: $(this).scrollLeft(), + y: $(this).scrollTop() + }); + }); + + $watchers.on(scrollEvent, function (ev) { + var position = Utils.GetData(this, 'select2-scroll-position'); + $(this).scrollTop(position.y); + }); + + $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent, + function (e) { + self._positionDropdown(); + self._resizeDropdown(); + }); + }; + + AttachBody.prototype._detachPositioningHandler = + function (decorated, container) { + var scrollEvent = 'scroll.select2.' + container.id; + var resizeEvent = 'resize.select2.' + container.id; + var orientationEvent = 'orientationchange.select2.' + container.id; + + var $watchers = this.$container.parents().filter(Utils.hasScroll); + $watchers.off(scrollEvent); + + $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent); + }; + + AttachBody.prototype._positionDropdown = function () { + var $window = $(window); + + var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above'); + var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below'); + + var newDirection = null; + + var offset = this.$container.offset(); + + offset.bottom = offset.top + this.$container.outerHeight(false); + + var container = { + height: this.$container.outerHeight(false) + }; + + container.top = offset.top; + container.bottom = offset.top + container.height; + + var dropdown = { + height: this.$dropdown.outerHeight(false) + }; + + var viewport = { + top: $window.scrollTop(), + bottom: $window.scrollTop() + $window.height() + }; + + var enoughRoomAbove = viewport.top < (offset.top - dropdown.height); + var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height); + + var css = { + left: offset.left, + top: container.bottom + }; + + // Determine what the parent element is to use for calculating the offset + var $offsetParent = this.$dropdownParent; + + // For statically positioned elements, we need to get the element + // that is determining the offset + if ($offsetParent.css('position') === 'static') { + $offsetParent = $offsetParent.offsetParent(); + } + + var parentOffset = $offsetParent.offset(); + + css.top -= parentOffset.top; + css.left -= parentOffset.left; + + if (!isCurrentlyAbove && !isCurrentlyBelow) { + newDirection = 'below'; + } + + if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) { + newDirection = 'above'; + } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) { + newDirection = 'below'; + } + + if (newDirection == 'above' || + (isCurrentlyAbove && newDirection !== 'below')) { + css.top = container.top - parentOffset.top - dropdown.height; + } + + if (newDirection != null) { + this.$dropdown + .removeClass('select2-dropdown--below select2-dropdown--above') + .addClass('select2-dropdown--' + newDirection); + this.$container + .removeClass('select2-container--below select2-container--above') + .addClass('select2-container--' + newDirection); + } + + this.$dropdownContainer.css(css); + }; + + AttachBody.prototype._resizeDropdown = function () { + var css = { + width: this.$container.outerWidth(false) + 'px' + }; + + if (this.options.get('dropdownAutoWidth')) { + css.minWidth = css.width; + css.position = 'relative'; + css.width = 'auto'; + } + + this.$dropdown.css(css); + }; + + AttachBody.prototype._showDropdown = function (decorated) { + this.$dropdownContainer.appendTo(this.$dropdownParent); + + this._positionDropdown(); + this._resizeDropdown(); + }; + + return AttachBody; +}); + +S2.define('select2/dropdown/minimumResultsForSearch',[ + +], function () { + function countResults (data) { + var count = 0; + + for (var d = 0; d < data.length; d++) { + var item = data[d]; + + if (item.children) { + count += countResults(item.children); + } else { + count++; + } + } + + return count; + } + + function MinimumResultsForSearch (decorated, $element, options, dataAdapter) { + this.minimumResultsForSearch = options.get('minimumResultsForSearch'); + + if (this.minimumResultsForSearch < 0) { + this.minimumResultsForSearch = Infinity; + } + + decorated.call(this, $element, options, dataAdapter); + } + + MinimumResultsForSearch.prototype.showSearch = function (decorated, params) { + if (countResults(params.data.results) < this.minimumResultsForSearch) { + return false; + } + + return decorated.call(this, params); + }; + + return MinimumResultsForSearch; +}); + +S2.define('select2/dropdown/selectOnClose',[ + '../utils' +], function (Utils) { + function SelectOnClose () { } + + SelectOnClose.prototype.bind = function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + container.on('close', function (params) { + self._handleSelectOnClose(params); + }); + }; + + SelectOnClose.prototype._handleSelectOnClose = function (_, params) { + if (params && params.originalSelect2Event != null) { + var event = params.originalSelect2Event; + + // Don't select an item if the close event was triggered from a select or + // unselect event + if (event._type === 'select' || event._type === 'unselect') { + return; + } + } + + var $highlightedResults = this.getHighlightedResults(); + + // Only select highlighted results + if ($highlightedResults.length < 1) { + return; + } + + var data = Utils.GetData($highlightedResults[0], 'data'); + + // Don't re-select already selected resulte + if ( + (data.element != null && data.element.selected) || + (data.element == null && data.selected) + ) { + return; + } + + this.trigger('select', { + data: data + }); + }; + + return SelectOnClose; +}); + +S2.define('select2/dropdown/closeOnSelect',[ + +], function () { + function CloseOnSelect () { } + + CloseOnSelect.prototype.bind = function (decorated, container, $container) { + var self = this; + + decorated.call(this, container, $container); + + container.on('select', function (evt) { + self._selectTriggered(evt); + }); + + container.on('unselect', function (evt) { + self._selectTriggered(evt); + }); + }; + + CloseOnSelect.prototype._selectTriggered = function (_, evt) { + var originalEvent = evt.originalEvent; + + // Don't close if the control key is being held + if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) { + return; + } + + this.trigger('close', { + originalEvent: originalEvent, + originalSelect2Event: evt + }); + }; + + return CloseOnSelect; +}); + +S2.define('select2/i18n/en',[],function () { + // English + return { + errorLoading: function () { + return 'The results could not be loaded.'; + }, + inputTooLong: function (args) { + var overChars = args.input.length - args.maximum; + + var message = 'Please delete ' + overChars + ' character'; + + if (overChars != 1) { + message += 's'; + } + + return message; + }, + inputTooShort: function (args) { + var remainingChars = args.minimum - args.input.length; + + var message = 'Please enter ' + remainingChars + ' or more characters'; + + return message; + }, + loadingMore: function () { + return 'Loading more results…'; + }, + maximumSelected: function (args) { + var message = 'You can only select ' + args.maximum + ' item'; + + if (args.maximum != 1) { + message += 's'; + } + + return message; + }, + noResults: function () { + return 'No results found'; + }, + searching: function () { + return 'Searching…'; + }, + removeAllItems: function () { + return 'Remove all items'; + } + }; +}); + +S2.define('select2/defaults',[ + 'jquery', + 'require', + + './results', + + './selection/single', + './selection/multiple', + './selection/placeholder', + './selection/allowClear', + './selection/search', + './selection/eventRelay', + + './utils', + './translation', + './diacritics', + + './data/select', + './data/array', + './data/ajax', + './data/tags', + './data/tokenizer', + './data/minimumInputLength', + './data/maximumInputLength', + './data/maximumSelectionLength', + + './dropdown', + './dropdown/search', + './dropdown/hidePlaceholder', + './dropdown/infiniteScroll', + './dropdown/attachBody', + './dropdown/minimumResultsForSearch', + './dropdown/selectOnClose', + './dropdown/closeOnSelect', + + './i18n/en' +], function ($, require, + + ResultsList, + + SingleSelection, MultipleSelection, Placeholder, AllowClear, + SelectionSearch, EventRelay, + + Utils, Translation, DIACRITICS, + + SelectData, ArrayData, AjaxData, Tags, Tokenizer, + MinimumInputLength, MaximumInputLength, MaximumSelectionLength, + + Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll, + AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect, + + EnglishTranslation) { + function Defaults () { + this.reset(); + } + + Defaults.prototype.apply = function (options) { + options = $.extend(true, {}, this.defaults, options); + + if (options.dataAdapter == null) { + if (options.ajax != null) { + options.dataAdapter = AjaxData; + } else if (options.data != null) { + options.dataAdapter = ArrayData; + } else { + options.dataAdapter = SelectData; + } + + if (options.minimumInputLength > 0) { + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + MinimumInputLength + ); + } + + if (options.maximumInputLength > 0) { + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + MaximumInputLength + ); + } + + if (options.maximumSelectionLength > 0) { + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + MaximumSelectionLength + ); + } + + if (options.tags) { + options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags); + } + + if (options.tokenSeparators != null || options.tokenizer != null) { + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + Tokenizer + ); + } + + if (options.query != null) { + var Query = require(options.amdBase + 'compat/query'); + + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + Query + ); + } + + if (options.initSelection != null) { + var InitSelection = require(options.amdBase + 'compat/initSelection'); + + options.dataAdapter = Utils.Decorate( + options.dataAdapter, + InitSelection + ); + } + } + + if (options.resultsAdapter == null) { + options.resultsAdapter = ResultsList; + + if (options.ajax != null) { + options.resultsAdapter = Utils.Decorate( + options.resultsAdapter, + InfiniteScroll + ); + } + + if (options.placeholder != null) { + options.resultsAdapter = Utils.Decorate( + options.resultsAdapter, + HidePlaceholder + ); + } + + if (options.selectOnClose) { + options.resultsAdapter = Utils.Decorate( + options.resultsAdapter, + SelectOnClose + ); + } + } + + if (options.dropdownAdapter == null) { + if (options.multiple) { + options.dropdownAdapter = Dropdown; + } else { + var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch); + + options.dropdownAdapter = SearchableDropdown; + } + + if (options.minimumResultsForSearch !== 0) { + options.dropdownAdapter = Utils.Decorate( + options.dropdownAdapter, + MinimumResultsForSearch + ); + } + + if (options.closeOnSelect) { + options.dropdownAdapter = Utils.Decorate( + options.dropdownAdapter, + CloseOnSelect + ); + } + + if ( + options.dropdownCssClass != null || + options.dropdownCss != null || + options.adaptDropdownCssClass != null + ) { + var DropdownCSS = require(options.amdBase + 'compat/dropdownCss'); + + options.dropdownAdapter = Utils.Decorate( + options.dropdownAdapter, + DropdownCSS + ); + } + + options.dropdownAdapter = Utils.Decorate( + options.dropdownAdapter, + AttachBody + ); + } + + if (options.selectionAdapter == null) { + if (options.multiple) { + options.selectionAdapter = MultipleSelection; + } else { + options.selectionAdapter = SingleSelection; + } + + // Add the placeholder mixin if a placeholder was specified + if (options.placeholder != null) { + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + Placeholder + ); + } + + if (options.allowClear) { + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + AllowClear + ); + } + + if (options.multiple) { + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + SelectionSearch + ); + } + + if ( + options.containerCssClass != null || + options.containerCss != null || + options.adaptContainerCssClass != null + ) { + var ContainerCSS = require(options.amdBase + 'compat/containerCss'); + + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + ContainerCSS + ); + } + + options.selectionAdapter = Utils.Decorate( + options.selectionAdapter, + EventRelay + ); + } + + if (typeof options.language === 'string') { + // Check if the language is specified with a region + if (options.language.indexOf('-') > 0) { + // Extract the region information if it is included + var languageParts = options.language.split('-'); + var baseLanguage = languageParts[0]; + + options.language = [options.language, baseLanguage]; + } else { + options.language = [options.language]; + } + } + + if ($.isArray(options.language)) { + var languages = new Translation(); + options.language.push('en'); + + var languageNames = options.language; + + for (var l = 0; l < languageNames.length; l++) { + var name = languageNames[l]; + var language = {}; + + try { + // Try to load it with the original name + language = Translation.loadPath(name); + } catch (e) { + try { + // If we couldn't load it, check if it wasn't the full path + name = this.defaults.amdLanguageBase + name; + language = Translation.loadPath(name); + } catch (ex) { + // The translation could not be loaded at all. Sometimes this is + // because of a configuration problem, other times this can be + // because of how Select2 helps load all possible translation files. + if (options.debug && window.console && console.warn) { + console.warn( + 'Select2: The language file for "' + name + '" could not be ' + + 'automatically loaded. A fallback will be used instead.' + ); + } + + continue; + } + } + + languages.extend(language); + } + + options.translations = languages; + } else { + var baseTranslation = Translation.loadPath( + this.defaults.amdLanguageBase + 'en' + ); + var customTranslation = new Translation(options.language); + + customTranslation.extend(baseTranslation); + + options.translations = customTranslation; + } + + return options; + }; + + Defaults.prototype.reset = function () { + function stripDiacritics (text) { + // Used 'uni range + named function' from http://jsperf.com/diacritics/18 + function match(a) { + return DIACRITICS[a] || a; + } + + return text.replace(/[^\u0000-\u007E]/g, match); + } + + function matcher (params, data) { + // Always return the object if there is nothing to compare + if ($.trim(params.term) === '') { + return data; + } + + // Do a recursive check for options with children + if (data.children && data.children.length > 0) { + // Clone the data object if there are children + // This is required as we modify the object to remove any non-matches + var match = $.extend(true, {}, data); + + // Check each child of the option + for (var c = data.children.length - 1; c >= 0; c--) { + var child = data.children[c]; + + var matches = matcher(params, child); + + // If there wasn't a match, remove the object in the array + if (matches == null) { + match.children.splice(c, 1); + } + } + + // If any children matched, return the new object + if (match.children.length > 0) { + return match; + } + + // If there were no matching children, check just the plain object + return matcher(params, match); + } + + var original = stripDiacritics(data.text).toUpperCase(); + var term = stripDiacritics(params.term).toUpperCase(); + + // Check if the text contains the term + if (original.indexOf(term) > -1) { + return data; + } + + // If it doesn't contain the term, don't return anything + return null; + } + + this.defaults = { + amdBase: './', + amdLanguageBase: './i18n/', + closeOnSelect: true, + debug: false, + dropdownAutoWidth: false, + escapeMarkup: Utils.escapeMarkup, + language: EnglishTranslation, + matcher: matcher, + minimumInputLength: 0, + maximumInputLength: 0, + maximumSelectionLength: 0, + minimumResultsForSearch: 0, + selectOnClose: false, + scrollAfterSelect: false, + sorter: function (data) { + return data; + }, + templateResult: function (result) { + return result.text; + }, + templateSelection: function (selection) { + return selection.text; + }, + theme: 'default', + width: 'resolve' + }; + }; + + Defaults.prototype.set = function (key, value) { + var camelKey = $.camelCase(key); + + var data = {}; + data[camelKey] = value; + + var convertedData = Utils._convertData(data); + + $.extend(true, this.defaults, convertedData); + }; + + var defaults = new Defaults(); + + return defaults; +}); + +S2.define('select2/options',[ + 'require', + 'jquery', + './defaults', + './utils' +], function (require, $, Defaults, Utils) { + function Options (options, $element) { + this.options = options; + + if ($element != null) { + this.fromElement($element); + } + + this.options = Defaults.apply(this.options); + + if ($element && $element.is('input')) { + var InputCompat = require(this.get('amdBase') + 'compat/inputData'); + + this.options.dataAdapter = Utils.Decorate( + this.options.dataAdapter, + InputCompat + ); + } + } + + Options.prototype.fromElement = function ($e) { + var excludedData = ['select2']; + + if (this.options.multiple == null) { + this.options.multiple = $e.prop('multiple'); + } + + if (this.options.disabled == null) { + this.options.disabled = $e.prop('disabled'); + } + + if (this.options.language == null) { + if ($e.prop('lang')) { + this.options.language = $e.prop('lang').toLowerCase(); + } else if ($e.closest('[lang]').prop('lang')) { + this.options.language = $e.closest('[lang]').prop('lang'); + } + } + + if (this.options.dir == null) { + if ($e.prop('dir')) { + this.options.dir = $e.prop('dir'); + } else if ($e.closest('[dir]').prop('dir')) { + this.options.dir = $e.closest('[dir]').prop('dir'); + } else { + this.options.dir = 'ltr'; + } + } + + $e.prop('disabled', this.options.disabled); + $e.prop('multiple', this.options.multiple); + + if (Utils.GetData($e[0], 'select2Tags')) { + if (this.options.debug && window.console && console.warn) { + console.warn( + 'Select2: The `data-select2-tags` attribute has been changed to ' + + 'use the `data-data` and `data-tags="true"` attributes and will be ' + + 'removed in future versions of Select2.' + ); + } + + Utils.StoreData($e[0], 'data', Utils.GetData($e[0], 'select2Tags')); + Utils.StoreData($e[0], 'tags', true); + } + + if (Utils.GetData($e[0], 'ajaxUrl')) { + if (this.options.debug && window.console && console.warn) { + console.warn( + 'Select2: The `data-ajax-url` attribute has been changed to ' + + '`data-ajax--url` and support for the old attribute will be removed' + + ' in future versions of Select2.' + ); + } + + $e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl')); + Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl')); + } + + var dataset = {}; + + function upperCaseLetter(_, letter) { + return letter.toUpperCase(); + } + + // Pre-load all of the attributes which are prefixed with `data-` + for (var attr = 0; attr < $e[0].attributes.length; attr++) { + var attributeName = $e[0].attributes[attr].name; + var prefix = 'data-'; + + if (attributeName.substr(0, prefix.length) == prefix) { + // Get the contents of the attribute after `data-` + var dataName = attributeName.substring(prefix.length); + + // Get the data contents from the consistent source + // This is more than likely the jQuery data helper + var dataValue = Utils.GetData($e[0], dataName); + + // camelCase the attribute name to match the spec + var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter); + + // Store the data attribute contents into the dataset since + dataset[camelDataName] = dataValue; + } + } + + // Prefer the element's `dataset` attribute if it exists + // jQuery 1.x does not correctly handle data attributes with multiple dashes + if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) { + dataset = $.extend(true, {}, $e[0].dataset, dataset); + } + + // Prefer our internal data cache if it exists + var data = $.extend(true, {}, Utils.GetData($e[0]), dataset); + + data = Utils._convertData(data); + + for (var key in data) { + if ($.inArray(key, excludedData) > -1) { + continue; + } + + if ($.isPlainObject(this.options[key])) { + $.extend(this.options[key], data[key]); + } else { + this.options[key] = data[key]; + } + } + + return this; + }; + + Options.prototype.get = function (key) { + return this.options[key]; + }; + + Options.prototype.set = function (key, val) { + this.options[key] = val; + }; + + return Options; +}); + +S2.define('select2/core',[ + 'jquery', + './options', + './utils', + './keys' +], function ($, Options, Utils, KEYS) { + var Select2 = function ($element, options) { + if (Utils.GetData($element[0], 'select2') != null) { + Utils.GetData($element[0], 'select2').destroy(); + } + + this.$element = $element; + + this.id = this._generateId($element); + + options = options || {}; + + this.options = new Options(options, $element); + + Select2.__super__.constructor.call(this); + + // Set up the tabindex + + var tabindex = $element.attr('tabindex') || 0; + Utils.StoreData($element[0], 'old-tabindex', tabindex); + $element.attr('tabindex', '-1'); + + // Set up containers and adapters + + var DataAdapter = this.options.get('dataAdapter'); + this.dataAdapter = new DataAdapter($element, this.options); + + var $container = this.render(); + + this._placeContainer($container); + + var SelectionAdapter = this.options.get('selectionAdapter'); + this.selection = new SelectionAdapter($element, this.options); + this.$selection = this.selection.render(); + + this.selection.position(this.$selection, $container); + + var DropdownAdapter = this.options.get('dropdownAdapter'); + this.dropdown = new DropdownAdapter($element, this.options); + this.$dropdown = this.dropdown.render(); + + this.dropdown.position(this.$dropdown, $container); + + var ResultsAdapter = this.options.get('resultsAdapter'); + this.results = new ResultsAdapter($element, this.options, this.dataAdapter); + this.$results = this.results.render(); + + this.results.position(this.$results, this.$dropdown); + + // Bind events + + var self = this; + + // Bind the container to all of the adapters + this._bindAdapters(); + + // Register any DOM event handlers + this._registerDomEvents(); + + // Register any internal event handlers + this._registerDataEvents(); + this._registerSelectionEvents(); + this._registerDropdownEvents(); + this._registerResultsEvents(); + this._registerEvents(); + + // Set the initial state + this.dataAdapter.current(function (initialData) { + self.trigger('selection:update', { + data: initialData + }); + }); + + // Hide the original select + $element.addClass('select2-hidden-accessible'); + $element.attr('aria-hidden', 'true'); + + // Synchronize any monitored attributes + this._syncAttributes(); + + Utils.StoreData($element[0], 'select2', this); + + // Ensure backwards compatibility with $element.data('select2'). + $element.data('select2', this); + }; + + Utils.Extend(Select2, Utils.Observable); + + Select2.prototype._generateId = function ($element) { + var id = ''; + + if ($element.attr('id') != null) { + id = $element.attr('id'); + } else if ($element.attr('name') != null) { + id = $element.attr('name') + '-' + Utils.generateChars(2); + } else { + id = Utils.generateChars(4); + } + + id = id.replace(/(:|\.|\[|\]|,)/g, ''); + id = 'select2-' + id; + + return id; + }; + + Select2.prototype._placeContainer = function ($container) { + $container.insertAfter(this.$element); + + var width = this._resolveWidth(this.$element, this.options.get('width')); + + if (width != null) { + $container.css('width', width); + } + }; + + Select2.prototype._resolveWidth = function ($element, method) { + var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i; + + if (method == 'resolve') { + var styleWidth = this._resolveWidth($element, 'style'); + + if (styleWidth != null) { + return styleWidth; + } + + return this._resolveWidth($element, 'element'); + } + + if (method == 'element') { + var elementWidth = $element.outerWidth(false); + + if (elementWidth <= 0) { + return 'auto'; + } + + return elementWidth + 'px'; + } + + if (method == 'style') { + var style = $element.attr('style'); + + if (typeof(style) !== 'string') { + return null; + } + + var attrs = style.split(';'); + + for (var i = 0, l = attrs.length; i < l; i = i + 1) { + var attr = attrs[i].replace(/\s/g, ''); + var matches = attr.match(WIDTH); + + if (matches !== null && matches.length >= 1) { + return matches[1]; + } + } + + return null; + } + + return method; + }; + + Select2.prototype._bindAdapters = function () { + this.dataAdapter.bind(this, this.$container); + this.selection.bind(this, this.$container); + + this.dropdown.bind(this, this.$container); + this.results.bind(this, this.$container); + }; + + Select2.prototype._registerDomEvents = function () { + var self = this; + + this.$element.on('change.select2', function () { + self.dataAdapter.current(function (data) { + self.trigger('selection:update', { + data: data + }); + }); + }); + + this.$element.on('focus.select2', function (evt) { + self.trigger('focus', evt); + }); + + this._syncA = Utils.bind(this._syncAttributes, this); + this._syncS = Utils.bind(this._syncSubtree, this); + + if (this.$element[0].attachEvent) { + this.$element[0].attachEvent('onpropertychange', this._syncA); + } + + var observer = window.MutationObserver || + window.WebKitMutationObserver || + window.MozMutationObserver + ; + + if (observer != null) { + this._observer = new observer(function (mutations) { + $.each(mutations, self._syncA); + $.each(mutations, self._syncS); + }); + this._observer.observe(this.$element[0], { + attributes: true, + childList: true, + subtree: false + }); + } else if (this.$element[0].addEventListener) { + this.$element[0].addEventListener( + 'DOMAttrModified', + self._syncA, + false + ); + this.$element[0].addEventListener( + 'DOMNodeInserted', + self._syncS, + false + ); + this.$element[0].addEventListener( + 'DOMNodeRemoved', + self._syncS, + false + ); + } + }; + + Select2.prototype._registerDataEvents = function () { + var self = this; + + this.dataAdapter.on('*', function (name, params) { + self.trigger(name, params); + }); + }; + + Select2.prototype._registerSelectionEvents = function () { + var self = this; + var nonRelayEvents = ['toggle', 'focus']; + + this.selection.on('toggle', function () { + self.toggleDropdown(); + }); + + this.selection.on('focus', function (params) { + self.focus(params); + }); + + this.selection.on('*', function (name, params) { + if ($.inArray(name, nonRelayEvents) !== -1) { + return; + } + + self.trigger(name, params); + }); + }; + + Select2.prototype._registerDropdownEvents = function () { + var self = this; + + this.dropdown.on('*', function (name, params) { + self.trigger(name, params); + }); + }; + + Select2.prototype._registerResultsEvents = function () { + var self = this; + + this.results.on('*', function (name, params) { + self.trigger(name, params); + }); + }; + + Select2.prototype._registerEvents = function () { + var self = this; + + this.on('open', function () { + self.$container.addClass('select2-container--open'); + }); + + this.on('close', function () { + self.$container.removeClass('select2-container--open'); + }); + + this.on('enable', function () { + self.$container.removeClass('select2-container--disabled'); + }); + + this.on('disable', function () { + self.$container.addClass('select2-container--disabled'); + }); + + this.on('blur', function () { + self.$container.removeClass('select2-container--focus'); + }); + + this.on('query', function (params) { + if (!self.isOpen()) { + self.trigger('open', {}); + } + + this.dataAdapter.query(params, function (data) { + self.trigger('results:all', { + data: data, + query: params + }); + }); + }); + + this.on('query:append', function (params) { + this.dataAdapter.query(params, function (data) { + self.trigger('results:append', { + data: data, + query: params + }); + }); + }); + + this.on('keypress', function (evt) { + var key = evt.which; + + if (self.isOpen()) { + if (key === KEYS.ESC || key === KEYS.TAB || + (key === KEYS.UP && evt.altKey)) { + self.close(); + + evt.preventDefault(); + } else if (key === KEYS.ENTER) { + self.trigger('results:select', {}); + + evt.preventDefault(); + } else if ((key === KEYS.SPACE && evt.ctrlKey)) { + self.trigger('results:toggle', {}); + + evt.preventDefault(); + } else if (key === KEYS.UP) { + self.trigger('results:previous', {}); + + evt.preventDefault(); + } else if (key === KEYS.DOWN) { + self.trigger('results:next', {}); + + evt.preventDefault(); + } + } else { + if (key === KEYS.ENTER || key === KEYS.SPACE || + (key === KEYS.DOWN && evt.altKey)) { + self.open(); + + evt.preventDefault(); + } + } + }); + }; + + Select2.prototype._syncAttributes = function () { + this.options.set('disabled', this.$element.prop('disabled')); + + if (this.options.get('disabled')) { + if (this.isOpen()) { + this.close(); + } + + this.trigger('disable', {}); + } else { + this.trigger('enable', {}); + } + }; + + Select2.prototype._syncSubtree = function (evt, mutations) { + var changed = false; + var self = this; + + // Ignore any mutation events raised for elements that aren't options or + // optgroups. This handles the case when the select element is destroyed + if ( + evt && evt.target && ( + evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP' + ) + ) { + return; + } + + if (!mutations) { + // If mutation events aren't supported, then we can only assume that the + // change affected the selections + changed = true; + } else if (mutations.addedNodes && mutations.addedNodes.length > 0) { + for (var n = 0; n < mutations.addedNodes.length; n++) { + var node = mutations.addedNodes[n]; + + if (node.selected) { + changed = true; + } + } + } else if (mutations.removedNodes && mutations.removedNodes.length > 0) { + changed = true; + } + + // Only re-pull the data if we think there is a change + if (changed) { + this.dataAdapter.current(function (currentData) { + self.trigger('selection:update', { + data: currentData + }); + }); + } + }; + + /** + * Override the trigger method to automatically trigger pre-events when + * there are events that can be prevented. + */ + Select2.prototype.trigger = function (name, args) { + var actualTrigger = Select2.__super__.trigger; + var preTriggerMap = { + 'open': 'opening', + 'close': 'closing', + 'select': 'selecting', + 'unselect': 'unselecting', + 'clear': 'clearing' + }; + + if (args === undefined) { + args = {}; + } + + if (name in preTriggerMap) { + var preTriggerName = preTriggerMap[name]; + var preTriggerArgs = { + prevented: false, + name: name, + args: args + }; + + actualTrigger.call(this, preTriggerName, preTriggerArgs); + + if (preTriggerArgs.prevented) { + args.prevented = true; + + return; + } + } + + actualTrigger.call(this, name, args); + }; + + Select2.prototype.toggleDropdown = function () { + if (this.options.get('disabled')) { + return; + } + + if (this.isOpen()) { + this.close(); + } else { + this.open(); + } + }; + + Select2.prototype.open = function () { + if (this.isOpen()) { + return; + } + + this.trigger('query', {}); + }; + + Select2.prototype.close = function () { + if (!this.isOpen()) { + return; + } + + this.trigger('close', {}); + }; + + Select2.prototype.isOpen = function () { + return this.$container.hasClass('select2-container--open'); + }; + + Select2.prototype.hasFocus = function () { + return this.$container.hasClass('select2-container--focus'); + }; + + Select2.prototype.focus = function (data) { + // No need to re-trigger focus events if we are already focused + if (this.hasFocus()) { + return; + } + + this.$container.addClass('select2-container--focus'); + this.trigger('focus', {}); + }; + + Select2.prototype.enable = function (args) { + if (this.options.get('debug') && window.console && console.warn) { + console.warn( + 'Select2: The `select2("enable")` method has been deprecated and will' + + ' be removed in later Select2 versions. Use $element.prop("disabled")' + + ' instead.' + ); + } + + if (args == null || args.length === 0) { + args = [true]; + } + + var disabled = !args[0]; + + this.$element.prop('disabled', disabled); + }; + + Select2.prototype.data = function () { + if (this.options.get('debug') && + arguments.length > 0 && window.console && console.warn) { + console.warn( + 'Select2: Data can no longer be set using `select2("data")`. You ' + + 'should consider setting the value instead using `$element.val()`.' + ); + } + + var data = []; + + this.dataAdapter.current(function (currentData) { + data = currentData; + }); + + return data; + }; + + Select2.prototype.val = function (args) { + if (this.options.get('debug') && window.console && console.warn) { + console.warn( + 'Select2: The `select2("val")` method has been deprecated and will be' + + ' removed in later Select2 versions. Use $element.val() instead.' + ); + } + + if (args == null || args.length === 0) { + return this.$element.val(); + } + + var newVal = args[0]; + + if ($.isArray(newVal)) { + newVal = $.map(newVal, function (obj) { + return obj.toString(); + }); + } + + this.$element.val(newVal).trigger('change'); + }; + + Select2.prototype.destroy = function () { + this.$container.remove(); + + if (this.$element[0].detachEvent) { + this.$element[0].detachEvent('onpropertychange', this._syncA); + } + + if (this._observer != null) { + this._observer.disconnect(); + this._observer = null; + } else if (this.$element[0].removeEventListener) { + this.$element[0] + .removeEventListener('DOMAttrModified', this._syncA, false); + this.$element[0] + .removeEventListener('DOMNodeInserted', this._syncS, false); + this.$element[0] + .removeEventListener('DOMNodeRemoved', this._syncS, false); + } + + this._syncA = null; + this._syncS = null; + + this.$element.off('.select2'); + this.$element.attr('tabindex', + Utils.GetData(this.$element[0], 'old-tabindex')); + + this.$element.removeClass('select2-hidden-accessible'); + this.$element.attr('aria-hidden', 'false'); + Utils.RemoveData(this.$element[0]); + this.$element.removeData('select2'); + + this.dataAdapter.destroy(); + this.selection.destroy(); + this.dropdown.destroy(); + this.results.destroy(); + + this.dataAdapter = null; + this.selection = null; + this.dropdown = null; + this.results = null; + }; + + Select2.prototype.render = function () { + var $container = $( + '' + + '' + + '' + + '' + ); + + $container.attr('dir', this.options.get('dir')); + + this.$container = $container; + + this.$container.addClass('select2-container--' + this.options.get('theme')); + + Utils.StoreData($container[0], 'element', this.$element); + + return $container; + }; + + return Select2; +}); + +S2.define('jquery-mousewheel',[ + 'jquery' +], function ($) { + // Used to shim jQuery.mousewheel for non-full builds. + return $; +}); + +S2.define('jquery.select2',[ + 'jquery', + 'jquery-mousewheel', + + './select2/core', + './select2/defaults', + './select2/utils' +], function ($, _, Select2, Defaults, Utils) { + if ($.fn.select2 == null) { + // All methods that should return the element + var thisMethods = ['open', 'close', 'destroy']; + + $.fn.select2 = function (options) { + options = options || {}; + + if (typeof options === 'object') { + this.each(function () { + var instanceOptions = $.extend(true, {}, options); + + var instance = new Select2($(this), instanceOptions); + }); + + return this; + } else if (typeof options === 'string') { + var ret; + var args = Array.prototype.slice.call(arguments, 1); + + this.each(function () { + var instance = Utils.GetData(this, 'select2'); + + if (instance == null && window.console && console.error) { + console.error( + 'The select2(\'' + options + '\') method was called on an ' + + 'element that is not using Select2.' + ); + } + + ret = instance[options].apply(instance, args); + }); + + // Check if we should be returning `this` + if ($.inArray(options, thisMethods) > -1) { + return this; + } + + return ret; + } else { + throw new Error('Invalid arguments for Select2: ' + options); + } + }; + } + + if ($.fn.select2.defaults == null) { + $.fn.select2.defaults = Defaults; + } + + return Select2; +}); + + // Return the AMD loader configuration so it can be used outside of this file + return { + define: S2.define, + require: S2.require + }; +}()); + + // Autoload the jQuery bindings + // We know that all of the modules exist above this, so we're safe + var select2 = S2.require('jquery.select2'); + + // Hold the AMD module references on the jQuery function that was just loaded + // This allows Select2 to use the internal loader outside of this file, such + // as in the language files. + jQuery.fn.select2.amd = S2; + + // Return the Select2 instance for anyone who is importing it. + return select2; +})); diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.min.css b/bmw-admin/src/main/resources/static/ajax/libs/select2/select2.min.css similarity index 99% rename from ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.min.css rename to bmw-admin/src/main/resources/static/ajax/libs/select2/select2.min.css index 446be676b..60d599044 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.min.css +++ b/bmw-admin/src/main/resources/static/ajax/libs/select2/select2.min.css @@ -1 +1 @@ -.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right;margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb} +.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right;margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb} diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.min.js b/bmw-admin/src/main/resources/static/ajax/libs/select2/select2.min.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/select2/select2.min.js rename to bmw-admin/src/main/resources/static/ajax/libs/select2/select2.min.js diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.css b/bmw-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.css similarity index 100% rename from ruoyi-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.css rename to bmw-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.css diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.js b/bmw-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.js similarity index 96% rename from ruoyi-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.js rename to bmw-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.js index 3ffcf50f7..03a0664c6 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.js +++ b/bmw-admin/src/main/resources/static/ajax/libs/staps/jquery.steps.js @@ -1,2042 +1,2042 @@ -/*! - * jQuery Steps v1.1.0 - 09/04/2014 - * Copyright (c) 2014 Rafael Staib (http://www.jquery-steps.com) - * Licensed under MIT http://www.opensource.org/licenses/MIT - */ -;(function ($, undefined) -{ -$.fn.extend({ - _aria: function (name, value) - { - return this.attr("aria-" + name, value); - }, - - _removeAria: function (name) - { - return this.removeAttr("aria-" + name); - }, - - _enableAria: function (enable) - { - return (enable == null || enable) ? - this.removeClass("disabled")._aria("disabled", "false") : - this.addClass("disabled")._aria("disabled", "true"); - }, - - _showAria: function (show) - { - return (show == null || show) ? - this.show()._aria("hidden", "false") : - this.hide()._aria("hidden", "true"); - }, - - _selectAria: function (select) - { - return (select == null || select) ? - this.addClass("current")._aria("selected", "true") : - this.removeClass("current")._aria("selected", "false"); - }, - - _id: function (id) - { - return (id) ? this.attr("id", id) : this.attr("id"); - } -}); - -if (!String.prototype.format) -{ - String.prototype.format = function() - { - var args = (arguments.length === 1 && $.isArray(arguments[0])) ? arguments[0] : arguments; - var formattedString = this; - for (var i = 0; i < args.length; i++) - { - var pattern = new RegExp("\\{" + i + "\\}", "gm"); - formattedString = formattedString.replace(pattern, args[i]); - } - return formattedString; - }; -} - -/** - * A global unique id count. - * - * @static - * @private - * @property _uniqueId - * @type Integer - **/ -var _uniqueId = 0; - -/** - * The plugin prefix for cookies. - * - * @final - * @private - * @property _cookiePrefix - * @type String - **/ -var _cookiePrefix = "jQu3ry_5teps_St@te_"; - -/** - * Suffix for the unique tab id. - * - * @final - * @private - * @property _tabSuffix - * @type String - * @since 0.9.7 - **/ -var _tabSuffix = "-t-"; - -/** - * Suffix for the unique tabpanel id. - * - * @final - * @private - * @property _tabpanelSuffix - * @type String - * @since 0.9.7 - **/ -var _tabpanelSuffix = "-p-"; - -/** - * Suffix for the unique title id. - * - * @final - * @private - * @property _titleSuffix - * @type String - * @since 0.9.7 - **/ -var _titleSuffix = "-h-"; - -/** - * An error message for an "index out of range" error. - * - * @final - * @private - * @property _indexOutOfRangeErrorMessage - * @type String - **/ -var _indexOutOfRangeErrorMessage = "Index out of range."; - -/** - * An error message for an "missing corresponding element" error. - * - * @final - * @private - * @property _missingCorrespondingElementErrorMessage - * @type String - **/ -var _missingCorrespondingElementErrorMessage = "One or more corresponding step {0} are missing."; - -/** - * Adds a step to the cache. - * - * @static - * @private - * @method addStepToCache - * @param wizard {Object} A jQuery wizard object - * @param step {Object} The step object to add - **/ -function addStepToCache(wizard, step) -{ - getSteps(wizard).push(step); -} - -function analyzeData(wizard, options, state) -{ - var stepTitles = wizard.children(options.headerTag), - stepContents = wizard.children(options.bodyTag); - - // Validate content - if (stepTitles.length > stepContents.length) - { - throwError(_missingCorrespondingElementErrorMessage, "contents"); - } - else if (stepTitles.length < stepContents.length) - { - throwError(_missingCorrespondingElementErrorMessage, "titles"); - } - - var startIndex = options.startIndex; - - state.stepCount = stepTitles.length; - - // Tries to load the saved state (step position) - if (options.saveState && $.cookie) - { - var savedState = $.cookie(_cookiePrefix + getUniqueId(wizard)); - // Sets the saved position to the start index if not undefined or out of range - var savedIndex = parseInt(savedState, 0); - if (!isNaN(savedIndex) && savedIndex < state.stepCount) - { - startIndex = savedIndex; - } - } - - state.currentIndex = startIndex; - - stepTitles.each(function (index) - { - var item = $(this), // item == header - content = stepContents.eq(index), - modeData = content.data("mode"), - mode = (modeData == null) ? contentMode.html : getValidEnumValue(contentMode, - (/^\s*$/.test(modeData) || isNaN(modeData)) ? modeData : parseInt(modeData, 0)), - contentUrl = (mode === contentMode.html || content.data("url") === undefined) ? - "" : content.data("url"), - contentLoaded = (mode !== contentMode.html && content.data("loaded") === "1"), - step = $.extend({}, stepModel, { - title: item.html(), - content: (mode === contentMode.html) ? content.html() : "", - contentUrl: contentUrl, - contentMode: mode, - contentLoaded: contentLoaded - }); - - addStepToCache(wizard, step); - }); -} - -/** - * Triggers the onCanceled event. - * - * @static - * @private - * @method cancel - * @param wizard {Object} The jQuery wizard object - **/ -function cancel(wizard) -{ - wizard.triggerHandler("canceled"); -} - -function decreaseCurrentIndexBy(state, decreaseBy) -{ - return state.currentIndex - decreaseBy; -} - -/** - * Removes the control functionality completely and transforms the current state to the initial HTML structure. - * - * @static - * @private - * @method destroy - * @param wizard {Object} A jQuery wizard object - **/ -function destroy(wizard, options) -{ - var eventNamespace = getEventNamespace(wizard); - - // Remove virtual data objects from the wizard - wizard.unbind(eventNamespace).removeData("uid").removeData("options") - .removeData("state").removeData("steps").removeData("eventNamespace") - .find(".actions a").unbind(eventNamespace); - - // Remove attributes and CSS classes from the wizard - wizard.removeClass(options.clearFixCssClass + " vertical"); - - var contents = wizard.find(".content > *"); - - // Remove virtual data objects from panels and their titles - contents.removeData("loaded").removeData("mode").removeData("url"); - - // Remove attributes, CSS classes and reset inline styles on all panels and their titles - contents.removeAttr("id").removeAttr("role").removeAttr("tabindex") - .removeAttr("class").removeAttr("style")._removeAria("labelledby") - ._removeAria("hidden"); - - // Empty panels if the mode is set to 'async' or 'iframe' - wizard.find(".content > [data-mode='async'],.content > [data-mode='iframe']").empty(); - - var wizardSubstitute = $("<{0} class=\"{1}\">".format(wizard.get(0).tagName, wizard.attr("class"))); - - var wizardId = wizard._id(); - if (wizardId != null && wizardId !== "") - { - wizardSubstitute._id(wizardId); - } - - wizardSubstitute.html(wizard.find(".content").html()); - wizard.after(wizardSubstitute); - wizard.remove(); - - return wizardSubstitute; -} - -/** - * Triggers the onFinishing and onFinished event. - * - * @static - * @private - * @method finishStep - * @param wizard {Object} The jQuery wizard object - * @param state {Object} The state container of the current wizard - **/ -function finishStep(wizard, state) -{ - var currentStep = wizard.find(".steps li").eq(state.currentIndex); - - if (wizard.triggerHandler("finishing", [state.currentIndex])) - { - currentStep.addClass("done").removeClass("error"); - wizard.triggerHandler("finished", [state.currentIndex]); - } - else - { - currentStep.addClass("error"); - } -} - -/** - * Gets or creates if not exist an unique event namespace for the given wizard instance. - * - * @static - * @private - * @method getEventNamespace - * @param wizard {Object} A jQuery wizard object - * @return {String} Returns the unique event namespace for the given wizard - */ -function getEventNamespace(wizard) -{ - var eventNamespace = wizard.data("eventNamespace"); - - if (eventNamespace == null) - { - eventNamespace = "." + getUniqueId(wizard); - wizard.data("eventNamespace", eventNamespace); - } - - return eventNamespace; -} - -function getStepAnchor(wizard, index) -{ - var uniqueId = getUniqueId(wizard); - - return wizard.find("#" + uniqueId + _tabSuffix + index); -} - -function getStepPanel(wizard, index) -{ - var uniqueId = getUniqueId(wizard); - - return wizard.find("#" + uniqueId + _tabpanelSuffix + index); -} - -function getStepTitle(wizard, index) -{ - var uniqueId = getUniqueId(wizard); - - return wizard.find("#" + uniqueId + _titleSuffix + index); -} - -function getOptions(wizard) -{ - return wizard.data("options"); -} - -function getState(wizard) -{ - return wizard.data("state"); -} - -function getSteps(wizard) -{ - return wizard.data("steps"); -} - -/** - * Gets a specific step object by index. - * - * @static - * @private - * @method getStep - * @param index {Integer} An integer that belongs to the position of a step - * @return {Object} A specific step object - **/ -function getStep(wizard, index) -{ - var steps = getSteps(wizard); - - if (index < 0 || index >= steps.length) - { - throwError(_indexOutOfRangeErrorMessage); - } - - return steps[index]; -} - -/** - * Gets or creates if not exist an unique id from the given wizard instance. - * - * @static - * @private - * @method getUniqueId - * @param wizard {Object} A jQuery wizard object - * @return {String} Returns the unique id for the given wizard - */ -function getUniqueId(wizard) -{ - var uniqueId = wizard.data("uid"); - - if (uniqueId == null) - { - uniqueId = wizard._id(); - if (uniqueId == null) - { - uniqueId = "steps-uid-".concat(_uniqueId); - wizard._id(uniqueId); - } - - _uniqueId++; - wizard.data("uid", uniqueId); - } - - return uniqueId; -} - -/** - * Gets a valid enum value by checking a specific enum key or value. - * - * @static - * @private - * @method getValidEnumValue - * @param enumType {Object} Type of enum - * @param keyOrValue {Object} Key as `String` or value as `Integer` to check for - */ -function getValidEnumValue(enumType, keyOrValue) -{ - validateArgument("enumType", enumType); - validateArgument("keyOrValue", keyOrValue); - - // Is key - if (typeof keyOrValue === "string") - { - var value = enumType[keyOrValue]; - if (value === undefined) - { - throwError("The enum key '{0}' does not exist.", keyOrValue); - } - - return value; - } - // Is value - else if (typeof keyOrValue === "number") - { - for (var key in enumType) - { - if (enumType[key] === keyOrValue) - { - return keyOrValue; - } - } - - throwError("Invalid enum value '{0}'.", keyOrValue); - } - // Type is not supported - else - { - throwError("Invalid key or value type."); - } -} - -/** - * Routes to the next step. - * - * @static - * @private - * @method goToNextStep - * @param wizard {Object} The jQuery wizard object - * @param options {Object} Settings of the current wizard - * @param state {Object} The state container of the current wizard - * @return {Boolean} Indicates whether the action executed - **/ -function goToNextStep(wizard, options, state) -{ - return paginationClick(wizard, options, state, increaseCurrentIndexBy(state, 1)); -} - -/** - * Routes to the previous step. - * - * @static - * @private - * @method goToPreviousStep - * @param wizard {Object} The jQuery wizard object - * @param options {Object} Settings of the current wizard - * @param state {Object} The state container of the current wizard - * @return {Boolean} Indicates whether the action executed - **/ -function goToPreviousStep(wizard, options, state) -{ - return paginationClick(wizard, options, state, decreaseCurrentIndexBy(state, 1)); -} - -/** - * Routes to a specific step by a given index. - * - * @static - * @private - * @method goToStep - * @param wizard {Object} The jQuery wizard object - * @param options {Object} Settings of the current wizard - * @param state {Object} The state container of the current wizard - * @param index {Integer} The position (zero-based) to route to - * @return {Boolean} Indicates whether the action succeeded or failed - **/ -function goToStep(wizard, options, state, index) -{ - if (index < 0 || index >= state.stepCount) - { - throwError(_indexOutOfRangeErrorMessage); - } - - if (options.forceMoveForward && index < state.currentIndex) - { - return; - } - - var oldIndex = state.currentIndex; - if (wizard.triggerHandler("stepChanging", [state.currentIndex, index])) - { - // Save new state - state.currentIndex = index; - saveCurrentStateToCookie(wizard, options, state); - - // Change visualisation - refreshStepNavigation(wizard, options, state, oldIndex); - refreshPagination(wizard, options, state); - loadAsyncContent(wizard, options, state); - startTransitionEffect(wizard, options, state, index, oldIndex, function() - { - wizard.triggerHandler("stepChanged", [index, oldIndex]); - }); - } - else - { - wizard.find(".steps li").eq(oldIndex).addClass("error"); - } - - return true; -} - -function increaseCurrentIndexBy(state, increaseBy) -{ - return state.currentIndex + increaseBy; -} - -/** - * Initializes the component. - * - * @static - * @private - * @method initialize - * @param options {Object} The component settings - **/ -function initialize(options) -{ - /*jshint -W040 */ - var opts = $.extend(true, {}, defaults, options); - - return this.each(function () - { - var wizard = $(this); - var state = { - currentIndex: opts.startIndex, - currentStep: null, - stepCount: 0, - transitionElement: null - }; - - // Create data container - wizard.data("options", opts); - wizard.data("state", state); - wizard.data("steps", []); - - analyzeData(wizard, opts, state); - render(wizard, opts, state); - registerEvents(wizard, opts); - - // Trigger focus - if (opts.autoFocus && _uniqueId === 0) - { - getStepAnchor(wizard, opts.startIndex).focus(); - } - - wizard.triggerHandler("init", [opts.startIndex]); - }); -} - -/** - * Inserts a new step to a specific position. - * - * @static - * @private - * @method insertStep - * @param wizard {Object} The jQuery wizard object - * @param options {Object} Settings of the current wizard - * @param state {Object} The state container of the current wizard - * @param index {Integer} The position (zero-based) to add - * @param step {Object} The step object to add - * @example - * $("#wizard").steps().insert(0, { - * title: "Title", - * content: "", // optional - * contentMode: "async", // optional - * contentUrl: "/Content/Step/1" // optional - * }); - * @chainable - **/ -function insertStep(wizard, options, state, index, step) -{ - if (index < 0 || index > state.stepCount) - { - throwError(_indexOutOfRangeErrorMessage); - } - - // TODO: Validate step object - - // Change data - step = $.extend({}, stepModel, step); - insertStepToCache(wizard, index, step); - if (state.currentIndex !== state.stepCount && state.currentIndex >= index) - { - state.currentIndex++; - saveCurrentStateToCookie(wizard, options, state); - } - state.stepCount++; - - var contentContainer = wizard.find(".content"), - header = $("<{0}>{1}".format(options.headerTag, step.title)), - body = $("<{0}>".format(options.bodyTag)); - - if (step.contentMode == null || step.contentMode === contentMode.html) - { - body.html(step.content); - } - - if (index === 0) - { - contentContainer.prepend(body).prepend(header); - } - else - { - getStepPanel(wizard, (index - 1)).after(body).after(header); - } - - renderBody(wizard, state, body, index); - renderTitle(wizard, options, state, header, index); - refreshSteps(wizard, options, state, index); - if (index === state.currentIndex) - { - refreshStepNavigation(wizard, options, state); - } - refreshPagination(wizard, options, state); - - return wizard; -} - -/** - * Inserts a step object to the cache at a specific position. - * - * @static - * @private - * @method insertStepToCache - * @param wizard {Object} A jQuery wizard object - * @param index {Integer} The position (zero-based) to add - * @param step {Object} The step object to add - **/ -function insertStepToCache(wizard, index, step) -{ - getSteps(wizard).splice(index, 0, step); -} - -/** - * Handles the keyup DOM event for pagination. - * - * @static - * @private - * @event keyup - * @param event {Object} An event object - */ -function keyUpHandler(event) -{ - var wizard = $(this), - options = getOptions(wizard), - state = getState(wizard); - - if (options.suppressPaginationOnFocus && wizard.find(":focus").is(":input")) - { - event.preventDefault(); - return false; - } - - var keyCodes = { left: 37, right: 39 }; - if (event.keyCode === keyCodes.left) - { - event.preventDefault(); - goToPreviousStep(wizard, options, state); - } - else if (event.keyCode === keyCodes.right) - { - event.preventDefault(); - goToNextStep(wizard, options, state); - } -} - -/** - * Loads and includes async content. - * - * @static - * @private - * @method loadAsyncContent - * @param wizard {Object} A jQuery wizard object - * @param options {Object} Settings of the current wizard - * @param state {Object} The state container of the current wizard - */ -function loadAsyncContent(wizard, options, state) -{ - if (state.stepCount > 0) - { - var currentIndex = state.currentIndex, - currentStep = getStep(wizard, currentIndex); - - if (!options.enableContentCache || !currentStep.contentLoaded) - { - switch (getValidEnumValue(contentMode, currentStep.contentMode)) - { - case contentMode.iframe: - wizard.find(".content > .body").eq(state.currentIndex).empty() - .html("'; - $('.mainContent').find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1); - - $.modal.loading("数据加载中,请稍后..."); - - $('.mainContent iframe:visible').load(function () { - $.modal.closeLoading(); - }); - - // 添加选项卡 - $('.menuTabs .page-tabs-content').append(str); - scrollToTab($('.menuTab.active')); - } - return false; - } - - function menuBlank() { - // 新窗口打开外网以http://开头,如http://ruoyi.vip - var dataUrl = $(this).attr('href'); - window.open(dataUrl); - return false; - } - - $('.menuItem').on('click', menuItem); - - $('.menuBlank').on('click', menuBlank); - - // 关闭选项卡菜单 - function closeTab() { - var closeTabId = $(this).parents('.menuTab').data('id'); - var currentWidth = $(this).parents('.menuTab').width(); - var panelUrl = $(this).parents('.menuTab').data('panel'); - // 当前元素处于活动状态 - if ($(this).parents('.menuTab').hasClass('active')) { - - // 当前元素后面有同辈元素,使后面的一个元素处于活动状态 - if ($(this).parents('.menuTab').next('.menuTab').size()) { - - var activeId = $(this).parents('.menuTab').next('.menuTab:eq(0)').data('id'); - $(this).parents('.menuTab').next('.menuTab:eq(0)').addClass('active'); - - $('.mainContent .RuoYi_iframe').each(function() { - if ($(this).data('id') == activeId) { - $(this).show().siblings('.RuoYi_iframe').hide(); - return false; - } - }); - - var marginLeftVal = parseInt($('.page-tabs-content').css('margin-left')); - if (marginLeftVal < 0) { - $('.page-tabs-content').animate({ - marginLeft: (marginLeftVal + currentWidth) + 'px' - }, - "fast"); - } - - // 移除当前选项卡 - $(this).parents('.menuTab').remove(); - - // 移除tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { - if ($(this).data('id') == closeTabId) { - $(this).remove(); - return false; - } - }); - } - - // 当前元素后面没有同辈元素,使当前元素的上一个元素处于活动状态 - if ($(this).parents('.menuTab').prev('.menuTab').size()) { - var activeId = $(this).parents('.menuTab').prev('.menuTab:last').data('id'); - $(this).parents('.menuTab').prev('.menuTab:last').addClass('active'); - $('.mainContent .RuoYi_iframe').each(function() { - if ($(this).data('id') == activeId) { - $(this).show().siblings('.RuoYi_iframe').hide(); - return false; - } - }); - - // 移除当前选项卡 - $(this).parents('.menuTab').remove(); - - // 移除tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { - if ($(this).data('id') == closeTabId) { - $(this).remove(); - return false; - } - }); - - if($.common.isNotEmpty(panelUrl)){ - $('.menuTab[data-id="' + panelUrl + '"]').addClass('active').siblings('.menuTab').removeClass('active'); - $('.mainContent .RuoYi_iframe').each(function() { - if ($(this).data('id') == panelUrl) { - $(this).show().siblings('.RuoYi_iframe').hide(); - return false; - } - }); - } - } - } - // 当前元素不处于活动状态 - else { - // 移除当前选项卡 - $(this).parents('.menuTab').remove(); - - // 移除相应tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { - if ($(this).data('id') == closeTabId) { - $(this).remove(); - return false; - } - }); - } - scrollToTab($('.menuTab.active')); - return false; - } - - $('.menuTabs').on('click', '.menuTab i', closeTab); - - //滚动到已激活的选项卡 - function showActiveTab() { - scrollToTab($('.menuTab.active')); - } - $('.tabShowActive').on('click', showActiveTab); - - // 点击选项卡菜单 - function activeTab() { - if (!$(this).hasClass('active')) { - var currentId = $(this).data('id'); - // 显示tab对应的内容区 - $('.mainContent .RuoYi_iframe').each(function() { - if ($(this).data('id') == currentId) { - $(this).show().siblings('.RuoYi_iframe').hide(); - return false; - } - }); - $(this).addClass('active').siblings('.menuTab').removeClass('active'); - scrollToTab(this); - } - } - - // 点击选项卡菜单 - $('.menuTabs').on('click', '.menuTab', activeTab); - - // 刷新iframe - function refreshTab() { - var currentId = $('.page-tabs-content').find('.active').attr('data-id'); - var target = $('.RuoYi_iframe[data-id="' + currentId + '"]'); - var url = target.attr('src'); - target.attr('src', url).ready(); - } - - // 关闭当前选项卡 - function tabCloseCurrent() { - $('.page-tabs-content').find('.active i').trigger("click"); - } - - //关闭其他选项卡 - function tabCloseOther() { - $('.page-tabs-content').children("[data-id]").not(":first").not(".active").each(function() { - $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove(); - $(this).remove(); - }); - $('.page-tabs-content').css("margin-left", "0"); - } - - // 关闭全部选项卡 - function tabCloseAll() { - $('.page-tabs-content').children("[data-id]").not(":first").each(function() { - $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove(); - $(this).remove(); - }); - $('.page-tabs-content').children("[data-id]:first").each(function() { - $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').show(); - $(this).addClass("active"); - }); - $('.page-tabs-content').css("margin-left", "0"); - } - - - // 全屏显示 - $('#fullScreen').on('click', function () { - $(document).toggleFullScreen(); - }); - - // 刷新按钮 - $('.tabReload').on('click', refreshTab); - - // 双击选项卡全屏显示 - $('.menuTabs').on('dblclick', '.menuTab', activeTabMax); - - // 左移按扭 - $('.tabLeft').on('click', scrollTabLeft); - - // 右移按扭 - $('.tabRight').on('click', scrollTabRight); - - // 关闭当前 - $('.tabCloseCurrent').on('click', tabCloseCurrent); - - // 关闭其他 - $('.tabCloseOther').on('click', tabCloseOther); - - // 关闭全部 - $('.tabCloseAll').on('click', tabCloseAll); - - // tab全屏显示 - $('.tabMaxCurrent').on('click', function () { - $('.page-tabs-content').find('.active').trigger("dblclick"); - }); - - // 关闭全屏 - $('#ax_close_max').click(function(){ - $('#content-main').toggleClass('max'); - $('#ax_close_max').hide(); - }) - - // 双击选项卡全屏显示 - function activeTabMax() { - $('#content-main').toggleClass('max'); - $('#ax_close_max').show(); - } - - $(window).keydown(function(event) { - if (event.keyCode == 27) { - $('#content-main').removeClass('max'); - $('#ax_close_max').hide(); - } - }); - - // 右键菜单实现 - $.contextMenu({ - selector: ".menuTab", - trigger: 'right', - autoHide: true, - items: { - "close_current": { - name: "关闭当前", - icon: "fa-close", - callback: function(key, opt) { - opt.$trigger.find('i').trigger("click"); - } - }, - "close_other": { - name: "关闭其他", - icon: "fa-window-close-o", - callback: function(key, opt) { - setActiveTab(this); - tabCloseOther(); - } - }, - "close_left": { - name: "关闭左侧", - icon: "fa-reply", - callback: function(key, opt) { - setActiveTab(this); - this.prevAll('.menuTab').not(":last").each(function() { - if ($(this).hasClass('active')) { - setActiveTab(this); - } - $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove(); - $(this).remove(); - }); - $('.page-tabs-content').css("margin-left", "0"); - } - }, - "close_right": { - name: "关闭右侧", - icon: "fa-share", - callback: function(key, opt) { - setActiveTab(this); - this.nextAll('.menuTab').each(function() { - $('.menuTab[data-id="' + $(this).data('id') + '"]').remove(); - $(this).remove(); - }); - } - }, - "close_all": { - name: "全部关闭", - icon: "fa-window-close", - callback: function(key, opt) { - tabCloseAll(); - } - }, - "step": "---------", - "full": { - name: "全屏显示", - icon: "fa-arrows-alt", - callback: function(key, opt) { - setActiveTab(this); - var target = $('.RuoYi_iframe[data-id="' + this.data('id') + '"]'); - target.fullScreen(true); - } - }, - "refresh": { - name: "刷新页面", - icon: "fa-refresh", - callback: function(key, opt) { - setActiveTab(this); - var target = $('.RuoYi_iframe[data-id="' + this.data('id') + '"]'); - var url = target.attr('src'); - target.attr('src', url).ready(); - $.modal.loading("数据加载中,请稍后..."); - target.attr('src', url).load(function () { - $.modal.closeLoading(); - }); - } - }, - "open": { - name: "新窗口打开", - icon: "fa-link", - callback: function(key, opt) { - var target = $('.RuoYi_iframe[data-id="' + this.data('id') + '"]'); - window.open(target.attr('src')); - } - }, - } - }) +/** + * 首页方法封装处理 + * Copyright (c) 2019 ruoyi + */ +layer.config({ + extend: 'moon/style.css', + skin: 'layer-ext-moon' +}); + +$(function() { + // MetsiMenu + $('#side-menu').metisMenu(); + + //固定菜单栏 + $(function() { + $('.sidebar-collapse').slimScroll({ + height: '100%', + railOpacity: 0.9, + alwaysVisible: false + }); + }); + + // 菜单切换 + $('.navbar-minimalize').click(function() { + $("body").toggleClass("mini-navbar"); + SmoothlyMenu(); + }); + + $('#side-menu>li').click(function() { + if ($('body').hasClass('mini-navbar')) { + NavToggle(); + } + }); + $('#side-menu>li li a').click(function() { + if ($(window).width() < 769) { + NavToggle(); + } + }); + + $('.nav-close').click(NavToggle); + + //ios浏览器兼容性处理 + if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { + $('#content-main').css('overflow-y', 'auto'); + } + +}); + +$(window).bind("load resize", +function() { + if ($(this).width() < 769) { + $('body').addClass('mini-navbar'); + $('.navbar-static-side').fadeIn(); + $(".sidebar-collapse .logo").addClass("hide"); + $(".slimScrollDiv").css({ "overflow":"hidden" }) + } +}); + +function NavToggle() { + $('.navbar-minimalize').trigger('click'); +} + +function SmoothlyMenu() { + if (!$('body').hasClass('mini-navbar')) { + $('#side-menu').hide(); + $(".sidebar-collapse .logo").removeClass("hide"); + setTimeout(function() { + $('#side-menu').fadeIn(500); + }, + 100); + } else if ($('body').hasClass('fixed-sidebar')) { + $('#side-menu').hide(); + $(".sidebar-collapse .logo").addClass("hide"); + setTimeout(function() { + $('#side-menu').fadeIn(500); + }, + 300); + } else { + $('#side-menu').removeAttr('style'); + } +} + +/** + * iframe处理 + */ +$(function() { + //计算元素集合的总宽度 + function calSumWidth(elements) { + var width = 0; + $(elements).each(function() { + width += $(this).outerWidth(true); + }); + return width; + } + + // 激活指定选项卡 + function setActiveTab(element) { + if (!$(element).hasClass('active')) { + var currentId = $(element).data('id'); + // 显示tab对应的内容区 + $('.RuoYi_iframe').each(function() { + if ($(this).data('id') == currentId) { + $(this).show().siblings('.RuoYi_iframe').hide(); + } + }); + $(element).addClass('active').siblings('.menuTab').removeClass('active'); + scrollToTab(element); + } + } + + //滚动到指定选项卡 + function scrollToTab(element) { + var marginLeftVal = calSumWidth($(element).prevAll()), + marginRightVal = calSumWidth($(element).nextAll()); + // 可视区域非tab宽度 + var tabOuterWidth = calSumWidth($(".content-tabs").children().not(".menuTabs")); + //可视区域tab宽度 + var visibleWidth = $(".content-tabs").outerWidth(true) - tabOuterWidth; + //实际滚动宽度 + var scrollVal = 0; + if ($(".page-tabs-content").outerWidth() < visibleWidth) { + scrollVal = 0; + } else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) { + if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) { + scrollVal = marginLeftVal; + var tabElement = element; + while ((scrollVal - $(tabElement).outerWidth()) > ($(".page-tabs-content").outerWidth() - visibleWidth)) { + scrollVal -= $(tabElement).prev().outerWidth(); + tabElement = $(tabElement).prev(); + } + } + } else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) { + scrollVal = marginLeftVal - $(element).prev().outerWidth(true); + } + $('.page-tabs-content').animate({ + marginLeft: 0 - scrollVal + 'px' + }, + "fast"); + } + + //查看左侧隐藏的选项卡 + function scrollTabLeft() { + var marginLeftVal = Math.abs(parseInt($('.page-tabs-content').css('margin-left'))); + // 可视区域非tab宽度 + var tabOuterWidth = calSumWidth($(".content-tabs").children().not(".menuTabs")); + //可视区域tab宽度 + var visibleWidth = $(".content-tabs").outerWidth(true) - tabOuterWidth; + //实际滚动宽度 + var scrollVal = 0; + if (($(".page-tabs-content").width()) < visibleWidth) { + return false; + } else { + var tabElement = $(".menuTab:first"); + var offsetVal = 0; + while ((offsetVal + $(tabElement).outerWidth(true)) <= marginLeftVal) { //找到离当前tab最近的元素 + offsetVal += $(tabElement).outerWidth(true); + tabElement = $(tabElement).next(); + } + offsetVal = 0; + if (calSumWidth($(tabElement).prevAll()) > visibleWidth) { + while ((offsetVal + $(tabElement).outerWidth(true)) < (visibleWidth) && tabElement.length > 0) { + offsetVal += $(tabElement).outerWidth(true); + tabElement = $(tabElement).prev(); + } + scrollVal = calSumWidth($(tabElement).prevAll()); + } + } + $('.page-tabs-content').animate({ + marginLeft: 0 - scrollVal + 'px' + }, + "fast"); + } + + //查看右侧隐藏的选项卡 + function scrollTabRight() { + var marginLeftVal = Math.abs(parseInt($('.page-tabs-content').css('margin-left'))); + // 可视区域非tab宽度 + var tabOuterWidth = calSumWidth($(".content-tabs").children().not(".menuTabs")); + //可视区域tab宽度 + var visibleWidth = $(".content-tabs").outerWidth(true) - tabOuterWidth; + //实际滚动宽度 + var scrollVal = 0; + if ($(".page-tabs-content").width() < visibleWidth) { + return false; + } else { + var tabElement = $(".menuTab:first"); + var offsetVal = 0; + while ((offsetVal + $(tabElement).outerWidth(true)) <= marginLeftVal) { //找到离当前tab最近的元素 + offsetVal += $(tabElement).outerWidth(true); + tabElement = $(tabElement).next(); + } + offsetVal = 0; + while ((offsetVal + $(tabElement).outerWidth(true)) < (visibleWidth) && tabElement.length > 0) { + offsetVal += $(tabElement).outerWidth(true); + tabElement = $(tabElement).next(); + } + scrollVal = calSumWidth($(tabElement).prevAll()); + if (scrollVal > 0) { + $('.page-tabs-content').animate({ + marginLeft: 0 - scrollVal + 'px' + }, + "fast"); + } + } + } + + //通过遍历给菜单项加上data-index属性 + $(".menuItem").each(function(index) { + if (!$(this).attr('data-index')) { + $(this).attr('data-index', index); + } + }); + + function menuItem() { + // 获取标识数据 + var dataUrl = $(this).attr('href'), + dataIndex = $(this).data('index'), + menuName = $.trim($(this).text()), + flag = true; + $(".nav ul li").removeClass("selected"); + $(this).parent("li").addClass("selected"); + if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false; + + // 选项卡菜单已存在 + $('.menuTab').each(function() { + if ($(this).data('id') == dataUrl) { + if (!$(this).hasClass('active')) { + $(this).addClass('active').siblings('.menuTab').removeClass('active'); + scrollToTab(this); + // 显示tab对应的内容区 + $('.mainContent .RuoYi_iframe').each(function() { + if ($(this).data('id') == dataUrl) { + $(this).show().siblings('.RuoYi_iframe').hide(); + return false; + } + }); + } + flag = false; + return false; + } + }); + // 选项卡菜单不存在 + if (flag) { + var str = '' + menuName + ' '; + $('.menuTab').removeClass('active'); + + // 添加选项卡对应的iframe + var str1 = ''; + $('.mainContent').find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1); + + $.modal.loading("数据加载中,请稍后..."); + + $('.mainContent iframe:visible').load(function () { + $.modal.closeLoading(); + }); + + // 添加选项卡 + $('.menuTabs .page-tabs-content').append(str); + scrollToTab($('.menuTab.active')); + } + return false; + } + + function menuBlank() { + // 新窗口打开外网以http://开头,如http://ruoyi.vip + var dataUrl = $(this).attr('href'); + window.open(dataUrl); + return false; + } + + $('.menuItem').on('click', menuItem); + + $('.menuBlank').on('click', menuBlank); + + // 关闭选项卡菜单 + function closeTab() { + var closeTabId = $(this).parents('.menuTab').data('id'); + var currentWidth = $(this).parents('.menuTab').width(); + var panelUrl = $(this).parents('.menuTab').data('panel'); + // 当前元素处于活动状态 + if ($(this).parents('.menuTab').hasClass('active')) { + + // 当前元素后面有同辈元素,使后面的一个元素处于活动状态 + if ($(this).parents('.menuTab').next('.menuTab').size()) { + + var activeId = $(this).parents('.menuTab').next('.menuTab:eq(0)').data('id'); + $(this).parents('.menuTab').next('.menuTab:eq(0)').addClass('active'); + + $('.mainContent .RuoYi_iframe').each(function() { + if ($(this).data('id') == activeId) { + $(this).show().siblings('.RuoYi_iframe').hide(); + return false; + } + }); + + var marginLeftVal = parseInt($('.page-tabs-content').css('margin-left')); + if (marginLeftVal < 0) { + $('.page-tabs-content').animate({ + marginLeft: (marginLeftVal + currentWidth) + 'px' + }, + "fast"); + } + + // 移除当前选项卡 + $(this).parents('.menuTab').remove(); + + // 移除tab对应的内容区 + $('.mainContent .RuoYi_iframe').each(function() { + if ($(this).data('id') == closeTabId) { + $(this).remove(); + return false; + } + }); + } + + // 当前元素后面没有同辈元素,使当前元素的上一个元素处于活动状态 + if ($(this).parents('.menuTab').prev('.menuTab').size()) { + var activeId = $(this).parents('.menuTab').prev('.menuTab:last').data('id'); + $(this).parents('.menuTab').prev('.menuTab:last').addClass('active'); + $('.mainContent .RuoYi_iframe').each(function() { + if ($(this).data('id') == activeId) { + $(this).show().siblings('.RuoYi_iframe').hide(); + return false; + } + }); + + // 移除当前选项卡 + $(this).parents('.menuTab').remove(); + + // 移除tab对应的内容区 + $('.mainContent .RuoYi_iframe').each(function() { + if ($(this).data('id') == closeTabId) { + $(this).remove(); + return false; + } + }); + + if($.common.isNotEmpty(panelUrl)){ + $('.menuTab[data-id="' + panelUrl + '"]').addClass('active').siblings('.menuTab').removeClass('active'); + $('.mainContent .RuoYi_iframe').each(function() { + if ($(this).data('id') == panelUrl) { + $(this).show().siblings('.RuoYi_iframe').hide(); + return false; + } + }); + } + } + } + // 当前元素不处于活动状态 + else { + // 移除当前选项卡 + $(this).parents('.menuTab').remove(); + + // 移除相应tab对应的内容区 + $('.mainContent .RuoYi_iframe').each(function() { + if ($(this).data('id') == closeTabId) { + $(this).remove(); + return false; + } + }); + } + scrollToTab($('.menuTab.active')); + return false; + } + + $('.menuTabs').on('click', '.menuTab i', closeTab); + + //滚动到已激活的选项卡 + function showActiveTab() { + scrollToTab($('.menuTab.active')); + } + $('.tabShowActive').on('click', showActiveTab); + + // 点击选项卡菜单 + function activeTab() { + if (!$(this).hasClass('active')) { + var currentId = $(this).data('id'); + // 显示tab对应的内容区 + $('.mainContent .RuoYi_iframe').each(function() { + if ($(this).data('id') == currentId) { + $(this).show().siblings('.RuoYi_iframe').hide(); + return false; + } + }); + $(this).addClass('active').siblings('.menuTab').removeClass('active'); + scrollToTab(this); + } + } + + // 点击选项卡菜单 + $('.menuTabs').on('click', '.menuTab', activeTab); + + // 刷新iframe + function refreshTab() { + var currentId = $('.page-tabs-content').find('.active').attr('data-id'); + var target = $('.RuoYi_iframe[data-id="' + currentId + '"]'); + var url = target.attr('src'); + target.attr('src', url).ready(); + } + + // 关闭当前选项卡 + function tabCloseCurrent() { + $('.page-tabs-content').find('.active i').trigger("click"); + } + + //关闭其他选项卡 + function tabCloseOther() { + $('.page-tabs-content').children("[data-id]").not(":first").not(".active").each(function() { + $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove(); + $(this).remove(); + }); + $('.page-tabs-content').css("margin-left", "0"); + } + + // 关闭全部选项卡 + function tabCloseAll() { + $('.page-tabs-content').children("[data-id]").not(":first").each(function() { + $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove(); + $(this).remove(); + }); + $('.page-tabs-content').children("[data-id]:first").each(function() { + $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').show(); + $(this).addClass("active"); + }); + $('.page-tabs-content').css("margin-left", "0"); + } + + + // 全屏显示 + $('#fullScreen').on('click', function () { + $(document).toggleFullScreen(); + }); + + // 刷新按钮 + $('.tabReload').on('click', refreshTab); + + // 双击选项卡全屏显示 + $('.menuTabs').on('dblclick', '.menuTab', activeTabMax); + + // 左移按扭 + $('.tabLeft').on('click', scrollTabLeft); + + // 右移按扭 + $('.tabRight').on('click', scrollTabRight); + + // 关闭当前 + $('.tabCloseCurrent').on('click', tabCloseCurrent); + + // 关闭其他 + $('.tabCloseOther').on('click', tabCloseOther); + + // 关闭全部 + $('.tabCloseAll').on('click', tabCloseAll); + + // tab全屏显示 + $('.tabMaxCurrent').on('click', function () { + $('.page-tabs-content').find('.active').trigger("dblclick"); + }); + + // 关闭全屏 + $('#ax_close_max').click(function(){ + $('#content-main').toggleClass('max'); + $('#ax_close_max').hide(); + }) + + // 双击选项卡全屏显示 + function activeTabMax() { + $('#content-main').toggleClass('max'); + $('#ax_close_max').show(); + } + + $(window).keydown(function(event) { + if (event.keyCode == 27) { + $('#content-main').removeClass('max'); + $('#ax_close_max').hide(); + } + }); + + // 右键菜单实现 + $.contextMenu({ + selector: ".menuTab", + trigger: 'right', + autoHide: true, + items: { + "close_current": { + name: "关闭当前", + icon: "fa-close", + callback: function(key, opt) { + opt.$trigger.find('i').trigger("click"); + } + }, + "close_other": { + name: "关闭其他", + icon: "fa-window-close-o", + callback: function(key, opt) { + setActiveTab(this); + tabCloseOther(); + } + }, + "close_left": { + name: "关闭左侧", + icon: "fa-reply", + callback: function(key, opt) { + setActiveTab(this); + this.prevAll('.menuTab').not(":last").each(function() { + if ($(this).hasClass('active')) { + setActiveTab(this); + } + $('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove(); + $(this).remove(); + }); + $('.page-tabs-content').css("margin-left", "0"); + } + }, + "close_right": { + name: "关闭右侧", + icon: "fa-share", + callback: function(key, opt) { + setActiveTab(this); + this.nextAll('.menuTab').each(function() { + $('.menuTab[data-id="' + $(this).data('id') + '"]').remove(); + $(this).remove(); + }); + } + }, + "close_all": { + name: "全部关闭", + icon: "fa-window-close", + callback: function(key, opt) { + tabCloseAll(); + } + }, + "step": "---------", + "full": { + name: "全屏显示", + icon: "fa-arrows-alt", + callback: function(key, opt) { + setActiveTab(this); + var target = $('.RuoYi_iframe[data-id="' + this.data('id') + '"]'); + target.fullScreen(true); + } + }, + "refresh": { + name: "刷新页面", + icon: "fa-refresh", + callback: function(key, opt) { + setActiveTab(this); + var target = $('.RuoYi_iframe[data-id="' + this.data('id') + '"]'); + var url = target.attr('src'); + target.attr('src', url).ready(); + $.modal.loading("数据加载中,请稍后..."); + target.attr('src', url).load(function () { + $.modal.closeLoading(); + }); + } + }, + "open": { + name: "新窗口打开", + icon: "fa-link", + callback: function(key, opt) { + var target = $('.RuoYi_iframe[data-id="' + this.data('id') + '"]'); + window.open(target.attr('src')); + } + }, + } + }) }); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js b/bmw-admin/src/main/resources/static/ruoyi/js/common.js similarity index 97% rename from ruoyi-admin/src/main/resources/static/ruoyi/js/common.js rename to bmw-admin/src/main/resources/static/ruoyi/js/common.js index 20b10e000..a2ecca71f 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js +++ b/bmw-admin/src/main/resources/static/ruoyi/js/common.js @@ -1,259 +1,259 @@ -/** - * 通用方法封装处理 - * Copyright (c) 2019 ruoyi - */ -$(function() { - // select2复选框事件绑定 - if ($.fn.select2 !== undefined) { - $.fn.select2.defaults.set( "theme", "bootstrap" ); - $("select.form-control:not(.noselect2)").each(function () { - $(this).select2().on("change", function () { - $(this).valid(); - }) - }) - } - - // iCheck单选框及复选框事件绑定 - if ($.fn.iCheck !== undefined) { - $(".check-box:not(.noicheck),.radio-box:not(.noicheck)").each(function() { - $(this).iCheck({ - checkboxClass: 'icheckbox-blue', - radioClass: 'iradio-blue', - }) - }) - } - - // laydate 时间控件绑定 - if ($(".select-time").length > 0) { - layui.use('laydate', function() { - var laydate = layui.laydate; - var startDate = laydate.render({ - elem: '#startTime', - max: $('#endTime').val(), - theme: 'molv', - trigger: 'click', - done: function(value, date) { - // 结束时间大于开始时间 - if (value !== '') { - endDate.config.min.year = date.year; - endDate.config.min.month = date.month - 1; - endDate.config.min.date = date.date; - } else { - endDate.config.min.year = ''; - endDate.config.min.month = ''; - endDate.config.min.date = ''; - } - } - }); - var endDate = laydate.render({ - elem: '#endTime', - min: $('#startTime').val(), - theme: 'molv', - trigger: 'click', - done: function(value, date) { - // 开始时间小于结束时间 - if (value !== '') { - startDate.config.max.year = date.year; - startDate.config.max.month = date.month - 1; - startDate.config.max.date = date.date; - } else { - startDate.config.max.year = ''; - startDate.config.max.month = ''; - startDate.config.max.date = ''; - } - } - }); - }); - } - // laydate time-input 时间控件绑定 - if ($(".time-input").length > 0) { - layui.use('laydate', function () { - var com = layui.laydate; - $(".time-input").each(function (index, item) { - var time = $(item); - // 控制控件外观 - var type = time.attr("data-type") || 'date'; - // 控制回显格式 - var format = time.attr("data-format") || 'yyyy-MM-dd'; - // 控制日期控件按钮 - var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = []; - // 日期控件选择完成后回调处理 - var callback = time.attr("data-callback") || {}; - if (buttons) { - if (buttons.indexOf("|") > 0) { - var btnArr = buttons.split("|"), btnLen = btnArr.length; - for (var j = 0; j < btnLen; j++) { - if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) { - newBtnArr.push(btnArr[j]); - } - } - } else { - if ("clear" === buttons || "now" === buttons || "confirm" === buttons) { - newBtnArr.push(buttons); - } - } - } else { - newBtnArr = ['clear', 'now', 'confirm']; - } - com.render({ - elem: item, - theme: 'molv', - trigger: 'click', - type: type, - format: format, - btns: newBtnArr, - done: function (value, data) { - if (typeof window[callback] != 'undefined' - && window[callback] instanceof Function) { - window[callback](value, data); - } - } - }); - }); - }); - } - // tree 关键字搜索绑定 - if ($("#keyword").length > 0) { - $("#keyword").bind("focus", function focusKey(e) { - if ($("#keyword").hasClass("empty")) { - $("#keyword").removeClass("empty"); - } - }).bind("blur", function blurKey(e) { - if ($("#keyword").val() === "") { - $("#keyword").addClass("empty"); - } - $.tree.searchNode(e); - }).bind("input propertychange", $.tree.searchNode); - } - // tree表格树 展开/折叠 - var expandFlag; - $("#expandAllBtn").click(function() { - var dataExpand = $.common.isEmpty($.table._option.expandAll) ? true : $.table._option.expandAll; - expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag; - if (!expandFlag) { - $.bttTable.bootstrapTreeTable('expandAll'); - } else { - $.bttTable.bootstrapTreeTable('collapseAll'); - } - expandFlag = expandFlag ? false: true; - }) - // 按下ESC按钮关闭弹层 - $('body', document).on('keyup', function(e) { - if (e.which === 27) { - $.modal.closeAll(); - } - }); -}); - -/** 刷新选项卡 */ -var refreshItem = function(){ - var topWindow = $(window.parent.document); - var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id'); - var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow); - var url = target.attr('src'); - target.attr('src', url).ready(); -} - -/** 关闭选项卡 */ -var closeItem = function(dataId){ - var topWindow = $(window.parent.document); - if($.common.isNotEmpty(dataId)){ - window.parent.$.modal.closeLoading(); - // 根据dataId关闭指定选项卡 - $('.menuTab[data-id="' + dataId + '"]', topWindow).remove(); - // 移除相应tab对应的内容区 - $('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove(); - return; - } - var panelUrl = window.frameElement.getAttribute('data-panel'); - $('.page-tabs-content .active i', topWindow).click(); - if($.common.isNotEmpty(panelUrl)){ - $('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active'); - $('.mainContent .RuoYi_iframe', topWindow).each(function() { - if ($(this).data('id') == panelUrl) { - $(this).show().siblings('.RuoYi_iframe').hide(); - return false; - } - }); - } -} - -/** 创建选项卡 */ -function createMenuItem(dataUrl, menuName) { - var panelUrl = window.frameElement.getAttribute('data-id'); - dataIndex = $.common.random(1,100), - flag = true; - if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false; - var topWindow = $(window.parent.document); - // 选项卡菜单已存在 - $('.menuTab', topWindow).each(function() { - if ($(this).data('id') == dataUrl) { - if (!$(this).hasClass('active')) { - $(this).addClass('active').siblings('.menuTab').removeClass('active'); - $('.page-tabs-content').animate({ marginLeft: ""}, "fast"); - // 显示tab对应的内容区 - $('.mainContent .RuoYi_iframe', topWindow).each(function() { - if ($(this).data('id') == dataUrl) { - $(this).show().siblings('.RuoYi_iframe').hide(); - return false; - } - }); - } - flag = false; - return false; - } - }); - // 选项卡菜单不存在 - if (flag) { - var str = '' + menuName + ' '; - $('.menuTab', topWindow).removeClass('active'); - - // 添加选项卡对应的iframe - var str1 = ''; - $('.mainContent', topWindow).find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1); - - window.parent.$.modal.loading("数据加载中,请稍后..."); - $('.mainContent iframe:visible', topWindow).load(function () { - window.parent.$.modal.closeLoading(); - }); - - // 添加选项卡 - $('.menuTabs .page-tabs-content', topWindow).append(str); - } - return false; -} - -//日志打印封装处理 -var log = { - log: function (msg) { - console.log(msg); - }, - info: function(msg) { - console.info(msg); - }, - warn: function(msg) { - console.warn(msg); - }, - error: function(msg) { - console.error(msg); - } -}; - -/** 设置全局ajax处理 */ -$.ajaxSetup({ - complete: function(XMLHttpRequest, textStatus) { - if (textStatus == 'timeout') { - $.modal.alertWarning("服务器超时,请稍后再试!"); - $.modal.enable(); - $.modal.closeLoading(); - } else if (textStatus == "parsererror" || textStatus == "error") { - $.modal.alertWarning("服务器错误,请联系管理员!"); - $.modal.enable(); - $.modal.closeLoading(); - } - } -}); -layer.config({ - extend: 'moon/style.css', - skin: 'layer-ext-moon' -}); +/** + * 通用方法封装处理 + * Copyright (c) 2019 ruoyi + */ +$(function() { + // select2复选框事件绑定 + if ($.fn.select2 !== undefined) { + $.fn.select2.defaults.set( "theme", "bootstrap" ); + $("select.form-control:not(.noselect2)").each(function () { + $(this).select2().on("change", function () { + $(this).valid(); + }) + }) + } + + // iCheck单选框及复选框事件绑定 + if ($.fn.iCheck !== undefined) { + $(".check-box:not(.noicheck),.radio-box:not(.noicheck)").each(function() { + $(this).iCheck({ + checkboxClass: 'icheckbox-blue', + radioClass: 'iradio-blue', + }) + }) + } + + // laydate 时间控件绑定 + if ($(".select-time").length > 0) { + layui.use('laydate', function() { + var laydate = layui.laydate; + var startDate = laydate.render({ + elem: '#startTime', + max: $('#endTime').val(), + theme: 'molv', + trigger: 'click', + done: function(value, date) { + // 结束时间大于开始时间 + if (value !== '') { + endDate.config.min.year = date.year; + endDate.config.min.month = date.month - 1; + endDate.config.min.date = date.date; + } else { + endDate.config.min.year = ''; + endDate.config.min.month = ''; + endDate.config.min.date = ''; + } + } + }); + var endDate = laydate.render({ + elem: '#endTime', + min: $('#startTime').val(), + theme: 'molv', + trigger: 'click', + done: function(value, date) { + // 开始时间小于结束时间 + if (value !== '') { + startDate.config.max.year = date.year; + startDate.config.max.month = date.month - 1; + startDate.config.max.date = date.date; + } else { + startDate.config.max.year = ''; + startDate.config.max.month = ''; + startDate.config.max.date = ''; + } + } + }); + }); + } + // laydate time-input 时间控件绑定 + if ($(".time-input").length > 0) { + layui.use('laydate', function () { + var com = layui.laydate; + $(".time-input").each(function (index, item) { + var time = $(item); + // 控制控件外观 + var type = time.attr("data-type") || 'date'; + // 控制回显格式 + var format = time.attr("data-format") || 'yyyy-MM-dd'; + // 控制日期控件按钮 + var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = []; + // 日期控件选择完成后回调处理 + var callback = time.attr("data-callback") || {}; + if (buttons) { + if (buttons.indexOf("|") > 0) { + var btnArr = buttons.split("|"), btnLen = btnArr.length; + for (var j = 0; j < btnLen; j++) { + if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) { + newBtnArr.push(btnArr[j]); + } + } + } else { + if ("clear" === buttons || "now" === buttons || "confirm" === buttons) { + newBtnArr.push(buttons); + } + } + } else { + newBtnArr = ['clear', 'now', 'confirm']; + } + com.render({ + elem: item, + theme: 'molv', + trigger: 'click', + type: type, + format: format, + btns: newBtnArr, + done: function (value, data) { + if (typeof window[callback] != 'undefined' + && window[callback] instanceof Function) { + window[callback](value, data); + } + } + }); + }); + }); + } + // tree 关键字搜索绑定 + if ($("#keyword").length > 0) { + $("#keyword").bind("focus", function focusKey(e) { + if ($("#keyword").hasClass("empty")) { + $("#keyword").removeClass("empty"); + } + }).bind("blur", function blurKey(e) { + if ($("#keyword").val() === "") { + $("#keyword").addClass("empty"); + } + $.tree.searchNode(e); + }).bind("input propertychange", $.tree.searchNode); + } + // tree表格树 展开/折叠 + var expandFlag; + $("#expandAllBtn").click(function() { + var dataExpand = $.common.isEmpty($.table._option.expandAll) ? true : $.table._option.expandAll; + expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag; + if (!expandFlag) { + $.bttTable.bootstrapTreeTable('expandAll'); + } else { + $.bttTable.bootstrapTreeTable('collapseAll'); + } + expandFlag = expandFlag ? false: true; + }) + // 按下ESC按钮关闭弹层 + $('body', document).on('keyup', function(e) { + if (e.which === 27) { + $.modal.closeAll(); + } + }); +}); + +/** 刷新选项卡 */ +var refreshItem = function(){ + var topWindow = $(window.parent.document); + var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id'); + var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow); + var url = target.attr('src'); + target.attr('src', url).ready(); +} + +/** 关闭选项卡 */ +var closeItem = function(dataId){ + var topWindow = $(window.parent.document); + if($.common.isNotEmpty(dataId)){ + window.parent.$.modal.closeLoading(); + // 根据dataId关闭指定选项卡 + $('.menuTab[data-id="' + dataId + '"]', topWindow).remove(); + // 移除相应tab对应的内容区 + $('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove(); + return; + } + var panelUrl = window.frameElement.getAttribute('data-panel'); + $('.page-tabs-content .active i', topWindow).click(); + if($.common.isNotEmpty(panelUrl)){ + $('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active'); + $('.mainContent .RuoYi_iframe', topWindow).each(function() { + if ($(this).data('id') == panelUrl) { + $(this).show().siblings('.RuoYi_iframe').hide(); + return false; + } + }); + } +} + +/** 创建选项卡 */ +function createMenuItem(dataUrl, menuName) { + var panelUrl = window.frameElement.getAttribute('data-id'); + dataIndex = $.common.random(1,100), + flag = true; + if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false; + var topWindow = $(window.parent.document); + // 选项卡菜单已存在 + $('.menuTab', topWindow).each(function() { + if ($(this).data('id') == dataUrl) { + if (!$(this).hasClass('active')) { + $(this).addClass('active').siblings('.menuTab').removeClass('active'); + $('.page-tabs-content').animate({ marginLeft: ""}, "fast"); + // 显示tab对应的内容区 + $('.mainContent .RuoYi_iframe', topWindow).each(function() { + if ($(this).data('id') == dataUrl) { + $(this).show().siblings('.RuoYi_iframe').hide(); + return false; + } + }); + } + flag = false; + return false; + } + }); + // 选项卡菜单不存在 + if (flag) { + var str = '' + menuName + ' '; + $('.menuTab', topWindow).removeClass('active'); + + // 添加选项卡对应的iframe + var str1 = ''; + $('.mainContent', topWindow).find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1); + + window.parent.$.modal.loading("数据加载中,请稍后..."); + $('.mainContent iframe:visible', topWindow).load(function () { + window.parent.$.modal.closeLoading(); + }); + + // 添加选项卡 + $('.menuTabs .page-tabs-content', topWindow).append(str); + } + return false; +} + +//日志打印封装处理 +var log = { + log: function (msg) { + console.log(msg); + }, + info: function(msg) { + console.info(msg); + }, + warn: function(msg) { + console.warn(msg); + }, + error: function(msg) { + console.error(msg); + } +}; + +/** 设置全局ajax处理 */ +$.ajaxSetup({ + complete: function(XMLHttpRequest, textStatus) { + if (textStatus == 'timeout') { + $.modal.alertWarning("服务器超时,请稍后再试!"); + $.modal.enable(); + $.modal.closeLoading(); + } else if (textStatus == "parsererror" || textStatus == "error") { + $.modal.alertWarning("服务器错误,请联系管理员!"); + $.modal.enable(); + $.modal.closeLoading(); + } + } +}); +layer.config({ + extend: 'moon/style.css', + skin: 'layer-ext-moon' +}); diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/bmw-admin/src/main/resources/static/ruoyi/js/ry-ui.js similarity index 100% rename from ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js rename to bmw-admin/src/main/resources/static/ruoyi/js/ry-ui.js diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/login.js b/bmw-admin/src/main/resources/static/ruoyi/login.js similarity index 96% rename from ruoyi-admin/src/main/resources/static/ruoyi/login.js rename to bmw-admin/src/main/resources/static/ruoyi/login.js index f633f51de..2a64ae161 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/login.js +++ b/bmw-admin/src/main/resources/static/ruoyi/login.js @@ -1,95 +1,95 @@ - -$(function() { - validateKickout(); - validateRule(); - $('.imgcode').click(function() { - var url = ctx + "captcha/captchaImage?type=" + captchaType + "&s=" + Math.random(); - $(".imgcode").attr("src", url); - }); -}); - -$.validator.setDefaults({ - submitHandler: function() { - login(); - } -}); - -function login() { - $.modal.loading($("#btnSubmit").data("loading")); - var username = $.common.trim($("input[name='username']").val()); - var password = $.common.trim($("input[name='password']").val()); - var validateCode = $("input[name='validateCode']").val(); - var rememberMe = $("input[name='rememberme']").is(':checked'); - $.ajax({ - type: "post", - url: ctx + "login", - data: { - "username": username, - "password": password, - "validateCode" : validateCode, - "rememberMe": rememberMe - }, - success: function(r) { - if (r.code == 0) { - location.href = ctx + 'index'; - } else { - $.modal.closeLoading(); - $('.imgcode').click(); - $(".code").val(""); - $.modal.msg(r.msg); - } - } - }); -} - -function validateRule() { - var icon = " "; - $("#signupForm").validate({ - rules: { - username: { - required: true - }, - password: { - required: true - } - }, - messages: { - username: { - required: icon + "请输入您的用户名", - }, - password: { - required: icon + "请输入您的密码", - } - } - }) -} - -function validateKickout() { - if (getParam("kickout") == 1) { - layer.alert("您已在别处登录,请您修改密码或重新登录", { - icon: 0, - title: "系统提示" - }, - function(index) { - //关闭弹窗 - layer.close(index); - if (top != self) { - top.location = self.location; - } else { - var url  =  location.search; - if (url) { - var oldUrl  = window.location.href; - var newUrl  = oldUrl.substring(0,  oldUrl.indexOf('?')); - self.location  = newUrl; - } - } - }); - } -} - -function getParam(paramName) { - var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)"); - var r = window.location.search.substr(1).match(reg); - if (r != null) return decodeURI(r[2]); - return null; + +$(function() { + validateKickout(); + validateRule(); + $('.imgcode').click(function() { + var url = ctx + "captcha/captchaImage?type=" + captchaType + "&s=" + Math.random(); + $(".imgcode").attr("src", url); + }); +}); + +$.validator.setDefaults({ + submitHandler: function() { + login(); + } +}); + +function login() { + $.modal.loading($("#btnSubmit").data("loading")); + var username = $.common.trim($("input[name='username']").val()); + var password = $.common.trim($("input[name='password']").val()); + var validateCode = $("input[name='validateCode']").val(); + var rememberMe = $("input[name='rememberme']").is(':checked'); + $.ajax({ + type: "post", + url: ctx + "login", + data: { + "username": username, + "password": password, + "validateCode" : validateCode, + "rememberMe": rememberMe + }, + success: function(r) { + if (r.code == 0) { + location.href = ctx + 'index'; + } else { + $.modal.closeLoading(); + $('.imgcode').click(); + $(".code").val(""); + $.modal.msg(r.msg); + } + } + }); +} + +function validateRule() { + var icon = " "; + $("#signupForm").validate({ + rules: { + username: { + required: true + }, + password: { + required: true + } + }, + messages: { + username: { + required: icon + "请输入您的用户名", + }, + password: { + required: icon + "请输入您的密码", + } + } + }) +} + +function validateKickout() { + if (getParam("kickout") == 1) { + layer.alert("您已在别处登录,请您修改密码或重新登录", { + icon: 0, + title: "系统提示" + }, + function(index) { + //关闭弹窗 + layer.close(index); + if (top != self) { + top.location = self.location; + } else { + var url  =  location.search; + if (url) { + var oldUrl  = window.location.href; + var newUrl  = oldUrl.substring(0,  oldUrl.indexOf('?')); + self.location  = newUrl; + } + } + }); + } +} + +function getParam(paramName) { + var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)"); + var r = window.location.search.substr(1).match(reg); + if (r != null) return decodeURI(r[2]); + return null; } \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/autocomplete.html b/bmw-admin/src/main/resources/templates/demo/form/autocomplete.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/form/autocomplete.html rename to bmw-admin/src/main/resources/templates/demo/form/autocomplete.html index 5db41bfc4..5a5c8e614 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/autocomplete.html +++ b/bmw-admin/src/main/resources/templates/demo/form/autocomplete.html @@ -1,322 +1,322 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            搜索自动补全https://github.com/lzwme/bootstrap-suggest-plugin
                            -
                            -
                            -

                            展示下拉菜单按钮。

                            -
                            -
                            -
                            - -
                            - - -
                            -
                            -
                            -
                            - -

                            不展示下拉菜单按钮。

                            -
                            -
                            -
                            - -
                            - - -
                            -
                            -
                            -
                            - -

                            前端json中获取数据

                            -
                            -
                            -
                            - -
                            - - -
                            - -
                            -
                            -
                            - -

                            百度搜索

                            -

                            支持逗号分隔多关键字

                            -
                            -
                            -
                            - -
                            - - -
                            - -
                            -
                            -
                            - -

                            淘宝搜索

                            -

                            支持逗号分隔多关键字

                            -
                            -
                            -
                            - -
                            - - -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            搜索自动补全https://github.com/bassjobsen/Bootstrap-3-Typeahead
                            -
                            -
                            -

                            通过数据属性的基本示例。

                            -
                            -
                            - -
                            -
                            -
                            - -

                            通过javascript的基本示例。

                            -
                            -
                            - -
                            -
                            - -
                            -

                            通过javascript的复杂示例。

                            -
                            -
                            - -
                            -
                            - -
                            -

                            后台url中获取简单数据

                            -
                            -
                            - -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - - - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            搜索自动补全https://github.com/lzwme/bootstrap-suggest-plugin
                            +
                            +
                            +

                            展示下拉菜单按钮。

                            +
                            +
                            +
                            + +
                            + + +
                            +
                            +
                            +
                            + +

                            不展示下拉菜单按钮。

                            +
                            +
                            +
                            + +
                            + + +
                            +
                            +
                            +
                            + +

                            前端json中获取数据

                            +
                            +
                            +
                            + +
                            + + +
                            + +
                            +
                            +
                            + +

                            百度搜索

                            +

                            支持逗号分隔多关键字

                            +
                            +
                            +
                            + +
                            + + +
                            + +
                            +
                            +
                            + +

                            淘宝搜索

                            +

                            支持逗号分隔多关键字

                            +
                            +
                            +
                            + +
                            + + +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            搜索自动补全https://github.com/bassjobsen/Bootstrap-3-Typeahead
                            +
                            +
                            +

                            通过数据属性的基本示例。

                            +
                            +
                            + +
                            +
                            +
                            + +

                            通过javascript的基本示例。

                            +
                            +
                            + +
                            +
                            + +
                            +

                            通过javascript的复杂示例。

                            +
                            +
                            + +
                            +
                            + +
                            +

                            后台url中获取简单数据

                            +
                            +
                            + +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/basic.html b/bmw-admin/src/main/resources/templates/demo/form/basic.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/form/basic.html rename to bmw-admin/src/main/resources/templates/demo/form/basic.html index bf1bc76d2..e1ab714e1 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/basic.html +++ b/bmw-admin/src/main/resources/templates/demo/form/basic.html @@ -1,593 +1,593 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            基本表单 简单登录表单示例
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -

                            登录

                            -

                            欢迎登录本站(⊙o⊙)

                            -
                            -
                            - - -
                            -
                            - - -
                            -
                            - - -
                            -
                            -
                            -
                            -

                            还不是会员?

                            -

                            您可以注册一个新账户

                            -

                            - -

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            横向表单
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -

                            欢迎登录本站(⊙o⊙)

                            -
                            - - -
                            - 请输入您注册时所填的E-mail -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            内联表单
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            - - -
                            -
                            - - -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            弹出表单 弹出框登录示例
                            -
                            - - - - - - - - - - -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            所有表单元素 包括自定义样式的复选和单选按钮
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            - -
                            - 帮助文本,可能会超过一行,以块级元素显示 -
                            -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            - - -
                            -

                            ruoyi.vip

                            -
                            -
                            -
                            -
                            - - -
                            -
                            - -
                            -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - -
                            - - - -
                            -
                            -
                            -
                            - - -
                            -
                            - -
                            -
                            - -
                            -
                            - -
                            -
                            - -
                            -
                            - -
                            -
                            - -
                            -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - -
                            - - - -
                            -
                            -
                            -
                            - - -
                            - - -
                            - -
                            -
                            -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            - - -
                            - - - -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            - -
                            -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - - -
                            -
                            @ - -
                            -
                            - .00 -
                            -
                            ¥ - .00 -
                            -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - -
                            -
                            - - -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            - - -
                            - -
                            -
                            - - -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            - - - -
                            - -
                            -
                            - - -
                            - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            基本表单 简单登录表单示例
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +

                            登录

                            +

                            欢迎登录本站(⊙o⊙)

                            +
                            +
                            + + +
                            +
                            + + +
                            +
                            + + +
                            +
                            +
                            +
                            +

                            还不是会员?

                            +

                            您可以注册一个新账户

                            +

                            + +

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            横向表单
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +

                            欢迎登录本站(⊙o⊙)

                            +
                            + + +
                            + 请输入您注册时所填的E-mail +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            内联表单
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            + + +
                            +
                            + + +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            弹出表单 弹出框登录示例
                            +
                            + + + + + + + + + + +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            所有表单元素 包括自定义样式的复选和单选按钮
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            + +
                            + 帮助文本,可能会超过一行,以块级元素显示 +
                            +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            + + +
                            +

                            ruoyi.vip

                            +
                            +
                            +
                            +
                            + + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + +
                            + + + +
                            +
                            +
                            +
                            + + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + +
                            + + + +
                            +
                            +
                            +
                            + + +
                            + + +
                            + +
                            +
                            +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            + + +
                            + + + +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + + +
                            +
                            @ + +
                            +
                            + .00 +
                            +
                            ¥ + .00 +
                            +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + +
                            +
                            + + +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            + + +
                            + +
                            +
                            + + +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            + + + +
                            + +
                            +
                            + + +
                            + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/button.html b/bmw-admin/src/main/resources/templates/demo/form/button.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/form/button.html rename to bmw-admin/src/main/resources/templates/demo/form/button.html index 0f4ab4ef7..b54bfcdeb 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/button.html +++ b/bmw-admin/src/main/resources/templates/demo/form/button.html @@ -1,620 +1,620 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            按钮颜色
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - 可使用class来快速改变按钮的颜色,如.btn-primary -

                            - -

                            - 普通按钮 -

                            -

                            - - - - - - - - -

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            按钮大小
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - 可以通过添加class的值为.btn-lg, .btn-sm, or .btn-xs来修改按钮的大小 -

                            -

                            按钮尺寸

                            -

                            - - -
                            - - -
                            - - -
                            - - -

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            线性按钮
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - 要使用线性按钮,可添加class.btn-block.btn-outline -

                            - -

                            线性按钮

                            -

                            - - - - - - - -

                            -

                            块级按钮

                            -

                            - -

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            3D按钮
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - 可以通过添加.dimclass来使用3D按钮. -

                            -

                            3D按钮

                            - - - - - - - - - - - - - - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            下拉按钮
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - 下拉按钮可使用任何颜色任何大小 -

                            - -

                            下拉按钮

                            -
                            - - -
                            -
                            - - -
                            -
                            - - -
                            - -
                            -
                            - - -
                            -
                            - - -
                            -
                            - - -
                            -
                            -
                            - - -
                            -
                            - - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            按钮组
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -

                            按钮组

                            -
                            - - - -
                            -
                            -
                            -
                            - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            图标按钮
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - 任何按钮都可以在左侧或右侧添加图标 -

                            - -

                            图标按钮

                            -

                            - - - - - - - - 分享到微信 - - - 使用QQ账号登录 - - - - - - - - - - - - - - - - - - - - - - - - 收藏 - -

                            - -

                            按钮切换

                            - - -
                            - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            圆形图标按钮
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - 要使用圆形图标按钮,可以通过添加class为.btn-circle实现 -

                            - -

                            圆形按钮

                            -
                            - - - - - - - -
                            -
                            - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            圆角按钮
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - 可以通过添加class的值微.btn-rounded来实现圆角按钮 -

                            - -

                            按钮组

                            -

                            - 默认 - 主要 - 成果 - 信息 - 警告 - 危险 - 危险 -
                            -
                            - 圆角块级带图标按钮 -

                            -
                            -
                            -
                            - -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            按钮颜色
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + 可使用class来快速改变按钮的颜色,如.btn-primary +

                            + +

                            + 普通按钮 +

                            +

                            + + + + + + + + +

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            按钮大小
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + 可以通过添加class的值为.btn-lg, .btn-sm, or .btn-xs来修改按钮的大小 +

                            +

                            按钮尺寸

                            +

                            + + +
                            + + +
                            + + +
                            + + +

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            线性按钮
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + 要使用线性按钮,可添加class.btn-block.btn-outline +

                            + +

                            线性按钮

                            +

                            + + + + + + + +

                            +

                            块级按钮

                            +

                            + +

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            3D按钮
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + 可以通过添加.dimclass来使用3D按钮. +

                            +

                            3D按钮

                            + + + + + + + + + + + + + + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            下拉按钮
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + 下拉按钮可使用任何颜色任何大小 +

                            + +

                            下拉按钮

                            +
                            + + +
                            +
                            + + +
                            +
                            + + +
                            + +
                            +
                            + + +
                            +
                            + + +
                            +
                            + + +
                            +
                            +
                            + + +
                            +
                            + + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            按钮组
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +

                            按钮组

                            +
                            + + + +
                            +
                            +
                            +
                            + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            图标按钮
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + 任何按钮都可以在左侧或右侧添加图标 +

                            + +

                            图标按钮

                            +

                            + + + + + + + + 分享到微信 + + + 使用QQ账号登录 + + + + + + + + + + + + + + + + + + + + + + + + 收藏 + +

                            + +

                            按钮切换

                            + + +
                            + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            圆形图标按钮
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + 要使用圆形图标按钮,可以通过添加class为.btn-circle实现 +

                            + +

                            圆形按钮

                            +
                            + + + + + + + +
                            +
                            + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            圆角按钮
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + 可以通过添加class的值微.btn-rounded来实现圆角按钮 +

                            + +

                            按钮组

                            +

                            + 默认 + 主要 + 成果 + 信息 + 警告 + 危险 + 危险 +
                            +
                            + 圆角块级带图标按钮 +

                            +
                            +
                            +
                            + +
                            +
                            +
                            + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/cards.html b/bmw-admin/src/main/resources/templates/demo/form/cards.html similarity index 100% rename from ruoyi-admin/src/main/resources/templates/demo/form/cards.html rename to bmw-admin/src/main/resources/templates/demo/form/cards.html diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/datetime.html b/bmw-admin/src/main/resources/templates/demo/form/datetime.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/form/datetime.html rename to bmw-admin/src/main/resources/templates/demo/form/datetime.html index f159f3d88..a7a527c58 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/datetime.html +++ b/bmw-admin/src/main/resources/templates/demo/form/datetime.html @@ -1,236 +1,236 @@ - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            日期选择器 https://github.com/smalot/bootstrap-datetimepicker
                            -
                            -
                            -
                            - -
                            - - -
                            -
                            - -
                            - -
                            - - -
                            -
                            - -
                            - -
                            - - -
                            -
                            - -
                            - -
                            - - - -
                            -
                            - -
                            - -
                            - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            日期选择器 https://github.com/sentsin/laydate
                            -
                            -
                            -
                            - -
                            - - -
                            -
                            - -
                            - -
                            - - -
                            -
                            - -
                            - -
                            - - -
                            -
                            - -
                            - -
                            - - -
                            -
                            - -
                            - -
                            - - - -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            日期选择器 https://github.com/smalot/bootstrap-datetimepicker
                            +
                            +
                            +
                            + +
                            + + +
                            +
                            + +
                            + +
                            + + +
                            +
                            + +
                            + +
                            + + +
                            +
                            + +
                            + +
                            + + + +
                            +
                            + +
                            + +
                            + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            日期选择器 https://github.com/sentsin/laydate
                            +
                            +
                            +
                            + +
                            + + +
                            +
                            + +
                            + +
                            + + +
                            +
                            + +
                            + +
                            + + +
                            +
                            + +
                            + +
                            + + +
                            +
                            + +
                            + +
                            + + + +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/duallistbox.html b/bmw-admin/src/main/resources/templates/demo/form/duallistbox.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/form/duallistbox.html rename to bmw-admin/src/main/resources/templates/demo/form/duallistbox.html index a8a55ddf1..76548d58b 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/duallistbox.html +++ b/bmw-admin/src/main/resources/templates/demo/form/duallistbox.html @@ -1,60 +1,60 @@ - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            双重列表框 https://github.com/istvan-ujjmeszaros/bootstrap-duallistbox
                            -
                            -
                            -

                            - Bootstrap Dual Listbox是针对Twitter Bootstrap进行了优化的响应式双列表框。它适用于所有现代浏览器和触摸设备。 -

                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            双重列表框 https://github.com/istvan-ujjmeszaros/bootstrap-duallistbox
                            +
                            +
                            +

                            + Bootstrap Dual Listbox是针对Twitter Bootstrap进行了优化的响应式双列表框。它适用于所有现代浏览器和触摸设备。 +

                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/grid.html b/bmw-admin/src/main/resources/templates/demo/form/grid.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/form/grid.html rename to bmw-admin/src/main/resources/templates/demo/form/grid.html index 1db0deffd..c92af9e92 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/grid.html +++ b/bmw-admin/src/main/resources/templates/demo/form/grid.html @@ -1,432 +1,432 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            栅格设置
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -

                            通过下表可以详细查看 Bootstrap 的栅格系统是如何在多种屏幕设备上工作的。

                            -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            - 超小屏幕 - 手机 (<768px) - - 小屏幕 - 平板 (≥768px) - - 中等屏幕 - 桌面显示器 (≥992px) - - 大屏幕 - 大桌面显示器 (≥1200px) -
                            栅格系统行为总是水平排列开始是堆叠在一起的,当大于这些阈值时将变为水平排列C
                            .container 最大宽度None (自动)750px970px1170px
                            类前缀.col-xs- - .col-sm- - .col-md- - .col-lg- -
                            列(column)数12
                            最大列(column)宽自动~62px~81px~97px
                            槽(gutter)宽30px (每列左右均有 15px)
                            可嵌套
                            偏移(Offsets)
                            列排序
                            -
                            - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            从堆叠到水平排列
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -

                            使用单一的一组 .col-md-* 栅格类,就可以创建一个基本的栅格系统,在手机和平板设备上一开始是堆叠在一起的(超小屏幕到小屏幕这一范围),在桌面(中等)屏幕设备上变为水平排列。所有“列(column)必须放在 ” .row 内。

                            -
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            .col-md-1
                            -
                            -
                            -
                            .col-md-8
                            -
                            .col-md-4
                            -
                            -
                            -
                            .col-md-4
                            -
                            .col-md-4
                            -
                            .col-md-4
                            -
                            -
                            -
                            .col-md-6
                            -
                            .col-md-6
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            移动设备和桌面屏幕
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -

                            是否不希望在小屏幕设备上所有列都堆叠在一起?那就使用针对超小屏幕和中等屏幕设备所定义的类吧,即 .col-xs-*.col-md-*。请看下面的实例,研究一下这些是如何工作的。

                            -
                            -
                            .col-xs-12 .col-md-8
                            -
                            .col-xs-6 .col-md-4
                            -
                            -
                            -
                            .col-xs-6 .col-md-4
                            -
                            .col-xs-6 .col-md-4
                            -
                            .col-xs-6 .col-md-4
                            -
                            -
                            -
                            .col-xs-6
                            -
                            .col-xs-6
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            手机、平板、桌面
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -

                            在上面案例的基础上,通过使用针对平板设备的 .col-sm-* 类,我们来创建更加动态和强大的布局吧。

                            -
                            -
                            .col-xs-12 .col-sm-6 .col-md-8
                            -
                            .col-xs-6 .col-md-4
                            -
                            -
                            -
                            .col-xs-6 .col-sm-4
                            -
                            .col-xs-6 .col-sm-4
                            - -
                            -
                            .col-xs-6 .col-sm-4
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            多余的列(column)将另起一行排列
                            - -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            在等宽的4网格中,网格不等高会碰到问题,为了解决这个问题,可使用.clearfix响应实用工具类 -

                            -
                            -
                            - .col-xs-6 .col-sm-3 -
                            调整窗口大小或者在手机上查看本示例 -
                            -
                            .col-xs-6 .col-sm-3
                            - - -
                            - -
                            .col-xs-6 .col-sm-3
                            -
                            .col-xs-6 .col-sm-3
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            列偏移
                            - -
                            - - - - - - - - - - -
                            -
                            -
                            - -

                            使用 .col-md-offset-* 类可以将列向右侧偏移。这些类实际是通过使用 * 选择器为当前元素增加了左侧的边距(margin)。例如,.col-md-offset-4 类将 .col-md-4 元素向右侧偏移了4个列(column)的宽度。

                            -
                            -
                            .col-md-4
                            -
                            .col-md-4 .col-md-offset-4
                            -
                            -
                            -
                            .col-md-3 .col-md-offset-3
                            -
                            .col-md-3 .col-md-offset-3
                            -
                            -
                            -
                            .col-md-6 .col-md-offset-3
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            嵌套列
                            - -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            为了使用内置的栅格系统将内容再次嵌套,可以通过添加一个新的 .row 元素和一系列 .col-sm-* 元素到已经存在的 .col-sm-* 元素内。被嵌套的行(row)所包含的列(column)的个数不能超过12(其实,没有要求你必须占满12列)。

                            -
                            -
                            - 第一级: .col-md-9 -
                            -
                            - 第二级: .col-md-6 -
                            -
                            - 第二级: .col-md-6 -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            列排序
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            通过使用 .col-md-push-*.col-md-pull-* 类就可以很容易的改变列(column)的顺序。

                            -
                            -
                            .col-md-9 .col-md-push-3
                            -
                            .col-md-3 .col-md-pull-9
                            -
                            -
                            -
                            - -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            栅格设置
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +

                            通过下表可以详细查看 Bootstrap 的栅格系统是如何在多种屏幕设备上工作的。

                            +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            + 超小屏幕 + 手机 (<768px) + + 小屏幕 + 平板 (≥768px) + + 中等屏幕 + 桌面显示器 (≥992px) + + 大屏幕 + 大桌面显示器 (≥1200px) +
                            栅格系统行为总是水平排列开始是堆叠在一起的,当大于这些阈值时将变为水平排列C
                            .container 最大宽度None (自动)750px970px1170px
                            类前缀.col-xs- + .col-sm- + .col-md- + .col-lg- +
                            列(column)数12
                            最大列(column)宽自动~62px~81px~97px
                            槽(gutter)宽30px (每列左右均有 15px)
                            可嵌套
                            偏移(Offsets)
                            列排序
                            +
                            + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            从堆叠到水平排列
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +

                            使用单一的一组 .col-md-* 栅格类,就可以创建一个基本的栅格系统,在手机和平板设备上一开始是堆叠在一起的(超小屏幕到小屏幕这一范围),在桌面(中等)屏幕设备上变为水平排列。所有“列(column)必须放在 ” .row 内。

                            +
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            .col-md-1
                            +
                            +
                            +
                            .col-md-8
                            +
                            .col-md-4
                            +
                            +
                            +
                            .col-md-4
                            +
                            .col-md-4
                            +
                            .col-md-4
                            +
                            +
                            +
                            .col-md-6
                            +
                            .col-md-6
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            移动设备和桌面屏幕
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +

                            是否不希望在小屏幕设备上所有列都堆叠在一起?那就使用针对超小屏幕和中等屏幕设备所定义的类吧,即 .col-xs-*.col-md-*。请看下面的实例,研究一下这些是如何工作的。

                            +
                            +
                            .col-xs-12 .col-md-8
                            +
                            .col-xs-6 .col-md-4
                            +
                            +
                            +
                            .col-xs-6 .col-md-4
                            +
                            .col-xs-6 .col-md-4
                            +
                            .col-xs-6 .col-md-4
                            +
                            +
                            +
                            .col-xs-6
                            +
                            .col-xs-6
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            手机、平板、桌面
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +

                            在上面案例的基础上,通过使用针对平板设备的 .col-sm-* 类,我们来创建更加动态和强大的布局吧。

                            +
                            +
                            .col-xs-12 .col-sm-6 .col-md-8
                            +
                            .col-xs-6 .col-md-4
                            +
                            +
                            +
                            .col-xs-6 .col-sm-4
                            +
                            .col-xs-6 .col-sm-4
                            + +
                            +
                            .col-xs-6 .col-sm-4
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            多余的列(column)将另起一行排列
                            + +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            在等宽的4网格中,网格不等高会碰到问题,为了解决这个问题,可使用.clearfix响应实用工具类 +

                            +
                            +
                            + .col-xs-6 .col-sm-3 +
                            调整窗口大小或者在手机上查看本示例 +
                            +
                            .col-xs-6 .col-sm-3
                            + + +
                            + +
                            .col-xs-6 .col-sm-3
                            +
                            .col-xs-6 .col-sm-3
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            列偏移
                            + +
                            + + + + + + + + + + +
                            +
                            +
                            + +

                            使用 .col-md-offset-* 类可以将列向右侧偏移。这些类实际是通过使用 * 选择器为当前元素增加了左侧的边距(margin)。例如,.col-md-offset-4 类将 .col-md-4 元素向右侧偏移了4个列(column)的宽度。

                            +
                            +
                            .col-md-4
                            +
                            .col-md-4 .col-md-offset-4
                            +
                            +
                            +
                            .col-md-3 .col-md-offset-3
                            +
                            .col-md-3 .col-md-offset-3
                            +
                            +
                            +
                            .col-md-6 .col-md-offset-3
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            嵌套列
                            + +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            为了使用内置的栅格系统将内容再次嵌套,可以通过添加一个新的 .row 元素和一系列 .col-sm-* 元素到已经存在的 .col-sm-* 元素内。被嵌套的行(row)所包含的列(column)的个数不能超过12(其实,没有要求你必须占满12列)。

                            +
                            +
                            + 第一级: .col-md-9 +
                            +
                            + 第二级: .col-md-6 +
                            +
                            + 第二级: .col-md-6 +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            列排序
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            通过使用 .col-md-push-*.col-md-pull-* 类就可以很容易的改变列(column)的顺序。

                            +
                            +
                            .col-md-9 .col-md-push-3
                            +
                            .col-md-3 .col-md-pull-9
                            +
                            +
                            +
                            + +
                            +
                            +
                            + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/jasny.html b/bmw-admin/src/main/resources/templates/demo/form/jasny.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/form/jasny.html rename to bmw-admin/src/main/resources/templates/demo/form/jasny.html index 25aefb835..7bbdcdec9 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/jasny.html +++ b/bmw-admin/src/main/resources/templates/demo/form/jasny.html @@ -1,118 +1,118 @@ - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            文件上传控件 https://github.com/jasny/bootstrap
                            -
                            -
                            -
                            - - -
                            -
                            - 选择文件更改 - 清除 -
                            -
                            - -
                            - -
                            -
                            - 选择文件更改 - - × -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - 选择图片更改 - 清除 -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            -
                            - 选择图片更改 - 清除 -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            固定格式文本 https://github.com/jasny/bootstrap
                            -
                            -
                            -
                            - - - 158-8888-88888 -
                            - -
                            - - - 0730-8888888 -
                            - -
                            - - - yyyy-mm-dd -
                            - -
                            - - - 192.168.100.200 -
                            - -
                            - - - 99-9999999 -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            文件上传控件 https://github.com/jasny/bootstrap
                            +
                            +
                            +
                            + + +
                            +
                            + 选择文件更改 + 清除 +
                            +
                            + +
                            + +
                            +
                            + 选择文件更改 + + × +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + 选择图片更改 + 清除 +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            +
                            + 选择图片更改 + 清除 +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            固定格式文本 https://github.com/jasny/bootstrap
                            +
                            +
                            +
                            + + + 158-8888-88888 +
                            + +
                            + + + 0730-8888888 +
                            + +
                            + + + yyyy-mm-dd +
                            + +
                            + + + 192.168.100.200 +
                            + +
                            + + + 99-9999999 +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/select.html b/bmw-admin/src/main/resources/templates/demo/form/select.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/form/select.html rename to bmw-admin/src/main/resources/templates/demo/form/select.html index 383c31e0f..96f921de2 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/select.html +++ b/bmw-admin/src/main/resources/templates/demo/form/select.html @@ -1,148 +1,148 @@ - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            下拉框 https://github.com/select2/select2
                            -
                            -
                            -
                            - - -
                            - -
                            - - -
                            - -
                            - - -
                            - -
                            - - -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            下拉框 https://github.com/snapappointments/bootstrap-select
                            -
                            -
                            -
                            - - -
                            - -
                            - - -
                            - -
                            - - -
                            - -
                            - - -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            下拉框 https://github.com/select2/select2
                            +
                            +
                            +
                            + + +
                            + +
                            + + +
                            + +
                            + + +
                            + +
                            + + +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            下拉框 https://github.com/snapappointments/bootstrap-select
                            +
                            +
                            +
                            + + +
                            + +
                            + + +
                            + +
                            + + +
                            + +
                            + + +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/sortable.html b/bmw-admin/src/main/resources/templates/demo/form/sortable.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/form/sortable.html rename to bmw-admin/src/main/resources/templates/demo/form/sortable.html index 3793571b3..478be4cdf 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/sortable.html +++ b/bmw-admin/src/main/resources/templates/demo/form/sortable.html @@ -1,198 +1,198 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -

                            任务列表

                            -

                            在列表之间拖动任务面板

                            - -
                            - - - - -
                            - -
                              -
                            • - 加强过程管理,及时统计教育经费使用情况,做到底码清楚, -
                              - 标签 - 2018.09.01 -
                              -
                            • -
                            • - 支持财会人员的继续培训工作。 -
                              - 标记 - 2018.05.12 -
                              -
                            • -
                            • - 协同教导处搞好助学金、减免教科书费的工作。 -
                              - 标记 - 2018.09.10 -
                              -
                            • -
                            • - 要求会计、出纳人员严格执行财务制度,遵守岗位职责,按时上报各种资料。 -
                              - 确定 - 2018.06.10 -
                              -
                            • -
                            • - 做好职工公费医疗工作,按时发放门诊费。 -
                              - 标签 - 2018.09.09 -
                              -
                            • -
                            • - 有计划地把课本复习三至五遍。 -
                              - 确定 - 2018.08.04 -
                              -
                            • -
                            • - 看一本高质量的高中语法书 -
                              - 标记 - 2018.05.12 -
                              -
                            • -
                            • - 选择一份较好的英语报纸,通过阅读提高英语学习效果。 -
                              - 标记 - 2018.09.10 -
                              -
                            • -
                            -
                            -
                            -
                            -
                            -
                            -
                            -

                            进行中

                            -

                            在列表之间拖动任务面板

                            -
                              -
                            • - 全面、较深入地掌握我们“产品”的功能、特色和优势并做到应用自如。 -
                              - 标签 - 2018.09.01 -
                              -
                            • -
                            • - 根据自己以前所了解的和从其他途径搜索到的信息,录入客户资料150家。 -
                              - 标记 - 2018.05.12 -
                              -
                            • -
                            • - 锁定有意向客户20家。 -
                              - 标记 - 2018.09.10 -
                              -
                            • -
                            • - 力争完成销售指标。 -
                              - 标签 - 2018.09.09 -
                              -
                            • -
                            • - 在总结和摸索中前进。 -
                              - 确定 - 2018.08.04 -
                              -
                            • -
                            • - 不断学习行业知识、产品知识,为客户带来实用介绍内容 -
                              - 标记 - 2018.05.12 -
                              -
                            • -
                            • - 先友后单:与客户发展良好友谊,转换销售员角色,处处为客户着想 -
                              - 标记 - 2018.11.04 -
                              -
                            • -
                            -
                            -
                            -
                            -
                            -
                            -
                            -

                            已完成

                            -

                            在列表之间拖动任务面板

                            -
                              -
                            • - 制定工作日程表 -
                              - 标记 - 2018.09.10 -
                              -
                            • -
                            • - 每天坚持打40个有效电话,挖掘潜在客户 -
                              - 标签 - 2018.09.09 -
                              -
                            • -
                            • - 拜访客户之前要对该客户做全面的了解(客户的潜在需求、职位、权限以及个人性格和爱好) -
                              - 标签 - 2018.09.09 -
                              -
                            • -
                            • - 提高自己电话营销技巧,灵活专业地与客户进行电话交流 -
                              - 确定 - 2018.08.04 -
                              -
                            • -
                            • - 通过电话销售过程中了解各盛市的设备仪器使用、采购情况及相关重要追踪人 -
                              - 标记 - 2018.05.12 -
                              -
                            • - -
                            -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +

                            任务列表

                            +

                            在列表之间拖动任务面板

                            + +
                            + + + + +
                            + +
                              +
                            • + 加强过程管理,及时统计教育经费使用情况,做到底码清楚, +
                              + 标签 + 2018.09.01 +
                              +
                            • +
                            • + 支持财会人员的继续培训工作。 +
                              + 标记 + 2018.05.12 +
                              +
                            • +
                            • + 协同教导处搞好助学金、减免教科书费的工作。 +
                              + 标记 + 2018.09.10 +
                              +
                            • +
                            • + 要求会计、出纳人员严格执行财务制度,遵守岗位职责,按时上报各种资料。 +
                              + 确定 + 2018.06.10 +
                              +
                            • +
                            • + 做好职工公费医疗工作,按时发放门诊费。 +
                              + 标签 + 2018.09.09 +
                              +
                            • +
                            • + 有计划地把课本复习三至五遍。 +
                              + 确定 + 2018.08.04 +
                              +
                            • +
                            • + 看一本高质量的高中语法书 +
                              + 标记 + 2018.05.12 +
                              +
                            • +
                            • + 选择一份较好的英语报纸,通过阅读提高英语学习效果。 +
                              + 标记 + 2018.09.10 +
                              +
                            • +
                            +
                            +
                            +
                            +
                            +
                            +
                            +

                            进行中

                            +

                            在列表之间拖动任务面板

                            +
                              +
                            • + 全面、较深入地掌握我们“产品”的功能、特色和优势并做到应用自如。 +
                              + 标签 + 2018.09.01 +
                              +
                            • +
                            • + 根据自己以前所了解的和从其他途径搜索到的信息,录入客户资料150家。 +
                              + 标记 + 2018.05.12 +
                              +
                            • +
                            • + 锁定有意向客户20家。 +
                              + 标记 + 2018.09.10 +
                              +
                            • +
                            • + 力争完成销售指标。 +
                              + 标签 + 2018.09.09 +
                              +
                            • +
                            • + 在总结和摸索中前进。 +
                              + 确定 + 2018.08.04 +
                              +
                            • +
                            • + 不断学习行业知识、产品知识,为客户带来实用介绍内容 +
                              + 标记 + 2018.05.12 +
                              +
                            • +
                            • + 先友后单:与客户发展良好友谊,转换销售员角色,处处为客户着想 +
                              + 标记 + 2018.11.04 +
                              +
                            • +
                            +
                            +
                            +
                            +
                            +
                            +
                            +

                            已完成

                            +

                            在列表之间拖动任务面板

                            +
                              +
                            • + 制定工作日程表 +
                              + 标记 + 2018.09.10 +
                              +
                            • +
                            • + 每天坚持打40个有效电话,挖掘潜在客户 +
                              + 标签 + 2018.09.09 +
                              +
                            • +
                            • + 拜访客户之前要对该客户做全面的了解(客户的潜在需求、职位、权限以及个人性格和爱好) +
                              + 标签 + 2018.09.09 +
                              +
                            • +
                            • + 提高自己电话营销技巧,灵活专业地与客户进行电话交流 +
                              + 确定 + 2018.08.04 +
                              +
                            • +
                            • + 通过电话销售过程中了解各盛市的设备仪器使用、采购情况及相关重要追踪人 +
                              + 标记 + 2018.05.12 +
                              +
                            • + +
                            +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/summernote.html b/bmw-admin/src/main/resources/templates/demo/form/summernote.html similarity index 100% rename from ruoyi-admin/src/main/resources/templates/demo/form/summernote.html rename to bmw-admin/src/main/resources/templates/demo/form/summernote.html diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/tabs_panels.html b/bmw-admin/src/main/resources/templates/demo/form/tabs_panels.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/form/tabs_panels.html rename to bmw-admin/src/main/resources/templates/demo/form/tabs_panels.html index e7a8fa7fc..230f68cd0 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/tabs_panels.html +++ b/bmw-admin/src/main/resources/templates/demo/form/tabs_panels.html @@ -1,353 +1,353 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            基本面板 这是一个自定义面板
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -

                            - Bootstrap
                            -

                            -

                            - 简洁、直观、强悍的前端开发框架,让web开发更迅速、简单。

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            - HTML5 文档类型 -

                            Bootstrap 使用到的某些 HTML 元素和 CSS 属性需要将页面设置为 HTML5 文档类型。在你项目中的每个页面都要参照下面的格式进行设置。

                            -
                            -
                            -
                            -
                            - 移动设备优先 -

                            在 Bootstrap 2 中,我们对框架中的某些关键部分增加了对移动设备友好的样式。而在 Bootstrap 3 中,我们重写了整个框架,使其一开始就是对移动设备友好的。这次不是简单的增加一些可选的针对移动设备的样式,而是直接融合进了框架的内核中。也就是说,Bootstrap 是移动设备优先的。针对移动设备的样式融合进了框架的每个角落,而不是增加一个额外的文件。

                            -
                            -
                            -
                            - - -
                            -
                            - -
                            -
                            - -
                            -
                            -

                            图标选项卡

                            -
                            -
                            - - -
                            -
                            - -
                            -
                            -
                            - 排版与链接 - -

                            Bootstrap 排版、链接样式设置了基本的全局样式。分别是: 为 body 元素设置 background-color: #fff; 使用 @font-family-base、@font-size-base 和 @line-height-base a变量作为排版的基本参数 为所有链接设置了基本颜色 @link-color ,并且当链接处于 :hover 状态时才添加下划线 这些样式都能在 scaffolding.less 文件中找到对应的源码。

                            -
                            - -
                            - Normalize.css - -

                            为了增强跨浏览器表现的一致性,我们使用了 Normalize.css,这是由 Nicolas Gallagher 和 Jonathan Neal 维护的一个CSS 重置样式库。

                            -
                            -
                            - 布局容器 - -

                            Bootstrap 需要为页面内容和栅格系统包裹一个 .container 容器。我们提供了两个作此用处的类。注意,由于 padding 等属性的原因,这两种 容器类不能互相嵌套。

                            -
                            -
                            - 栅格系统 - -

                            Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列。它包含了易于使用的预定义类,还有强大的mixin 用于生成更具语义的布局。

                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - 排版与链接 - -

                            Bootstrap 排版、链接样式设置了基本的全局样式。分别是: 为 body 元素设置 background-color: #fff; 使用 @font-family-base、@font-size-base 和 @line-height-base a变量作为排版的基本参数 为所有链接设置了基本颜色 @link-color ,并且当链接处于 :hover 状态时才添加下划线 这些样式都能在 scaffolding.less 文件中找到对应的源码。

                            -
                            -
                            -
                            -
                            - 栅格系统 - -

                            Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列。它包含了易于使用的预定义类,还有强大的mixin 用于生成更具语义的布局。

                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            - 排版与链接 - -

                            Bootstrap 排版、链接样式设置了基本的全局样式。分别是: 为 body 元素设置 background-color: #fff; 使用 @font-family-base、@font-size-base 和 @line-height-base a变量作为排版的基本参数 为所有链接设置了基本颜色 @link-color ,并且当链接处于 :hover 状态时才添加下划线 这些样式都能在 scaffolding.less 文件中找到对应的源码。

                            -
                            -
                            -
                            -
                            - 栅格系统 - -

                            Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列。它包含了易于使用的预定义类,还有强大的mixin 用于生成更具语义的布局。

                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            Bootstrap面板 自定义背景
                            -
                            -
                            - -
                            -
                            -
                            -
                            - 默认面板 -
                            -
                            -

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            -
                            - -
                            -
                            -
                            -
                            -
                            - 主要 -
                            -
                            -

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            -
                            -
                            -
                            -
                            -
                            -
                            - 成功 -
                            -
                            -

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - 信息 -
                            -
                            -

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            -
                            - -
                            -
                            -
                            -
                            -
                            - 警告 -
                            -
                            -

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            -
                            -
                            -
                            -
                            -
                            -
                            - 危险 -
                            -
                            -

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            -
                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            折叠面板
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - 标题 #1 -
                            -
                            -
                            -
                            - Bootstrap相关优质项目推荐 这些项目或者是对Bootstrap进行了有益的补充,或者是基于Bootstrap开发的 -
                            -
                            -
                            -
                            -
                            -

                            - 标题 #2 -

                            -
                            -
                            -
                            - Bootstrap相关优质项目推荐 这些项目或者是对Bootstrap进行了有益的补充,或者是基于Bootstrap开发的 -
                            -
                            -
                            -
                            -
                            -

                            - 标题 #3 -

                            -
                            -
                            -
                            - Bootstrap相关优质项目推荐 这些项目或者是对Bootstrap进行了有益的补充,或者是基于Bootstrap开发的 -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -

                            超大屏幕

                            -

                            Bootstrap 支持的另一个特性,超大屏幕(Jumbotron)。顾名思义该组件可以增加标题的大小,并为登陆页面内容添加更多的外边距(margin)。使用超大屏幕(Jumbotron)的步骤如下:

                            -
                            -
                              -
                            1. 创建一个带有 class .jumbotron. 的容器
                            2. -
                            3. 除了更大的 <h1>,字体粗细 font-weight 被减为 200px。
                            4. -
                            -
                            - -

                            了解更多 -

                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            基本面板 这是一个自定义面板
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +

                            + Bootstrap
                            +

                            +

                            + 简洁、直观、强悍的前端开发框架,让web开发更迅速、简单。

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            + HTML5 文档类型 +

                            Bootstrap 使用到的某些 HTML 元素和 CSS 属性需要将页面设置为 HTML5 文档类型。在你项目中的每个页面都要参照下面的格式进行设置。

                            +
                            +
                            +
                            +
                            + 移动设备优先 +

                            在 Bootstrap 2 中,我们对框架中的某些关键部分增加了对移动设备友好的样式。而在 Bootstrap 3 中,我们重写了整个框架,使其一开始就是对移动设备友好的。这次不是简单的增加一些可选的针对移动设备的样式,而是直接融合进了框架的内核中。也就是说,Bootstrap 是移动设备优先的。针对移动设备的样式融合进了框架的每个角落,而不是增加一个额外的文件。

                            +
                            +
                            +
                            + + +
                            +
                            + +
                            +
                            + +
                            +
                            +

                            图标选项卡

                            +
                            +
                            + + +
                            +
                            + +
                            +
                            +
                            + 排版与链接 + +

                            Bootstrap 排版、链接样式设置了基本的全局样式。分别是: 为 body 元素设置 background-color: #fff; 使用 @font-family-base、@font-size-base 和 @line-height-base a变量作为排版的基本参数 为所有链接设置了基本颜色 @link-color ,并且当链接处于 :hover 状态时才添加下划线 这些样式都能在 scaffolding.less 文件中找到对应的源码。

                            +
                            + +
                            + Normalize.css + +

                            为了增强跨浏览器表现的一致性,我们使用了 Normalize.css,这是由 Nicolas Gallagher 和 Jonathan Neal 维护的一个CSS 重置样式库。

                            +
                            +
                            + 布局容器 + +

                            Bootstrap 需要为页面内容和栅格系统包裹一个 .container 容器。我们提供了两个作此用处的类。注意,由于 padding 等属性的原因,这两种 容器类不能互相嵌套。

                            +
                            +
                            + 栅格系统 + +

                            Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列。它包含了易于使用的预定义类,还有强大的mixin 用于生成更具语义的布局。

                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + 排版与链接 + +

                            Bootstrap 排版、链接样式设置了基本的全局样式。分别是: 为 body 元素设置 background-color: #fff; 使用 @font-family-base、@font-size-base 和 @line-height-base a变量作为排版的基本参数 为所有链接设置了基本颜色 @link-color ,并且当链接处于 :hover 状态时才添加下划线 这些样式都能在 scaffolding.less 文件中找到对应的源码。

                            +
                            +
                            +
                            +
                            + 栅格系统 + +

                            Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列。它包含了易于使用的预定义类,还有强大的mixin 用于生成更具语义的布局。

                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            + 排版与链接 + +

                            Bootstrap 排版、链接样式设置了基本的全局样式。分别是: 为 body 元素设置 background-color: #fff; 使用 @font-family-base、@font-size-base 和 @line-height-base a变量作为排版的基本参数 为所有链接设置了基本颜色 @link-color ,并且当链接处于 :hover 状态时才添加下划线 这些样式都能在 scaffolding.less 文件中找到对应的源码。

                            +
                            +
                            +
                            +
                            + 栅格系统 + +

                            Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列。它包含了易于使用的预定义类,还有强大的mixin 用于生成更具语义的布局。

                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            Bootstrap面板 自定义背景
                            +
                            +
                            + +
                            +
                            +
                            +
                            + 默认面板 +
                            +
                            +

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            +
                            + +
                            +
                            +
                            +
                            +
                            + 主要 +
                            +
                            +

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            +
                            +
                            +
                            +
                            +
                            +
                            + 成功 +
                            +
                            +

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + 信息 +
                            +
                            +

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            +
                            + +
                            +
                            +
                            +
                            +
                            + 警告 +
                            +
                            +

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            +
                            +
                            +
                            +
                            +
                            +
                            + 危险 +
                            +
                            +

                            通过 .panel-heading 可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title 类的标签,添加一个预定义样式的标题。 为了给链接设置合适的颜色,务必将链接放到带有 .panel-title 类的标题标签内。

                            +
                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            折叠面板
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + 标题 #1 +
                            +
                            +
                            +
                            + Bootstrap相关优质项目推荐 这些项目或者是对Bootstrap进行了有益的补充,或者是基于Bootstrap开发的 +
                            +
                            +
                            +
                            +
                            +

                            + 标题 #2 +

                            +
                            +
                            +
                            + Bootstrap相关优质项目推荐 这些项目或者是对Bootstrap进行了有益的补充,或者是基于Bootstrap开发的 +
                            +
                            +
                            +
                            +
                            +

                            + 标题 #3 +

                            +
                            +
                            +
                            + Bootstrap相关优质项目推荐 这些项目或者是对Bootstrap进行了有益的补充,或者是基于Bootstrap开发的 +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +

                            超大屏幕

                            +

                            Bootstrap 支持的另一个特性,超大屏幕(Jumbotron)。顾名思义该组件可以增加标题的大小,并为登陆页面内容添加更多的外边距(margin)。使用超大屏幕(Jumbotron)的步骤如下:

                            +
                            +
                              +
                            1. 创建一个带有 class .jumbotron. 的容器
                            2. +
                            3. 除了更大的 <h1>,字体粗细 font-weight 被减为 200px。
                            4. +
                            +
                            + +

                            了解更多 +

                            +
                            +
                            +
                            +
                            + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/upload.html b/bmw-admin/src/main/resources/templates/demo/form/upload.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/form/upload.html rename to bmw-admin/src/main/resources/templates/demo/form/upload.html index 7c78daa34..8368e32f9 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/upload.html +++ b/bmw-admin/src/main/resources/templates/demo/form/upload.html @@ -1,55 +1,55 @@ - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            文件上传控件 https://github.com/kartik-v/bootstrap-fileinput
                            -
                            -
                            -
                            - -
                            - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            文件上传控件 https://github.com/kartik-v/bootstrap-fileinput
                            +
                            +
                            +
                            + +
                            + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/validate.html b/bmw-admin/src/main/resources/templates/demo/form/validate.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/form/validate.html rename to bmw-admin/src/main/resources/templates/demo/form/validate.html index 35f48fa48..13f0b10a9 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/validate.html +++ b/bmw-admin/src/main/resources/templates/demo/form/validate.html @@ -1,193 +1,193 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            jQuery Validate 简介
                            -
                            -
                            -

                            jquery.validate.js 是一款优秀的jQuery表单验证插件。它具有如下特点:

                            -
                              -
                            • 安装简单
                            • -
                            • 内置超过20种数据验证方法
                            • -
                            • 直列错误提示信息
                            • -
                            • 可扩展的数据验证方法
                            • -
                            • 使用内置的元数据或插件选项来指定您的验证规则
                            • -
                            • 优雅的交互设计
                            • -
                            -

                            官网:http://jqueryvalidation.org/ -

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            简单示例
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -

                            更多示例请访问官方示例页面:查看 -

                            -

                            中文API可参考:http://doc.ruoyi.vip/#/standard/zjwd?id=jquery-validate -

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            完整验证表单
                            -
                            -
                            -
                            -
                            - -
                            - - 这里写点提示的内容 -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - 请再次输入您的密码 -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            jQuery Validate 简介
                            +
                            +
                            +

                            jquery.validate.js 是一款优秀的jQuery表单验证插件。它具有如下特点:

                            +
                              +
                            • 安装简单
                            • +
                            • 内置超过20种数据验证方法
                            • +
                            • 直列错误提示信息
                            • +
                            • 可扩展的数据验证方法
                            • +
                            • 使用内置的元数据或插件选项来指定您的验证规则
                            • +
                            • 优雅的交互设计
                            • +
                            +

                            官网:http://jqueryvalidation.org/ +

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            简单示例
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +

                            更多示例请访问官方示例页面:查看 +

                            +

                            中文API可参考:http://doc.ruoyi.vip/#/standard/zjwd?id=jquery-validate +

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            完整验证表单
                            +
                            +
                            +
                            +
                            + +
                            + + 这里写点提示的内容 +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + 请再次输入您的密码 +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/form/wizard.html b/bmw-admin/src/main/resources/templates/demo/form/wizard.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/form/wizard.html rename to bmw-admin/src/main/resources/templates/demo/form/wizard.html index 428f330ec..1b48de347 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/form/wizard.html +++ b/bmw-admin/src/main/resources/templates/demo/form/wizard.html @@ -1,192 +1,192 @@ - - - - - - - -
                            -
                            -
                            -
                            -

                            表单向导

                            -

                            Smart UI 部件允许您快速创建表单向导接口。

                            -

                            了解 jQuery Steps -

                            -
                            -
                            -
                            -
                            -
                            -
                            基础表单向导
                            -
                            -
                            -

                            - 这是一个简单的表单向导示例 -

                            -
                            -

                            第一步

                            -
                            -
                            -

                            第一步

                            -

                            - 这是第一步的内容 -

                            -
                            -
                            - -

                            第二步

                            -
                            -
                            -

                            第二步

                            -

                            - 这是第二步的内容 -

                            -
                            -
                            - -

                            第三步

                            -
                            -
                            -

                            第三步

                            -

                            - 这是第三步的内容 -

                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            带验证的表单向导
                            -
                            -
                            -

                            - 带验证的表单向导 -

                            -

                            - 下面这个示例展示了如何在表单向导中使用 jQuery Validation 插件 -

                            - -
                            -

                            账户

                            -
                            -

                            账户信息

                            -
                            -
                            -
                            - - -
                            -
                            - - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -

                            个人资料

                            -
                            -

                            个人资料信息

                            -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            - - -
                            -
                            - - -
                            -
                            -
                            -
                            - -

                            警告

                            -
                            -
                            -

                            你是火星人 :-)

                            -
                            -
                            - -

                            完成

                            -
                            -

                            条款

                            - - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            - - - - - + + + + + + + +
                            +
                            +
                            +
                            +

                            表单向导

                            +

                            Smart UI 部件允许您快速创建表单向导接口。

                            +

                            了解 jQuery Steps +

                            +
                            +
                            +
                            +
                            +
                            +
                            基础表单向导
                            +
                            +
                            +

                            + 这是一个简单的表单向导示例 +

                            +
                            +

                            第一步

                            +
                            +
                            +

                            第一步

                            +

                            + 这是第一步的内容 +

                            +
                            +
                            + +

                            第二步

                            +
                            +
                            +

                            第二步

                            +

                            + 这是第二步的内容 +

                            +
                            +
                            + +

                            第三步

                            +
                            +
                            +

                            第三步

                            +

                            + 这是第三步的内容 +

                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            带验证的表单向导
                            +
                            +
                            +

                            + 带验证的表单向导 +

                            +

                            + 下面这个示例展示了如何在表单向导中使用 jQuery Validation 插件 +

                            + +
                            +

                            账户

                            +
                            +

                            账户信息

                            +
                            +
                            +
                            + + +
                            +
                            + + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +

                            个人资料

                            +
                            +

                            个人资料信息

                            +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            + + +
                            +
                            + + +
                            +
                            +
                            +
                            + +

                            警告

                            +
                            +
                            +

                            你是火星人 :-)

                            +
                            +
                            + +

                            完成

                            +
                            +

                            条款

                            + + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/icon/fontawesome.html b/bmw-admin/src/main/resources/templates/demo/icon/fontawesome.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/icon/fontawesome.html rename to bmw-admin/src/main/resources/templates/demo/icon/fontawesome.html index 7206094af..14943817a 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/icon/fontawesome.html +++ b/bmw-admin/src/main/resources/templates/demo/icon/fontawesome.html @@ -1,1944 +1,1944 @@ - - - - - - -
                            -
                            -
                            -
                            -

                            Font Awesome 4.4.0

                            字体图标的最佳集合。提供可伸缩矢量图标,可以立即进行定制大小、颜色、阴影,所有都可以用CSS样式来完成。 -
                            -
                            -
                            -
                            -
                            -
                            所有图标 所有图标集合 - Font Awesome
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            - - - - - -
                            -
                            - - -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            - -
                            -
                            - - - - -
                            - -
                            - - - - -
                            -
                            - - - - -
                            -
                            - - - - -
                            -
                            - - -
                            -
                              -
                            • - 给这些图标加上 - fa-spin class,就可以表现出加载动画了 -
                            • -
                            -
                            - - -
                            -
                            - - - -
                            -
                            - - - - -
                            -
                            - - - - -
                            -
                            - - - - -
                            -
                            - - - - -
                            -
                            - - - - -
                            -
                            - - - - -
                            -
                            - - -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            - -
                            -
                              -
                            • 所有品牌图标均为其各自所有者的商标
                            • -
                            • 使用这些商标并不表示该商标持有人的认可,反之亦然
                            • -
                            - -
                            -
                            -
                            - - - - -
                            -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +

                            Font Awesome 4.4.0

                            字体图标的最佳集合。提供可伸缩矢量图标,可以立即进行定制大小、颜色、阴影,所有都可以用CSS样式来完成。 +
                            +
                            +
                            +
                            +
                            +
                            所有图标 所有图标集合 - Font Awesome
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            + + + + + +
                            +
                            + + +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            + +
                            +
                            + + + + +
                            + +
                            + + + + +
                            +
                            + + + + +
                            +
                            + + + + +
                            +
                            + + +
                            +
                              +
                            • + 给这些图标加上 + fa-spin class,就可以表现出加载动画了 +
                            • +
                            +
                            + + +
                            +
                            + + + +
                            +
                            + + + + +
                            +
                            + + + + +
                            +
                            + + + + +
                            +
                            + + + + +
                            +
                            + + + + +
                            +
                            + + + + +
                            +
                            + + +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            + +
                            +
                              +
                            • 所有品牌图标均为其各自所有者的商标
                            • +
                            • 使用这些商标并不表示该商标持有人的认可,反之亦然
                            • +
                            + +
                            +
                            +
                            + + + + +
                            +
                            +
                            +
                            +
                            +
                            + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/icon/glyphicons.html b/bmw-admin/src/main/resources/templates/demo/icon/glyphicons.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/icon/glyphicons.html rename to bmw-admin/src/main/resources/templates/demo/icon/glyphicons.html index aaf71d467..e8ee7c64d 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/icon/glyphicons.html +++ b/bmw-admin/src/main/resources/templates/demo/icon/glyphicons.html @@ -1,1364 +1,1364 @@ - - - - - - -
                            -
                            -
                            -
                            -

                            Glyphicons 字体图标

                            包括250多个来自 Glyphicon Halflings 的字体图标。Glyphicons Halflings 一般是收费的,但是他们的作者允许 Bootstrap 免费使用。为了表示感谢,希望你在使用时尽量为 Glyphicons 添加一个友情链接。 -
                            -
                            -
                            -
                            -
                            -
                            所有图标 所有图标集合 - Glyphicons
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                              - -
                            • - - glyphicon glyphicon-asterisk -
                            • - -
                            • - - glyphicon glyphicon-plus -
                            • - -
                            • - - glyphicon glyphicon-euro -
                            • - -
                            • - - glyphicon glyphicon-eur -
                            • - -
                            • - - glyphicon glyphicon-minus -
                            • - -
                            • - - glyphicon glyphicon-cloud -
                            • - -
                            • - - glyphicon glyphicon-envelope -
                            • - -
                            • - - glyphicon glyphicon-pencil -
                            • - -
                            • - - glyphicon glyphicon-glass -
                            • - -
                            • - - glyphicon glyphicon-music -
                            • - -
                            • - - glyphicon glyphicon-search -
                            • - -
                            • - - glyphicon glyphicon-heart -
                            • - -
                            • - - glyphicon glyphicon-star -
                            • - -
                            • - - glyphicon glyphicon-star-empty -
                            • - -
                            • - - glyphicon glyphicon-user -
                            • - -
                            • - - glyphicon glyphicon-film -
                            • - -
                            • - - glyphicon glyphicon-th-large -
                            • - -
                            • - - glyphicon glyphicon-th -
                            • - -
                            • - - glyphicon glyphicon-th-list -
                            • - -
                            • - - glyphicon glyphicon-ok -
                            • - -
                            • - - glyphicon glyphicon-remove -
                            • - -
                            • - - glyphicon glyphicon-zoom-in -
                            • - -
                            • - - glyphicon glyphicon-zoom-out -
                            • - -
                            • - - glyphicon glyphicon-off -
                            • - -
                            • - - glyphicon glyphicon-signal -
                            • - -
                            • - - glyphicon glyphicon-cog -
                            • - -
                            • - - glyphicon glyphicon-trash -
                            • - -
                            • - - glyphicon glyphicon-home -
                            • - -
                            • - - glyphicon glyphicon-file -
                            • - -
                            • - - glyphicon glyphicon-time -
                            • - -
                            • - - glyphicon glyphicon-road -
                            • - -
                            • - - glyphicon glyphicon-download-alt -
                            • - -
                            • - - glyphicon glyphicon-download -
                            • - -
                            • - - glyphicon glyphicon-upload -
                            • - -
                            • - - glyphicon glyphicon-inbox -
                            • - -
                            • - - glyphicon glyphicon-play-circle -
                            • - -
                            • - - glyphicon glyphicon-repeat -
                            • - -
                            • - - glyphicon glyphicon-refresh -
                            • - -
                            • - - glyphicon glyphicon-list-alt -
                            • - -
                            • - - glyphicon glyphicon-lock -
                            • - -
                            • - - glyphicon glyphicon-flag -
                            • - -
                            • - - glyphicon glyphicon-headphones -
                            • - -
                            • - - glyphicon glyphicon-volume-off -
                            • - -
                            • - - glyphicon glyphicon-volume-down -
                            • - -
                            • - - glyphicon glyphicon-volume-up -
                            • - -
                            • - - glyphicon glyphicon-qrcode -
                            • - -
                            • - - glyphicon glyphicon-barcode -
                            • - -
                            • - - glyphicon glyphicon-tag -
                            • - -
                            • - - glyphicon glyphicon-tags -
                            • - -
                            • - - glyphicon glyphicon-book -
                            • - -
                            • - - glyphicon glyphicon-bookmark -
                            • - -
                            • - - glyphicon glyphicon-print -
                            • - -
                            • - - glyphicon glyphicon-camera -
                            • - -
                            • - - glyphicon glyphicon-font -
                            • - -
                            • - - glyphicon glyphicon-bold -
                            • - -
                            • - - glyphicon glyphicon-italic -
                            • - -
                            • - - glyphicon glyphicon-text-height -
                            • - -
                            • - - glyphicon glyphicon-text-width -
                            • - -
                            • - - glyphicon glyphicon-align-left -
                            • - -
                            • - - glyphicon glyphicon-align-center -
                            • - -
                            • - - glyphicon glyphicon-align-right -
                            • - -
                            • - - glyphicon glyphicon-align-justify -
                            • - -
                            • - - glyphicon glyphicon-list -
                            • - -
                            • - - glyphicon glyphicon-indent-left -
                            • - -
                            • - - glyphicon glyphicon-indent-right -
                            • - -
                            • - - glyphicon glyphicon-facetime-video -
                            • - -
                            • - - glyphicon glyphicon-picture -
                            • - -
                            • - - glyphicon glyphicon-map-marker -
                            • - -
                            • - - glyphicon glyphicon-adjust -
                            • - -
                            • - - glyphicon glyphicon-tint -
                            • - -
                            • - - glyphicon glyphicon-edit -
                            • - -
                            • - - glyphicon glyphicon-share -
                            • - -
                            • - - glyphicon glyphicon-check -
                            • - -
                            • - - glyphicon glyphicon-move -
                            • - -
                            • - - glyphicon glyphicon-step-backward -
                            • - -
                            • - - glyphicon glyphicon-fast-backward -
                            • - -
                            • - - glyphicon glyphicon-backward -
                            • - -
                            • - - glyphicon glyphicon-play -
                            • - -
                            • - - glyphicon glyphicon-pause -
                            • - -
                            • - - glyphicon glyphicon-stop -
                            • - -
                            • - - glyphicon glyphicon-forward -
                            • - -
                            • - - glyphicon glyphicon-fast-forward -
                            • - -
                            • - - glyphicon glyphicon-step-forward -
                            • - -
                            • - - glyphicon glyphicon-eject -
                            • - -
                            • - - glyphicon glyphicon-chevron-left -
                            • - -
                            • - - glyphicon glyphicon-chevron-right -
                            • - -
                            • - - glyphicon glyphicon-plus-sign -
                            • - -
                            • - - glyphicon glyphicon-minus-sign -
                            • - -
                            • - - glyphicon glyphicon-remove-sign -
                            • - -
                            • - - glyphicon glyphicon-ok-sign -
                            • - -
                            • - - glyphicon glyphicon-question-sign -
                            • - -
                            • - - glyphicon glyphicon-info-sign -
                            • - -
                            • - - glyphicon glyphicon-screenshot -
                            • - -
                            • - - glyphicon glyphicon-remove-circle -
                            • - -
                            • - - glyphicon glyphicon-ok-circle -
                            • - -
                            • - - glyphicon glyphicon-ban-circle -
                            • - -
                            • - - glyphicon glyphicon-arrow-left -
                            • - -
                            • - - glyphicon glyphicon-arrow-right -
                            • - -
                            • - - glyphicon glyphicon-arrow-up -
                            • - -
                            • - - glyphicon glyphicon-arrow-down -
                            • - -
                            • - - glyphicon glyphicon-share-alt -
                            • - -
                            • - - glyphicon glyphicon-resize-full -
                            • - -
                            • - - glyphicon glyphicon-resize-small -
                            • - -
                            • - - glyphicon glyphicon-exclamation-sign -
                            • - -
                            • - - glyphicon glyphicon-gift -
                            • - -
                            • - - glyphicon glyphicon-leaf -
                            • - -
                            • - - glyphicon glyphicon-fire -
                            • - -
                            • - - glyphicon glyphicon-eye-open -
                            • - -
                            • - - glyphicon glyphicon-eye-close -
                            • - -
                            • - - glyphicon glyphicon-warning-sign -
                            • - -
                            • - - glyphicon glyphicon-plane -
                            • - -
                            • - - glyphicon glyphicon-calendar -
                            • - -
                            • - - glyphicon glyphicon-random -
                            • - -
                            • - - glyphicon glyphicon-comment -
                            • - -
                            • - - glyphicon glyphicon-magnet -
                            • - -
                            • - - glyphicon glyphicon-chevron-up -
                            • - -
                            • - - glyphicon glyphicon-chevron-down -
                            • - -
                            • - - glyphicon glyphicon-retweet -
                            • - -
                            • - - glyphicon glyphicon-shopping-cart -
                            • - -
                            • - - glyphicon glyphicon-folder-close -
                            • - -
                            • - - glyphicon glyphicon-folder-open -
                            • - -
                            • - - glyphicon glyphicon-resize-vertical -
                            • - -
                            • - - glyphicon glyphicon-resize-horizontal -
                            • - -
                            • - - glyphicon glyphicon-hdd -
                            • - -
                            • - - glyphicon glyphicon-bullhorn -
                            • - -
                            • - - glyphicon glyphicon-bell -
                            • - -
                            • - - glyphicon glyphicon-certificate -
                            • - -
                            • - - glyphicon glyphicon-thumbs-up -
                            • - -
                            • - - glyphicon glyphicon-thumbs-down -
                            • - -
                            • - - glyphicon glyphicon-hand-right -
                            • - -
                            • - - glyphicon glyphicon-hand-left -
                            • - -
                            • - - glyphicon glyphicon-hand-up -
                            • - -
                            • - - glyphicon glyphicon-hand-down -
                            • - -
                            • - - glyphicon glyphicon-circle-arrow-right -
                            • - -
                            • - - glyphicon glyphicon-circle-arrow-left -
                            • - -
                            • - - glyphicon glyphicon-circle-arrow-up -
                            • - -
                            • - - glyphicon glyphicon-circle-arrow-down -
                            • - -
                            • - - glyphicon glyphicon-globe -
                            • - -
                            • - - glyphicon glyphicon-wrench -
                            • - -
                            • - - glyphicon glyphicon-tasks -
                            • - -
                            • - - glyphicon glyphicon-filter -
                            • - -
                            • - - glyphicon glyphicon-briefcase -
                            • - -
                            • - - glyphicon glyphicon-fullscreen -
                            • - -
                            • - - glyphicon glyphicon-dashboard -
                            • - -
                            • - - glyphicon glyphicon-paperclip -
                            • - -
                            • - - glyphicon glyphicon-heart-empty -
                            • - -
                            • - - glyphicon glyphicon-link -
                            • - -
                            • - - glyphicon glyphicon-phone -
                            • - -
                            • - - glyphicon glyphicon-pushpin -
                            • - -
                            • - - glyphicon glyphicon-usd -
                            • - -
                            • - - glyphicon glyphicon-gbp -
                            • - -
                            • - - glyphicon glyphicon-sort -
                            • - -
                            • - - glyphicon glyphicon-sort-by-alphabet -
                            • - -
                            • - - glyphicon glyphicon-sort-by-alphabet-alt -
                            • - -
                            • - - glyphicon glyphicon-sort-by-order -
                            • - -
                            • - - glyphicon glyphicon-sort-by-order-alt -
                            • - -
                            • - - glyphicon glyphicon-sort-by-attributes -
                            • - -
                            • - - glyphicon glyphicon-sort-by-attributes-alt -
                            • - -
                            • - - glyphicon glyphicon-unchecked -
                            • - -
                            • - - glyphicon glyphicon-expand -
                            • - -
                            • - - glyphicon glyphicon-collapse-down -
                            • - -
                            • - - glyphicon glyphicon-collapse-up -
                            • - -
                            • - - glyphicon glyphicon-log-in -
                            • - -
                            • - - glyphicon glyphicon-flash -
                            • - -
                            • - - glyphicon glyphicon-log-out -
                            • - -
                            • - - glyphicon glyphicon-new-window -
                            • - -
                            • - - glyphicon glyphicon-record -
                            • - -
                            • - - glyphicon glyphicon-save -
                            • - -
                            • - - glyphicon glyphicon-open -
                            • - -
                            • - - glyphicon glyphicon-saved -
                            • - -
                            • - - glyphicon glyphicon-import -
                            • - -
                            • - - glyphicon glyphicon-export -
                            • - -
                            • - - glyphicon glyphicon-send -
                            • - -
                            • - - glyphicon glyphicon-floppy-disk -
                            • - -
                            • - - glyphicon glyphicon-floppy-saved -
                            • - -
                            • - - glyphicon glyphicon-floppy-remove -
                            • - -
                            • - - glyphicon glyphicon-floppy-save -
                            • - -
                            • - - glyphicon glyphicon-floppy-open -
                            • - -
                            • - - glyphicon glyphicon-credit-card -
                            • - -
                            • - - glyphicon glyphicon-transfer -
                            • - -
                            • - - glyphicon glyphicon-cutlery -
                            • - -
                            • - - glyphicon glyphicon-header -
                            • - -
                            • - - glyphicon glyphicon-compressed -
                            • - -
                            • - - glyphicon glyphicon-earphone -
                            • - -
                            • - - glyphicon glyphicon-phone-alt -
                            • - -
                            • - - glyphicon glyphicon-tower -
                            • - -
                            • - - glyphicon glyphicon-stats -
                            • - -
                            • - - glyphicon glyphicon-sd-video -
                            • - -
                            • - - glyphicon glyphicon-hd-video -
                            • - -
                            • - - glyphicon glyphicon-subtitles -
                            • - -
                            • - - glyphicon glyphicon-sound-stereo -
                            • - -
                            • - - glyphicon glyphicon-sound-dolby -
                            • - -
                            • - - glyphicon glyphicon-sound-5-1 -
                            • - -
                            • - - glyphicon glyphicon-sound-6-1 -
                            • - -
                            • - - glyphicon glyphicon-sound-7-1 -
                            • - -
                            • - - glyphicon glyphicon-copyright-mark -
                            • - -
                            • - - glyphicon glyphicon-registration-mark -
                            • - -
                            • - - glyphicon glyphicon-cloud-download -
                            • - -
                            • - - glyphicon glyphicon-cloud-upload -
                            • - -
                            • - - glyphicon glyphicon-tree-conifer -
                            • - -
                            • - - glyphicon glyphicon-tree-deciduous -
                            • - -
                            • - - glyphicon glyphicon-cd -
                            • - -
                            • - - glyphicon glyphicon-save-file -
                            • - -
                            • - - glyphicon glyphicon-open-file -
                            • - -
                            • - - glyphicon glyphicon-level-up -
                            • - -
                            • - - glyphicon glyphicon-copy -
                            • - -
                            • - - glyphicon glyphicon-paste -
                            • - -
                            • - - glyphicon glyphicon-alert -
                            • - -
                            • - - glyphicon glyphicon-equalizer -
                            • - -
                            • - - glyphicon glyphicon-king -
                            • - -
                            • - - glyphicon glyphicon-queen -
                            • - -
                            • - - glyphicon glyphicon-pawn -
                            • - -
                            • - - glyphicon glyphicon-bishop -
                            • - -
                            • - - glyphicon glyphicon-knight -
                            • - -
                            • - - glyphicon glyphicon-baby-formula -
                            • - -
                            • - - glyphicon glyphicon-tent -
                            • - -
                            • - - glyphicon glyphicon-blackboard -
                            • - -
                            • - - glyphicon glyphicon-bed -
                            • - -
                            • - - glyphicon glyphicon-apple -
                            • - -
                            • - - glyphicon glyphicon-erase -
                            • - -
                            • - - glyphicon glyphicon-hourglass -
                            • - -
                            • - - glyphicon glyphicon-lamp -
                            • - -
                            • - - glyphicon glyphicon-duplicate -
                            • - -
                            • - - glyphicon glyphicon-piggy-bank -
                            • - -
                            • - - glyphicon glyphicon-scissors -
                            • - -
                            • - - glyphicon glyphicon-bitcoin -
                            • - -
                            • - - glyphicon glyphicon-btc -
                            • - -
                            • - - glyphicon glyphicon-xbt -
                            • - -
                            • - - glyphicon glyphicon-yen -
                            • - -
                            • - - glyphicon glyphicon-jpy -
                            • - -
                            • - - glyphicon glyphicon-ruble -
                            • - -
                            • - - glyphicon glyphicon-rub -
                            • - -
                            • - - glyphicon glyphicon-scale -
                            • - -
                            • - - glyphicon glyphicon-ice-lolly -
                            • - -
                            • - - glyphicon glyphicon-ice-lolly-tasted -
                            • - -
                            • - - glyphicon glyphicon-education -
                            • - -
                            • - - glyphicon glyphicon-option-horizontal -
                            • - -
                            • - - glyphicon glyphicon-option-vertical -
                            • - -
                            • - - glyphicon glyphicon-menu-hamburger -
                            • - -
                            • - - glyphicon glyphicon-modal-window -
                            • - -
                            • - - glyphicon glyphicon-oil -
                            • - -
                            • - - glyphicon glyphicon-grain -
                            • - -
                            • - - glyphicon glyphicon-sunglasses -
                            • - -
                            • - - glyphicon glyphicon-text-size -
                            • - -
                            • - - glyphicon glyphicon-text-color -
                            • - -
                            • - - glyphicon glyphicon-text-background -
                            • - -
                            • - - glyphicon glyphicon-object-align-top -
                            • - -
                            • - - glyphicon glyphicon-object-align-bottom -
                            • - -
                            • - - glyphicon glyphicon-object-align-horizontal -
                            • - -
                            • - - glyphicon glyphicon-object-align-left -
                            • - -
                            • - - glyphicon glyphicon-object-align-vertical -
                            • - -
                            • - - glyphicon glyphicon-object-align-right -
                            • - -
                            • - - glyphicon glyphicon-triangle-right -
                            • - -
                            • - - glyphicon glyphicon-triangle-left -
                            • - -
                            • - - glyphicon glyphicon-triangle-bottom -
                            • - -
                            • - - glyphicon glyphicon-triangle-top -
                            • - -
                            • - - glyphicon glyphicon-console -
                            • - -
                            • - - glyphicon glyphicon-superscript -
                            • - -
                            • - - glyphicon glyphicon-subscript -
                            • - -
                            • - - glyphicon glyphicon-menu-left -
                            • - -
                            • - - glyphicon glyphicon-menu-right -
                            • - -
                            • - - glyphicon glyphicon-menu-down -
                            • - -
                            • - - glyphicon glyphicon-menu-up -
                            • - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +

                            Glyphicons 字体图标

                            包括250多个来自 Glyphicon Halflings 的字体图标。Glyphicons Halflings 一般是收费的,但是他们的作者允许 Bootstrap 免费使用。为了表示感谢,希望你在使用时尽量为 Glyphicons 添加一个友情链接。 +
                            +
                            +
                            +
                            +
                            +
                            所有图标 所有图标集合 - Glyphicons
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                              + +
                            • + + glyphicon glyphicon-asterisk +
                            • + +
                            • + + glyphicon glyphicon-plus +
                            • + +
                            • + + glyphicon glyphicon-euro +
                            • + +
                            • + + glyphicon glyphicon-eur +
                            • + +
                            • + + glyphicon glyphicon-minus +
                            • + +
                            • + + glyphicon glyphicon-cloud +
                            • + +
                            • + + glyphicon glyphicon-envelope +
                            • + +
                            • + + glyphicon glyphicon-pencil +
                            • + +
                            • + + glyphicon glyphicon-glass +
                            • + +
                            • + + glyphicon glyphicon-music +
                            • + +
                            • + + glyphicon glyphicon-search +
                            • + +
                            • + + glyphicon glyphicon-heart +
                            • + +
                            • + + glyphicon glyphicon-star +
                            • + +
                            • + + glyphicon glyphicon-star-empty +
                            • + +
                            • + + glyphicon glyphicon-user +
                            • + +
                            • + + glyphicon glyphicon-film +
                            • + +
                            • + + glyphicon glyphicon-th-large +
                            • + +
                            • + + glyphicon glyphicon-th +
                            • + +
                            • + + glyphicon glyphicon-th-list +
                            • + +
                            • + + glyphicon glyphicon-ok +
                            • + +
                            • + + glyphicon glyphicon-remove +
                            • + +
                            • + + glyphicon glyphicon-zoom-in +
                            • + +
                            • + + glyphicon glyphicon-zoom-out +
                            • + +
                            • + + glyphicon glyphicon-off +
                            • + +
                            • + + glyphicon glyphicon-signal +
                            • + +
                            • + + glyphicon glyphicon-cog +
                            • + +
                            • + + glyphicon glyphicon-trash +
                            • + +
                            • + + glyphicon glyphicon-home +
                            • + +
                            • + + glyphicon glyphicon-file +
                            • + +
                            • + + glyphicon glyphicon-time +
                            • + +
                            • + + glyphicon glyphicon-road +
                            • + +
                            • + + glyphicon glyphicon-download-alt +
                            • + +
                            • + + glyphicon glyphicon-download +
                            • + +
                            • + + glyphicon glyphicon-upload +
                            • + +
                            • + + glyphicon glyphicon-inbox +
                            • + +
                            • + + glyphicon glyphicon-play-circle +
                            • + +
                            • + + glyphicon glyphicon-repeat +
                            • + +
                            • + + glyphicon glyphicon-refresh +
                            • + +
                            • + + glyphicon glyphicon-list-alt +
                            • + +
                            • + + glyphicon glyphicon-lock +
                            • + +
                            • + + glyphicon glyphicon-flag +
                            • + +
                            • + + glyphicon glyphicon-headphones +
                            • + +
                            • + + glyphicon glyphicon-volume-off +
                            • + +
                            • + + glyphicon glyphicon-volume-down +
                            • + +
                            • + + glyphicon glyphicon-volume-up +
                            • + +
                            • + + glyphicon glyphicon-qrcode +
                            • + +
                            • + + glyphicon glyphicon-barcode +
                            • + +
                            • + + glyphicon glyphicon-tag +
                            • + +
                            • + + glyphicon glyphicon-tags +
                            • + +
                            • + + glyphicon glyphicon-book +
                            • + +
                            • + + glyphicon glyphicon-bookmark +
                            • + +
                            • + + glyphicon glyphicon-print +
                            • + +
                            • + + glyphicon glyphicon-camera +
                            • + +
                            • + + glyphicon glyphicon-font +
                            • + +
                            • + + glyphicon glyphicon-bold +
                            • + +
                            • + + glyphicon glyphicon-italic +
                            • + +
                            • + + glyphicon glyphicon-text-height +
                            • + +
                            • + + glyphicon glyphicon-text-width +
                            • + +
                            • + + glyphicon glyphicon-align-left +
                            • + +
                            • + + glyphicon glyphicon-align-center +
                            • + +
                            • + + glyphicon glyphicon-align-right +
                            • + +
                            • + + glyphicon glyphicon-align-justify +
                            • + +
                            • + + glyphicon glyphicon-list +
                            • + +
                            • + + glyphicon glyphicon-indent-left +
                            • + +
                            • + + glyphicon glyphicon-indent-right +
                            • + +
                            • + + glyphicon glyphicon-facetime-video +
                            • + +
                            • + + glyphicon glyphicon-picture +
                            • + +
                            • + + glyphicon glyphicon-map-marker +
                            • + +
                            • + + glyphicon glyphicon-adjust +
                            • + +
                            • + + glyphicon glyphicon-tint +
                            • + +
                            • + + glyphicon glyphicon-edit +
                            • + +
                            • + + glyphicon glyphicon-share +
                            • + +
                            • + + glyphicon glyphicon-check +
                            • + +
                            • + + glyphicon glyphicon-move +
                            • + +
                            • + + glyphicon glyphicon-step-backward +
                            • + +
                            • + + glyphicon glyphicon-fast-backward +
                            • + +
                            • + + glyphicon glyphicon-backward +
                            • + +
                            • + + glyphicon glyphicon-play +
                            • + +
                            • + + glyphicon glyphicon-pause +
                            • + +
                            • + + glyphicon glyphicon-stop +
                            • + +
                            • + + glyphicon glyphicon-forward +
                            • + +
                            • + + glyphicon glyphicon-fast-forward +
                            • + +
                            • + + glyphicon glyphicon-step-forward +
                            • + +
                            • + + glyphicon glyphicon-eject +
                            • + +
                            • + + glyphicon glyphicon-chevron-left +
                            • + +
                            • + + glyphicon glyphicon-chevron-right +
                            • + +
                            • + + glyphicon glyphicon-plus-sign +
                            • + +
                            • + + glyphicon glyphicon-minus-sign +
                            • + +
                            • + + glyphicon glyphicon-remove-sign +
                            • + +
                            • + + glyphicon glyphicon-ok-sign +
                            • + +
                            • + + glyphicon glyphicon-question-sign +
                            • + +
                            • + + glyphicon glyphicon-info-sign +
                            • + +
                            • + + glyphicon glyphicon-screenshot +
                            • + +
                            • + + glyphicon glyphicon-remove-circle +
                            • + +
                            • + + glyphicon glyphicon-ok-circle +
                            • + +
                            • + + glyphicon glyphicon-ban-circle +
                            • + +
                            • + + glyphicon glyphicon-arrow-left +
                            • + +
                            • + + glyphicon glyphicon-arrow-right +
                            • + +
                            • + + glyphicon glyphicon-arrow-up +
                            • + +
                            • + + glyphicon glyphicon-arrow-down +
                            • + +
                            • + + glyphicon glyphicon-share-alt +
                            • + +
                            • + + glyphicon glyphicon-resize-full +
                            • + +
                            • + + glyphicon glyphicon-resize-small +
                            • + +
                            • + + glyphicon glyphicon-exclamation-sign +
                            • + +
                            • + + glyphicon glyphicon-gift +
                            • + +
                            • + + glyphicon glyphicon-leaf +
                            • + +
                            • + + glyphicon glyphicon-fire +
                            • + +
                            • + + glyphicon glyphicon-eye-open +
                            • + +
                            • + + glyphicon glyphicon-eye-close +
                            • + +
                            • + + glyphicon glyphicon-warning-sign +
                            • + +
                            • + + glyphicon glyphicon-plane +
                            • + +
                            • + + glyphicon glyphicon-calendar +
                            • + +
                            • + + glyphicon glyphicon-random +
                            • + +
                            • + + glyphicon glyphicon-comment +
                            • + +
                            • + + glyphicon glyphicon-magnet +
                            • + +
                            • + + glyphicon glyphicon-chevron-up +
                            • + +
                            • + + glyphicon glyphicon-chevron-down +
                            • + +
                            • + + glyphicon glyphicon-retweet +
                            • + +
                            • + + glyphicon glyphicon-shopping-cart +
                            • + +
                            • + + glyphicon glyphicon-folder-close +
                            • + +
                            • + + glyphicon glyphicon-folder-open +
                            • + +
                            • + + glyphicon glyphicon-resize-vertical +
                            • + +
                            • + + glyphicon glyphicon-resize-horizontal +
                            • + +
                            • + + glyphicon glyphicon-hdd +
                            • + +
                            • + + glyphicon glyphicon-bullhorn +
                            • + +
                            • + + glyphicon glyphicon-bell +
                            • + +
                            • + + glyphicon glyphicon-certificate +
                            • + +
                            • + + glyphicon glyphicon-thumbs-up +
                            • + +
                            • + + glyphicon glyphicon-thumbs-down +
                            • + +
                            • + + glyphicon glyphicon-hand-right +
                            • + +
                            • + + glyphicon glyphicon-hand-left +
                            • + +
                            • + + glyphicon glyphicon-hand-up +
                            • + +
                            • + + glyphicon glyphicon-hand-down +
                            • + +
                            • + + glyphicon glyphicon-circle-arrow-right +
                            • + +
                            • + + glyphicon glyphicon-circle-arrow-left +
                            • + +
                            • + + glyphicon glyphicon-circle-arrow-up +
                            • + +
                            • + + glyphicon glyphicon-circle-arrow-down +
                            • + +
                            • + + glyphicon glyphicon-globe +
                            • + +
                            • + + glyphicon glyphicon-wrench +
                            • + +
                            • + + glyphicon glyphicon-tasks +
                            • + +
                            • + + glyphicon glyphicon-filter +
                            • + +
                            • + + glyphicon glyphicon-briefcase +
                            • + +
                            • + + glyphicon glyphicon-fullscreen +
                            • + +
                            • + + glyphicon glyphicon-dashboard +
                            • + +
                            • + + glyphicon glyphicon-paperclip +
                            • + +
                            • + + glyphicon glyphicon-heart-empty +
                            • + +
                            • + + glyphicon glyphicon-link +
                            • + +
                            • + + glyphicon glyphicon-phone +
                            • + +
                            • + + glyphicon glyphicon-pushpin +
                            • + +
                            • + + glyphicon glyphicon-usd +
                            • + +
                            • + + glyphicon glyphicon-gbp +
                            • + +
                            • + + glyphicon glyphicon-sort +
                            • + +
                            • + + glyphicon glyphicon-sort-by-alphabet +
                            • + +
                            • + + glyphicon glyphicon-sort-by-alphabet-alt +
                            • + +
                            • + + glyphicon glyphicon-sort-by-order +
                            • + +
                            • + + glyphicon glyphicon-sort-by-order-alt +
                            • + +
                            • + + glyphicon glyphicon-sort-by-attributes +
                            • + +
                            • + + glyphicon glyphicon-sort-by-attributes-alt +
                            • + +
                            • + + glyphicon glyphicon-unchecked +
                            • + +
                            • + + glyphicon glyphicon-expand +
                            • + +
                            • + + glyphicon glyphicon-collapse-down +
                            • + +
                            • + + glyphicon glyphicon-collapse-up +
                            • + +
                            • + + glyphicon glyphicon-log-in +
                            • + +
                            • + + glyphicon glyphicon-flash +
                            • + +
                            • + + glyphicon glyphicon-log-out +
                            • + +
                            • + + glyphicon glyphicon-new-window +
                            • + +
                            • + + glyphicon glyphicon-record +
                            • + +
                            • + + glyphicon glyphicon-save +
                            • + +
                            • + + glyphicon glyphicon-open +
                            • + +
                            • + + glyphicon glyphicon-saved +
                            • + +
                            • + + glyphicon glyphicon-import +
                            • + +
                            • + + glyphicon glyphicon-export +
                            • + +
                            • + + glyphicon glyphicon-send +
                            • + +
                            • + + glyphicon glyphicon-floppy-disk +
                            • + +
                            • + + glyphicon glyphicon-floppy-saved +
                            • + +
                            • + + glyphicon glyphicon-floppy-remove +
                            • + +
                            • + + glyphicon glyphicon-floppy-save +
                            • + +
                            • + + glyphicon glyphicon-floppy-open +
                            • + +
                            • + + glyphicon glyphicon-credit-card +
                            • + +
                            • + + glyphicon glyphicon-transfer +
                            • + +
                            • + + glyphicon glyphicon-cutlery +
                            • + +
                            • + + glyphicon glyphicon-header +
                            • + +
                            • + + glyphicon glyphicon-compressed +
                            • + +
                            • + + glyphicon glyphicon-earphone +
                            • + +
                            • + + glyphicon glyphicon-phone-alt +
                            • + +
                            • + + glyphicon glyphicon-tower +
                            • + +
                            • + + glyphicon glyphicon-stats +
                            • + +
                            • + + glyphicon glyphicon-sd-video +
                            • + +
                            • + + glyphicon glyphicon-hd-video +
                            • + +
                            • + + glyphicon glyphicon-subtitles +
                            • + +
                            • + + glyphicon glyphicon-sound-stereo +
                            • + +
                            • + + glyphicon glyphicon-sound-dolby +
                            • + +
                            • + + glyphicon glyphicon-sound-5-1 +
                            • + +
                            • + + glyphicon glyphicon-sound-6-1 +
                            • + +
                            • + + glyphicon glyphicon-sound-7-1 +
                            • + +
                            • + + glyphicon glyphicon-copyright-mark +
                            • + +
                            • + + glyphicon glyphicon-registration-mark +
                            • + +
                            • + + glyphicon glyphicon-cloud-download +
                            • + +
                            • + + glyphicon glyphicon-cloud-upload +
                            • + +
                            • + + glyphicon glyphicon-tree-conifer +
                            • + +
                            • + + glyphicon glyphicon-tree-deciduous +
                            • + +
                            • + + glyphicon glyphicon-cd +
                            • + +
                            • + + glyphicon glyphicon-save-file +
                            • + +
                            • + + glyphicon glyphicon-open-file +
                            • + +
                            • + + glyphicon glyphicon-level-up +
                            • + +
                            • + + glyphicon glyphicon-copy +
                            • + +
                            • + + glyphicon glyphicon-paste +
                            • + +
                            • + + glyphicon glyphicon-alert +
                            • + +
                            • + + glyphicon glyphicon-equalizer +
                            • + +
                            • + + glyphicon glyphicon-king +
                            • + +
                            • + + glyphicon glyphicon-queen +
                            • + +
                            • + + glyphicon glyphicon-pawn +
                            • + +
                            • + + glyphicon glyphicon-bishop +
                            • + +
                            • + + glyphicon glyphicon-knight +
                            • + +
                            • + + glyphicon glyphicon-baby-formula +
                            • + +
                            • + + glyphicon glyphicon-tent +
                            • + +
                            • + + glyphicon glyphicon-blackboard +
                            • + +
                            • + + glyphicon glyphicon-bed +
                            • + +
                            • + + glyphicon glyphicon-apple +
                            • + +
                            • + + glyphicon glyphicon-erase +
                            • + +
                            • + + glyphicon glyphicon-hourglass +
                            • + +
                            • + + glyphicon glyphicon-lamp +
                            • + +
                            • + + glyphicon glyphicon-duplicate +
                            • + +
                            • + + glyphicon glyphicon-piggy-bank +
                            • + +
                            • + + glyphicon glyphicon-scissors +
                            • + +
                            • + + glyphicon glyphicon-bitcoin +
                            • + +
                            • + + glyphicon glyphicon-btc +
                            • + +
                            • + + glyphicon glyphicon-xbt +
                            • + +
                            • + + glyphicon glyphicon-yen +
                            • + +
                            • + + glyphicon glyphicon-jpy +
                            • + +
                            • + + glyphicon glyphicon-ruble +
                            • + +
                            • + + glyphicon glyphicon-rub +
                            • + +
                            • + + glyphicon glyphicon-scale +
                            • + +
                            • + + glyphicon glyphicon-ice-lolly +
                            • + +
                            • + + glyphicon glyphicon-ice-lolly-tasted +
                            • + +
                            • + + glyphicon glyphicon-education +
                            • + +
                            • + + glyphicon glyphicon-option-horizontal +
                            • + +
                            • + + glyphicon glyphicon-option-vertical +
                            • + +
                            • + + glyphicon glyphicon-menu-hamburger +
                            • + +
                            • + + glyphicon glyphicon-modal-window +
                            • + +
                            • + + glyphicon glyphicon-oil +
                            • + +
                            • + + glyphicon glyphicon-grain +
                            • + +
                            • + + glyphicon glyphicon-sunglasses +
                            • + +
                            • + + glyphicon glyphicon-text-size +
                            • + +
                            • + + glyphicon glyphicon-text-color +
                            • + +
                            • + + glyphicon glyphicon-text-background +
                            • + +
                            • + + glyphicon glyphicon-object-align-top +
                            • + +
                            • + + glyphicon glyphicon-object-align-bottom +
                            • + +
                            • + + glyphicon glyphicon-object-align-horizontal +
                            • + +
                            • + + glyphicon glyphicon-object-align-left +
                            • + +
                            • + + glyphicon glyphicon-object-align-vertical +
                            • + +
                            • + + glyphicon glyphicon-object-align-right +
                            • + +
                            • + + glyphicon glyphicon-triangle-right +
                            • + +
                            • + + glyphicon glyphicon-triangle-left +
                            • + +
                            • + + glyphicon glyphicon-triangle-bottom +
                            • + +
                            • + + glyphicon glyphicon-triangle-top +
                            • + +
                            • + + glyphicon glyphicon-console +
                            • + +
                            • + + glyphicon glyphicon-superscript +
                            • + +
                            • + + glyphicon glyphicon-subscript +
                            • + +
                            • + + glyphicon glyphicon-menu-left +
                            • + +
                            • + + glyphicon glyphicon-menu-right +
                            • + +
                            • + + glyphicon glyphicon-menu-down +
                            • + +
                            • + + glyphicon glyphicon-menu-up +
                            • + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/modal/dialog.html b/bmw-admin/src/main/resources/templates/demo/modal/dialog.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/demo/modal/dialog.html rename to bmw-admin/src/main/resources/templates/demo/modal/dialog.html index 58ffc2db8..2444334b2 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/modal/dialog.html +++ b/bmw-admin/src/main/resources/templates/demo/modal/dialog.html @@ -1,215 +1,215 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            模态窗口
                            - -
                            -
                            -

                            创建自定义的RuoYi模态窗口可通过添加.inmodal类来实现。

                            -
                            - -
                            - - -
                            -
                            -
                            -
                            -
                            大小设置
                            - -
                            -
                            -

                            模态窗口提供两种大小尺寸,可以通过为模态窗口的.modal-dialog添加类来实现

                            - -
                            - - -
                            - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            动画窗口
                            - -
                            -
                            -

                            您可以通过为模态窗口的.modal-content添加类来实现动画效果

                            - - - - - - - -
                            -
                            -
                            -
                            -
                            设置选项
                            - -
                            -
                            -

                            可以通过数据绑定或者Javascript来实现模态窗口的相关功能,如果使用数据绑定,可以为元素添加data-,如data-backdrop=""

                            - -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            名称类型默认值说明
                            backdropboolean 或 string 'static'true遮罩层,或使用'static'指定遮罩层与关闭模态窗口不关联
                            keyboardbooleantrue按Esc键时退出模态窗口
                            showbooleantrue初始化完成后显示模态窗口
                            remotepathfalse -

                            推荐使用数据绑定方式,或使用 - jQuery.load

                            -

                            远程URL示例:

                            -
                            -
                            <a data-toggle="modal" href="remote.html" data-target="#modal">Click me</a>
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            模态窗口
                            + +
                            +
                            +

                            创建自定义的RuoYi模态窗口可通过添加.inmodal类来实现。

                            +
                            + +
                            + + +
                            +
                            +
                            +
                            +
                            大小设置
                            + +
                            +
                            +

                            模态窗口提供两种大小尺寸,可以通过为模态窗口的.modal-dialog添加类来实现

                            + +
                            + + +
                            + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            动画窗口
                            + +
                            +
                            +

                            您可以通过为模态窗口的.modal-content添加类来实现动画效果

                            + + + + + + + +
                            +
                            +
                            +
                            +
                            设置选项
                            + +
                            +
                            +

                            可以通过数据绑定或者Javascript来实现模态窗口的相关功能,如果使用数据绑定,可以为元素添加data-,如data-backdrop=""

                            + +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            名称类型默认值说明
                            backdropboolean 或 string 'static'true遮罩层,或使用'static'指定遮罩层与关闭模态窗口不关联
                            keyboardbooleantrue按Esc键时退出模态窗口
                            showbooleantrue初始化完成后显示模态窗口
                            remotepathfalse +

                            推荐使用数据绑定方式,或使用 + jQuery.load

                            +

                            远程URL示例:

                            +
                            +
                            <a data-toggle="modal" href="remote.html" data-target="#modal">Click me</a>
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/modal/form.html b/bmw-admin/src/main/resources/templates/demo/modal/form.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/modal/form.html rename to bmw-admin/src/main/resources/templates/demo/modal/form.html index ae0ab6ac5..5af6f6120 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/modal/form.html +++ b/bmw-admin/src/main/resources/templates/demo/modal/form.html @@ -1,95 +1,95 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/modal/layer.html b/bmw-admin/src/main/resources/templates/demo/modal/layer.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/modal/layer.html rename to bmw-admin/src/main/resources/templates/demo/modal/layer.html index 31c642480..9eba7486e 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/modal/layer.html +++ b/bmw-admin/src/main/resources/templates/demo/modal/layer.html @@ -1,256 +1,256 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            信息框
                            -
                            -
                            -

                            通过调用$.modal.alert()实现。

                            - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            提示框
                            -
                            -
                            -

                            通过调用$.modal.msg()实现。

                            - - - - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            询问框
                            -
                            -
                            -

                            通过调用$.modal.confirm()实现。

                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            消息提示并刷新父窗体
                            -
                            -
                            -

                            通过调用$.modal.msgReload()实现。

                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            普通弹出层
                            -
                            -
                            -

                            通过调用$.modal.open()实现。

                            - - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            选卡页方式
                            -
                            -
                            -

                            通过调用$.modal.openTab()实现。

                            - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            其他内容
                            -
                            -
                            -

                            通过调用layer实现。

                            - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            遮罩层
                            -
                            -
                            -

                            通过调用blockUI实现。

                            - - - -
                            -
                            -
                            - -
                            -
                            -
                            - - -
                            -
                            - -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            信息框
                            +
                            +
                            +

                            通过调用$.modal.alert()实现。

                            + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            提示框
                            +
                            +
                            +

                            通过调用$.modal.msg()实现。

                            + + + + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            询问框
                            +
                            +
                            +

                            通过调用$.modal.confirm()实现。

                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            消息提示并刷新父窗体
                            +
                            +
                            +

                            通过调用$.modal.msgReload()实现。

                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            普通弹出层
                            +
                            +
                            +

                            通过调用$.modal.open()实现。

                            + + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            选卡页方式
                            +
                            +
                            +

                            通过调用$.modal.openTab()实现。

                            + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            其他内容
                            +
                            +
                            +

                            通过调用layer实现。

                            + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            遮罩层
                            +
                            +
                            +

                            通过调用blockUI实现。

                            + + + +
                            +
                            +
                            + +
                            +
                            +
                            + + +
                            +
                            + +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/modal/table.html b/bmw-admin/src/main/resources/templates/demo/modal/table.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/modal/table.html rename to bmw-admin/src/main/resources/templates/demo/modal/table.html index e93131830..9feec45c2 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/modal/table.html +++ b/bmw-admin/src/main/resources/templates/demo/modal/table.html @@ -1,56 +1,56 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            弹层框
                            -
                            -
                            -

                            弹出复选框表格及单选框表格(点击提交后得到数据)。

                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            弹层框
                            -
                            -
                            -

                            弹出复选框表格及单选框表格(点击提交后得到数据并回显到父窗体)。

                            - -

                            -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            弹层框
                            +
                            +
                            +

                            弹出复选框表格及单选框表格(点击提交后得到数据)。

                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            弹层框
                            +
                            +
                            +

                            弹出复选框表格及单选框表格(点击提交后得到数据并回显到父窗体)。

                            + +

                            +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/modal/table/check.html b/bmw-admin/src/main/resources/templates/demo/modal/table/check.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/modal/table/check.html rename to bmw-admin/src/main/resources/templates/demo/modal/table/check.html index cf8d178d1..15c4eaace 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/modal/table/check.html +++ b/bmw-admin/src/main/resources/templates/demo/modal/table/check.html @@ -1,86 +1,86 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/modal/table/parent.html b/bmw-admin/src/main/resources/templates/demo/modal/table/parent.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/modal/table/parent.html rename to bmw-admin/src/main/resources/templates/demo/modal/table/parent.html index 14f59dcc7..eb8d6277f 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/modal/table/parent.html +++ b/bmw-admin/src/main/resources/templates/demo/modal/table/parent.html @@ -1,90 +1,90 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/modal/table/radio.html b/bmw-admin/src/main/resources/templates/demo/modal/table/radio.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/modal/table/radio.html rename to bmw-admin/src/main/resources/templates/demo/modal/table/radio.html index 4c9607dfc..4f3bea80a 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/modal/table/radio.html +++ b/bmw-admin/src/main/resources/templates/demo/modal/table/radio.html @@ -1,86 +1,86 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/operate/add.html b/bmw-admin/src/main/resources/templates/demo/operate/add.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/operate/add.html rename to bmw-admin/src/main/resources/templates/demo/operate/add.html index 3a95e7939..ee01f18d7 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/operate/add.html +++ b/bmw-admin/src/main/resources/templates/demo/operate/add.html @@ -1,78 +1,78 @@ - - - - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/operate/detail.html b/bmw-admin/src/main/resources/templates/demo/operate/detail.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/operate/detail.html rename to bmw-admin/src/main/resources/templates/demo/operate/detail.html index 42eda918c..6b5505568 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/operate/detail.html +++ b/bmw-admin/src/main/resources/templates/demo/operate/detail.html @@ -1,69 +1,69 @@ - - - - - - -
                            -
                            -
                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/operate/edit.html b/bmw-admin/src/main/resources/templates/demo/operate/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/operate/edit.html rename to bmw-admin/src/main/resources/templates/demo/operate/edit.html index d7d87fcfb..355f0ba9e 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/operate/edit.html +++ b/bmw-admin/src/main/resources/templates/demo/operate/edit.html @@ -1,79 +1,79 @@ - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/demo/operate/other.html b/bmw-admin/src/main/resources/templates/demo/operate/other.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/operate/other.html rename to bmw-admin/src/main/resources/templates/demo/operate/other.html index ed0c55bbf..09938d94d 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/operate/other.html +++ b/bmw-admin/src/main/resources/templates/demo/operate/other.html @@ -1,77 +1,77 @@ - - - - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -   -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -   -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +   +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +   +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/operate/table.html b/bmw-admin/src/main/resources/templates/demo/operate/table.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/operate/table.html rename to bmw-admin/src/main/resources/templates/demo/operate/table.html index 18f01e67d..03f27e570 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/operate/table.html +++ b/bmw-admin/src/main/resources/templates/demo/operate/table.html @@ -1,125 +1,125 @@ - - - - - - - -
                            - - - - + + + + + + + +
                            + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/report/echarts.html b/bmw-admin/src/main/resources/templates/demo/report/echarts.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/report/echarts.html rename to bmw-admin/src/main/resources/templates/demo/report/echarts.html index 31c63dc08..224340a9a 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/report/echarts.html +++ b/bmw-admin/src/main/resources/templates/demo/report/echarts.html @@ -1,1494 +1,1494 @@ - - - - - - -
                            -
                            -

                            ECharts开源来自百度商业前端数据可视化团队,基于html5 Canvas,是一个纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据可视化图表。创新的拖拽重计算、数据视图、值域漫游等特性大大增强了用户体验,赋予了用户对数据进行挖掘、整合的能力。 了解更多 -

                            -

                            ECharts官网:http://echarts.baidu.com/ -

                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            折线图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            柱状图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            散点图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            K线图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            饼状图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            雷达图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            和弦图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            仪表盘
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            漏斗图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            力导向布局图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            中国地图
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +

                            ECharts开源来自百度商业前端数据可视化团队,基于html5 Canvas,是一个纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据可视化图表。创新的拖拽重计算、数据视图、值域漫游等特性大大增强了用户体验,赋予了用户对数据进行挖掘、整合的能力。 了解更多 +

                            +

                            ECharts官网:http://echarts.baidu.com/ +

                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            折线图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            柱状图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            散点图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            K线图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            饼状图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            雷达图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            和弦图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            仪表盘
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            漏斗图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            力导向布局图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            中国地图
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/report/metrics.html b/bmw-admin/src/main/resources/templates/demo/report/metrics.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/report/metrics.html rename to bmw-admin/src/main/resources/templates/demo/report/metrics.html index 6493eed7a..853f672e9 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/report/metrics.html +++ b/bmw-admin/src/main/resources/templates/demo/report/metrics.html @@ -1,478 +1,478 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            Q1 销量
                            -

                            - 上升 -

                            - 更新时间:12天以前 -
                            -
                            -
                            -
                            -
                            -
                            -
                            Q2 销量
                            -

                            - 上升 -

                            - 更新时间:12天以前 -
                            -
                            -
                            -
                            -
                            -
                            -
                            Q3 销量
                            -

                            - 下降 -

                            - 更新时间:12天以前 -
                            -
                            -
                            -
                            -
                            -
                            -
                            Q4 销量
                            -

                            - 下降 -

                            - 更新时间:12天以前 -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            本日访问量
                            -

                            198 009

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            本周访问量
                            -

                            65 000

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            本月访问量
                            -

                            680 900

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            平均停留时间
                            -

                            00:06:40

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            使用率
                            -

                            65%

                            -
                            -
                            -
                            - -
                            4:32更新
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            使用率
                            -

                            50%

                            -
                            -
                            -
                            - -
                            4:32更新
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            使用率
                            -

                            14%

                            -
                            -
                            -
                            - -
                            4:32更新
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            使用率
                            -

                            20%

                            -
                            -
                            -
                            - -
                            4:32更新
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            百分比
                            -

                            42/20

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            百分比
                            -

                            100/54

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            百分比
                            -

                            685/211

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            百分比
                            -

                            240/32

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            收入
                            -

                            886,200

                            -
                            98%
                            - 总收入 -
                            -
                            -
                            -
                            -
                            -
                            -
                            本月收入
                            -

                            1 738,200

                            -
                            98%
                            - 总收入 -
                            -
                            -
                            -
                            -
                            -
                            -
                            本日收入
                            -

                            -200,100

                            -
                            12%
                            - 总收入 -
                            -
                            -
                            -
                            -
                            -
                            -
                            搜索有收入
                            -

                            54,200

                            -
                            24%
                            - 总收入 -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            预警
                            - - - - - - - - - - - - - - - -
                            - - - 示例 01 -
                            - - - 示例 02 -
                            - - - 示例 03 -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            项目
                            - - - - - - - - - - - - - - - -
                            - - - 示例 01 -
                            - - - 示例 02 -
                            - - - 示例 03 -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            消息
                            - - - - - - - - - - - - - - - -
                            - - - 示例 01 -
                            - - - 示例 02 -
                            - - - 示例 03 -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            通知
                            - - - - - - - - - - - - - - - -
                            - - - 示例 01 -
                            - - - 示例 02 -
                            - - - 示例 03 -
                            -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            Q1 销量
                            +

                            + 上升 +

                            + 更新时间:12天以前 +
                            +
                            +
                            +
                            +
                            +
                            +
                            Q2 销量
                            +

                            + 上升 +

                            + 更新时间:12天以前 +
                            +
                            +
                            +
                            +
                            +
                            +
                            Q3 销量
                            +

                            + 下降 +

                            + 更新时间:12天以前 +
                            +
                            +
                            +
                            +
                            +
                            +
                            Q4 销量
                            +

                            + 下降 +

                            + 更新时间:12天以前 +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            本日访问量
                            +

                            198 009

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            本周访问量
                            +

                            65 000

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            本月访问量
                            +

                            680 900

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            平均停留时间
                            +

                            00:06:40

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            使用率
                            +

                            65%

                            +
                            +
                            +
                            + +
                            4:32更新
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            使用率
                            +

                            50%

                            +
                            +
                            +
                            + +
                            4:32更新
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            使用率
                            +

                            14%

                            +
                            +
                            +
                            + +
                            4:32更新
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            使用率
                            +

                            20%

                            +
                            +
                            +
                            + +
                            4:32更新
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            百分比
                            +

                            42/20

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            百分比
                            +

                            100/54

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            百分比
                            +

                            685/211

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            百分比
                            +

                            240/32

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            收入
                            +

                            886,200

                            +
                            98%
                            + 总收入 +
                            +
                            +
                            +
                            +
                            +
                            +
                            本月收入
                            +

                            1 738,200

                            +
                            98%
                            + 总收入 +
                            +
                            +
                            +
                            +
                            +
                            +
                            本日收入
                            +

                            -200,100

                            +
                            12%
                            + 总收入 +
                            +
                            +
                            +
                            +
                            +
                            +
                            搜索有收入
                            +

                            54,200

                            +
                            24%
                            + 总收入 +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            预警
                            + + + + + + + + + + + + + + + +
                            + + + 示例 01 +
                            + + + 示例 02 +
                            + + + 示例 03 +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            项目
                            + + + + + + + + + + + + + + + +
                            + + + 示例 01 +
                            + + + 示例 02 +
                            + + + 示例 03 +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            消息
                            + + + + + + + + + + + + + + + +
                            + + + 示例 01 +
                            + + + 示例 02 +
                            + + + 示例 03 +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            通知
                            + + + + + + + + + + + + + + + +
                            + + + 示例 01 +
                            + + + 示例 02 +
                            + + + 示例 03 +
                            +
                            +
                            +
                            +
                            +
                            + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/report/peity.html b/bmw-admin/src/main/resources/templates/demo/report/peity.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/report/peity.html rename to bmw-admin/src/main/resources/templates/demo/report/peity.html index 4ebbc17c8..93c519478 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/report/peity.html +++ b/bmw-admin/src/main/resources/templates/demo/report/peity.html @@ -1,206 +1,206 @@ - - - - - - -
                            - -
                            -
                            -
                            -

                            Peity图表

                            -

                            是一个内嵌数据图形可视化的图表库

                            -

                            了解 Peity -

                            -
                            -
                            -
                            -
                            -
                            -
                            饼状图 自定义颜色
                            -
                            - - - -
                            -
                            -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            图表代码
                            - 1/5 - - <span class="pie">1/5</span> -
                            - 226/360 - - <span class="pie">226/360</span> -
                            - 0.52/1.561 - - <span class="pie">0.52/1.561</span> -
                            - 1,4 - - <span class="pie">1,4</span> -
                            - 226,134 - - <span class="pie">226,134</span> -
                            - 0.52,1.041 - - <span class="pie">0.52,1.041</span> -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            线性图
                            -
                            - - - -
                            -
                            -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            图表代码
                            - 5,3,9,6,5,9,7,3,5,2,5,3,9,6,5,9,7,3,5,2 - - <span class="line">5,3,9,6,5,9,7,3,5,2</span> -
                            - 5,3,9,6,5,9,7,3,5,2 - - <span class="line">5,3,9,6,5,9,7,3,5,2</span> -
                            - 5,3,2,-1,-3,-2,2,3,5,2 - - <span class="line">5,3,2,-1,-3,-2,2,3,5,2</span> -
                            - 0,-3,-6,-4,-5,-4,-7,-3,-5,-2 - - <span class="line">0,-3,-6,-4,-5,-4,-7,-3,-5,-2</span> -
                            - 5,3,9,6,5,9,7,3,5,2 - - <span class="bar">5,3,9,6,5,9,7,3,5,2</span> -
                            - 5,3,2,-1,-3,-2,2,3,5,2 - - <span class="bar">5,3,2,-1,-3,-2,2,3,5,2</span> -
                            -
                            -
                            -
                            - -
                            -
                            - - - - + + + + + + +
                            + +
                            +
                            +
                            +

                            Peity图表

                            +

                            是一个内嵌数据图形可视化的图表库

                            +

                            了解 Peity +

                            +
                            +
                            +
                            +
                            +
                            +
                            饼状图 自定义颜色
                            +
                            + + + +
                            +
                            +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            图表代码
                            + 1/5 + + <span class="pie">1/5</span> +
                            + 226/360 + + <span class="pie">226/360</span> +
                            + 0.52/1.561 + + <span class="pie">0.52/1.561</span> +
                            + 1,4 + + <span class="pie">1,4</span> +
                            + 226,134 + + <span class="pie">226,134</span> +
                            + 0.52,1.041 + + <span class="pie">0.52,1.041</span> +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            线性图
                            +
                            + + + +
                            +
                            +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            图表代码
                            + 5,3,9,6,5,9,7,3,5,2,5,3,9,6,5,9,7,3,5,2 + + <span class="line">5,3,9,6,5,9,7,3,5,2</span> +
                            + 5,3,9,6,5,9,7,3,5,2 + + <span class="line">5,3,9,6,5,9,7,3,5,2</span> +
                            + 5,3,2,-1,-3,-2,2,3,5,2 + + <span class="line">5,3,2,-1,-3,-2,2,3,5,2</span> +
                            + 0,-3,-6,-4,-5,-4,-7,-3,-5,-2 + + <span class="line">0,-3,-6,-4,-5,-4,-7,-3,-5,-2</span> +
                            + 5,3,9,6,5,9,7,3,5,2 + + <span class="bar">5,3,9,6,5,9,7,3,5,2</span> +
                            + 5,3,2,-1,-3,-2,2,3,5,2 + + <span class="bar">5,3,2,-1,-3,-2,2,3,5,2</span> +
                            +
                            +
                            +
                            + +
                            +
                            + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/report/sparkline.html b/bmw-admin/src/main/resources/templates/demo/report/sparkline.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/report/sparkline.html rename to bmw-admin/src/main/resources/templates/demo/report/sparkline.html index 5ed6f05b2..241983df3 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/report/sparkline.html +++ b/bmw-admin/src/main/resources/templates/demo/report/sparkline.html @@ -1,232 +1,232 @@ - - - - - - -
                            - -
                            -
                            -
                            -

                            Sparkline

                            -

                            这是另一个可视化图表库

                            -

                            了解 Sparkline -

                            -
                            -
                            -
                            -
                            -
                            -
                            Sparkline图表 自定义颜色
                            -
                            - - - -
                            -
                            -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            图表类型
                            - - - 内联线性图 -
                            - - - 柱状图 -
                            - - - 饼状图 -
                            - - - 长线性图 -
                            - - - 三态图 -
                            - - - 散点图 -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            自定义饼状图尺寸
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            自定义柱状图尺寸
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            自定义线性图尺寸
                            -
                            - - - - - - - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            + +
                            +
                            +
                            +

                            Sparkline

                            +

                            这是另一个可视化图表库

                            +

                            了解 Sparkline +

                            +
                            +
                            +
                            +
                            +
                            +
                            Sparkline图表 自定义颜色
                            +
                            + + + +
                            +
                            +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            图表类型
                            + + + 内联线性图 +
                            + + + 柱状图 +
                            + + + 饼状图 +
                            + + + 长线性图 +
                            + + + 三态图 +
                            + + + 散点图 +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            自定义饼状图尺寸
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            自定义柱状图尺寸
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            自定义线性图尺寸
                            +
                            + + + + + + + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/button.html b/bmw-admin/src/main/resources/templates/demo/table/button.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/button.html rename to bmw-admin/src/main/resources/templates/demo/table/button.html index bd87d27c0..7dd439e1c 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/button.html +++ b/bmw-admin/src/main/resources/templates/demo/table/button.html @@ -1,92 +1,92 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/curd.html b/bmw-admin/src/main/resources/templates/demo/table/curd.html similarity index 100% rename from ruoyi-admin/src/main/resources/templates/demo/table/curd.html rename to bmw-admin/src/main/resources/templates/demo/table/curd.html diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/detail.html b/bmw-admin/src/main/resources/templates/demo/table/detail.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/detail.html rename to bmw-admin/src/main/resources/templates/demo/table/detail.html index a51c634be..34605290d 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/detail.html +++ b/bmw-admin/src/main/resources/templates/demo/table/detail.html @@ -1,86 +1,86 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/event.html b/bmw-admin/src/main/resources/templates/demo/table/event.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/event.html rename to bmw-admin/src/main/resources/templates/demo/table/event.html index 89f7f2a86..58197b3ff 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/event.html +++ b/bmw-admin/src/main/resources/templates/demo/table/event.html @@ -1,107 +1,107 @@ - - - - - - -
                            -
                            -
                            -

                            自定义触发事件(点击某行/双击某行/单击某格/双击某格/服务器发送数据前触发/数据被加载时触发)

                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +

                            自定义触发事件(点击某行/双击某行/单击某格/双击某格/服务器发送数据前触发/数据被加载时触发)

                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/export.html b/bmw-admin/src/main/resources/templates/demo/table/export.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/export.html rename to bmw-admin/src/main/resources/templates/demo/table/export.html index 85ba38d30..f7ab3db77 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/export.html +++ b/bmw-admin/src/main/resources/templates/demo/table/export.html @@ -1,80 +1,80 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/fixedColumns.html b/bmw-admin/src/main/resources/templates/demo/table/fixedColumns.html similarity index 95% rename from ruoyi-admin/src/main/resources/templates/demo/table/fixedColumns.html rename to bmw-admin/src/main/resources/templates/demo/table/fixedColumns.html index a42c879f3..132cb1515 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/fixedColumns.html +++ b/bmw-admin/src/main/resources/templates/demo/table/fixedColumns.html @@ -1,143 +1,143 @@ - - - - - - - -
                            - - + + + + + + + +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/footer.html b/bmw-admin/src/main/resources/templates/demo/table/footer.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/footer.html rename to bmw-admin/src/main/resources/templates/demo/table/footer.html index 225d12dae..cc62007ee 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/footer.html +++ b/bmw-admin/src/main/resources/templates/demo/table/footer.html @@ -1,83 +1,83 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/groupHeader.html b/bmw-admin/src/main/resources/templates/demo/table/groupHeader.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/groupHeader.html rename to bmw-admin/src/main/resources/templates/demo/table/groupHeader.html index b7b3903ec..8a828b0d1 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/groupHeader.html +++ b/bmw-admin/src/main/resources/templates/demo/table/groupHeader.html @@ -1,80 +1,80 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/image.html b/bmw-admin/src/main/resources/templates/demo/table/image.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/image.html rename to bmw-admin/src/main/resources/templates/demo/table/image.html index 4aaf51eb4..26166ea77 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/image.html +++ b/bmw-admin/src/main/resources/templates/demo/table/image.html @@ -1,79 +1,79 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/multi.html b/bmw-admin/src/main/resources/templates/demo/table/multi.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/multi.html rename to bmw-admin/src/main/resources/templates/demo/table/multi.html index 43331e02b..c8e858b65 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/multi.html +++ b/bmw-admin/src/main/resources/templates/demo/table/multi.html @@ -1,150 +1,150 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/other.html b/bmw-admin/src/main/resources/templates/demo/table/other.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/other.html rename to bmw-admin/src/main/resources/templates/demo/table/other.html index e9ed0ac49..84c4b7bfd 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/other.html +++ b/bmw-admin/src/main/resources/templates/demo/table/other.html @@ -1,106 +1,106 @@ - - - - - - - -
                            - - + + + + + + + +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/pageGo.html b/bmw-admin/src/main/resources/templates/demo/table/pageGo.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/pageGo.html rename to bmw-admin/src/main/resources/templates/demo/table/pageGo.html index 9eab0de97..f714fedbf 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/pageGo.html +++ b/bmw-admin/src/main/resources/templates/demo/table/pageGo.html @@ -1,77 +1,77 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/params.html b/bmw-admin/src/main/resources/templates/demo/table/params.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/params.html rename to bmw-admin/src/main/resources/templates/demo/table/params.html index 7193af190..0d2329a1d 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/params.html +++ b/bmw-admin/src/main/resources/templates/demo/table/params.html @@ -1,158 +1,158 @@ - - - - - - -
                            -
                            -
                            -

                            通过queryParams方法设置

                            -
                            -
                            - -
                            -
                            -
                            -
                              -
                            • - 用户姓名: -
                            • -
                            -
                            -
                            -
                            -
                            -

                            通过form自动填充

                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +

                            通过queryParams方法设置

                            +
                            +
                            + +
                            +
                            +
                            +
                              +
                            • + 用户姓名: +
                            • +
                            +
                            +
                            +
                            +
                            +

                            通过form自动填充

                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/remember.html b/bmw-admin/src/main/resources/templates/demo/table/remember.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/demo/table/remember.html rename to bmw-admin/src/main/resources/templates/demo/table/remember.html index ca175863f..03384c5b9 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/remember.html +++ b/bmw-admin/src/main/resources/templates/demo/table/remember.html @@ -1,89 +1,89 @@ - - - - - - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/reorder.html b/bmw-admin/src/main/resources/templates/demo/table/reorder.html similarity index 100% rename from ruoyi-admin/src/main/resources/templates/demo/table/reorder.html rename to bmw-admin/src/main/resources/templates/demo/table/reorder.html diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/search.html b/bmw-admin/src/main/resources/templates/demo/table/search.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/demo/table/search.html rename to bmw-admin/src/main/resources/templates/demo/table/search.html index 210b58b0b..34001c41f 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/search.html +++ b/bmw-admin/src/main/resources/templates/demo/table/search.html @@ -1,168 +1,168 @@ - - - - - - - -
                            -
                            -
                            -

                            普通条件查询

                            -
                            -
                            -
                              -
                            • - 商户编号: -
                            • -
                            • - 终端编号: -
                            • -
                            • - 处理状态: -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - -
                            -

                            时间条件查询

                            -
                            -
                            -
                              -
                            • - 商户编号: -
                            • -
                            • - 终端编号: -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - -
                            -

                            下拉多选条件查询

                            -
                            -
                            -
                              -
                            • - 商户编号: -
                            • -
                            • - 终端编号: -
                            • -
                            • - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - -
                            -

                            复杂条件查询

                            -
                            -
                            -
                              -
                            • -

                              商户编号:

                              - -
                            • -
                            • -

                              订单号:

                              - -
                            • -
                            • -

                              日期:

                              - -
                            • -
                            • -

                              状态:

                              - -
                            • -
                            • -

                              供货商通道:

                              - -
                            • -
                            • -

                              来源:

                              - -
                            • -
                            • -

                              运营商:

                              - -
                            • -
                            • -

                              回调时间:

                              - - - - -
                            • - -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + + +
                            +
                            +
                            +

                            普通条件查询

                            +
                            +
                            +
                              +
                            • + 商户编号: +
                            • +
                            • + 终端编号: +
                            • +
                            • + 处理状态: +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + +
                            +

                            时间条件查询

                            +
                            +
                            +
                              +
                            • + 商户编号: +
                            • +
                            • + 终端编号: +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + +
                            +

                            下拉多选条件查询

                            +
                            +
                            +
                              +
                            • + 商户编号: +
                            • +
                            • + 终端编号: +
                            • +
                            • + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + +
                            +

                            复杂条件查询

                            +
                            +
                            +
                              +
                            • +

                              商户编号:

                              + +
                            • +
                            • +

                              订单号:

                              + +
                            • +
                            • +

                              日期:

                              + +
                            • +
                            • +

                              状态:

                              + +
                            • +
                            • +

                              供货商通道:

                              + +
                            • +
                            • +

                              来源:

                              + +
                            • +
                            • +

                              运营商:

                              + +
                            • +
                            • +

                              回调时间:

                              + + - + +
                            • + +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/error/404.html b/bmw-admin/src/main/resources/templates/error/404.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/error/404.html rename to bmw-admin/src/main/resources/templates/error/404.html index 774a58dfd..4221066f1 100644 --- a/ruoyi-admin/src/main/resources/templates/error/404.html +++ b/bmw-admin/src/main/resources/templates/error/404.html @@ -1,21 +1,21 @@ - - - - - - RuoYi - 404 - - - - - -
                            -

                            404

                            -

                            找不到网页!

                            -
                            - 对不起,您正在寻找的页面不存在。尝试检查URL的错误,然后按浏览器上的刷新按钮或尝试在我们的应用程序中找到其他内容。 - 主页 -
                            -
                            - - + + + + + + RuoYi - 404 + + + + + +
                            +

                            404

                            +

                            找不到网页!

                            +
                            + 对不起,您正在寻找的页面不存在。尝试检查URL的错误,然后按浏览器上的刷新按钮或尝试在我们的应用程序中找到其他内容。 + 主页 +
                            +
                            + + diff --git a/ruoyi-admin/src/main/resources/templates/error/500.html b/bmw-admin/src/main/resources/templates/error/500.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/error/500.html rename to bmw-admin/src/main/resources/templates/error/500.html index f59b91b93..5e9d15093 100644 --- a/ruoyi-admin/src/main/resources/templates/error/500.html +++ b/bmw-admin/src/main/resources/templates/error/500.html @@ -1,22 +1,22 @@ - - - - - - RuoYi - 500 - - - - - -
                            -

                            500

                            -

                            内部服务器错误!

                            - -
                            - 服务器遇到意外事件,不允许完成请求。我们抱歉。您可以返回主页面。 - 主页 -
                            -
                            - - + + + + + + RuoYi - 500 + + + + + +
                            +

                            500

                            +

                            内部服务器错误!

                            + +
                            + 服务器遇到意外事件,不允许完成请求。我们抱歉。您可以返回主页面。 + 主页 +
                            +
                            + + diff --git a/ruoyi-admin/src/main/resources/templates/error/business.html b/bmw-admin/src/main/resources/templates/error/business.html similarity index 100% rename from ruoyi-admin/src/main/resources/templates/error/business.html rename to bmw-admin/src/main/resources/templates/error/business.html diff --git a/ruoyi-admin/src/main/resources/templates/error/unauth.html b/bmw-admin/src/main/resources/templates/error/unauth.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/error/unauth.html rename to bmw-admin/src/main/resources/templates/error/unauth.html index ca14e5526..739a8ce1e 100644 --- a/ruoyi-admin/src/main/resources/templates/error/unauth.html +++ b/bmw-admin/src/main/resources/templates/error/unauth.html @@ -1,22 +1,22 @@ - - - - - - RuoYi - 403 - - - - - -
                            -

                            403

                            -

                            您没有访问权限!

                            - -
                            - 对不起,您没有访问权限,请不要进行非法操作!您可以返回主页面 - 返回主页 -
                            -
                            - - + + + + + + RuoYi - 403 + + + + + +
                            +

                            403

                            +

                            您没有访问权限!

                            + +
                            + 对不起,您没有访问权限,请不要进行非法操作!您可以返回主页面 + 返回主页 +
                            +
                            + + diff --git a/ruoyi-admin/src/main/resources/templates/include.html b/bmw-admin/src/main/resources/templates/include.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/include.html rename to bmw-admin/src/main/resources/templates/include.html index cbb6f6ca7..d0a31caf1 100644 --- a/ruoyi-admin/src/main/resources/templates/include.html +++ b/bmw-admin/src/main/resources/templates/include.html @@ -1,175 +1,175 @@ - - - - - - - - - - - - - - - - - - -
                            - - - - - - - - - - - - - - - - - - - - - - - - - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - - -
                            -
                            - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - - -
                            -
                            - - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - -
                            - - -
                            - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - -
                            -
                            - -
                            - - -
                            - -
                            - - -
                            - -
                            - - -
                            - -
                            - - -
                            - - + + + + + + + + + + + + + + + + + + +
                            + + + + + + + + + + + + + + + + + + + + + + + + + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + + +
                            +
                            + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + + +
                            +
                            + + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + +
                            + + +
                            + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + +
                            +
                            + +
                            + + +
                            + +
                            + + +
                            + +
                            + + +
                            + +
                            + + +
                            + +
                            \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/index.html b/bmw-admin/src/main/resources/templates/index.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/index.html rename to bmw-admin/src/main/resources/templates/index.html index 1a111b0a9..9589b0d54 100644 --- a/ruoyi-admin/src/main/resources/templates/index.html +++ b/bmw-admin/src/main/resources/templates/index.html @@ -1,247 +1,247 @@ - - - - - - - 若依系统首页 - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + 若依系统首页 + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/login.html b/bmw-admin/src/main/resources/templates/login.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/login.html rename to bmw-admin/src/main/resources/templates/login.html index 941b426c2..1230b4a48 100644 --- a/ruoyi-admin/src/main/resources/templates/login.html +++ b/bmw-admin/src/main/resources/templates/login.html @@ -1,86 +1,86 @@ - - - - - - - 登录若依系统 - - - - - - - - - - - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -

                            登录:

                            -

                            你若不离不弃,我必生死相依

                            - - -
                            -
                            - -
                            -
                            - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - - - - - - - - - - - - + + + + + + + 登录若依系统 + + + + + + + + + + + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +

                            登录:

                            +

                            你若不离不弃,我必生死相依

                            + + +
                            +
                            + +
                            +
                            + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + + + + + + + + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/main.html b/bmw-admin/src/main/resources/templates/main.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/main.html rename to bmw-admin/src/main/resources/templates/main.html index 3e13919c6..d18a1dcfd 100644 --- a/ruoyi-admin/src/main/resources/templates/main.html +++ b/bmw-admin/src/main/resources/templates/main.html @@ -1,770 +1,770 @@ - - - - - - - 若依介绍 - - - - - - - - -
                            -
                            -
                            - 领取阿里云通用云产品1888优惠券 -
                            https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=brki8iof
                            - 领取腾讯云通用云产品2860优惠券 -
                            https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console
                            - 阿里云Hi拼购 限量爆款 低至199元/年 -
                            https://www.aliyun.com/acts/hi-group-buying?userCode=brki8iof -

                            云产品通用红包,可叠加官网常规优惠使用。(仅限新用户)

                            -
                            - -
                            -
                            -
                            -

                            Hello,Guest

                            - 移动设备访问请扫描以下二维码: -
                            -
                            - -
                            -
                            -
                            -

                            若依后台管理框架

                            -

                            一直想做一款后台管理系统,看了很多优秀的开源项目但是发现没有合适自己的。于是利用空闲休息时间开始自己写一套后台系统。如此有了若依管理系统。,她可以用于所有的Web应用程序,如网站管理后台网站会员中心CMSCRMOA等等,当然,您也可以对她进行深度定制,以做出更强系统。所有前端后台代码封装过后十分精简易上手,出错概率低。同时支持移动客户端访问。系统会陆续更新一些实用功能。

                            -

                            - 当前版本:v[[${version}]] -

                            -

                            - ¥免费开源 -

                            -
                            -

                            - - 访问码云 - - - 访问主页 - -

                            -
                            -
                            -

                            技术选型:

                            -
                              -
                            1. 核心框架:Spring Boot。
                            2. -
                            3. 安全框架:Apache Shiro。
                            4. -
                            5. 模板引擎:Thymeleaf。
                            6. -
                            7. 持久层框架:MyBatis。
                            8. -
                            9. 定时任务:Quartz。
                            10. -
                            11. 数据库连接池:Druid。
                            12. -
                            13. 工具类:Fastjson。
                            14. -
                            15. 更多……
                            16. -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            联系信息
                            - -
                            -
                            -

                            官网:http://www.ruoyi.vip -

                            -

                            QQ群:满1389287 满1679294 满1529866 满1772718 满1366522 1382251 -

                            -

                            微信:/ *若依 -

                            -

                            支付宝:/ *若依 -

                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            更新日志
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v3.4.02019.06.03 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增实例演示菜单及demo
                            2. -
                            3. 新增页签右键操作
                            4. -
                            5. 菜单管理新增打开方式
                            6. -
                            7. 新增点击某行触发的事件
                            8. -
                            9. 新增双击某行触发的事件
                            10. -
                            11. 新增单击某格触发的事件
                            12. -
                            13. 新增双击某格触发的事件
                            14. -
                            15. 新增是否启用显示细节视图
                            16. -
                            17. 支持上传任意格式文件
                            18. -
                            19. 修复角色权限注解失效问题
                            20. -
                            21. 左侧的菜单栏宽度调整
                            22. -
                            23. 新增响应完成后自定义回调函数
                            24. -
                            25. 支持前端及其他模块直接获取用户信息
                            26. -
                            27. 升级swagger到最新版2.9.2
                            28. -
                            29. 升级jquery.slimscroll到最新版1.3.8
                            30. -
                            31. 升级select2到最新版4.0.7
                            32. -
                            33. 新增角色配置本部门数据权限
                            34. -
                            35. 新增角色配置本部门及以下数据权限
                            36. -
                            37. 优化底部操作防止跳到页面顶端
                            38. -
                            39. 修改冻结列选框无效及样式问题
                            40. -
                            41. 修复部门四层级修改祖级无效问题
                            42. -
                            43. 更换开关切换按钮样式
                            44. -
                            45. 新增select2-bootstrap美化下拉框
                            46. -
                            47. 添加表格内图片预览方法
                            48. -
                            49. 修复权限校验失败跳转页面路径错误
                            50. -
                            51. 国际化资源文件调整
                            52. -
                            53. 通知公告布局调整
                            54. -
                            55. 删除页签操作功能
                            56. -
                            57. 表格树新增查询指定列值
                            58. -
                            59. 更改系统接口扫描方式及完善测试案例
                            60. -
                            61. 表格列浮动提示及字典回显默认去背景
                            62. -
                            63. 修复启用翻页记住前面的选择check没选中问题
                            64. -
                            65. 去除监控页面底部的广告
                            66. -
                            67. 日期控件功问题修复及data功能增强
                            68. -
                            69. 新增角色权限可见性(前端直接调用)
                            70. -
                            71. 新增获取当前登录用户方法(前端及子模块调用)
                            72. -
                            73. 修复热部署重启导致菜单丢失问题
                            74. -
                            75. 优化业务校验失败普通请求跳转页面
                            76. -
                            77. 操作日志新增状态条件查询
                            78. -
                            79. 操作类型支持多选条件查询
                            80. -
                            81. 通知公告防止滚动触底回弹优化
                            82. -
                            83. 其他细节优化
                            84. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v3.3.02019.04.01 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增线程池统一管理
                            2. -
                            3. 新增支持左右冻结列
                            4. -
                            5. 新增表格字符超长浮动提示
                            6. -
                            7. 升级datepicker拓展并汉化
                            8. -
                            9. 升级druid到最新版本v1.1.14
                            10. -
                            11. 修复个人头像为图片服务器跨域问题
                            12. -
                            13. 修改上传文件按日期存储
                            14. -
                            15. 新增表格客户端分页选项
                            16. -
                            17. 新增表格的高度参数
                            18. -
                            19. 新增表格销毁方法
                            20. -
                            21. 新增表格下拉按钮切换方法
                            22. -
                            23. 新增表格分页跳转到指定页码
                            24. -
                            25. 新增表格启用点击选中行参数
                            26. -
                            27. 修复表格数据重新加载未触发部分按钮禁用
                            28. -
                            29. 使用jsonview展示操作日志参数
                            30. -
                            31. 新增方法(addTab、editTab)
                            32. -
                            33. 修改用户管理界面为Tab打开方式
                            34. -
                            35. 表单验证代码优化
                            36. -
                            37. 修复@Excel注解 prompt 属性使用报错
                            38. -
                            39. 修复combo属性Excel兼容性问题
                            40. -
                            41. 新增@Excel导入导出支持父类字段
                            42. -
                            43. 修复关闭最后选项卡无法激活滚动问题
                            44. -
                            45. 增加日期控件显示类型及回显格式扩展选项
                            46. -
                            47. 修复定时任务执行失败后入库状态为成功状态
                            48. -
                            49. 支持定时任务并发开关控制
                            50. -
                            51. 优化权限校验失败普通请求跳转页面
                            52. -
                            53. 捕获线程池执行任务抛出的异常
                            54. -
                            55. 修复IE浏览器导出功能报错
                            56. -
                            57. 新增角色管理分配用户功能
                            58. -
                            59. 新增表格翻页记住前面的选择
                            60. -
                            61. 调整用户个人中心页面
                            62. -
                            63. 修复界面存在的一些安全问题
                            64. -
                            65. 其他细节优化
                            66. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v3.2.02019.01.18 -
                            -
                            -
                            -
                            -
                              -
                            1. 部门修改时不允许选择最后节点
                            2. -
                            3. 修复部门菜单排序字段无效
                            4. -
                            5. 修复光驱磁盘导致服务监控异常
                            6. -
                            7. 登录界面去除check插件
                            8. -
                            9. 验证码文本字符间距修正
                            10. -
                            11. 升级SpringBoot到最新版本2.1.1
                            12. -
                            13. 升级MYSQL驱动
                            14. -
                            15. 修正登录必填项位置偏移
                            16. -
                            17. Session会话检查优化
                            18. -
                            19. Excel注解支持多级获取
                            20. -
                            21. 新增序列号生成方法
                            22. -
                            23. 修复WAR部署tomcat退出线程异常
                            24. -
                            25. 全屏操作增加默认确认/关闭
                            26. -
                            27. 修复个人信息可能导致漏洞
                            28. -
                            29. 字典数据根据下拉选择新增类型
                            30. -
                            31. 升级Summernote到最新版本v0.8.11
                            32. -
                            33. 新增用户数据导入
                            34. -
                            35. 首页主题样式更换
                            36. -
                            37. layer扩展主题更换
                            38. -
                            39. 用户管理移动端默认隐藏左侧布局
                            40. -
                            41. 详细信息弹出层显示在顶层
                            42. -
                            43. 表格支持切换状态(用户/角色/定时任务)
                            44. -
                            45. Druid数据源支持配置继承
                            46. -
                            47. 修正部分iPhone手机端表格适配问题
                            48. -
                            49. 新增防止重复提交表单方法
                            50. -
                            51. 新增表格数据统计汇总方法
                            52. -
                            53. 支持富文本上传图片文件
                            54. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v3.1.02018.12.03 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增内网不获取IP地址
                            2. -
                            3. 新增cron表达式有效校验
                            4. -
                            5. 定时任务新增详细信息
                            6. -
                            7. 定时任务默认策略修改(不触发立即执行)
                            8. -
                            9. 定时任务显示下一个执行周期
                            10. -
                            11. 支持前端任意日期格式处理
                            12. -
                            13. 上传头像删除多余提交按钮
                            14. -
                            15. 表格增加行间隔色配置项
                            16. -
                            17. 表格增加转义HTML字符串配置项
                            18. -
                            19. 表格增加显示/隐藏指定列
                            20. -
                            21. 代码生成优化
                            22. -
                            23. 操作日志参数格式化显示
                            24. -
                            25. 页签新增新增全屏显示
                            26. -
                            27. 新增一键打包部署
                            28. -
                            29. Excel注解新增多个参数
                            30. -
                            31. 新增提交静默更新表格方法
                            32. -
                            33. 新增服务监控菜单
                            34. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v3.0.02018.10.08 -
                            -
                            -
                            -
                            -
                              -
                            1. 升级poi到最新版3.17
                            2. -
                            3. 导出修改临时目录绝对路径
                            4. -
                            5. 升级laydate到最新版5.0.9
                            6. -
                            7. 升级SpringBoot到最新版本2.0.5
                            8. -
                            9. 优化开始/结束时间校验限制
                            10. -
                            11. 重置密码参数表中获取默认值
                            12. -
                            13. 修复头像修改显示问题
                            14. -
                            15. 新增数据权限过滤注解
                            16. -
                            17. 新增表格检索折叠按钮
                            18. -
                            19. 新增清空(登录、操作、调度)日志
                            20. -
                            21. 固定按钮位置(提交/关闭)
                            22. -
                            23. 部门/菜单支持(展开/折叠)
                            24. -
                            25. 部分细节调整优化
                            26. -
                            27. 项目采用分模块
                            28. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v2.4.02018.09.03 -
                            -
                            -
                            -
                            -
                              -
                            1. 支持部门多级查询
                            2. -
                            3. 修复菜单状态查询无效
                            4. -
                            5. 支持IP地址开关
                            6. -
                            7. 支持XSS开关
                            8. -
                            9. 记录日志异步处理
                            10. -
                            11. 字典回显样式更改为下拉框
                            12. -
                            13. 菜单类型必填校验
                            14. -
                            15. 修复在线用户排序报错
                            16. -
                            17. 增加重置按钮
                            18. -
                            19. 支持注解导入数据
                            20. -
                            21. 支持弹层外区域关闭
                            22. -
                            23. 备注更换为文本区域
                            24. -
                            25. 新增角色逻辑删除
                            26. -
                            27. 新增部门逻辑删除
                            28. -
                            29. 支持部门数据权限
                            30. -
                            31. 管理员默认拥有所有授权
                            32. -
                            33. 字典数据采用分页
                            34. -
                            35. 部分细节调整优化
                            36. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v2.3.02018.08.06 -
                            -
                            -
                            -
                            -
                              -
                            1. 支持表格不分页开关控制
                            2. -
                            3. 修改字典类型同步修改字典数据
                            4. -
                            5. 代码生成新增修改后缀处理
                            6. -
                            7. 代码生成新增实体toString
                            8. -
                            9. 代码生成非字符串去除!=''
                            10. -
                            11. 导出数据前加载遮罩层
                            12. -
                            13. 部门删除校验条件修改
                            14. -
                            15. 搜索查询下载优化
                            16. -
                            17. 手机打开弹出层自适应
                            18. -
                            19. 角色岗位禁用显示置灰
                            20. -
                            21. 角色禁用不显示菜单
                            22. -
                            23. 新增导出权限
                            24. -
                            25. 角色权限唯一校验
                            26. -
                            27. 岗位名称编码唯一校验
                            28. -
                            29. TreeTable优化
                            30. -
                            31. 支持多数据源
                            32. -
                            33. 其他细节优化
                            34. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v2.2.02018.07.23 -
                            -
                            -
                            -
                            -
                              -
                            1. 修复批量生成代码异常问题
                            2. -
                            3. 修复定时器保存失败问题
                            4. -
                            5. 修复热部署转换问题
                            6. -
                            7. 支持查询菜单管理,部门管理
                            8. -
                            9. 大多数功能支持时间查询
                            10. -
                            11. 自定义导出注解自动匹配column
                            12. -
                            13. 新增任务执行策略
                            14. -
                            15. 操作详细动态显示类型
                            16. -
                            17. 支持动态回显字典数据
                            18. -
                            19. 后台代码优化调整
                            20. -
                            21. 其他细节优化
                            22. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v2.1.02018.07.10 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增登陆超时提醒
                            2. -
                            3. 修复定时器热部署转换问题
                            4. -
                            5. 修复登录验证码校验无效问题
                            6. -
                            7. 定时任务新增立即执行一次
                            8. -
                            9. 存在字典数据不允许删除字典
                            10. -
                            11. 字典数据支持按名称查询
                            12. -
                            13. 代码生成增加日志注解&表格优化
                            14. -
                            15. 修复用户逻辑删除后能登录问题
                            16. -
                            17. 表格支持多字段动态排序
                            18. -
                            19. 支持三级菜单显示
                            20. -
                            21. 新增ry.sh启动程序脚本
                            22. -
                            23. 其他细节优化
                            24. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v2.0.02018.07.02 -
                            -
                            -
                            -
                            -
                              -
                            1. 升级SpringBoot到最新版本2.0.3
                            2. -
                            3. 新增公告管理
                            4. -
                            5. 表单校验示提体验优化
                            6. -
                            7. 前端通用方法封装调整
                            8. -
                            9. 前端去除js文件,合并到html
                            10. -
                            11. 操作加载遮罩层
                            12. -
                            13. 支持全屏模式操作
                            14. -
                            15. 支持注解导出数据
                            16. -
                            17. 系统支持多查询&下载
                            18. -
                            19. 系统样式调整
                            20. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.1.62018.06.04 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增用户列表部门列
                            2. -
                            3. 新增登录地点
                            4. -
                            5. 新增swagger
                            6. -
                            7. 修复排序数字校验
                            8. -
                            9. 优化头像上传文件类型限定为图片
                            10. -
                            11. 新增XSS过滤
                            12. -
                            13. 新增热部署提高开发效率
                            14. -
                            15. 修复treegrid居中无效
                            16. -
                            17. 角色多条件查询
                            18. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.1.52018.05.28 -
                            -
                            -
                            -
                            -
                              -
                            1. 优化登录失败刷新验证码
                            2. -
                            3. 新增用户登陆地址时间
                            4. -
                            5. 修复ajax超时退出问题
                            6. -
                            7. 新增html调用数据字典(若依首创)
                            8. -
                            9. 调整系统部分样式
                            10. -
                            11. 新增用户逻辑删除
                            12. -
                            13. 新增管理员不允许删除修改
                            14. -
                            15. 升级bootstrapTable到最新版本1.12.1
                            16. -
                            17. 升级layer到最新版本3.1.1
                            18. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.1.42018.05.20 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增参数管理
                            2. -
                            3. 修复头像上传bug
                            4. -
                            5. 手机邮箱唯一校验
                            6. -
                            7. 支持手机邮箱登录
                            8. -
                            9. 代码生成优化
                            10. -
                            11. 支持模糊查询
                            12. -
                            13. 支持切换主题皮肤
                            14. -
                            15. 修改权限即时生效
                            16. -
                            17. 修复页签Tab关闭问题
                            18. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.1.32018.05.14 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增验证码(数组计算、字符验证)
                            2. -
                            3. 新增cookie记住我
                            4. -
                            5. 新增头像上传
                            6. -
                            7. 用户名密码长度限制
                            8. -
                            9. 通用字段提取
                            10. -
                            11. 支持自定义条件查询
                            12. -
                            13. 部门名称必填、时间格式调整
                            14. -
                            15. 其他细节优化
                            16. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.1.22018.05.07 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增个人信息修改
                            2. -
                            3. 菜单存在子菜单不允许删除
                            4. -
                            5. 菜单分配角色不允许删除
                            6. -
                            7. 角色分配人员不允许删除
                            8. -
                            9. 岗位使用后不允许删除
                            10. -
                            11. 保证用户的数据完整性加入事物
                            12. -
                            13. 新增环境使用手册、数据建模
                            14. -
                            15. Thymeleaf升级到3.0
                            16. -
                            17. 支持非ROOT部署
                            18. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.1.12018.04.23 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增表单构建器
                            2. -
                            3. 代码生成优化
                            4. -
                            5. 支持新增主部门
                            6. -
                            7. 支持选择上级部门、上级菜单
                            8. -
                            9. 新增字典管理单条删除
                            10. -
                            11. 优化一些其他细节
                            12. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.1.02018.04.20 -
                            -
                            -
                            -
                            -
                              -
                            1. 支持密码盐
                            2. -
                            3. 支持新增主目录
                            4. -
                            5. 支持批量生成代码
                            6. -
                            7. 支持表格导出(csv、txt、doc、excel)
                            8. -
                            9. 自动适应宽高模式窗体
                            10. -
                            11. 重复校验(角色名、菜单名、部门名)
                            12. -
                            13. 优化一些其他细节
                            14. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.92018.04.14 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增代码生成(生成包括 java、html、js、xml、sql)
                            2. -
                            3. 新增按钮权限控制隐藏(若依首创)
                            4. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.82018.04.08 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增定时任务(新增、修改、删除、查询、启动/暂停)
                            2. -
                            3. 新增调度日志(查询、删除)
                            4. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.72018.04.04 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增岗位管理(新增、修改、删除、查询)
                            2. -
                            3. 优化用户管理,菜单管理部分细节
                            4. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.62018.03.15 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增字典管理(新增、删除、修改、查询、数据选择)
                            2. -
                            3. 新增用户密码重置
                            4. -
                            5. 优化一些其他细节
                            6. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.52018.03.12 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增菜单管理(新增、删除、修改、查询、图标选择)
                            2. -
                            3. 部门管理优化(添加责任人、联系电话、邮箱、修改者)
                            4. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.42018.03.11 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增角色管理(新增、删除、修改、查询、菜单选择)
                            2. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.32018.03.08 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增用户管理(新增、删除、修改、查询、部门选择)
                            2. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.22018.03.04 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增部门管理 (新增、删除、修改、查询)
                            2. -
                            -
                            -
                            -
                            -
                            -
                            -
                            - v1.0.12018.03.03 -
                            -
                            -
                            -
                            -
                              -
                            1. 新增在线用户 (批量强退、单条强退、查询)
                            2. -
                            3. 新增登录日志 (批量删除、查询)
                            4. -
                            5. 新增操作日志 (批量删除、查询、详细)
                            6. -
                            7. 新增数据监控 (监控DB池连接和SQL的执行)
                            8. -
                            -
                            -
                            -
                            -
                            -
                            -

                            - v1.0.02018.03.01 -

                            -
                            -
                            -
                            -
                              -
                            1. 若依管理系统正式发布。
                            2. -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            捐赠
                            -
                            -
                            -
                            - 请作者喝杯咖啡(点击图片放大) -
                            -

                            - 请使用手机支付宝或者微信扫码支付 - -

                            - -
                            -
                            -
                            -
                            -
                            - - - - - - + + + + + + + 若依介绍 + + + + + + + + +
                            +
                            +
                            + 领取阿里云通用云产品1888优惠券 +
                            https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=brki8iof
                            + 领取腾讯云通用云产品2860优惠券 +
                            https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console
                            + 阿里云Hi拼购 限量爆款 低至199元/年 +
                            https://www.aliyun.com/acts/hi-group-buying?userCode=brki8iof +

                            云产品通用红包,可叠加官网常规优惠使用。(仅限新用户)

                            +
                            + +
                            +
                            +
                            +

                            Hello,Guest

                            + 移动设备访问请扫描以下二维码: +
                            +
                            + +
                            +
                            +
                            +

                            若依后台管理框架

                            +

                            一直想做一款后台管理系统,看了很多优秀的开源项目但是发现没有合适自己的。于是利用空闲休息时间开始自己写一套后台系统。如此有了若依管理系统。,她可以用于所有的Web应用程序,如网站管理后台网站会员中心CMSCRMOA等等,当然,您也可以对她进行深度定制,以做出更强系统。所有前端后台代码封装过后十分精简易上手,出错概率低。同时支持移动客户端访问。系统会陆续更新一些实用功能。

                            +

                            + 当前版本:v[[${version}]] +

                            +

                            + ¥免费开源 +

                            +
                            +

                            + + 访问码云 + + + 访问主页 + +

                            +
                            +
                            +

                            技术选型:

                            +
                              +
                            1. 核心框架:Spring Boot。
                            2. +
                            3. 安全框架:Apache Shiro。
                            4. +
                            5. 模板引擎:Thymeleaf。
                            6. +
                            7. 持久层框架:MyBatis。
                            8. +
                            9. 定时任务:Quartz。
                            10. +
                            11. 数据库连接池:Druid。
                            12. +
                            13. 工具类:Fastjson。
                            14. +
                            15. 更多……
                            16. +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            联系信息
                            + +
                            +
                            +

                            官网:http://www.ruoyi.vip +

                            +

                            QQ群:满1389287 满1679294 满1529866 满1772718 满1366522 1382251 +

                            +

                            微信:/ *若依 +

                            +

                            支付宝:/ *若依 +

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            更新日志
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v3.4.02019.06.03 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增实例演示菜单及demo
                            2. +
                            3. 新增页签右键操作
                            4. +
                            5. 菜单管理新增打开方式
                            6. +
                            7. 新增点击某行触发的事件
                            8. +
                            9. 新增双击某行触发的事件
                            10. +
                            11. 新增单击某格触发的事件
                            12. +
                            13. 新增双击某格触发的事件
                            14. +
                            15. 新增是否启用显示细节视图
                            16. +
                            17. 支持上传任意格式文件
                            18. +
                            19. 修复角色权限注解失效问题
                            20. +
                            21. 左侧的菜单栏宽度调整
                            22. +
                            23. 新增响应完成后自定义回调函数
                            24. +
                            25. 支持前端及其他模块直接获取用户信息
                            26. +
                            27. 升级swagger到最新版2.9.2
                            28. +
                            29. 升级jquery.slimscroll到最新版1.3.8
                            30. +
                            31. 升级select2到最新版4.0.7
                            32. +
                            33. 新增角色配置本部门数据权限
                            34. +
                            35. 新增角色配置本部门及以下数据权限
                            36. +
                            37. 优化底部操作防止跳到页面顶端
                            38. +
                            39. 修改冻结列选框无效及样式问题
                            40. +
                            41. 修复部门四层级修改祖级无效问题
                            42. +
                            43. 更换开关切换按钮样式
                            44. +
                            45. 新增select2-bootstrap美化下拉框
                            46. +
                            47. 添加表格内图片预览方法
                            48. +
                            49. 修复权限校验失败跳转页面路径错误
                            50. +
                            51. 国际化资源文件调整
                            52. +
                            53. 通知公告布局调整
                            54. +
                            55. 删除页签操作功能
                            56. +
                            57. 表格树新增查询指定列值
                            58. +
                            59. 更改系统接口扫描方式及完善测试案例
                            60. +
                            61. 表格列浮动提示及字典回显默认去背景
                            62. +
                            63. 修复启用翻页记住前面的选择check没选中问题
                            64. +
                            65. 去除监控页面底部的广告
                            66. +
                            67. 日期控件功问题修复及data功能增强
                            68. +
                            69. 新增角色权限可见性(前端直接调用)
                            70. +
                            71. 新增获取当前登录用户方法(前端及子模块调用)
                            72. +
                            73. 修复热部署重启导致菜单丢失问题
                            74. +
                            75. 优化业务校验失败普通请求跳转页面
                            76. +
                            77. 操作日志新增状态条件查询
                            78. +
                            79. 操作类型支持多选条件查询
                            80. +
                            81. 通知公告防止滚动触底回弹优化
                            82. +
                            83. 其他细节优化
                            84. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v3.3.02019.04.01 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增线程池统一管理
                            2. +
                            3. 新增支持左右冻结列
                            4. +
                            5. 新增表格字符超长浮动提示
                            6. +
                            7. 升级datepicker拓展并汉化
                            8. +
                            9. 升级druid到最新版本v1.1.14
                            10. +
                            11. 修复个人头像为图片服务器跨域问题
                            12. +
                            13. 修改上传文件按日期存储
                            14. +
                            15. 新增表格客户端分页选项
                            16. +
                            17. 新增表格的高度参数
                            18. +
                            19. 新增表格销毁方法
                            20. +
                            21. 新增表格下拉按钮切换方法
                            22. +
                            23. 新增表格分页跳转到指定页码
                            24. +
                            25. 新增表格启用点击选中行参数
                            26. +
                            27. 修复表格数据重新加载未触发部分按钮禁用
                            28. +
                            29. 使用jsonview展示操作日志参数
                            30. +
                            31. 新增方法(addTab、editTab)
                            32. +
                            33. 修改用户管理界面为Tab打开方式
                            34. +
                            35. 表单验证代码优化
                            36. +
                            37. 修复@Excel注解 prompt 属性使用报错
                            38. +
                            39. 修复combo属性Excel兼容性问题
                            40. +
                            41. 新增@Excel导入导出支持父类字段
                            42. +
                            43. 修复关闭最后选项卡无法激活滚动问题
                            44. +
                            45. 增加日期控件显示类型及回显格式扩展选项
                            46. +
                            47. 修复定时任务执行失败后入库状态为成功状态
                            48. +
                            49. 支持定时任务并发开关控制
                            50. +
                            51. 优化权限校验失败普通请求跳转页面
                            52. +
                            53. 捕获线程池执行任务抛出的异常
                            54. +
                            55. 修复IE浏览器导出功能报错
                            56. +
                            57. 新增角色管理分配用户功能
                            58. +
                            59. 新增表格翻页记住前面的选择
                            60. +
                            61. 调整用户个人中心页面
                            62. +
                            63. 修复界面存在的一些安全问题
                            64. +
                            65. 其他细节优化
                            66. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v3.2.02019.01.18 +
                            +
                            +
                            +
                            +
                              +
                            1. 部门修改时不允许选择最后节点
                            2. +
                            3. 修复部门菜单排序字段无效
                            4. +
                            5. 修复光驱磁盘导致服务监控异常
                            6. +
                            7. 登录界面去除check插件
                            8. +
                            9. 验证码文本字符间距修正
                            10. +
                            11. 升级SpringBoot到最新版本2.1.1
                            12. +
                            13. 升级MYSQL驱动
                            14. +
                            15. 修正登录必填项位置偏移
                            16. +
                            17. Session会话检查优化
                            18. +
                            19. Excel注解支持多级获取
                            20. +
                            21. 新增序列号生成方法
                            22. +
                            23. 修复WAR部署tomcat退出线程异常
                            24. +
                            25. 全屏操作增加默认确认/关闭
                            26. +
                            27. 修复个人信息可能导致漏洞
                            28. +
                            29. 字典数据根据下拉选择新增类型
                            30. +
                            31. 升级Summernote到最新版本v0.8.11
                            32. +
                            33. 新增用户数据导入
                            34. +
                            35. 首页主题样式更换
                            36. +
                            37. layer扩展主题更换
                            38. +
                            39. 用户管理移动端默认隐藏左侧布局
                            40. +
                            41. 详细信息弹出层显示在顶层
                            42. +
                            43. 表格支持切换状态(用户/角色/定时任务)
                            44. +
                            45. Druid数据源支持配置继承
                            46. +
                            47. 修正部分iPhone手机端表格适配问题
                            48. +
                            49. 新增防止重复提交表单方法
                            50. +
                            51. 新增表格数据统计汇总方法
                            52. +
                            53. 支持富文本上传图片文件
                            54. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v3.1.02018.12.03 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增内网不获取IP地址
                            2. +
                            3. 新增cron表达式有效校验
                            4. +
                            5. 定时任务新增详细信息
                            6. +
                            7. 定时任务默认策略修改(不触发立即执行)
                            8. +
                            9. 定时任务显示下一个执行周期
                            10. +
                            11. 支持前端任意日期格式处理
                            12. +
                            13. 上传头像删除多余提交按钮
                            14. +
                            15. 表格增加行间隔色配置项
                            16. +
                            17. 表格增加转义HTML字符串配置项
                            18. +
                            19. 表格增加显示/隐藏指定列
                            20. +
                            21. 代码生成优化
                            22. +
                            23. 操作日志参数格式化显示
                            24. +
                            25. 页签新增新增全屏显示
                            26. +
                            27. 新增一键打包部署
                            28. +
                            29. Excel注解新增多个参数
                            30. +
                            31. 新增提交静默更新表格方法
                            32. +
                            33. 新增服务监控菜单
                            34. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v3.0.02018.10.08 +
                            +
                            +
                            +
                            +
                              +
                            1. 升级poi到最新版3.17
                            2. +
                            3. 导出修改临时目录绝对路径
                            4. +
                            5. 升级laydate到最新版5.0.9
                            6. +
                            7. 升级SpringBoot到最新版本2.0.5
                            8. +
                            9. 优化开始/结束时间校验限制
                            10. +
                            11. 重置密码参数表中获取默认值
                            12. +
                            13. 修复头像修改显示问题
                            14. +
                            15. 新增数据权限过滤注解
                            16. +
                            17. 新增表格检索折叠按钮
                            18. +
                            19. 新增清空(登录、操作、调度)日志
                            20. +
                            21. 固定按钮位置(提交/关闭)
                            22. +
                            23. 部门/菜单支持(展开/折叠)
                            24. +
                            25. 部分细节调整优化
                            26. +
                            27. 项目采用分模块
                            28. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v2.4.02018.09.03 +
                            +
                            +
                            +
                            +
                              +
                            1. 支持部门多级查询
                            2. +
                            3. 修复菜单状态查询无效
                            4. +
                            5. 支持IP地址开关
                            6. +
                            7. 支持XSS开关
                            8. +
                            9. 记录日志异步处理
                            10. +
                            11. 字典回显样式更改为下拉框
                            12. +
                            13. 菜单类型必填校验
                            14. +
                            15. 修复在线用户排序报错
                            16. +
                            17. 增加重置按钮
                            18. +
                            19. 支持注解导入数据
                            20. +
                            21. 支持弹层外区域关闭
                            22. +
                            23. 备注更换为文本区域
                            24. +
                            25. 新增角色逻辑删除
                            26. +
                            27. 新增部门逻辑删除
                            28. +
                            29. 支持部门数据权限
                            30. +
                            31. 管理员默认拥有所有授权
                            32. +
                            33. 字典数据采用分页
                            34. +
                            35. 部分细节调整优化
                            36. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v2.3.02018.08.06 +
                            +
                            +
                            +
                            +
                              +
                            1. 支持表格不分页开关控制
                            2. +
                            3. 修改字典类型同步修改字典数据
                            4. +
                            5. 代码生成新增修改后缀处理
                            6. +
                            7. 代码生成新增实体toString
                            8. +
                            9. 代码生成非字符串去除!=''
                            10. +
                            11. 导出数据前加载遮罩层
                            12. +
                            13. 部门删除校验条件修改
                            14. +
                            15. 搜索查询下载优化
                            16. +
                            17. 手机打开弹出层自适应
                            18. +
                            19. 角色岗位禁用显示置灰
                            20. +
                            21. 角色禁用不显示菜单
                            22. +
                            23. 新增导出权限
                            24. +
                            25. 角色权限唯一校验
                            26. +
                            27. 岗位名称编码唯一校验
                            28. +
                            29. TreeTable优化
                            30. +
                            31. 支持多数据源
                            32. +
                            33. 其他细节优化
                            34. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v2.2.02018.07.23 +
                            +
                            +
                            +
                            +
                              +
                            1. 修复批量生成代码异常问题
                            2. +
                            3. 修复定时器保存失败问题
                            4. +
                            5. 修复热部署转换问题
                            6. +
                            7. 支持查询菜单管理,部门管理
                            8. +
                            9. 大多数功能支持时间查询
                            10. +
                            11. 自定义导出注解自动匹配column
                            12. +
                            13. 新增任务执行策略
                            14. +
                            15. 操作详细动态显示类型
                            16. +
                            17. 支持动态回显字典数据
                            18. +
                            19. 后台代码优化调整
                            20. +
                            21. 其他细节优化
                            22. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v2.1.02018.07.10 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增登陆超时提醒
                            2. +
                            3. 修复定时器热部署转换问题
                            4. +
                            5. 修复登录验证码校验无效问题
                            6. +
                            7. 定时任务新增立即执行一次
                            8. +
                            9. 存在字典数据不允许删除字典
                            10. +
                            11. 字典数据支持按名称查询
                            12. +
                            13. 代码生成增加日志注解&表格优化
                            14. +
                            15. 修复用户逻辑删除后能登录问题
                            16. +
                            17. 表格支持多字段动态排序
                            18. +
                            19. 支持三级菜单显示
                            20. +
                            21. 新增ry.sh启动程序脚本
                            22. +
                            23. 其他细节优化
                            24. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v2.0.02018.07.02 +
                            +
                            +
                            +
                            +
                              +
                            1. 升级SpringBoot到最新版本2.0.3
                            2. +
                            3. 新增公告管理
                            4. +
                            5. 表单校验示提体验优化
                            6. +
                            7. 前端通用方法封装调整
                            8. +
                            9. 前端去除js文件,合并到html
                            10. +
                            11. 操作加载遮罩层
                            12. +
                            13. 支持全屏模式操作
                            14. +
                            15. 支持注解导出数据
                            16. +
                            17. 系统支持多查询&下载
                            18. +
                            19. 系统样式调整
                            20. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.1.62018.06.04 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增用户列表部门列
                            2. +
                            3. 新增登录地点
                            4. +
                            5. 新增swagger
                            6. +
                            7. 修复排序数字校验
                            8. +
                            9. 优化头像上传文件类型限定为图片
                            10. +
                            11. 新增XSS过滤
                            12. +
                            13. 新增热部署提高开发效率
                            14. +
                            15. 修复treegrid居中无效
                            16. +
                            17. 角色多条件查询
                            18. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.1.52018.05.28 +
                            +
                            +
                            +
                            +
                              +
                            1. 优化登录失败刷新验证码
                            2. +
                            3. 新增用户登陆地址时间
                            4. +
                            5. 修复ajax超时退出问题
                            6. +
                            7. 新增html调用数据字典(若依首创)
                            8. +
                            9. 调整系统部分样式
                            10. +
                            11. 新增用户逻辑删除
                            12. +
                            13. 新增管理员不允许删除修改
                            14. +
                            15. 升级bootstrapTable到最新版本1.12.1
                            16. +
                            17. 升级layer到最新版本3.1.1
                            18. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.1.42018.05.20 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增参数管理
                            2. +
                            3. 修复头像上传bug
                            4. +
                            5. 手机邮箱唯一校验
                            6. +
                            7. 支持手机邮箱登录
                            8. +
                            9. 代码生成优化
                            10. +
                            11. 支持模糊查询
                            12. +
                            13. 支持切换主题皮肤
                            14. +
                            15. 修改权限即时生效
                            16. +
                            17. 修复页签Tab关闭问题
                            18. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.1.32018.05.14 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增验证码(数组计算、字符验证)
                            2. +
                            3. 新增cookie记住我
                            4. +
                            5. 新增头像上传
                            6. +
                            7. 用户名密码长度限制
                            8. +
                            9. 通用字段提取
                            10. +
                            11. 支持自定义条件查询
                            12. +
                            13. 部门名称必填、时间格式调整
                            14. +
                            15. 其他细节优化
                            16. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.1.22018.05.07 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增个人信息修改
                            2. +
                            3. 菜单存在子菜单不允许删除
                            4. +
                            5. 菜单分配角色不允许删除
                            6. +
                            7. 角色分配人员不允许删除
                            8. +
                            9. 岗位使用后不允许删除
                            10. +
                            11. 保证用户的数据完整性加入事物
                            12. +
                            13. 新增环境使用手册、数据建模
                            14. +
                            15. Thymeleaf升级到3.0
                            16. +
                            17. 支持非ROOT部署
                            18. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.1.12018.04.23 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增表单构建器
                            2. +
                            3. 代码生成优化
                            4. +
                            5. 支持新增主部门
                            6. +
                            7. 支持选择上级部门、上级菜单
                            8. +
                            9. 新增字典管理单条删除
                            10. +
                            11. 优化一些其他细节
                            12. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.1.02018.04.20 +
                            +
                            +
                            +
                            +
                              +
                            1. 支持密码盐
                            2. +
                            3. 支持新增主目录
                            4. +
                            5. 支持批量生成代码
                            6. +
                            7. 支持表格导出(csv、txt、doc、excel)
                            8. +
                            9. 自动适应宽高模式窗体
                            10. +
                            11. 重复校验(角色名、菜单名、部门名)
                            12. +
                            13. 优化一些其他细节
                            14. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.92018.04.14 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增代码生成(生成包括 java、html、js、xml、sql)
                            2. +
                            3. 新增按钮权限控制隐藏(若依首创)
                            4. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.82018.04.08 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增定时任务(新增、修改、删除、查询、启动/暂停)
                            2. +
                            3. 新增调度日志(查询、删除)
                            4. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.72018.04.04 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增岗位管理(新增、修改、删除、查询)
                            2. +
                            3. 优化用户管理,菜单管理部分细节
                            4. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.62018.03.15 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增字典管理(新增、删除、修改、查询、数据选择)
                            2. +
                            3. 新增用户密码重置
                            4. +
                            5. 优化一些其他细节
                            6. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.52018.03.12 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增菜单管理(新增、删除、修改、查询、图标选择)
                            2. +
                            3. 部门管理优化(添加责任人、联系电话、邮箱、修改者)
                            4. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.42018.03.11 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增角色管理(新增、删除、修改、查询、菜单选择)
                            2. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.32018.03.08 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增用户管理(新增、删除、修改、查询、部门选择)
                            2. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.22018.03.04 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增部门管理 (新增、删除、修改、查询)
                            2. +
                            +
                            +
                            +
                            +
                            +
                            +
                            + v1.0.12018.03.03 +
                            +
                            +
                            +
                            +
                              +
                            1. 新增在线用户 (批量强退、单条强退、查询)
                            2. +
                            3. 新增登录日志 (批量删除、查询)
                            4. +
                            5. 新增操作日志 (批量删除、查询、详细)
                            6. +
                            7. 新增数据监控 (监控DB池连接和SQL的执行)
                            8. +
                            +
                            +
                            +
                            +
                            +
                            +

                            + v1.0.02018.03.01 +

                            +
                            +
                            +
                            +
                              +
                            1. 若依管理系统正式发布。
                            2. +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            捐赠
                            +
                            +
                            +
                            + 请作者喝杯咖啡(点击图片放大) +
                            +

                            + 请使用手机支付宝或者微信扫码支付 + +

                            + +
                            +
                            +
                            +
                            +
                            + + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/main_v1.html b/bmw-admin/src/main/resources/templates/main_v1.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/main_v1.html rename to bmw-admin/src/main/resources/templates/main_v1.html index f0e434bc1..4ace108fa 100644 --- a/ruoyi-admin/src/main/resources/templates/main_v1.html +++ b/bmw-admin/src/main/resources/templates/main_v1.html @@ -1,336 +1,336 @@ - - - - - - 统计 - - - - - - - - -
                            - -
                            -
                            -
                            -
                            - -
                            收入
                            -
                            -
                            -

                            40 886,200

                            -
                            98% -
                            - 总收入 -
                            -
                            -
                            -
                            -
                            -
                            - 全年 -
                            订单
                            -
                            -
                            -

                            275,800

                            -
                            20% -
                            - 新订单 -
                            -
                            -
                            -
                            -
                            -
                            - 今天 -
                            访客
                            -
                            -
                            -

                            106,120

                            -
                            44% -
                            - 新访客 -
                            -
                            -
                            -
                            -
                            -
                            - 最近一个月 -
                            活跃用户
                            -
                            -
                            -

                            80,600

                            -
                            38% -
                            - 12月 -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            订单
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                              -
                            • -

                              2,346

                              - 订单总数 -
                              48% -
                              -
                              -
                              -
                              -
                            • -
                            • -

                              4,422

                              - 最近一个月订单 -
                              60% -
                              -
                              -
                              -
                              -
                            • -
                            • -

                              9,180

                              - 最近一个月销售额 -
                              22% -
                              -
                              -
                              -
                              -
                            • -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            用户项目列表
                            - -
                            -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            状态日期用户
                            进行中... - 11:20青衣5858 24%
                            已取消 - 10:40徐子崴 66%
                            进行中... - 01:30姜岚昕 54%
                            进行中... - 02:20武汉大兵哥 12%
                            进行中... - 09:40荆莹儿 22%
                            已完成 - 04:10栾某某 66%
                            进行中... - 12:08范范范二妮 23%
                            -
                            -
                            -
                            -
                            -
                            -
                            - - - - - - - - + + + + + + 统计 + + + + + + + + +
                            + +
                            +
                            +
                            +
                            + +
                            收入
                            +
                            +
                            +

                            40 886,200

                            +
                            98% +
                            + 总收入 +
                            +
                            +
                            +
                            +
                            +
                            + 全年 +
                            订单
                            +
                            +
                            +

                            275,800

                            +
                            20% +
                            + 新订单 +
                            +
                            +
                            +
                            +
                            +
                            + 今天 +
                            访客
                            +
                            +
                            +

                            106,120

                            +
                            44% +
                            + 新访客 +
                            +
                            +
                            +
                            +
                            +
                            + 最近一个月 +
                            活跃用户
                            +
                            +
                            +

                            80,600

                            +
                            38% +
                            + 12月 +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            订单
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                              +
                            • +

                              2,346

                              + 订单总数 +
                              48% +
                              +
                              +
                              +
                              +
                            • +
                            • +

                              4,422

                              + 最近一个月订单 +
                              60% +
                              +
                              +
                              +
                              +
                            • +
                            • +

                              9,180

                              + 最近一个月销售额 +
                              22% +
                              +
                              +
                              +
                              +
                            • +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            用户项目列表
                            + +
                            +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            状态日期用户
                            进行中... + 11:20青衣5858 24%
                            已取消 + 10:40徐子崴 66%
                            进行中... + 01:30姜岚昕 54%
                            进行中... + 02:20武汉大兵哥 12%
                            进行中... + 09:40荆莹儿 22%
                            已完成 + 04:10栾某某 66%
                            进行中... + 12:08范范范二妮 23%
                            +
                            +
                            +
                            +
                            +
                            +
                            + + + + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/monitor/logininfor/logininfor.html b/bmw-admin/src/main/resources/templates/monitor/logininfor/logininfor.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/monitor/logininfor/logininfor.html rename to bmw-admin/src/main/resources/templates/monitor/logininfor/logininfor.html index 0be36dcaf..ce44db3e0 100644 --- a/ruoyi-admin/src/main/resources/templates/monitor/logininfor/logininfor.html +++ b/bmw-admin/src/main/resources/templates/monitor/logininfor/logininfor.html @@ -1,126 +1,126 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - -
                            • -
                            • - -
                            • -
                            • - -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + +
                            • +
                            • + +
                            • +
                            • + +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/monitor/online/online.html b/bmw-admin/src/main/resources/templates/monitor/online/online.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/monitor/online/online.html rename to bmw-admin/src/main/resources/templates/monitor/online/online.html index 573b19156..721eca31d 100644 --- a/ruoyi-admin/src/main/resources/templates/monitor/online/online.html +++ b/bmw-admin/src/main/resources/templates/monitor/online/online.html @@ -1,148 +1,148 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/monitor/operlog/detail.html b/bmw-admin/src/main/resources/templates/monitor/operlog/detail.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/monitor/operlog/detail.html rename to bmw-admin/src/main/resources/templates/monitor/operlog/detail.html index 39c6a28ad..0200e6373 100644 --- a/ruoyi-admin/src/main/resources/templates/monitor/operlog/detail.html +++ b/bmw-admin/src/main/resources/templates/monitor/operlog/detail.html @@ -1,59 +1,59 @@ - - - - - - - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/monitor/operlog/operlog.html b/bmw-admin/src/main/resources/templates/monitor/operlog/operlog.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/monitor/operlog/operlog.html rename to bmw-admin/src/main/resources/templates/monitor/operlog/operlog.html index 3cef2bb7b..0390b207b 100644 --- a/ruoyi-admin/src/main/resources/templates/monitor/operlog/operlog.html +++ b/bmw-admin/src/main/resources/templates/monitor/operlog/operlog.html @@ -1,163 +1,163 @@ - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - -
                            • -
                            • - -
                            • -
                            • - -
                            • -
                            • - -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + +
                            • +
                            • + +
                            • +
                            • + +
                            • +
                            • + +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/monitor/server/server.html b/bmw-admin/src/main/resources/templates/monitor/server/server.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/monitor/server/server.html rename to bmw-admin/src/main/resources/templates/monitor/server/server.html index dae4c4b04..49692bd6d 100644 --- a/ruoyi-admin/src/main/resources/templates/monitor/server/server.html +++ b/bmw-admin/src/main/resources/templates/monitor/server/server.html @@ -1,254 +1,254 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            CPU
                            -
                            - - - -
                            -
                            -
                            - - - - - - - - - - - - - - - - - - - - - - - - - -
                            属性
                            核心数0个
                            用户使用率0%
                            系统使用率0%
                            当前空闲率0%
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            内存
                            -
                            - - -
                            -
                            -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            属性内存JVM
                            总内存0GB0MB
                            已用内存0GB0MB
                            剩余内存0GB0MB
                            使用率[[${server.mem.usage}]]%[[${server.jvm.usage}]]%
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            服务器信息
                            - -
                            -
                            -
                            -
                            - - - - - - - - - - - - - - - -
                            服务器名称RuoYi操作系统Linux
                            服务器IP127.0.0.1系统架构amd64
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            Java虚拟机信息
                            - -
                            -
                            - -
                            -
                            - - - - - - - - - - - - - - - - - - - - - - - -
                            Java名称JavaJava版本1.8.0
                            启动时间2018-12-31 00:00:00运行时长0天0时0分0秒
                            安装路径
                            项目路径
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            磁盘状态
                            - -
                            -
                            - -
                            -
                            - - - - - - - - - - - - - - - - - - - - - - - -
                            盘符路径文件系统盘符类型总大小可用大小已用大小已用百分比
                            C:\NTFSlocal0GB0GB0GB[[${sysFile.usage}]]%
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            CPU
                            +
                            + + + +
                            +
                            +
                            + + + + + + + + + + + + + + + + + + + + + + + + + +
                            属性
                            核心数0个
                            用户使用率0%
                            系统使用率0%
                            当前空闲率0%
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            内存
                            +
                            + + +
                            +
                            +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            属性内存JVM
                            总内存0GB0MB
                            已用内存0GB0MB
                            剩余内存0GB0MB
                            使用率[[${server.mem.usage}]]%[[${server.jvm.usage}]]%
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            服务器信息
                            + +
                            +
                            +
                            +
                            + + + + + + + + + + + + + + + +
                            服务器名称RuoYi操作系统Linux
                            服务器IP127.0.0.1系统架构amd64
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            Java虚拟机信息
                            + +
                            +
                            + +
                            +
                            + + + + + + + + + + + + + + + + + + + + + + + +
                            Java名称JavaJava版本1.8.0
                            启动时间2018-12-31 00:00:00运行时长0天0时0分0秒
                            安装路径
                            项目路径
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            磁盘状态
                            + +
                            +
                            + +
                            +
                            + + + + + + + + + + + + + + + + + + + + + + + +
                            盘符路径文件系统盘符类型总大小可用大小已用大小已用百分比
                            C:\NTFSlocal0GB0GB0GB[[${sysFile.usage}]]%
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/config/add.html b/bmw-admin/src/main/resources/templates/system/config/add.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/config/add.html rename to bmw-admin/src/main/resources/templates/system/config/add.html index 68b6dee33..dc0589a5d 100644 --- a/ruoyi-admin/src/main/resources/templates/system/config/add.html +++ b/bmw-admin/src/main/resources/templates/system/config/add.html @@ -1,82 +1,82 @@ - - - - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/config/config.html b/bmw-admin/src/main/resources/templates/system/config/config.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/config/config.html rename to bmw-admin/src/main/resources/templates/system/config/config.html index 14be0fcbb..b6a1fc7ea 100644 --- a/ruoyi-admin/src/main/resources/templates/system/config/config.html +++ b/bmw-admin/src/main/resources/templates/system/config/config.html @@ -1,130 +1,130 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 参数名称: -
                            • -
                            • - 参数键名: -
                            • -
                            • - 系统内置: -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 参数名称: +
                            • +
                            • + 参数键名: +
                            • +
                            • + 系统内置: +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/config/edit.html b/bmw-admin/src/main/resources/templates/system/config/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/config/edit.html rename to bmw-admin/src/main/resources/templates/system/config/edit.html index b74007e84..6c4c91c5d 100644 --- a/ruoyi-admin/src/main/resources/templates/system/config/edit.html +++ b/bmw-admin/src/main/resources/templates/system/config/edit.html @@ -1,86 +1,86 @@ - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/dept/add.html b/bmw-admin/src/main/resources/templates/system/dept/add.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/dept/add.html rename to bmw-admin/src/main/resources/templates/system/dept/add.html index 3ce6aae14..449fc3407 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dept/add.html +++ b/bmw-admin/src/main/resources/templates/system/dept/add.html @@ -1,128 +1,128 @@ - - - - - - -
                            -
                            - -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/dept/dept.html b/bmw-admin/src/main/resources/templates/system/dept/dept.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/dept/dept.html rename to bmw-admin/src/main/resources/templates/system/dept/dept.html index 6663d1848..56d94e32b 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dept/dept.html +++ b/bmw-admin/src/main/resources/templates/system/dept/dept.html @@ -1,112 +1,112 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 部门名称: -
                            • -
                            • - 部门状态: -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 部门名称: +
                            • +
                            • + 部门状态: +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/dept/edit.html b/bmw-admin/src/main/resources/templates/system/dept/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/dept/edit.html rename to bmw-admin/src/main/resources/templates/system/dept/edit.html index f21db0843..9cbfc9227 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dept/edit.html +++ b/bmw-admin/src/main/resources/templates/system/dept/edit.html @@ -1,140 +1,140 @@ - - - - - - -
                            -
                            - - -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + + +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/dept/tree.html b/bmw-admin/src/main/resources/templates/system/dept/tree.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/dept/tree.html rename to bmw-admin/src/main/resources/templates/system/dept/tree.html index 0f35a4b4c..d943e3b01 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dept/tree.html +++ b/bmw-admin/src/main/resources/templates/system/dept/tree.html @@ -1,49 +1,49 @@ - - - - - - - - - - -
                            - - -
                            - -
                            - 展开 / - 折叠 -
                            -
                            -
                            - - - - - + + + + + + + + + + +
                            + + +
                            + +
                            + 展开 / + 折叠 +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/dict/data/add.html b/bmw-admin/src/main/resources/templates/system/dict/data/add.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/dict/data/add.html rename to bmw-admin/src/main/resources/templates/system/dict/data/add.html index c780d5db2..d13b92b80 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dict/data/add.html +++ b/bmw-admin/src/main/resources/templates/system/dict/data/add.html @@ -1,100 +1,100 @@ - - - - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - table表格字典列显示样式属性 -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + table表格字典列显示样式属性 +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/dict/data/data.html b/bmw-admin/src/main/resources/templates/system/dict/data/data.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/dict/data/data.html rename to bmw-admin/src/main/resources/templates/system/dict/data/data.html index ecd733707..fc8143132 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dict/data/data.html +++ b/bmw-admin/src/main/resources/templates/system/dict/data/data.html @@ -1,137 +1,137 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 字典名称: -
                            • -
                            • - 字典标签: -
                            • -
                            • - 数据状态: -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 字典名称: +
                            • +
                            • + 字典标签: +
                            • +
                            • + 数据状态: +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/dict/data/edit.html b/bmw-admin/src/main/resources/templates/system/dict/data/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/dict/data/edit.html rename to bmw-admin/src/main/resources/templates/system/dict/data/edit.html index bdb2bd2a2..69b7162bb 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dict/data/edit.html +++ b/bmw-admin/src/main/resources/templates/system/dict/data/edit.html @@ -1,101 +1,101 @@ - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - table表格字典列显示样式属性 -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + table表格字典列显示样式属性 +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/dict/type/add.html b/bmw-admin/src/main/resources/templates/system/dict/type/add.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/dict/type/add.html rename to bmw-admin/src/main/resources/templates/system/dict/type/add.html index 31756c56c..9dad238c9 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dict/type/add.html +++ b/bmw-admin/src/main/resources/templates/system/dict/type/add.html @@ -1,77 +1,77 @@ - - - - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/dict/type/edit.html b/bmw-admin/src/main/resources/templates/system/dict/type/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/dict/type/edit.html rename to bmw-admin/src/main/resources/templates/system/dict/type/edit.html index 2bcb15f82..d00728fa1 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dict/type/edit.html +++ b/bmw-admin/src/main/resources/templates/system/dict/type/edit.html @@ -1,81 +1,81 @@ - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/dict/type/type.html b/bmw-admin/src/main/resources/templates/system/dict/type/type.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/dict/type/type.html rename to bmw-admin/src/main/resources/templates/system/dict/type/type.html index ac51b5e2a..dd5d74bd7 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dict/type/type.html +++ b/bmw-admin/src/main/resources/templates/system/dict/type/type.html @@ -1,137 +1,137 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 字典名称: -
                            • -
                            • - 字典类型: -
                            • -
                            • - 字典状态: -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 字典名称: +
                            • +
                            • + 字典类型: +
                            • +
                            • + 字典状态: +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/menu/add.html b/bmw-admin/src/main/resources/templates/system/menu/add.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/menu/add.html rename to bmw-admin/src/main/resources/templates/system/menu/add.html index 2fd6b972b..466998318 100644 --- a/ruoyi-admin/src/main/resources/templates/system/menu/add.html +++ b/bmw-admin/src/main/resources/templates/system/menu/add.html @@ -1,185 +1,185 @@ - - - - - - -
                            -
                            - -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - 控制器中定义的权限标识,如:@RequiresPermissions("") -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + 控制器中定义的权限标识,如:@RequiresPermissions("") +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/menu/edit.html b/bmw-admin/src/main/resources/templates/system/menu/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/menu/edit.html rename to bmw-admin/src/main/resources/templates/system/menu/edit.html index c7fc244bf..1f9d75861 100644 --- a/ruoyi-admin/src/main/resources/templates/system/menu/edit.html +++ b/bmw-admin/src/main/resources/templates/system/menu/edit.html @@ -1,213 +1,213 @@ - - - - - - -
                            -
                            - - -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - 控制器中定义的权限标识,如:@RequiresPermissions("") -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + + +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + 控制器中定义的权限标识,如:@RequiresPermissions("") +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/menu/icon.html b/bmw-admin/src/main/resources/templates/system/menu/icon.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/menu/icon.html rename to bmw-admin/src/main/resources/templates/system/menu/icon.html index 61cb177ba..f9f7f1944 100644 --- a/ruoyi-admin/src/main/resources/templates/system/menu/icon.html +++ b/bmw-admin/src/main/resources/templates/system/menu/icon.html @@ -1,928 +1,928 @@ - - - - - Font Awesome Ico list - - - - - -
                            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                            - + + + + + Font Awesome Ico list + + + + + +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                            + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/menu/menu.html b/bmw-admin/src/main/resources/templates/system/menu/menu.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/menu/menu.html rename to bmw-admin/src/main/resources/templates/system/menu/menu.html index a5ee47679..d0e4a4e0d 100644 --- a/ruoyi-admin/src/main/resources/templates/system/menu/menu.html +++ b/bmw-admin/src/main/resources/templates/system/menu/menu.html @@ -1,145 +1,145 @@ - - - - - - -
                            -
                            -
                            - -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            + +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/menu/tree.html b/bmw-admin/src/main/resources/templates/system/menu/tree.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/menu/tree.html rename to bmw-admin/src/main/resources/templates/system/menu/tree.html index 9eb444766..a38e8510a 100644 --- a/ruoyi-admin/src/main/resources/templates/system/menu/tree.html +++ b/bmw-admin/src/main/resources/templates/system/menu/tree.html @@ -1,49 +1,49 @@ - - - - - - - - - - -
                            - - -
                            - -
                            - 展开 / - 折叠 -
                            -
                            -
                            - - - - - + + + + + + + + + + +
                            + + +
                            + +
                            + 展开 / + 折叠 +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/notice/add.html b/bmw-admin/src/main/resources/templates/system/notice/add.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/notice/add.html rename to bmw-admin/src/main/resources/templates/system/notice/add.html index 4c1893e3e..df2525688 100644 --- a/ruoyi-admin/src/main/resources/templates/system/notice/add.html +++ b/bmw-admin/src/main/resources/templates/system/notice/add.html @@ -1,97 +1,97 @@ - - - - - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/notice/edit.html b/bmw-admin/src/main/resources/templates/system/notice/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/notice/edit.html rename to bmw-admin/src/main/resources/templates/system/notice/edit.html index 8987df2c7..85612a899 100644 --- a/ruoyi-admin/src/main/resources/templates/system/notice/edit.html +++ b/bmw-admin/src/main/resources/templates/system/notice/edit.html @@ -1,102 +1,102 @@ - - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/notice/notice.html b/bmw-admin/src/main/resources/templates/system/notice/notice.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/notice/notice.html rename to bmw-admin/src/main/resources/templates/system/notice/notice.html index ab117fad5..548f19b50 100644 --- a/ruoyi-admin/src/main/resources/templates/system/notice/notice.html +++ b/bmw-admin/src/main/resources/templates/system/notice/notice.html @@ -1,117 +1,117 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 公告标题: -
                            • -
                            • - 操作人员: -
                            • -
                            • - 公告类型: -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 公告标题: +
                            • +
                            • + 操作人员: +
                            • +
                            • + 公告类型: +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/post/add.html b/bmw-admin/src/main/resources/templates/system/post/add.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/post/add.html rename to bmw-admin/src/main/resources/templates/system/post/add.html index cd84ada21..5f385de81 100644 --- a/ruoyi-admin/src/main/resources/templates/system/post/add.html +++ b/bmw-admin/src/main/resources/templates/system/post/add.html @@ -1,103 +1,103 @@ - - - - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/post/edit.html b/bmw-admin/src/main/resources/templates/system/post/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/post/edit.html rename to bmw-admin/src/main/resources/templates/system/post/edit.html index 862e72119..d13cad0aa 100644 --- a/ruoyi-admin/src/main/resources/templates/system/post/edit.html +++ b/bmw-admin/src/main/resources/templates/system/post/edit.html @@ -1,110 +1,110 @@ - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/post/post.html b/bmw-admin/src/main/resources/templates/system/post/post.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/post/post.html rename to bmw-admin/src/main/resources/templates/system/post/post.html index 6166546c5..34e5b2cfa 100644 --- a/ruoyi-admin/src/main/resources/templates/system/post/post.html +++ b/bmw-admin/src/main/resources/templates/system/post/post.html @@ -1,120 +1,120 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 岗位编码: -
                            • -
                            • - 岗位名称: -
                            • -
                            • - 岗位状态: -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 岗位编码: +
                            • +
                            • + 岗位名称: +
                            • +
                            • + 岗位状态: +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/role/add.html b/bmw-admin/src/main/resources/templates/system/role/add.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/role/add.html rename to bmw-admin/src/main/resources/templates/system/role/add.html index 20dad50eb..bcd0b83b7 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/add.html +++ b/bmw-admin/src/main/resources/templates/system/role/add.html @@ -1,150 +1,150 @@ - - - - - - - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - 控制器中定义的权限字符,如:@RequiresRoles("") -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + 控制器中定义的权限字符,如:@RequiresRoles("") +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/role/authUser.html b/bmw-admin/src/main/resources/templates/system/role/authUser.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/role/authUser.html rename to bmw-admin/src/main/resources/templates/system/role/authUser.html index f474d901d..b7ddd8818 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/authUser.html +++ b/bmw-admin/src/main/resources/templates/system/role/authUser.html @@ -1,149 +1,149 @@ - - - - - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/role/dataScope.html b/bmw-admin/src/main/resources/templates/system/role/dataScope.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/role/dataScope.html rename to bmw-admin/src/main/resources/templates/system/role/dataScope.html index 7cb3d8cb1..97755daaa 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/dataScope.html +++ b/bmw-admin/src/main/resources/templates/system/role/dataScope.html @@ -1,107 +1,107 @@ - - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - 特殊情况下,设置为“自定数据权限” -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + 特殊情况下,设置为“自定数据权限” +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/role/edit.html b/bmw-admin/src/main/resources/templates/system/role/edit.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/role/edit.html rename to bmw-admin/src/main/resources/templates/system/role/edit.html index 063968e32..d0c529389 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/edit.html +++ b/bmw-admin/src/main/resources/templates/system/role/edit.html @@ -1,159 +1,159 @@ - - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - - 控制器中定义的权限字符,如:@RequiresRoles("") -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + + 控制器中定义的权限字符,如:@RequiresRoles("") +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/role/role.html b/bmw-admin/src/main/resources/templates/system/role/role.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/role/role.html rename to bmw-admin/src/main/resources/templates/system/role/role.html index 61a3f1197..c03bbf0bd 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/role.html +++ b/bmw-admin/src/main/resources/templates/system/role/role.html @@ -1,163 +1,163 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 角色名称: -
                            • -
                            • - 权限字符: -
                            • -
                            • - 角色状态: -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 角色名称: +
                            • +
                            • + 权限字符: +
                            • +
                            • + 角色状态: +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/role/selectUser.html b/bmw-admin/src/main/resources/templates/system/role/selectUser.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/role/selectUser.html rename to bmw-admin/src/main/resources/templates/system/role/selectUser.html index 8bafb7460..cdc89823e 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/selectUser.html +++ b/bmw-admin/src/main/resources/templates/system/role/selectUser.html @@ -1,120 +1,120 @@ - - - - - - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/user/add.html b/bmw-admin/src/main/resources/templates/system/user/add.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/user/add.html rename to bmw-admin/src/main/resources/templates/system/user/add.html index 6d270cf3c..f98b5ce96 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/add.html +++ b/bmw-admin/src/main/resources/templates/system/user/add.html @@ -1,257 +1,257 @@ - - - - - - - -
                            -
                            - -

                            基本信息

                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -

                            其他信息

                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -   - -
                            -
                            - - - - - + + + + + + + +
                            +
                            + +

                            基本信息

                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +

                            其他信息

                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +   + +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/user/edit.html b/bmw-admin/src/main/resources/templates/system/user/edit.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/user/edit.html rename to bmw-admin/src/main/resources/templates/system/user/edit.html index e10e45a75..5336e4415 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/edit.html +++ b/bmw-admin/src/main/resources/templates/system/user/edit.html @@ -1,228 +1,228 @@ - - - - - - - -
                            -
                            - - -

                            基本信息

                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -

                            其他信息

                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -   - -
                            -
                            - - - - + + + + + + + +
                            +
                            + + +

                            基本信息

                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +

                            其他信息

                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +   + +
                            +
                            + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/user/profile/avatar.html b/bmw-admin/src/main/resources/templates/system/user/profile/avatar.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/user/profile/avatar.html rename to bmw-admin/src/main/resources/templates/system/user/profile/avatar.html index a7064f648..0114e7035 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/profile/avatar.html +++ b/bmw-admin/src/main/resources/templates/system/user/profile/avatar.html @@ -1,84 +1,84 @@ - - - - - - - -
                            -
                            -
                            - -
                            -
                            - - - - -
                            -
                            -
                            - - - - - + + + + + + + +
                            +
                            +
                            + +
                            +
                            + + + + +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html b/bmw-admin/src/main/resources/templates/system/user/profile/profile.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html rename to bmw-admin/src/main/resources/templates/system/user/profile/profile.html index b83dab3e4..5a3a5a070 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html +++ b/bmw-admin/src/main/resources/templates/system/user/profile/profile.html @@ -1,272 +1,272 @@ - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            个人资料
                            -
                            -
                            -
                            -

                            -

                            修改头像

                            -
                            -
                              -
                            • - 登录名称: -

                              [[${user.loginName}]]

                              -
                            • -
                            • - 手机号码: -

                              [[${user.phonenumber}]]

                              -
                            • -
                            • - 所属部门: -

                              [[${user.dept?.deptName}]] / [[${#strings.defaultString(postGroup,'无岗位')}]]

                              -
                            • -
                            • - 邮箱地址: -

                              [[${user.email}]]

                              -
                            • -
                            • - 创建时间: -

                              [[${#dates.format(user.createTime, 'yyyy-MM-dd')}]]

                              -
                            • -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            基本资料
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - - - - + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            个人资料
                            +
                            +
                            +
                            +

                            +

                            修改头像

                            +
                            +
                              +
                            • + 登录名称: +

                              [[${user.loginName}]]

                              +
                            • +
                            • + 手机号码: +

                              [[${user.phonenumber}]]

                              +
                            • +
                            • + 所属部门: +

                              [[${user.dept?.deptName}]] / [[${#strings.defaultString(postGroup,'无岗位')}]]

                              +
                            • +
                            • + 邮箱地址: +

                              [[${user.email}]]

                              +
                            • +
                            • + 创建时间: +

                              [[${#dates.format(user.createTime, 'yyyy-MM-dd')}]]

                              +
                            • +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            基本资料
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/user/profile/resetPwd.html b/bmw-admin/src/main/resources/templates/system/user/profile/resetPwd.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/user/profile/resetPwd.html rename to bmw-admin/src/main/resources/templates/system/user/profile/resetPwd.html index e6a87b68d..63ccfb16b 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/profile/resetPwd.html +++ b/bmw-admin/src/main/resources/templates/system/user/profile/resetPwd.html @@ -1,92 +1,92 @@ - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - 请再次输入您的密码 -
                            -
                            -
                            -
                            - - - - - - + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + 请再次输入您的密码 +
                            +
                            +
                            +
                            + + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/user/resetPwd.html b/bmw-admin/src/main/resources/templates/system/user/resetPwd.html similarity index 96% rename from ruoyi-admin/src/main/resources/templates/system/user/resetPwd.html rename to bmw-admin/src/main/resources/templates/system/user/resetPwd.html index e20dc85b0..0d8bc6282 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/resetPwd.html +++ b/bmw-admin/src/main/resources/templates/system/user/resetPwd.html @@ -1,45 +1,45 @@ - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - - + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + + diff --git a/ruoyi-admin/src/main/resources/templates/system/user/user.html b/bmw-admin/src/main/resources/templates/system/user/user.html similarity index 97% rename from ruoyi-admin/src/main/resources/templates/system/user/user.html rename to bmw-admin/src/main/resources/templates/system/user/user.html index ccd2df756..b89106eab 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/user.html +++ b/bmw-admin/src/main/resources/templates/system/user/user.html @@ -1,263 +1,263 @@ - - - - - - - - -
                            -
                            -
                            -
                            -
                            - 组织机构 -
                            -
                            - - - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            -
                            - - -
                            -
                              -
                            • - 登录名称: -
                            • -
                            • - 手机号码: -
                            • -
                            • - 用户状态: -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            -
                            - - - - - - - - + + + + + + + + +
                            +
                            +
                            +
                            +
                            + 组织机构 +
                            +
                            + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            +
                            + + +
                            +
                              +
                            • + 登录名称: +
                            • +
                            • + 手机号码: +
                            • +
                            • + 用户状态: +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            +
                            + + + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/tool/build/build.html b/bmw-admin/src/main/resources/templates/tool/build/build.html similarity index 98% rename from ruoyi-admin/src/main/resources/templates/tool/build/build.html rename to bmw-admin/src/main/resources/templates/tool/build/build.html index 435fe9ff6..74487b928 100644 --- a/ruoyi-admin/src/main/resources/templates/tool/build/build.html +++ b/bmw-admin/src/main/resources/templates/tool/build/build.html @@ -1,175 +1,175 @@ - - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                            元素
                            -
                            - - - - - - - - - - -
                            -
                            -
                            -
                            - 拖拽左侧的表单元素到右侧区域,即可生成相应的HTML代码,表单代码,轻松搞定! -
                            -
                            -
                            - -
                            - -
                            -
                            - -
                            - -
                            - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - - -
                            -

                            这里是纯文字信息

                            -
                            -
                            -
                            - - -
                            - - -
                            -
                            -
                            - - -
                            - - - -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            - - -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            -
                            拖拽左侧表单元素到此区域
                            -
                            - 请选择显示的列数: - -
                            -
                            - -
                            -
                            -
                            -
                            - - -
                            - -
                            -
                            -
                            -
                            -
                            - - - - - - - + + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                            元素
                            +
                            + + + + + + + + + + +
                            +
                            +
                            +
                            + 拖拽左侧的表单元素到右侧区域,即可生成相应的HTML代码,表单代码,轻松搞定! +
                            +
                            +
                            + +
                            + +
                            +
                            + +
                            + +
                            + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + + +
                            +

                            这里是纯文字信息

                            +
                            +
                            +
                            + + +
                            + + +
                            +
                            +
                            + + +
                            + + + +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            + + +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            拖拽左侧表单元素到此区域
                            +
                            + 请选择显示的列数: + +
                            +
                            + +
                            +
                            +
                            +
                            + + +
                            + +
                            +
                            +
                            +
                            +
                            + + + + + + + diff --git a/ruoyi-common/pom.xml b/bmw-common/pom.xml similarity index 96% rename from ruoyi-common/pom.xml rename to bmw-common/pom.xml index 64b65161d..a9a6886e6 100644 --- a/ruoyi-common/pom.xml +++ b/bmw-common/pom.xml @@ -1,100 +1,100 @@ - - - - ruoyi - com.ruoyi - 3.4 - - 4.0.0 - - ruoyi-common - - - common通用工具 - - - - - - - org.springframework - spring-context-support - - - - - org.springframework - spring-web - - - - - org.apache.shiro - shiro-core - - - - - com.github.pagehelper - pagehelper-spring-boot-starter - - - - - javax.validation - validation-api - - - - - org.apache.commons - commons-lang3 - - - - - com.fasterxml.jackson.core - jackson-databind - - - - - commons-io - commons-io - - - - - commons-fileupload - commons-fileupload - - - - - org.jsoup - jsoup - - - - - org.apache.poi - poi-ooxml - - - - - org.yaml - snakeyaml - - - - - javax.servlet - javax.servlet-api - - - - + + + + ruoyi + com.ruoyi + 3.4 + + 4.0.0 + + ruoyi-common + + + common通用工具 + + + + + + + org.springframework + spring-context-support + + + + + org.springframework + spring-web + + + + + org.apache.shiro + shiro-core + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + + + javax.validation + validation-api + + + + + org.apache.commons + commons-lang3 + + + + + com.fasterxml.jackson.core + jackson-databind + + + + + commons-io + commons-io + + + + + commons-fileupload + commons-fileupload + + + + + org.jsoup + jsoup + + + + + org.apache.poi + poi-ooxml + + + + + org.yaml + snakeyaml + + + + + javax.servlet + javax.servlet-api + + + + \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java b/bmw-common/src/main/java/com/ruoyi/common/annotation/DataScope.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java rename to bmw-common/src/main/java/com/ruoyi/common/annotation/DataScope.java index fe5a01f55..176878e9d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java +++ b/bmw-common/src/main/java/com/ruoyi/common/annotation/DataScope.java @@ -1,28 +1,28 @@ -package com.ruoyi.common.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 数据权限过滤注解 - * - * @author ruoyi - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface DataScope -{ - /** - * 部门表的别名 - */ - public String deptAlias() default ""; - - /** - * 用户表的别名 - */ - public String userAlias() default ""; -} +package com.ruoyi.common.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 数据权限过滤注解 + * + * @author ruoyi + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DataScope +{ + /** + * 部门表的别名 + */ + public String deptAlias() default ""; + + /** + * 用户表的别名 + */ + public String userAlias() default ""; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java b/bmw-common/src/main/java/com/ruoyi/common/annotation/DataSource.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java rename to bmw-common/src/main/java/com/ruoyi/common/annotation/DataSource.java index 5a41a2c6d..7a36288ec 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java +++ b/bmw-common/src/main/java/com/ruoyi/common/annotation/DataSource.java @@ -1,22 +1,22 @@ -package com.ruoyi.common.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import com.ruoyi.common.enums.DataSourceType; - -/** - * 自定义多数据源切换注解 - * - * @author ruoyi - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface DataSource -{ - /** - * 切换数据源名称 - */ - public DataSourceType value() default DataSourceType.MASTER; -} +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import com.ruoyi.common.enums.DataSourceType; + +/** + * 自定义多数据源切换注解 + * + * @author ruoyi + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface DataSource +{ + /** + * 切换数据源名称 + */ + public DataSourceType value() default DataSourceType.MASTER; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java b/bmw-common/src/main/java/com/ruoyi/common/annotation/Excel.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java rename to bmw-common/src/main/java/com/ruoyi/common/annotation/Excel.java index 610b64550..1590a4c9b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java +++ b/bmw-common/src/main/java/com/ruoyi/common/annotation/Excel.java @@ -1,92 +1,92 @@ -package com.ruoyi.common.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 自定义导出Excel数据注解 - * - * @author ruoyi - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Excel -{ - /** - * 导出到Excel中的名字. - */ - public String name() default ""; - - /** - * 日期格式, 如: yyyy-MM-dd - */ - public String dateFormat() default ""; - - /** - * 读取内容转表达式 (如: 0=男,1=女,2=未知) - */ - public String readConverterExp() default ""; - - /** - * 导出时在excel中每个列的高度 单位为字符 - */ - public double height() default 14; - - /** - * 导出时在excel中每个列的宽 单位为字符 - */ - public double width() default 16; - - /** - * 文字后缀,如% 90 变成90% - */ - public String suffix() default ""; - - /** - * 当值为空时,字段的默认值 - */ - public String defaultValue() default ""; - - /** - * 提示信息 - */ - public String prompt() default ""; - - /** - * 设置只能选择不能输入的列内容. - */ - public String[] combo() default {}; - - /** - * 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写. - */ - public boolean isExport() default true; - - /** - * 另一个类中的属性名称,支持多级获取,以小数点隔开 - */ - public String targetAttr() default ""; - - /** - * 字段类型(0:导出导入;1:仅导出;2:仅导入) - */ - Type type() default Type.ALL; - - public enum Type - { - ALL(0), EXPORT(1), IMPORT(2); - private final int value; - - Type(int value) - { - this.value = value; - } - - public int value() - { - return this.value; - } - } +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 自定义导出Excel数据注解 + * + * @author ruoyi + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Excel +{ + /** + * 导出到Excel中的名字. + */ + public String name() default ""; + + /** + * 日期格式, 如: yyyy-MM-dd + */ + public String dateFormat() default ""; + + /** + * 读取内容转表达式 (如: 0=男,1=女,2=未知) + */ + public String readConverterExp() default ""; + + /** + * 导出时在excel中每个列的高度 单位为字符 + */ + public double height() default 14; + + /** + * 导出时在excel中每个列的宽 单位为字符 + */ + public double width() default 16; + + /** + * 文字后缀,如% 90 变成90% + */ + public String suffix() default ""; + + /** + * 当值为空时,字段的默认值 + */ + public String defaultValue() default ""; + + /** + * 提示信息 + */ + public String prompt() default ""; + + /** + * 设置只能选择不能输入的列内容. + */ + public String[] combo() default {}; + + /** + * 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写. + */ + public boolean isExport() default true; + + /** + * 另一个类中的属性名称,支持多级获取,以小数点隔开 + */ + public String targetAttr() default ""; + + /** + * 字段类型(0:导出导入;1:仅导出;2:仅导入) + */ + Type type() default Type.ALL; + + public enum Type + { + ALL(0), EXPORT(1), IMPORT(2); + private final int value; + + Type(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java b/bmw-common/src/main/java/com/ruoyi/common/annotation/Excels.java similarity index 100% rename from ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java rename to bmw-common/src/main/java/com/ruoyi/common/annotation/Excels.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java b/bmw-common/src/main/java/com/ruoyi/common/annotation/Log.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java rename to bmw-common/src/main/java/com/ruoyi/common/annotation/Log.java index 8982f07be..157ecff6b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java +++ b/bmw-common/src/main/java/com/ruoyi/common/annotation/Log.java @@ -1,40 +1,40 @@ -package com.ruoyi.common.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.enums.OperatorType; - -/** - * 自定义操作日志记录注解 - * - * @author ruoyi - */ -@Target({ ElementType.PARAMETER, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Log -{ - /** - * 模块 - */ - public String title() default ""; - - /** - * 功能 - */ - public BusinessType businessType() default BusinessType.OTHER; - - /** - * 操作人类别 - */ - public OperatorType operatorType() default OperatorType.MANAGE; - - /** - * 是否保存请求的参数 - */ - public boolean isSaveRequestData() default true; -} +package com.ruoyi.common.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.enums.OperatorType; + +/** + * 自定义操作日志记录注解 + * + * @author ruoyi + */ +@Target({ ElementType.PARAMETER, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Log +{ + /** + * 模块 + */ + public String title() default ""; + + /** + * 功能 + */ + public BusinessType businessType() default BusinessType.OTHER; + + /** + * 操作人类别 + */ + public OperatorType operatorType() default OperatorType.MANAGE; + + /** + * 是否保存请求的参数 + */ + public boolean isSaveRequestData() default true; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/Global.java b/bmw-common/src/main/java/com/ruoyi/common/config/Global.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/config/Global.java rename to bmw-common/src/main/java/com/ruoyi/common/config/Global.java index cd1c1d54a..c03908cda 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/Global.java +++ b/bmw-common/src/main/java/com/ruoyi/common/config/Global.java @@ -1,142 +1,142 @@ -package com.ruoyi.common.config; - -import java.io.FileNotFoundException; -import java.util.HashMap; -import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.YamlUtil; - -/** - * 全局配置类 - * - * @author ruoyi - */ -public class Global -{ - private static final Logger log = LoggerFactory.getLogger(Global.class); - - private static String NAME = "application.yml"; - - /** - * 当前对象实例 - */ - private static Global global; - - /** - * 保存全局属性值 - */ - private static Map map = new HashMap(); - - private Global() - { - } - - /** - * 静态工厂方法 - */ - public static synchronized Global getInstance() - { - if (global == null) - { - global = new Global(); - } - return global; - } - - /** - * 获取配置 - */ - public static String getConfig(String key) - { - String value = map.get(key); - if (value == null) - { - Map yamlMap = null; - try - { - yamlMap = YamlUtil.loadYaml(NAME); - value = String.valueOf(YamlUtil.getProperty(yamlMap, key)); - map.put(key, value != null ? value : StringUtils.EMPTY); - } - catch (FileNotFoundException e) - { - log.error("获取全局配置异常 {}", key); - } - } - return value; - } - - /** - * 获取项目名称 - */ - public static String getName() - { - return StringUtils.nvl(getConfig("ruoyi.name"), "RuoYi"); - } - - /** - * 获取项目版本 - */ - public static String getVersion() - { - return StringUtils.nvl(getConfig("ruoyi.version"), "3.4.0"); - } - - /** - * 获取版权年份 - */ - public static String getCopyrightYear() - { - return StringUtils.nvl(getConfig("ruoyi.copyrightYear"), "2019"); - } - - /** - * 实例演示开关 - */ - public static String isDemoEnabled() - { - return StringUtils.nvl(getConfig("ruoyi.demoEnabled"), "true"); - } - - /** - * 获取ip地址开关 - */ - public static Boolean isAddressEnabled() - { - return Boolean.valueOf(getConfig("ruoyi.addressEnabled")); - } - - /** - * 获取文件上传路径 - */ - public static String getProfile() - { - return getConfig("ruoyi.profile"); - } - - /** - * 获取头像上传路径 - */ - public static String getAvatarPath() - { - return getProfile() + "/avatar"; - } - - /** - * 获取下载路径 - */ - public static String getDownloadPath() - { - return getProfile() + "/download"; - } - - /** - * 获取上传路径 - */ - public static String getUploadPath() - { - return getProfile() + "/upload"; - } -} +package com.ruoyi.common.config; + +import java.io.FileNotFoundException; +import java.util.HashMap; +import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.YamlUtil; + +/** + * 全局配置类 + * + * @author ruoyi + */ +public class Global +{ + private static final Logger log = LoggerFactory.getLogger(Global.class); + + private static String NAME = "application.yml"; + + /** + * 当前对象实例 + */ + private static Global global; + + /** + * 保存全局属性值 + */ + private static Map map = new HashMap(); + + private Global() + { + } + + /** + * 静态工厂方法 + */ + public static synchronized Global getInstance() + { + if (global == null) + { + global = new Global(); + } + return global; + } + + /** + * 获取配置 + */ + public static String getConfig(String key) + { + String value = map.get(key); + if (value == null) + { + Map yamlMap = null; + try + { + yamlMap = YamlUtil.loadYaml(NAME); + value = String.valueOf(YamlUtil.getProperty(yamlMap, key)); + map.put(key, value != null ? value : StringUtils.EMPTY); + } + catch (FileNotFoundException e) + { + log.error("获取全局配置异常 {}", key); + } + } + return value; + } + + /** + * 获取项目名称 + */ + public static String getName() + { + return StringUtils.nvl(getConfig("ruoyi.name"), "RuoYi"); + } + + /** + * 获取项目版本 + */ + public static String getVersion() + { + return StringUtils.nvl(getConfig("ruoyi.version"), "3.4.0"); + } + + /** + * 获取版权年份 + */ + public static String getCopyrightYear() + { + return StringUtils.nvl(getConfig("ruoyi.copyrightYear"), "2019"); + } + + /** + * 实例演示开关 + */ + public static String isDemoEnabled() + { + return StringUtils.nvl(getConfig("ruoyi.demoEnabled"), "true"); + } + + /** + * 获取ip地址开关 + */ + public static Boolean isAddressEnabled() + { + return Boolean.valueOf(getConfig("ruoyi.addressEnabled")); + } + + /** + * 获取文件上传路径 + */ + public static String getProfile() + { + return getConfig("ruoyi.profile"); + } + + /** + * 获取头像上传路径 + */ + public static String getAvatarPath() + { + return getProfile() + "/avatar"; + } + + /** + * 获取下载路径 + */ + public static String getDownloadPath() + { + return getProfile() + "/download"; + } + + /** + * 获取上传路径 + */ + public static String getUploadPath() + { + return getProfile() + "/upload"; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/ServerConfig.java b/bmw-common/src/main/java/com/ruoyi/common/config/ServerConfig.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/config/ServerConfig.java rename to bmw-common/src/main/java/com/ruoyi/common/config/ServerConfig.java index ddb873097..b6b35e481 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/ServerConfig.java +++ b/bmw-common/src/main/java/com/ruoyi/common/config/ServerConfig.java @@ -1,33 +1,33 @@ -package com.ruoyi.common.config; - -import javax.servlet.http.HttpServletRequest; -import org.springframework.stereotype.Component; -import com.ruoyi.common.utils.ServletUtils; - -/** - * 服务相关配置 - * - * @author ruoyi - * - */ -@Component -public class ServerConfig -{ - /** - * 获取完整的请求路径,包括:域名,端口,上下文访问路径 - * - * @return 服务地址 - */ - public String getUrl() - { - HttpServletRequest request = ServletUtils.getRequest(); - return getDomain(request); - } - - public static String getDomain(HttpServletRequest request) - { - StringBuffer url = request.getRequestURL(); - String contextPath = request.getServletContext().getContextPath(); - return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString(); - } -} +package com.ruoyi.common.config; + +import javax.servlet.http.HttpServletRequest; +import org.springframework.stereotype.Component; +import com.ruoyi.common.utils.ServletUtils; + +/** + * 服务相关配置 + * + * @author ruoyi + * + */ +@Component +public class ServerConfig +{ + /** + * 获取完整的请求路径,包括:域名,端口,上下文访问路径 + * + * @return 服务地址 + */ + public String getUrl() + { + HttpServletRequest request = ServletUtils.getRequest(); + return getDomain(request); + } + + public static String getDomain(HttpServletRequest request) + { + StringBuffer url = request.getRequestURL(); + String contextPath = request.getServletContext().getContextPath(); + return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString(); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java b/bmw-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java rename to bmw-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java index 6bc9e6178..6937dca75 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java +++ b/bmw-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java @@ -1,45 +1,45 @@ -package com.ruoyi.common.config.datasource; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 数据源切换处理 - * - * @author ruoyi - */ -public class DynamicDataSourceContextHolder -{ - public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class); - - /** - * 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本, - * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。 - */ - private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); - - /** - * 设置数据源的变量 - */ - public static void setDataSourceType(String dsType) - { - log.info("切换到{}数据源", dsType); - CONTEXT_HOLDER.set(dsType); - } - - /** - * 获得数据源的变量 - */ - public static String getDataSourceType() - { - return CONTEXT_HOLDER.get(); - } - - /** - * 清空数据源变量 - */ - public static void clearDataSourceType() - { - CONTEXT_HOLDER.remove(); - } -} +package com.ruoyi.common.config.datasource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 数据源切换处理 + * + * @author ruoyi + */ +public class DynamicDataSourceContextHolder +{ + public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class); + + /** + * 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本, + * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。 + */ + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); + + /** + * 设置数据源的变量 + */ + public static void setDataSourceType(String dsType) + { + log.info("切换到{}数据源", dsType); + CONTEXT_HOLDER.set(dsType); + } + + /** + * 获得数据源的变量 + */ + public static String getDataSourceType() + { + return CONTEXT_HOLDER.get(); + } + + /** + * 清空数据源变量 + */ + public static void clearDataSourceType() + { + CONTEXT_HOLDER.remove(); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java b/bmw-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java similarity index 97% rename from ruoyi-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java rename to bmw-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java index 1ff207552..4c63c9f45 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java +++ b/bmw-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java @@ -1,62 +1,62 @@ -package com.ruoyi.common.config.thread; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadPoolExecutor; -import org.apache.commons.lang3.concurrent.BasicThreadFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import com.ruoyi.common.utils.Threads; - -/** - * 线程池配置 - * - * @author ruoyi - **/ -@Configuration -public class ThreadPoolConfig -{ - // 核心线程池大小 - private int corePoolSize = 50; - - // 最大可创建的线程数 - private int maxPoolSize = 200; - - // 队列最大长度 - private int queueCapacity = 1000; - - // 线程池维护线程所允许的空闲时间 - private int keepAliveSeconds = 300; - - @Bean(name = "threadPoolTaskExecutor") - public ThreadPoolTaskExecutor threadPoolTaskExecutor() - { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setMaxPoolSize(maxPoolSize); - executor.setCorePoolSize(corePoolSize); - executor.setQueueCapacity(queueCapacity); - executor.setKeepAliveSeconds(keepAliveSeconds); - // 线程池对拒绝任务(无线程可用)的处理策略 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); - return executor; - } - - /** - * 执行周期性或定时任务 - */ - @Bean(name = "scheduledExecutorService") - protected ScheduledExecutorService scheduledExecutorService() - { - return new ScheduledThreadPoolExecutor(corePoolSize, - new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) - { - @Override - protected void afterExecute(Runnable r, Throwable t) - { - super.afterExecute(r, t); - Threads.printException(r, t); - } - }; - } -} +package com.ruoyi.common.config.thread; + +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadPoolExecutor; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import com.ruoyi.common.utils.Threads; + +/** + * 线程池配置 + * + * @author ruoyi + **/ +@Configuration +public class ThreadPoolConfig +{ + // 核心线程池大小 + private int corePoolSize = 50; + + // 最大可创建的线程数 + private int maxPoolSize = 200; + + // 队列最大长度 + private int queueCapacity = 1000; + + // 线程池维护线程所允许的空闲时间 + private int keepAliveSeconds = 300; + + @Bean(name = "threadPoolTaskExecutor") + public ThreadPoolTaskExecutor threadPoolTaskExecutor() + { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setMaxPoolSize(maxPoolSize); + executor.setCorePoolSize(corePoolSize); + executor.setQueueCapacity(queueCapacity); + executor.setKeepAliveSeconds(keepAliveSeconds); + // 线程池对拒绝任务(无线程可用)的处理策略 + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + return executor; + } + + /** + * 执行周期性或定时任务 + */ + @Bean(name = "scheduledExecutorService") + protected ScheduledExecutorService scheduledExecutorService() + { + return new ScheduledThreadPoolExecutor(corePoolSize, + new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) + { + @Override + protected void afterExecute(Runnable r, Throwable t) + { + super.afterExecute(r, t); + Threads.printException(r, t); + } + }; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/bmw-common/src/main/java/com/ruoyi/common/constant/Constants.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java rename to bmw-common/src/main/java/com/ruoyi/common/constant/Constants.java index 1a52c1f7f..99ecc5e61 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/bmw-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -1,64 +1,64 @@ -package com.ruoyi.common.constant; - -/** - * 通用常量信息 - * - * @author ruoyi - */ -public class Constants -{ - /** - * UTF-8 字符集 - */ - public static final String UTF8 = "UTF-8"; - - /** - * 通用成功标识 - */ - public static final String SUCCESS = "0"; - - /** - * 通用失败标识 - */ - public static final String FAIL = "1"; - - /** - * 登录成功 - */ - public static final String LOGIN_SUCCESS = "Success"; - - /** - * 注销 - */ - public static final String LOGOUT = "Logout"; - - /** - * 登录失败 - */ - public static final String LOGIN_FAIL = "Error"; - - /** - * 自动去除表前缀 - */ - public static final String AUTO_REOMVE_PRE = "true"; - - /** - * 当前记录起始索引 - */ - public static final String PAGE_NUM = "pageNum"; - - /** - * 每页显示记录数 - */ - public static final String PAGE_SIZE = "pageSize"; - - /** - * 排序列 - */ - public static final String ORDER_BY_COLUMN = "orderByColumn"; - - /** - * 排序的方向 "desc" 或者 "asc". - */ - public static final String IS_ASC = "isAsc"; -} +package com.ruoyi.common.constant; + +/** + * 通用常量信息 + * + * @author ruoyi + */ +public class Constants +{ + /** + * UTF-8 字符集 + */ + public static final String UTF8 = "UTF-8"; + + /** + * 通用成功标识 + */ + public static final String SUCCESS = "0"; + + /** + * 通用失败标识 + */ + public static final String FAIL = "1"; + + /** + * 登录成功 + */ + public static final String LOGIN_SUCCESS = "Success"; + + /** + * 注销 + */ + public static final String LOGOUT = "Logout"; + + /** + * 登录失败 + */ + public static final String LOGIN_FAIL = "Error"; + + /** + * 自动去除表前缀 + */ + public static final String AUTO_REOMVE_PRE = "true"; + + /** + * 当前记录起始索引 + */ + public static final String PAGE_NUM = "pageNum"; + + /** + * 每页显示记录数 + */ + public static final String PAGE_SIZE = "pageSize"; + + /** + * 排序列 + */ + public static final String ORDER_BY_COLUMN = "orderByColumn"; + + /** + * 排序的方向 "desc" 或者 "asc". + */ + public static final String IS_ASC = "isAsc"; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/PermissionConstants.java b/bmw-common/src/main/java/com/ruoyi/common/constant/PermissionConstants.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/constant/PermissionConstants.java rename to bmw-common/src/main/java/com/ruoyi/common/constant/PermissionConstants.java index 7caf18542..896721454 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/PermissionConstants.java +++ b/bmw-common/src/main/java/com/ruoyi/common/constant/PermissionConstants.java @@ -1,27 +1,27 @@ -package com.ruoyi.common.constant; - -/** - * 权限通用常量 - * - * @author ruoyi - */ -public class PermissionConstants -{ - /** 新增权限 */ - public static final String ADD_PERMISSION = "add"; - - /** 修改权限 */ - public static final String EDIT_PERMISSION = "edit"; - - /** 删除权限 */ - public static final String REMOVE_PERMISSION = "remove"; - - /** 导出权限 */ - public static final String EXPORT_PERMISSION = "export"; - - /** 显示权限 */ - public static final String VIEW_PERMISSION = "view"; - - /** 查询权限 */ - public static final String LIST_PERMISSION = "list"; -} +package com.ruoyi.common.constant; + +/** + * 权限通用常量 + * + * @author ruoyi + */ +public class PermissionConstants +{ + /** 新增权限 */ + public static final String ADD_PERMISSION = "add"; + + /** 修改权限 */ + public static final String EDIT_PERMISSION = "edit"; + + /** 删除权限 */ + public static final String REMOVE_PERMISSION = "remove"; + + /** 导出权限 */ + public static final String EXPORT_PERMISSION = "export"; + + /** 显示权限 */ + public static final String VIEW_PERMISSION = "view"; + + /** 查询权限 */ + public static final String LIST_PERMISSION = "list"; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java b/bmw-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java rename to bmw-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java index b82036666..005e17623 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java +++ b/bmw-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java @@ -1,50 +1,50 @@ -package com.ruoyi.common.constant; - -/** - * 任务调度通用常量 - * - * @author ruoyi - */ -public interface ScheduleConstants -{ - public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; - - /** 执行目标key */ - public static final String TASK_PROPERTIES = "TASK_PROPERTIES"; - - /** 默认 */ - public static final String MISFIRE_DEFAULT = "0"; - - /** 立即触发执行 */ - public static final String MISFIRE_IGNORE_MISFIRES = "1"; - - /** 触发一次执行 */ - public static final String MISFIRE_FIRE_AND_PROCEED = "2"; - - /** 不触发立即执行 */ - public static final String MISFIRE_DO_NOTHING = "3"; - - public enum Status - { - /** - * 正常 - */ - NORMAL("0"), - /** - * 暂停 - */ - PAUSE("1"); - - private String value; - - private Status(String value) - { - this.value = value; - } - - public String getValue() - { - return value; - } - } -} +package com.ruoyi.common.constant; + +/** + * 任务调度通用常量 + * + * @author ruoyi + */ +public interface ScheduleConstants +{ + public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; + + /** 执行目标key */ + public static final String TASK_PROPERTIES = "TASK_PROPERTIES"; + + /** 默认 */ + public static final String MISFIRE_DEFAULT = "0"; + + /** 立即触发执行 */ + public static final String MISFIRE_IGNORE_MISFIRES = "1"; + + /** 触发一次执行 */ + public static final String MISFIRE_FIRE_AND_PROCEED = "2"; + + /** 不触发立即执行 */ + public static final String MISFIRE_DO_NOTHING = "3"; + + public enum Status + { + /** + * 正常 + */ + NORMAL("0"), + /** + * 暂停 + */ + PAUSE("1"); + + private String value; + + private Status(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java b/bmw-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java rename to bmw-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java index c5027c240..6a026e6b8 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java +++ b/bmw-common/src/main/java/com/ruoyi/common/constant/ShiroConstants.java @@ -1,74 +1,74 @@ -package com.ruoyi.common.constant; - -/** - * Shiro通用常量 - * - * @author ruoyi - */ -public interface ShiroConstants -{ - /** - * 当前登录的用户 - */ - public static final String CURRENT_USER = "currentUser"; - - /** - * 用户名 - */ - public static final String CURRENT_USERNAME = "username"; - - /** - * 消息key - */ - public static String MESSAGE = "message"; - - /** - * 错误key - */ - public static String ERROR = "errorMsg"; - - /** - * 编码格式 - */ - public static String ENCODING = "UTF-8"; - - /** - * 当前在线会话 - */ - public String ONLINE_SESSION = "online_session"; - - /** - * 验证码key - */ - public static final String CURRENT_CAPTCHA = "captcha"; - - /** - * 验证码开关 - */ - public static final String CURRENT_ENABLED = "captchaEnabled"; - - /** - * 验证码类型 - */ - public static final String CURRENT_TYPE = "captchaType"; - - /** - * 验证码 - */ - public static final String CURRENT_VALIDATECODE = "validateCode"; - - /** - * 验证码错误 - */ - public static final String CAPTCHA_ERROR = "captchaError"; - - /** - * 登录记录缓存 - */ - public static final String LOGINRECORDCACHE = "loginRecordCache"; - - /** - * 系统活跃用户缓存 - */ - public static final String SYS_USERCACHE = "sys-userCache"; -} +package com.ruoyi.common.constant; + +/** + * Shiro通用常量 + * + * @author ruoyi + */ +public interface ShiroConstants +{ + /** + * 当前登录的用户 + */ + public static final String CURRENT_USER = "currentUser"; + + /** + * 用户名 + */ + public static final String CURRENT_USERNAME = "username"; + + /** + * 消息key + */ + public static String MESSAGE = "message"; + + /** + * 错误key + */ + public static String ERROR = "errorMsg"; + + /** + * 编码格式 + */ + public static String ENCODING = "UTF-8"; + + /** + * 当前在线会话 + */ + public String ONLINE_SESSION = "online_session"; + + /** + * 验证码key + */ + public static final String CURRENT_CAPTCHA = "captcha"; + + /** + * 验证码开关 + */ + public static final String CURRENT_ENABLED = "captchaEnabled"; + + /** + * 验证码类型 + */ + public static final String CURRENT_TYPE = "captchaType"; + + /** + * 验证码 + */ + public static final String CURRENT_VALIDATECODE = "validateCode"; + + /** + * 验证码错误 + */ + public static final String CAPTCHA_ERROR = "captchaError"; + + /** + * 登录记录缓存 + */ + public static final String LOGINRECORDCACHE = "loginRecordCache"; + + /** + * 系统活跃用户缓存 + */ + public static final String SYS_USERCACHE = "sys-userCache"; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java b/bmw-common/src/main/java/com/ruoyi/common/constant/UserConstants.java similarity index 97% rename from ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java rename to bmw-common/src/main/java/com/ruoyi/common/constant/UserConstants.java index a51ba3bfd..85164caf0 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java +++ b/bmw-common/src/main/java/com/ruoyi/common/constant/UserConstants.java @@ -1,101 +1,101 @@ -package com.ruoyi.common.constant; - -/** - * 用户常量信息 - * - * @author ruoyi - */ -public class UserConstants -{ - /** - * 平台内系统用户的唯一标志 - */ - public static final String SYS_USER = "SYS_USER"; - - /** 正常状态 */ - public static final String NORMAL = "0"; - - /** 异常状态 */ - public static final String EXCEPTION = "1"; - - /** 用户封禁状态 */ - public static final String USER_BLOCKED = "1"; - - /** 角色封禁状态 */ - public static final String ROLE_BLOCKED = "1"; - - /** 部门正常状态 */ - public static final String DEPT_NORMAL = "0"; - - /** 字典正常状态 */ - public static final String DICT_NORMAL = "0"; - - /** 是否为系统默认(是) */ - public static final String YES = "Y"; - - /** - * 用户名长度限制 - */ - public static final int USERNAME_MIN_LENGTH = 2; - public static final int USERNAME_MAX_LENGTH = 20; - - /** 登录名称是否唯一的返回结果码 */ - public final static String USER_NAME_UNIQUE = "0"; - public final static String USER_NAME_NOT_UNIQUE = "1"; - - /** 手机号码是否唯一的返回结果 */ - public final static String USER_PHONE_UNIQUE = "0"; - public final static String USER_PHONE_NOT_UNIQUE = "1"; - - /** e-mail 是否唯一的返回结果 */ - public final static String USER_EMAIL_UNIQUE = "0"; - public final static String USER_EMAIL_NOT_UNIQUE = "1"; - - /** 部门名称是否唯一的返回结果码 */ - public final static String DEPT_NAME_UNIQUE = "0"; - public final static String DEPT_NAME_NOT_UNIQUE = "1"; - - /** 角色名称是否唯一的返回结果码 */ - public final static String ROLE_NAME_UNIQUE = "0"; - public final static String ROLE_NAME_NOT_UNIQUE = "1"; - - /** 岗位名称是否唯一的返回结果码 */ - public final static String POST_NAME_UNIQUE = "0"; - public final static String POST_NAME_NOT_UNIQUE = "1"; - - /** 角色权限是否唯一的返回结果码 */ - public final static String ROLE_KEY_UNIQUE = "0"; - public final static String ROLE_KEY_NOT_UNIQUE = "1"; - - /** 岗位编码是否唯一的返回结果码 */ - public final static String POST_CODE_UNIQUE = "0"; - public final static String POST_CODE_NOT_UNIQUE = "1"; - - /** 菜单名称是否唯一的返回结果码 */ - public final static String MENU_NAME_UNIQUE = "0"; - public final static String MENU_NAME_NOT_UNIQUE = "1"; - - /** 字典类型是否唯一的返回结果码 */ - public final static String DICT_TYPE_UNIQUE = "0"; - public final static String DICT_TYPE_NOT_UNIQUE = "1"; - - /** 参数键名是否唯一的返回结果码 */ - public final static String CONFIG_KEY_UNIQUE = "0"; - public final static String CONFIG_KEY_NOT_UNIQUE = "1"; - - /** - * 密码长度限制 - */ - public static final int PASSWORD_MIN_LENGTH = 5; - public static final int PASSWORD_MAX_LENGTH = 20; - - /** - * 手机号码格式限制 - */ - public static final String MOBILE_PHONE_NUMBER_PATTERN = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$"; - - /** - * 邮箱格式限制 - */ - public static final String EMAIL_PATTERN = "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?"; -} +package com.ruoyi.common.constant; + +/** + * 用户常量信息 + * + * @author ruoyi + */ +public class UserConstants +{ + /** + * 平台内系统用户的唯一标志 + */ + public static final String SYS_USER = "SYS_USER"; + + /** 正常状态 */ + public static final String NORMAL = "0"; + + /** 异常状态 */ + public static final String EXCEPTION = "1"; + + /** 用户封禁状态 */ + public static final String USER_BLOCKED = "1"; + + /** 角色封禁状态 */ + public static final String ROLE_BLOCKED = "1"; + + /** 部门正常状态 */ + public static final String DEPT_NORMAL = "0"; + + /** 字典正常状态 */ + public static final String DICT_NORMAL = "0"; + + /** 是否为系统默认(是) */ + public static final String YES = "Y"; + + /** + * 用户名长度限制 + */ + public static final int USERNAME_MIN_LENGTH = 2; + public static final int USERNAME_MAX_LENGTH = 20; + + /** 登录名称是否唯一的返回结果码 */ + public final static String USER_NAME_UNIQUE = "0"; + public final static String USER_NAME_NOT_UNIQUE = "1"; + + /** 手机号码是否唯一的返回结果 */ + public final static String USER_PHONE_UNIQUE = "0"; + public final static String USER_PHONE_NOT_UNIQUE = "1"; + + /** e-mail 是否唯一的返回结果 */ + public final static String USER_EMAIL_UNIQUE = "0"; + public final static String USER_EMAIL_NOT_UNIQUE = "1"; + + /** 部门名称是否唯一的返回结果码 */ + public final static String DEPT_NAME_UNIQUE = "0"; + public final static String DEPT_NAME_NOT_UNIQUE = "1"; + + /** 角色名称是否唯一的返回结果码 */ + public final static String ROLE_NAME_UNIQUE = "0"; + public final static String ROLE_NAME_NOT_UNIQUE = "1"; + + /** 岗位名称是否唯一的返回结果码 */ + public final static String POST_NAME_UNIQUE = "0"; + public final static String POST_NAME_NOT_UNIQUE = "1"; + + /** 角色权限是否唯一的返回结果码 */ + public final static String ROLE_KEY_UNIQUE = "0"; + public final static String ROLE_KEY_NOT_UNIQUE = "1"; + + /** 岗位编码是否唯一的返回结果码 */ + public final static String POST_CODE_UNIQUE = "0"; + public final static String POST_CODE_NOT_UNIQUE = "1"; + + /** 菜单名称是否唯一的返回结果码 */ + public final static String MENU_NAME_UNIQUE = "0"; + public final static String MENU_NAME_NOT_UNIQUE = "1"; + + /** 字典类型是否唯一的返回结果码 */ + public final static String DICT_TYPE_UNIQUE = "0"; + public final static String DICT_TYPE_NOT_UNIQUE = "1"; + + /** 参数键名是否唯一的返回结果码 */ + public final static String CONFIG_KEY_UNIQUE = "0"; + public final static String CONFIG_KEY_NOT_UNIQUE = "1"; + + /** + * 密码长度限制 + */ + public static final int PASSWORD_MIN_LENGTH = 5; + public static final int PASSWORD_MAX_LENGTH = 20; + + /** + * 手机号码格式限制 + */ + public static final String MOBILE_PHONE_NUMBER_PATTERN = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$"; + + /** + * 邮箱格式限制 + */ + public static final String EMAIL_PATTERN = "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?"; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/bmw-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java rename to bmw-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index 149ac01d1..fbf480e63 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -1,172 +1,172 @@ -package com.ruoyi.common.core.controller; - -import java.beans.PropertyEditorSupport; -import java.util.Date; -import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.AjaxResult.Type; -import com.ruoyi.common.core.page.PageDomain; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.core.page.TableSupport; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.ServletUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.sql.SqlUtil; - -/** - * web层通用数据处理 - * - * @author ruoyi - */ -public class BaseController -{ - protected final Logger logger = LoggerFactory.getLogger(BaseController.class); - - /** - * 将前台传递过来的日期格式的字符串,自动转化为Date类型 - */ - @InitBinder - public void initBinder(WebDataBinder binder) - { - // Date 类型转换 - binder.registerCustomEditor(Date.class, new PropertyEditorSupport() - { - @Override - public void setAsText(String text) - { - setValue(DateUtils.parseDate(text)); - } - }); - } - - /** - * 设置请求分页数据 - */ - protected void startPage() - { - PageDomain pageDomain = TableSupport.buildPageRequest(); - Integer pageNum = pageDomain.getPageNum(); - Integer pageSize = pageDomain.getPageSize(); - if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) - { - String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); - PageHelper.startPage(pageNum, pageSize, orderBy); - } - } - - /** - * 获取request - */ - public HttpServletRequest getRequest() - { - return ServletUtils.getRequest(); - } - - /** - * 获取response - */ - public HttpServletResponse getResponse() - { - return ServletUtils.getResponse(); - } - - /** - * 获取session - */ - public HttpSession getSession() - { - return getRequest().getSession(); - } - - /** - * 响应请求分页数据 - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected TableDataInfo getDataTable(List list) - { - TableDataInfo rspData = new TableDataInfo(); - rspData.setCode(0); - rspData.setRows(list); - rspData.setTotal(new PageInfo(list).getTotal()); - return rspData; - } - - /** - * 响应返回结果 - * - * @param rows 影响行数 - * @return 操作结果 - */ - protected AjaxResult toAjax(int rows) - { - return rows > 0 ? success() : error(); - } - - /** - * 响应返回结果 - * - * @param result 结果 - * @return 操作结果 - */ - protected AjaxResult toAjax(boolean result) - { - return result ? success() : error(); - } - - /** - * 返回成功 - */ - public AjaxResult success() - { - return AjaxResult.success(); - } - - /** - * 返回失败消息 - */ - public AjaxResult error() - { - return AjaxResult.error(); - } - - /** - * 返回成功消息 - */ - public AjaxResult success(String message) - { - return AjaxResult.success(message); - } - - /** - * 返回失败消息 - */ - public AjaxResult error(String message) - { - return AjaxResult.error(message); - } - - /** - * 返回错误码消息 - */ - public AjaxResult error(Type type, String message) - { - return new AjaxResult(type, message); - } - - /** - * 页面跳转 - */ - public String redirect(String url) - { - return StringUtils.format("redirect:{}", url); - } -} +package com.ruoyi.common.core.controller; + +import java.beans.PropertyEditorSupport; +import java.util.Date; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.AjaxResult.Type; +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.page.TableSupport; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.sql.SqlUtil; + +/** + * web层通用数据处理 + * + * @author ruoyi + */ +public class BaseController +{ + protected final Logger logger = LoggerFactory.getLogger(BaseController.class); + + /** + * 将前台传递过来的日期格式的字符串,自动转化为Date类型 + */ + @InitBinder + public void initBinder(WebDataBinder binder) + { + // Date 类型转换 + binder.registerCustomEditor(Date.class, new PropertyEditorSupport() + { + @Override + public void setAsText(String text) + { + setValue(DateUtils.parseDate(text)); + } + }); + } + + /** + * 设置请求分页数据 + */ + protected void startPage() + { + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) + { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + PageHelper.startPage(pageNum, pageSize, orderBy); + } + } + + /** + * 获取request + */ + public HttpServletRequest getRequest() + { + return ServletUtils.getRequest(); + } + + /** + * 获取response + */ + public HttpServletResponse getResponse() + { + return ServletUtils.getResponse(); + } + + /** + * 获取session + */ + public HttpSession getSession() + { + return getRequest().getSession(); + } + + /** + * 响应请求分页数据 + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected TableDataInfo getDataTable(List list) + { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(0); + rspData.setRows(list); + rspData.setTotal(new PageInfo(list).getTotal()); + return rspData; + } + + /** + * 响应返回结果 + * + * @param rows 影响行数 + * @return 操作结果 + */ + protected AjaxResult toAjax(int rows) + { + return rows > 0 ? success() : error(); + } + + /** + * 响应返回结果 + * + * @param result 结果 + * @return 操作结果 + */ + protected AjaxResult toAjax(boolean result) + { + return result ? success() : error(); + } + + /** + * 返回成功 + */ + public AjaxResult success() + { + return AjaxResult.success(); + } + + /** + * 返回失败消息 + */ + public AjaxResult error() + { + return AjaxResult.error(); + } + + /** + * 返回成功消息 + */ + public AjaxResult success(String message) + { + return AjaxResult.success(message); + } + + /** + * 返回失败消息 + */ + public AjaxResult error(String message) + { + return AjaxResult.error(message); + } + + /** + * 返回错误码消息 + */ + public AjaxResult error(Type type, String message) + { + return new AjaxResult(type, message); + } + + /** + * 页面跳转 + */ + public String redirect(String url) + { + return StringUtils.format("redirect:{}", url); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java b/bmw-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java rename to bmw-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java index 5463547aa..4b6c4d276 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java @@ -1,242 +1,242 @@ -package com.ruoyi.common.core.domain; - -import java.util.HashMap; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.utils.StringUtils; - -/** - * 操作消息提醒 - * - * @author ruoyi - */ -public class AjaxResult extends HashMap -{ - private static final long serialVersionUID = 1L; - - public static final String CODE_TAG = "code"; - - public static final String MSG_TAG = "msg"; - - public static final String DATA_TAG = "data"; - - /** - * 状态类型 - */ - public enum Type - { - /** 成功 */ - SUCCESS(0), - /** 警告 */ - WARN(301), - /** 错误 */ - ERROR(500); - private final int value; - - Type(int value) - { - this.value = value; - } - - public int value() - { - return this.value; - } - } - - /** 状态类型 */ - private Type type; - - /** 状态码 */ - private int code; - - /** 返回内容 */ - private String msg; - - /** 数据对象 */ - private Object data; - - /** - * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 - */ - public AjaxResult() - { - } - - /** - * 初始化一个新创建的 AjaxResult 对象 - * - * @param type 状态类型 - * @param msg 返回内容 - */ - public AjaxResult(Type type, String msg) - { - super.put(CODE_TAG, type.value); - super.put(MSG_TAG, msg); - } - - /** - * 初始化一个新创建的 AjaxResult 对象 - * - * @param type 状态类型 - * @param msg 返回内容 - * @param data 数据对象 - */ - public AjaxResult(Type type, String msg, Object data) - { - super.put(CODE_TAG, type.value); - super.put(MSG_TAG, msg); - if (StringUtils.isNotNull(data)) - { - super.put(DATA_TAG, data); - } - } - - /** - * 返回成功消息 - * - * @return 成功消息 - */ - public static AjaxResult success() - { - return AjaxResult.success("操作成功"); - } - - /** - * 返回成功数据 - * - * @return 成功消息 - */ - public static AjaxResult success(Object data) - { - return AjaxResult.success("操作成功", data); - } - - /** - * 返回成功消息 - * - * @param msg 返回内容 - * @return 成功消息 - */ - public static AjaxResult success(String msg) - { - return AjaxResult.success(msg, null); - } - - /** - * 返回成功消息 - * - * @param msg 返回内容 - * @param data 数据对象 - * @return 成功消息 - */ - public static AjaxResult success(String msg, Object data) - { - return new AjaxResult(Type.SUCCESS, msg, data); - } - - /** - * 返回警告消息 - * - * @param msg 返回内容 - * @return 警告消息 - */ - public static AjaxResult warn(String msg) - { - return AjaxResult.warn(msg, null); - } - - /** - * 返回警告消息 - * - * @param msg 返回内容 - * @param data 数据对象 - * @return 警告消息 - */ - public static AjaxResult warn(String msg, Object data) - { - return new AjaxResult(Type.WARN, msg, data); - } - - /** - * 返回错误消息 - * - * @return - */ - public static AjaxResult error() - { - return AjaxResult.error("操作失败"); - } - - /** - * 返回错误消息 - * - * @param msg 返回内容 - * @return 警告消息 - */ - public static AjaxResult error(String msg) - { - return AjaxResult.error(msg, null); - } - - /** - * 返回错误消息 - * - * @param msg 返回内容 - * @param data 数据对象 - * @return 警告消息 - */ - public static AjaxResult error(String msg, Object data) - { - return new AjaxResult(Type.ERROR, msg, data); - } - - public Type getType() - { - return type; - } - - public void setType(Type type) - { - this.type = type; - } - - public int getCode() - { - return code; - } - - public void setCode(int code) - { - this.code = code; - } - - public String getMsg() - { - return msg; - } - - public void setMsg(String msg) - { - this.msg = msg; - } - - public Object getData() - { - return data; - } - - public void setData(Object data) - { - this.data = data; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("code", getCode()) - .append("msg", getMsg()) - .append("data", getData()) - .toString(); - } -} +package com.ruoyi.common.core.domain; + +import java.util.HashMap; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.utils.StringUtils; + +/** + * 操作消息提醒 + * + * @author ruoyi + */ +public class AjaxResult extends HashMap +{ + private static final long serialVersionUID = 1L; + + public static final String CODE_TAG = "code"; + + public static final String MSG_TAG = "msg"; + + public static final String DATA_TAG = "data"; + + /** + * 状态类型 + */ + public enum Type + { + /** 成功 */ + SUCCESS(0), + /** 警告 */ + WARN(301), + /** 错误 */ + ERROR(500); + private final int value; + + Type(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } + + /** 状态类型 */ + private Type type; + + /** 状态码 */ + private int code; + + /** 返回内容 */ + private String msg; + + /** 数据对象 */ + private Object data; + + /** + * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 + */ + public AjaxResult() + { + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param type 状态类型 + * @param msg 返回内容 + */ + public AjaxResult(Type type, String msg) + { + super.put(CODE_TAG, type.value); + super.put(MSG_TAG, msg); + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param type 状态类型 + * @param msg 返回内容 + * @param data 数据对象 + */ + public AjaxResult(Type type, String msg, Object data) + { + super.put(CODE_TAG, type.value); + super.put(MSG_TAG, msg); + if (StringUtils.isNotNull(data)) + { + super.put(DATA_TAG, data); + } + } + + /** + * 返回成功消息 + * + * @return 成功消息 + */ + public static AjaxResult success() + { + return AjaxResult.success("操作成功"); + } + + /** + * 返回成功数据 + * + * @return 成功消息 + */ + public static AjaxResult success(Object data) + { + return AjaxResult.success("操作成功", data); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @return 成功消息 + */ + public static AjaxResult success(String msg) + { + return AjaxResult.success(msg, null); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 成功消息 + */ + public static AjaxResult success(String msg, Object data) + { + return new AjaxResult(Type.SUCCESS, msg, data); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult warn(String msg) + { + return AjaxResult.warn(msg, null); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult warn(String msg, Object data) + { + return new AjaxResult(Type.WARN, msg, data); + } + + /** + * 返回错误消息 + * + * @return + */ + public static AjaxResult error() + { + return AjaxResult.error("操作失败"); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult error(String msg) + { + return AjaxResult.error(msg, null); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult error(String msg, Object data) + { + return new AjaxResult(Type.ERROR, msg, data); + } + + public Type getType() + { + return type; + } + + public void setType(Type type) + { + this.type = type; + } + + public int getCode() + { + return code; + } + + public void setCode(int code) + { + this.code = code; + } + + public String getMsg() + { + return msg; + } + + public void setMsg(String msg) + { + this.msg = msg; + } + + public Object getData() + { + return data; + } + + public void setData(Object data) + { + this.data = data; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("code", getCode()) + .append("msg", getMsg()) + .append("data", getData()) + .toString(); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java b/bmw-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java rename to bmw-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java index 0fc68beb5..f7d5bf46d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java @@ -1,114 +1,114 @@ -package com.ruoyi.common.core.domain; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonFormat; - -/** - * Entity基类 - * - * @author ruoyi - */ -public class BaseEntity implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** 搜索值 */ - private String searchValue; - - /** 创建者 */ - private String createBy; - - /** 创建时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date createTime; - - /** 更新者 */ - private String updateBy; - - /** 更新时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date updateTime; - - /** 备注 */ - private String remark; - - /** 请求参数 */ - private Map params; - - public String getSearchValue() - { - return searchValue; - } - - public void setSearchValue(String searchValue) - { - this.searchValue = searchValue; - } - - public String getCreateBy() - { - return createBy; - } - - public void setCreateBy(String createBy) - { - this.createBy = createBy; - } - - public Date getCreateTime() - { - return createTime; - } - - public void setCreateTime(Date createTime) - { - this.createTime = createTime; - } - - public String getUpdateBy() - { - return updateBy; - } - - public void setUpdateBy(String updateBy) - { - this.updateBy = updateBy; - } - - public Date getUpdateTime() - { - return updateTime; - } - - public void setUpdateTime(Date updateTime) - { - this.updateTime = updateTime; - } - - public String getRemark() - { - return remark; - } - - public void setRemark(String remark) - { - this.remark = remark; - } - - public Map getParams() - { - if (params == null) - { - params = new HashMap<>(); - } - return params; - } - - public void setParams(Map params) - { - this.params = params; - } -} +package com.ruoyi.common.core.domain; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * Entity基类 + * + * @author ruoyi + */ +public class BaseEntity implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 搜索值 */ + private String searchValue; + + /** 创建者 */ + private String createBy; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 更新者 */ + private String updateBy; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** 备注 */ + private String remark; + + /** 请求参数 */ + private Map params; + + public String getSearchValue() + { + return searchValue; + } + + public void setSearchValue(String searchValue) + { + this.searchValue = searchValue; + } + + public String getCreateBy() + { + return createBy; + } + + public void setCreateBy(String createBy) + { + this.createBy = createBy; + } + + public Date getCreateTime() + { + return createTime; + } + + public void setCreateTime(Date createTime) + { + this.createTime = createTime; + } + + public String getUpdateBy() + { + return updateBy; + } + + public void setUpdateBy(String updateBy) + { + this.updateBy = updateBy; + } + + public Date getUpdateTime() + { + return updateTime; + } + + public void setUpdateTime(Date updateTime) + { + this.updateTime = updateTime; + } + + public String getRemark() + { + return remark; + } + + public void setRemark(String remark) + { + this.remark = remark; + } + + public Map getParams() + { + if (params == null) + { + params = new HashMap<>(); + } + return params; + } + + public void setParams(Map params) + { + this.params = params; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Ztree.java b/bmw-common/src/main/java/com/ruoyi/common/core/domain/Ztree.java similarity index 93% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Ztree.java rename to bmw-common/src/main/java/com/ruoyi/common/core/domain/Ztree.java index e7fe780e4..5567a4dde 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/Ztree.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/domain/Ztree.java @@ -1,104 +1,104 @@ -package com.ruoyi.common.core.domain; - -import java.io.Serializable; - -/** - * Ztree树结构实体类 - * - * @author ruoyi - */ -public class Ztree implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** 节点ID */ - private Long id; - - /** 节点父ID */ - private Long pId; - - /** 节点名称 */ - private String name; - - /** 节点标题 */ - private String title; - - /** 是否勾选 */ - private boolean checked = false; - - /** 是否展开 */ - private boolean open = false; - - /** 是否能勾选 */ - private boolean nocheck = false; - - public Long getId() - { - return id; - } - - public void setId(Long id) - { - this.id = id; - } - - public Long getpId() - { - return pId; - } - - public void setpId(Long pId) - { - this.pId = pId; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public boolean isChecked() - { - return checked; - } - - public void setChecked(boolean checked) - { - this.checked = checked; - } - - public boolean isOpen() - { - return open; - } - - public void setOpen(boolean open) - { - this.open = open; - } - - public boolean isNocheck() - { - return nocheck; - } - - public void setNocheck(boolean nocheck) - { - this.nocheck = nocheck; - } -} +package com.ruoyi.common.core.domain; + +import java.io.Serializable; + +/** + * Ztree树结构实体类 + * + * @author ruoyi + */ +public class Ztree implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 节点ID */ + private Long id; + + /** 节点父ID */ + private Long pId; + + /** 节点名称 */ + private String name; + + /** 节点标题 */ + private String title; + + /** 是否勾选 */ + private boolean checked = false; + + /** 是否展开 */ + private boolean open = false; + + /** 是否能勾选 */ + private boolean nocheck = false; + + public Long getId() + { + return id; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getpId() + { + return pId; + } + + public void setpId(Long pId) + { + this.pId = pId; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public boolean isChecked() + { + return checked; + } + + public void setChecked(boolean checked) + { + this.checked = checked; + } + + public boolean isOpen() + { + return open; + } + + public void setOpen(boolean open) + { + this.open = open; + } + + public boolean isNocheck() + { + return nocheck; + } + + public void setNocheck(boolean nocheck) + { + this.nocheck = nocheck; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java b/bmw-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java rename to bmw-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java index 7fccaf46e..4355c3eb0 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java @@ -1,69 +1,69 @@ -package com.ruoyi.common.core.page; - -import com.ruoyi.common.utils.StringUtils; - -/** - * 分页数据 - * - * @author ruoyi - */ -public class PageDomain -{ - /** 当前记录起始索引 */ - private Integer pageNum; - /** 每页显示记录数 */ - private Integer pageSize; - /** 排序列 */ - private String orderByColumn; - /** 排序的方向 "desc" 或者 "asc". */ - private String isAsc; - - public String getOrderBy() - { - if (StringUtils.isEmpty(orderByColumn)) - { - return ""; - } - return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; - } - - public Integer getPageNum() - { - return pageNum; - } - - public void setPageNum(Integer pageNum) - { - this.pageNum = pageNum; - } - - public Integer getPageSize() - { - return pageSize; - } - - public void setPageSize(Integer pageSize) - { - this.pageSize = pageSize; - } - - public String getOrderByColumn() - { - return orderByColumn; - } - - public void setOrderByColumn(String orderByColumn) - { - this.orderByColumn = orderByColumn; - } - - public String getIsAsc() - { - return isAsc; - } - - public void setIsAsc(String isAsc) - { - this.isAsc = isAsc; - } -} +package com.ruoyi.common.core.page; + +import com.ruoyi.common.utils.StringUtils; + +/** + * 分页数据 + * + * @author ruoyi + */ +public class PageDomain +{ + /** 当前记录起始索引 */ + private Integer pageNum; + /** 每页显示记录数 */ + private Integer pageSize; + /** 排序列 */ + private String orderByColumn; + /** 排序的方向 "desc" 或者 "asc". */ + private String isAsc; + + public String getOrderBy() + { + if (StringUtils.isEmpty(orderByColumn)) + { + return ""; + } + return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; + } + + public Integer getPageNum() + { + return pageNum; + } + + public void setPageNum(Integer pageNum) + { + this.pageNum = pageNum; + } + + public Integer getPageSize() + { + return pageSize; + } + + public void setPageSize(Integer pageSize) + { + this.pageSize = pageSize; + } + + public String getOrderByColumn() + { + return orderByColumn; + } + + public void setOrderByColumn(String orderByColumn) + { + this.orderByColumn = orderByColumn; + } + + public String getIsAsc() + { + return isAsc; + } + + public void setIsAsc(String isAsc) + { + this.isAsc = isAsc; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java b/bmw-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java rename to bmw-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java index 10f3b4d4f..2fadf70ea 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java @@ -1,69 +1,69 @@ -package com.ruoyi.common.core.page; - -import java.io.Serializable; -import java.util.List; - -/** - * 表格分页数据对象 - * - * @author ruoyi - */ -public class TableDataInfo implements Serializable -{ - private static final long serialVersionUID = 1L; - /** 总记录数 */ - private long total; - /** 列表数据 */ - private List rows; - /** 消息状态码 */ - private int code; - - /** - * 表格数据对象 - */ - public TableDataInfo() - { - } - - /** - * 分页 - * - * @param list 列表数据 - * @param total 总记录数 - */ - public TableDataInfo(List list, int total) - { - this.rows = list; - this.total = total; - } - - public long getTotal() - { - return total; - } - - public void setTotal(long total) - { - this.total = total; - } - - public List getRows() - { - return rows; - } - - public void setRows(List rows) - { - this.rows = rows; - } - - public int getCode() - { - return code; - } - - public void setCode(int code) - { - this.code = code; - } -} +package com.ruoyi.common.core.page; + +import java.io.Serializable; +import java.util.List; + +/** + * 表格分页数据对象 + * + * @author ruoyi + */ +public class TableDataInfo implements Serializable +{ + private static final long serialVersionUID = 1L; + /** 总记录数 */ + private long total; + /** 列表数据 */ + private List rows; + /** 消息状态码 */ + private int code; + + /** + * 表格数据对象 + */ + public TableDataInfo() + { + } + + /** + * 分页 + * + * @param list 列表数据 + * @param total 总记录数 + */ + public TableDataInfo(List list, int total) + { + this.rows = list; + this.total = total; + } + + public long getTotal() + { + return total; + } + + public void setTotal(long total) + { + this.total = total; + } + + public List getRows() + { + return rows; + } + + public void setRows(List rows) + { + this.rows = rows; + } + + public int getCode() + { + return code; + } + + public void setCode(int code) + { + this.code = code; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java b/bmw-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java rename to bmw-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java index 0efd82b32..8eab41342 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java @@ -1,30 +1,30 @@ -package com.ruoyi.common.core.page; - -import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.utils.ServletUtils; - -/** - * 表格数据处理 - * - * @author ruoyi - */ -public class TableSupport -{ - /** - * 封装分页对象 - */ - public static PageDomain getPageDomain() - { - PageDomain pageDomain = new PageDomain(); - pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM)); - pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE)); - pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN)); - pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC)); - return pageDomain; - } - - public static PageDomain buildPageRequest() - { - return getPageDomain(); - } -} +package com.ruoyi.common.core.page; + +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.ServletUtils; + +/** + * 表格数据处理 + * + * @author ruoyi + */ +public class TableSupport +{ + /** + * 封装分页对象 + */ + public static PageDomain getPageDomain() + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM)); + pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE)); + pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN)); + pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC)); + return pageDomain; + } + + public static PageDomain buildPageRequest() + { + return getPageDomain(); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java b/bmw-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java rename to bmw-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java index 8297661af..77b1a79dd 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java @@ -1,86 +1,86 @@ -package com.ruoyi.common.core.text; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import com.ruoyi.common.utils.StringUtils; - -/** - * 字符集工具类 - * - * @author ruoyi - */ -public class CharsetKit -{ - /** ISO-8859-1 */ - public static final String ISO_8859_1 = "ISO-8859-1"; - /** UTF-8 */ - public static final String UTF_8 = "UTF-8"; - /** GBK */ - public static final String GBK = "GBK"; - - /** ISO-8859-1 */ - public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); - /** UTF-8 */ - public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); - /** GBK */ - public static final Charset CHARSET_GBK = Charset.forName(GBK); - - /** - * 转换为Charset对象 - * - * @param charset 字符集,为空则返回默认字符集 - * @return Charset - */ - public static Charset charset(String charset) - { - return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); - } - - /** - * 转换字符串的字符集编码 - * - * @param source 字符串 - * @param srcCharset 源字符集,默认ISO-8859-1 - * @param destCharset 目标字符集,默认UTF-8 - * @return 转换后的字符集 - */ - public static String convert(String source, String srcCharset, String destCharset) - { - return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); - } - - /** - * 转换字符串的字符集编码 - * - * @param source 字符串 - * @param srcCharset 源字符集,默认ISO-8859-1 - * @param destCharset 目标字符集,默认UTF-8 - * @return 转换后的字符集 - */ - public static String convert(String source, Charset srcCharset, Charset destCharset) - { - if (null == srcCharset) - { - srcCharset = StandardCharsets.ISO_8859_1; - } - - if (null == destCharset) - { - srcCharset = StandardCharsets.UTF_8; - } - - if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) - { - return source; - } - return new String(source.getBytes(srcCharset), destCharset); - } - - /** - * @return 系统字符集编码 - */ - public static String systemCharset() - { - return Charset.defaultCharset().name(); - } -} +package com.ruoyi.common.core.text; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import com.ruoyi.common.utils.StringUtils; + +/** + * 字符集工具类 + * + * @author ruoyi + */ +public class CharsetKit +{ + /** ISO-8859-1 */ + public static final String ISO_8859_1 = "ISO-8859-1"; + /** UTF-8 */ + public static final String UTF_8 = "UTF-8"; + /** GBK */ + public static final String GBK = "GBK"; + + /** ISO-8859-1 */ + public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1); + /** UTF-8 */ + public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8); + /** GBK */ + public static final Charset CHARSET_GBK = Charset.forName(GBK); + + /** + * 转换为Charset对象 + * + * @param charset 字符集,为空则返回默认字符集 + * @return Charset + */ + public static Charset charset(String charset) + { + return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); + } + + /** + * 转换字符串的字符集编码 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 + * @param destCharset 目标字符集,默认UTF-8 + * @return 转换后的字符集 + */ + public static String convert(String source, String srcCharset, String destCharset) + { + return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); + } + + /** + * 转换字符串的字符集编码 + * + * @param source 字符串 + * @param srcCharset 源字符集,默认ISO-8859-1 + * @param destCharset 目标字符集,默认UTF-8 + * @return 转换后的字符集 + */ + public static String convert(String source, Charset srcCharset, Charset destCharset) + { + if (null == srcCharset) + { + srcCharset = StandardCharsets.ISO_8859_1; + } + + if (null == destCharset) + { + srcCharset = StandardCharsets.UTF_8; + } + + if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) + { + return source; + } + return new String(source.getBytes(srcCharset), destCharset); + } + + /** + * @return 系统字符集编码 + */ + public static String systemCharset() + { + return Charset.defaultCharset().name(); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java b/bmw-common/src/main/java/com/ruoyi/common/core/text/Convert.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java rename to bmw-common/src/main/java/com/ruoyi/common/core/text/Convert.java index 9dd076d04..b17dfdda6 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/text/Convert.java @@ -1,999 +1,999 @@ -package com.ruoyi.common.core.text; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.nio.ByteBuffer; -import java.nio.charset.Charset; -import java.text.NumberFormat; -import java.util.Set; -import com.ruoyi.common.utils.StringUtils; - -/** - * 类型转换器 - * - * @author ruoyi - */ -public class Convert -{ - /** - * 转换为字符串
                            - * 如果给定的值为null,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static String toStr(Object value, String defaultValue) - { - if (null == value) - { - return defaultValue; - } - if (value instanceof String) - { - return (String) value; - } - return value.toString(); - } - - /** - * 转换为字符串
                            - * 如果给定的值为null,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static String toStr(Object value) - { - return toStr(value, null); - } - - /** - * 转换为字符
                            - * 如果给定的值为null,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Character toChar(Object value, Character defaultValue) - { - if (null == value) - { - return defaultValue; - } - if (value instanceof Character) - { - return (Character) value; - } - - final String valueStr = toStr(value, null); - return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0); - } - - /** - * 转换为字符
                            - * 如果给定的值为null,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Character toChar(Object value) - { - return toChar(value, null); - } - - /** - * 转换为byte
                            - * 如果给定的值为null,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Byte toByte(Object value, Byte defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Byte) - { - return (Byte) value; - } - if (value instanceof Number) - { - return ((Number) value).byteValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Byte.parseByte(valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为byte
                            - * 如果给定的值为null,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Byte toByte(Object value) - { - return toByte(value, null); - } - - /** - * 转换为Short
                            - * 如果给定的值为null,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Short toShort(Object value, Short defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Short) - { - return (Short) value; - } - if (value instanceof Number) - { - return ((Number) value).shortValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Short.parseShort(valueStr.trim()); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为Short
                            - * 如果给定的值为null,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Short toShort(Object value) - { - return toShort(value, null); - } - - /** - * 转换为Number
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Number toNumber(Object value, Number defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Number) - { - return (Number) value; - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return NumberFormat.getInstance().parse(valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为Number
                            - * 如果给定的值为空,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Number toNumber(Object value) - { - return toNumber(value, null); - } - - /** - * 转换为int
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Integer toInt(Object value, Integer defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Integer) - { - return (Integer) value; - } - if (value instanceof Number) - { - return ((Number) value).intValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Integer.parseInt(valueStr.trim()); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为int
                            - * 如果给定的值为null,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Integer toInt(Object value) - { - return toInt(value, null); - } - - /** - * 转换为Integer数组
                            - * - * @param str 被转换的值 - * @return 结果 - */ - public static Integer[] toIntArray(String str) - { - return toIntArray(",", str); - } - - /** - * 转换为Long数组
                            - * - * @param str 被转换的值 - * @return 结果 - */ - public static Long[] toLongArray(String str) - { - return toLongArray(",", str); - } - - /** - * 转换为Integer数组
                            - * - * @param split 分隔符 - * @param split 被转换的值 - * @return 结果 - */ - public static Integer[] toIntArray(String split, String str) - { - if (StringUtils.isEmpty(str)) - { - return new Integer[] {}; - } - String[] arr = str.split(split); - final Integer[] ints = new Integer[arr.length]; - for (int i = 0; i < arr.length; i++) - { - final Integer v = toInt(arr[i], 0); - ints[i] = v; - } - return ints; - } - - /** - * 转换为Long数组
                            - * - * @param split 分隔符 - * @param str 被转换的值 - * @return 结果 - */ - public static Long[] toLongArray(String split, String str) - { - if (StringUtils.isEmpty(str)) - { - return new Long[] {}; - } - String[] arr = str.split(split); - final Long[] longs = new Long[arr.length]; - for (int i = 0; i < arr.length; i++) - { - final Long v = toLong(arr[i], null); - longs[i] = v; - } - return longs; - } - - /** - * 转换为String数组
                            - * - * @param str 被转换的值 - * @return 结果 - */ - public static String[] toStrArray(String str) - { - return toStrArray(",", str); - } - - /** - * 转换为String数组
                            - * - * @param split 分隔符 - * @param split 被转换的值 - * @return 结果 - */ - public static String[] toStrArray(String split, String str) - { - return str.split(split); - } - - /** - * 转换为long
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Long toLong(Object value, Long defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Long) - { - return (Long) value; - } - if (value instanceof Number) - { - return ((Number) value).longValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - // 支持科学计数法 - return new BigDecimal(valueStr.trim()).longValue(); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为long
                            - * 如果给定的值为null,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Long toLong(Object value) - { - return toLong(value, null); - } - - /** - * 转换为double
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Double toDouble(Object value, Double defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Double) - { - return (Double) value; - } - if (value instanceof Number) - { - return ((Number) value).doubleValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - // 支持科学计数法 - return new BigDecimal(valueStr.trim()).doubleValue(); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为double
                            - * 如果给定的值为空,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Double toDouble(Object value) - { - return toDouble(value, null); - } - - /** - * 转换为Float
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Float toFloat(Object value, Float defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Float) - { - return (Float) value; - } - if (value instanceof Number) - { - return ((Number) value).floatValue(); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Float.parseFloat(valueStr.trim()); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为Float
                            - * 如果给定的值为空,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Float toFloat(Object value) - { - return toFloat(value, null); - } - - /** - * 转换为boolean
                            - * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static Boolean toBool(Object value, Boolean defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof Boolean) - { - return (Boolean) value; - } - String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - valueStr = valueStr.trim().toLowerCase(); - switch (valueStr) - { - case "true": - return true; - case "false": - return false; - case "yes": - return true; - case "ok": - return true; - case "no": - return false; - case "1": - return true; - case "0": - return false; - default: - return defaultValue; - } - } - - /** - * 转换为boolean
                            - * 如果给定的值为空,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static Boolean toBool(Object value) - { - return toBool(value, null); - } - - /** - * 转换为Enum对象
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * - * @param clazz Enum的Class - * @param value 值 - * @param defaultValue 默认值 - * @return Enum - */ - public static > E toEnum(Class clazz, Object value, E defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (clazz.isAssignableFrom(value.getClass())) - { - @SuppressWarnings("unchecked") - E myE = (E) value; - return myE; - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return Enum.valueOf(clazz, valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为Enum对象
                            - * 如果给定的值为空,或者转换失败,返回默认值null
                            - * - * @param clazz Enum的Class - * @param value 值 - * @return Enum - */ - public static > E toEnum(Class clazz, Object value) - { - return toEnum(clazz, value, null); - } - - /** - * 转换为BigInteger
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static BigInteger toBigInteger(Object value, BigInteger defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof BigInteger) - { - return (BigInteger) value; - } - if (value instanceof Long) - { - return BigInteger.valueOf((Long) value); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return new BigInteger(valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为BigInteger
                            - * 如果给定的值为空,或者转换失败,返回默认值null
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static BigInteger toBigInteger(Object value) - { - return toBigInteger(value, null); - } - - /** - * 转换为BigDecimal
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @param defaultValue 转换错误时的默认值 - * @return 结果 - */ - public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) - { - if (value == null) - { - return defaultValue; - } - if (value instanceof BigDecimal) - { - return (BigDecimal) value; - } - if (value instanceof Long) - { - return new BigDecimal((Long) value); - } - if (value instanceof Double) - { - return new BigDecimal((Double) value); - } - if (value instanceof Integer) - { - return new BigDecimal((Integer) value); - } - final String valueStr = toStr(value, null); - if (StringUtils.isEmpty(valueStr)) - { - return defaultValue; - } - try - { - return new BigDecimal(valueStr); - } - catch (Exception e) - { - return defaultValue; - } - } - - /** - * 转换为BigDecimal
                            - * 如果给定的值为空,或者转换失败,返回默认值
                            - * 转换失败不会报错 - * - * @param value 被转换的值 - * @return 结果 - */ - public static BigDecimal toBigDecimal(Object value) - { - return toBigDecimal(value, null); - } - - /** - * 将对象转为字符串
                            - * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * - * @param obj 对象 - * @return 字符串 - */ - public static String utf8Str(Object obj) - { - return str(obj, CharsetKit.CHARSET_UTF_8); - } - - /** - * 将对象转为字符串
                            - * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * - * @param obj 对象 - * @param charsetName 字符集 - * @return 字符串 - */ - public static String str(Object obj, String charsetName) - { - return str(obj, Charset.forName(charsetName)); - } - - /** - * 将对象转为字符串
                            - * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 - * - * @param obj 对象 - * @param charset 字符集 - * @return 字符串 - */ - public static String str(Object obj, Charset charset) - { - if (null == obj) - { - return null; - } - - if (obj instanceof String) - { - return (String) obj; - } - else if (obj instanceof byte[] || obj instanceof Byte[]) - { - return str((Byte[]) obj, charset); - } - else if (obj instanceof ByteBuffer) - { - return str((ByteBuffer) obj, charset); - } - return obj.toString(); - } - - /** - * 将byte数组转为字符串 - * - * @param bytes byte数组 - * @param charset 字符集 - * @return 字符串 - */ - public static String str(byte[] bytes, String charset) - { - return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); - } - - /** - * 解码字节码 - * - * @param data 字符串 - * @param charset 字符集,如果此字段为空,则解码的结果取决于平台 - * @return 解码后的字符串 - */ - public static String str(byte[] data, Charset charset) - { - if (data == null) - { - return null; - } - - if (null == charset) - { - return new String(data); - } - return new String(data, charset); - } - - /** - * 将编码的byteBuffer数据转换为字符串 - * - * @param data 数据 - * @param charset 字符集,如果为空使用当前系统字符集 - * @return 字符串 - */ - public static String str(ByteBuffer data, String charset) - { - if (data == null) - { - return null; - } - - return str(data, Charset.forName(charset)); - } - - /** - * 将编码的byteBuffer数据转换为字符串 - * - * @param data 数据 - * @param charset 字符集,如果为空使用当前系统字符集 - * @return 字符串 - */ - public static String str(ByteBuffer data, Charset charset) - { - if (null == charset) - { - charset = Charset.defaultCharset(); - } - return charset.decode(data).toString(); - } - - // ----------------------------------------------------------------------- 全角半角转换 - /** - * 半角转全角 - * - * @param input String. - * @return 全角字符串. - */ - public static String toSBC(String input) - { - return toSBC(input, null); - } - - /** - * 半角转全角 - * - * @param input String - * @param notConvertSet 不替换的字符集合 - * @return 全角字符串. - */ - public static String toSBC(String input, Set notConvertSet) - { - char c[] = input.toCharArray(); - for (int i = 0; i < c.length; i++) - { - if (null != notConvertSet && notConvertSet.contains(c[i])) - { - // 跳过不替换的字符 - continue; - } - - if (c[i] == ' ') - { - c[i] = '\u3000'; - } - else if (c[i] < '\177') - { - c[i] = (char) (c[i] + 65248); - - } - } - return new String(c); - } - - /** - * 全角转半角 - * - * @param input String. - * @return 半角字符串 - */ - public static String toDBC(String input) - { - return toDBC(input, null); - } - - /** - * 替换全角为半角 - * - * @param text 文本 - * @param notConvertSet 不替换的字符集合 - * @return 替换后的字符 - */ - public static String toDBC(String text, Set notConvertSet) - { - char c[] = text.toCharArray(); - for (int i = 0; i < c.length; i++) - { - if (null != notConvertSet && notConvertSet.contains(c[i])) - { - // 跳过不替换的字符 - continue; - } - - if (c[i] == '\u3000') - { - c[i] = ' '; - } - else if (c[i] > '\uFF00' && c[i] < '\uFF5F') - { - c[i] = (char) (c[i] - 65248); - } - } - String returnString = new String(c); - - return returnString; - } - - /** - * 数字金额大写转换 先写个完整的然后将如零拾替换成零 - * - * @param n 数字 - * @return 中文大写数字 - */ - public static String digitUppercase(double n) - { - String[] fraction = { "角", "分" }; - String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; - String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; - - String head = n < 0 ? "负" : ""; - n = Math.abs(n); - - String s = ""; - for (int i = 0; i < fraction.length; i++) - { - s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); - } - if (s.length() < 1) - { - s = "整"; - } - int integerPart = (int) Math.floor(n); - - for (int i = 0; i < unit[0].length && integerPart > 0; i++) - { - String p = ""; - for (int j = 0; j < unit[1].length && n > 0; j++) - { - p = digit[integerPart % 10] + unit[1][j] + p; - integerPart = integerPart / 10; - } - s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s; - } - return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); - } -} +package com.ruoyi.common.core.text; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.text.NumberFormat; +import java.util.Set; +import com.ruoyi.common.utils.StringUtils; + +/** + * 类型转换器 + * + * @author ruoyi + */ +public class Convert +{ + /** + * 转换为字符串
                            + * 如果给定的值为null,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static String toStr(Object value, String defaultValue) + { + if (null == value) + { + return defaultValue; + } + if (value instanceof String) + { + return (String) value; + } + return value.toString(); + } + + /** + * 转换为字符串
                            + * 如果给定的值为null,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static String toStr(Object value) + { + return toStr(value, null); + } + + /** + * 转换为字符
                            + * 如果给定的值为null,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Character toChar(Object value, Character defaultValue) + { + if (null == value) + { + return defaultValue; + } + if (value instanceof Character) + { + return (Character) value; + } + + final String valueStr = toStr(value, null); + return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0); + } + + /** + * 转换为字符
                            + * 如果给定的值为null,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Character toChar(Object value) + { + return toChar(value, null); + } + + /** + * 转换为byte
                            + * 如果给定的值为null,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Byte toByte(Object value, Byte defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Byte) + { + return (Byte) value; + } + if (value instanceof Number) + { + return ((Number) value).byteValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Byte.parseByte(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为byte
                            + * 如果给定的值为null,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Byte toByte(Object value) + { + return toByte(value, null); + } + + /** + * 转换为Short
                            + * 如果给定的值为null,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Short toShort(Object value, Short defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Short) + { + return (Short) value; + } + if (value instanceof Number) + { + return ((Number) value).shortValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Short.parseShort(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Short
                            + * 如果给定的值为null,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Short toShort(Object value) + { + return toShort(value, null); + } + + /** + * 转换为Number
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Number toNumber(Object value, Number defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Number) + { + return (Number) value; + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return NumberFormat.getInstance().parse(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Number
                            + * 如果给定的值为空,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Number toNumber(Object value) + { + return toNumber(value, null); + } + + /** + * 转换为int
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Integer toInt(Object value, Integer defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Integer) + { + return (Integer) value; + } + if (value instanceof Number) + { + return ((Number) value).intValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Integer.parseInt(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为int
                            + * 如果给定的值为null,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Integer toInt(Object value) + { + return toInt(value, null); + } + + /** + * 转换为Integer数组
                            + * + * @param str 被转换的值 + * @return 结果 + */ + public static Integer[] toIntArray(String str) + { + return toIntArray(",", str); + } + + /** + * 转换为Long数组
                            + * + * @param str 被转换的值 + * @return 结果 + */ + public static Long[] toLongArray(String str) + { + return toLongArray(",", str); + } + + /** + * 转换为Integer数组
                            + * + * @param split 分隔符 + * @param split 被转换的值 + * @return 结果 + */ + public static Integer[] toIntArray(String split, String str) + { + if (StringUtils.isEmpty(str)) + { + return new Integer[] {}; + } + String[] arr = str.split(split); + final Integer[] ints = new Integer[arr.length]; + for (int i = 0; i < arr.length; i++) + { + final Integer v = toInt(arr[i], 0); + ints[i] = v; + } + return ints; + } + + /** + * 转换为Long数组
                            + * + * @param split 分隔符 + * @param str 被转换的值 + * @return 结果 + */ + public static Long[] toLongArray(String split, String str) + { + if (StringUtils.isEmpty(str)) + { + return new Long[] {}; + } + String[] arr = str.split(split); + final Long[] longs = new Long[arr.length]; + for (int i = 0; i < arr.length; i++) + { + final Long v = toLong(arr[i], null); + longs[i] = v; + } + return longs; + } + + /** + * 转换为String数组
                            + * + * @param str 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String str) + { + return toStrArray(",", str); + } + + /** + * 转换为String数组
                            + * + * @param split 分隔符 + * @param split 被转换的值 + * @return 结果 + */ + public static String[] toStrArray(String split, String str) + { + return str.split(split); + } + + /** + * 转换为long
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Long toLong(Object value, Long defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Long) + { + return (Long) value; + } + if (value instanceof Number) + { + return ((Number) value).longValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + // 支持科学计数法 + return new BigDecimal(valueStr.trim()).longValue(); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为long
                            + * 如果给定的值为null,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Long toLong(Object value) + { + return toLong(value, null); + } + + /** + * 转换为double
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Double toDouble(Object value, Double defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Double) + { + return (Double) value; + } + if (value instanceof Number) + { + return ((Number) value).doubleValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + // 支持科学计数法 + return new BigDecimal(valueStr.trim()).doubleValue(); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为double
                            + * 如果给定的值为空,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Double toDouble(Object value) + { + return toDouble(value, null); + } + + /** + * 转换为Float
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Float toFloat(Object value, Float defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Float) + { + return (Float) value; + } + if (value instanceof Number) + { + return ((Number) value).floatValue(); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Float.parseFloat(valueStr.trim()); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Float
                            + * 如果给定的值为空,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Float toFloat(Object value) + { + return toFloat(value, null); + } + + /** + * 转换为boolean
                            + * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static Boolean toBool(Object value, Boolean defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof Boolean) + { + return (Boolean) value; + } + String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + valueStr = valueStr.trim().toLowerCase(); + switch (valueStr) + { + case "true": + return true; + case "false": + return false; + case "yes": + return true; + case "ok": + return true; + case "no": + return false; + case "1": + return true; + case "0": + return false; + default: + return defaultValue; + } + } + + /** + * 转换为boolean
                            + * 如果给定的值为空,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static Boolean toBool(Object value) + { + return toBool(value, null); + } + + /** + * 转换为Enum对象
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * + * @param clazz Enum的Class + * @param value 值 + * @param defaultValue 默认值 + * @return Enum + */ + public static > E toEnum(Class clazz, Object value, E defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (clazz.isAssignableFrom(value.getClass())) + { + @SuppressWarnings("unchecked") + E myE = (E) value; + return myE; + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return Enum.valueOf(clazz, valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为Enum对象
                            + * 如果给定的值为空,或者转换失败,返回默认值null
                            + * + * @param clazz Enum的Class + * @param value 值 + * @return Enum + */ + public static > E toEnum(Class clazz, Object value) + { + return toEnum(clazz, value, null); + } + + /** + * 转换为BigInteger
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static BigInteger toBigInteger(Object value, BigInteger defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof BigInteger) + { + return (BigInteger) value; + } + if (value instanceof Long) + { + return BigInteger.valueOf((Long) value); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return new BigInteger(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为BigInteger
                            + * 如果给定的值为空,或者转换失败,返回默认值null
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static BigInteger toBigInteger(Object value) + { + return toBigInteger(value, null); + } + + /** + * 转换为BigDecimal
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @param defaultValue 转换错误时的默认值 + * @return 结果 + */ + public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) + { + if (value == null) + { + return defaultValue; + } + if (value instanceof BigDecimal) + { + return (BigDecimal) value; + } + if (value instanceof Long) + { + return new BigDecimal((Long) value); + } + if (value instanceof Double) + { + return new BigDecimal((Double) value); + } + if (value instanceof Integer) + { + return new BigDecimal((Integer) value); + } + final String valueStr = toStr(value, null); + if (StringUtils.isEmpty(valueStr)) + { + return defaultValue; + } + try + { + return new BigDecimal(valueStr); + } + catch (Exception e) + { + return defaultValue; + } + } + + /** + * 转换为BigDecimal
                            + * 如果给定的值为空,或者转换失败,返回默认值
                            + * 转换失败不会报错 + * + * @param value 被转换的值 + * @return 结果 + */ + public static BigDecimal toBigDecimal(Object value) + { + return toBigDecimal(value, null); + } + + /** + * 将对象转为字符串
                            + * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @return 字符串 + */ + public static String utf8Str(Object obj) + { + return str(obj, CharsetKit.CHARSET_UTF_8); + } + + /** + * 将对象转为字符串
                            + * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @param charsetName 字符集 + * @return 字符串 + */ + public static String str(Object obj, String charsetName) + { + return str(obj, Charset.forName(charsetName)); + } + + /** + * 将对象转为字符串
                            + * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法 + * + * @param obj 对象 + * @param charset 字符集 + * @return 字符串 + */ + public static String str(Object obj, Charset charset) + { + if (null == obj) + { + return null; + } + + if (obj instanceof String) + { + return (String) obj; + } + else if (obj instanceof byte[] || obj instanceof Byte[]) + { + return str((Byte[]) obj, charset); + } + else if (obj instanceof ByteBuffer) + { + return str((ByteBuffer) obj, charset); + } + return obj.toString(); + } + + /** + * 将byte数组转为字符串 + * + * @param bytes byte数组 + * @param charset 字符集 + * @return 字符串 + */ + public static String str(byte[] bytes, String charset) + { + return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset)); + } + + /** + * 解码字节码 + * + * @param data 字符串 + * @param charset 字符集,如果此字段为空,则解码的结果取决于平台 + * @return 解码后的字符串 + */ + public static String str(byte[] data, Charset charset) + { + if (data == null) + { + return null; + } + + if (null == charset) + { + return new String(data); + } + return new String(data, charset); + } + + /** + * 将编码的byteBuffer数据转换为字符串 + * + * @param data 数据 + * @param charset 字符集,如果为空使用当前系统字符集 + * @return 字符串 + */ + public static String str(ByteBuffer data, String charset) + { + if (data == null) + { + return null; + } + + return str(data, Charset.forName(charset)); + } + + /** + * 将编码的byteBuffer数据转换为字符串 + * + * @param data 数据 + * @param charset 字符集,如果为空使用当前系统字符集 + * @return 字符串 + */ + public static String str(ByteBuffer data, Charset charset) + { + if (null == charset) + { + charset = Charset.defaultCharset(); + } + return charset.decode(data).toString(); + } + + // ----------------------------------------------------------------------- 全角半角转换 + /** + * 半角转全角 + * + * @param input String. + * @return 全角字符串. + */ + public static String toSBC(String input) + { + return toSBC(input, null); + } + + /** + * 半角转全角 + * + * @param input String + * @param notConvertSet 不替换的字符集合 + * @return 全角字符串. + */ + public static String toSBC(String input, Set notConvertSet) + { + char c[] = input.toCharArray(); + for (int i = 0; i < c.length; i++) + { + if (null != notConvertSet && notConvertSet.contains(c[i])) + { + // 跳过不替换的字符 + continue; + } + + if (c[i] == ' ') + { + c[i] = '\u3000'; + } + else if (c[i] < '\177') + { + c[i] = (char) (c[i] + 65248); + + } + } + return new String(c); + } + + /** + * 全角转半角 + * + * @param input String. + * @return 半角字符串 + */ + public static String toDBC(String input) + { + return toDBC(input, null); + } + + /** + * 替换全角为半角 + * + * @param text 文本 + * @param notConvertSet 不替换的字符集合 + * @return 替换后的字符 + */ + public static String toDBC(String text, Set notConvertSet) + { + char c[] = text.toCharArray(); + for (int i = 0; i < c.length; i++) + { + if (null != notConvertSet && notConvertSet.contains(c[i])) + { + // 跳过不替换的字符 + continue; + } + + if (c[i] == '\u3000') + { + c[i] = ' '; + } + else if (c[i] > '\uFF00' && c[i] < '\uFF5F') + { + c[i] = (char) (c[i] - 65248); + } + } + String returnString = new String(c); + + return returnString; + } + + /** + * 数字金额大写转换 先写个完整的然后将如零拾替换成零 + * + * @param n 数字 + * @return 中文大写数字 + */ + public static String digitUppercase(double n) + { + String[] fraction = { "角", "分" }; + String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; + String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } }; + + String head = n < 0 ? "负" : ""; + n = Math.abs(n); + + String s = ""; + for (int i = 0; i < fraction.length; i++) + { + s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); + } + if (s.length() < 1) + { + s = "整"; + } + int integerPart = (int) Math.floor(n); + + for (int i = 0; i < unit[0].length && integerPart > 0; i++) + { + String p = ""; + for (int j = 0; j < unit[1].length && n > 0; j++) + { + p = digit[integerPart % 10] + unit[1][j] + p; + integerPart = integerPart / 10; + } + s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s; + } + return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java b/bmw-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java similarity index 97% rename from ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java rename to bmw-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java index dbf3e2375..c78ac776d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java +++ b/bmw-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java @@ -1,92 +1,92 @@ -package com.ruoyi.common.core.text; - -import com.ruoyi.common.utils.StringUtils; - -/** - * 字符串格式化 - * - * @author ruoyi - */ -public class StrFormatter -{ - public static final String EMPTY_JSON = "{}"; - public static final char C_BACKSLASH = '\\'; - public static final char C_DELIM_START = '{'; - public static final char C_DELIM_END = '}'; - - /** - * 格式化字符串
                            - * 此方法只是简单将占位符 {} 按照顺序替换为参数
                            - * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
                            - * 例:
                            - * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
                            - * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
                            - * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
                            - * - * @param strPattern 字符串模板 - * @param argArray 参数列表 - * @return 结果 - */ - public static String format(final String strPattern, final Object... argArray) - { - if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) - { - return strPattern; - } - final int strPatternLength = strPattern.length(); - - // 初始化定义好的长度以获得更好的性能 - StringBuilder sbuf = new StringBuilder(strPatternLength + 50); - - int handledPosition = 0; - int delimIndex;// 占位符所在位置 - for (int argIndex = 0; argIndex < argArray.length; argIndex++) - { - delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); - if (delimIndex == -1) - { - if (handledPosition == 0) - { - return strPattern; - } - else - { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果 - sbuf.append(strPattern, handledPosition, strPatternLength); - return sbuf.toString(); - } - } - else - { - if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) - { - if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) - { - // 转义符之前还有一个转义符,占位符依旧有效 - sbuf.append(strPattern, handledPosition, delimIndex - 1); - sbuf.append(Convert.utf8Str(argArray[argIndex])); - handledPosition = delimIndex + 2; - } - else - { - // 占位符被转义 - argIndex--; - sbuf.append(strPattern, handledPosition, delimIndex - 1); - sbuf.append(C_DELIM_START); - handledPosition = delimIndex + 1; - } - } - else - { - // 正常占位符 - sbuf.append(strPattern, handledPosition, delimIndex); - sbuf.append(Convert.utf8Str(argArray[argIndex])); - handledPosition = delimIndex + 2; - } - } - } - // 加入最后一个占位符后所有的字符 - sbuf.append(strPattern, handledPosition, strPattern.length()); - - return sbuf.toString(); - } -} +package com.ruoyi.common.core.text; + +import com.ruoyi.common.utils.StringUtils; + +/** + * 字符串格式化 + * + * @author ruoyi + */ +public class StrFormatter +{ + public static final String EMPTY_JSON = "{}"; + public static final char C_BACKSLASH = '\\'; + public static final char C_DELIM_START = '{'; + public static final char C_DELIM_END = '}'; + + /** + * 格式化字符串
                            + * 此方法只是简单将占位符 {} 按照顺序替换为参数
                            + * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
                            + * 例:
                            + * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
                            + * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
                            + * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
                            + * + * @param strPattern 字符串模板 + * @param argArray 参数列表 + * @return 结果 + */ + public static String format(final String strPattern, final Object... argArray) + { + if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) + { + return strPattern; + } + final int strPatternLength = strPattern.length(); + + // 初始化定义好的长度以获得更好的性能 + StringBuilder sbuf = new StringBuilder(strPatternLength + 50); + + int handledPosition = 0; + int delimIndex;// 占位符所在位置 + for (int argIndex = 0; argIndex < argArray.length; argIndex++) + { + delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); + if (delimIndex == -1) + { + if (handledPosition == 0) + { + return strPattern; + } + else + { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果 + sbuf.append(strPattern, handledPosition, strPatternLength); + return sbuf.toString(); + } + } + else + { + if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) + { + if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) + { + // 转义符之前还有一个转义符,占位符依旧有效 + sbuf.append(strPattern, handledPosition, delimIndex - 1); + sbuf.append(Convert.utf8Str(argArray[argIndex])); + handledPosition = delimIndex + 2; + } + else + { + // 占位符被转义 + argIndex--; + sbuf.append(strPattern, handledPosition, delimIndex - 1); + sbuf.append(C_DELIM_START); + handledPosition = delimIndex + 1; + } + } + else + { + // 正常占位符 + sbuf.append(strPattern, handledPosition, delimIndex); + sbuf.append(Convert.utf8Str(argArray[argIndex])); + handledPosition = delimIndex + 2; + } + } + } + // 加入最后一个占位符后所有的字符 + sbuf.append(strPattern, handledPosition, strPattern.length()); + + return sbuf.toString(); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java b/bmw-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java similarity index 91% rename from ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java rename to bmw-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java index 43612e5d7..c6640bbc5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java +++ b/bmw-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java @@ -1,19 +1,19 @@ -package com.ruoyi.common.enums; - -/** - * 操作状态 - * - * @author ruoyi - */ -public enum BusinessStatus -{ - /** - * 成功 - */ - SUCCESS, - - /** - * 失败 - */ - FAIL, -} +package com.ruoyi.common.enums; + +/** + * 操作状态 + * + * @author ruoyi + */ +public enum BusinessStatus +{ + /** + * 成功 + */ + SUCCESS, + + /** + * 失败 + */ + FAIL, +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java b/bmw-common/src/main/java/com/ruoyi/common/enums/BusinessType.java similarity index 90% rename from ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java rename to bmw-common/src/main/java/com/ruoyi/common/enums/BusinessType.java index d22bccbd3..24d076a44 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java +++ b/bmw-common/src/main/java/com/ruoyi/common/enums/BusinessType.java @@ -1,59 +1,59 @@ -package com.ruoyi.common.enums; - -/** - * 业务操作类型 - * - * @author ruoyi - */ -public enum BusinessType -{ - /** - * 其它 - */ - OTHER, - - /** - * 新增 - */ - INSERT, - - /** - * 修改 - */ - UPDATE, - - /** - * 删除 - */ - DELETE, - - /** - * 授权 - */ - GRANT, - - /** - * 导出 - */ - EXPORT, - - /** - * 导入 - */ - IMPORT, - - /** - * 强退 - */ - FORCE, - - /** - * 生成代码 - */ - GENCODE, - - /** - * 清空 - */ - CLEAN, -} +package com.ruoyi.common.enums; + +/** + * 业务操作类型 + * + * @author ruoyi + */ +public enum BusinessType +{ + /** + * 其它 + */ + OTHER, + + /** + * 新增 + */ + INSERT, + + /** + * 修改 + */ + UPDATE, + + /** + * 删除 + */ + DELETE, + + /** + * 授权 + */ + GRANT, + + /** + * 导出 + */ + EXPORT, + + /** + * 导入 + */ + IMPORT, + + /** + * 强退 + */ + FORCE, + + /** + * 生成代码 + */ + GENCODE, + + /** + * 清空 + */ + CLEAN, +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java b/bmw-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java similarity index 90% rename from ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java rename to bmw-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java index 4b5341d19..0d945be54 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java +++ b/bmw-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java @@ -1,19 +1,19 @@ -package com.ruoyi.common.enums; - -/** - * 数据源 - * - * @author ruoyi - */ -public enum DataSourceType -{ - /** - * 主库 - */ - MASTER, - - /** - * 从库 - */ - SLAVE -} +package com.ruoyi.common.enums; + +/** + * 数据源 + * + * @author ruoyi + */ +public enum DataSourceType +{ + /** + * 主库 + */ + MASTER, + + /** + * 从库 + */ + SLAVE +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/OnlineStatus.java b/bmw-common/src/main/java/com/ruoyi/common/enums/OnlineStatus.java similarity index 93% rename from ruoyi-common/src/main/java/com/ruoyi/common/enums/OnlineStatus.java rename to bmw-common/src/main/java/com/ruoyi/common/enums/OnlineStatus.java index b0bdd1003..a05d5ffb8 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/OnlineStatus.java +++ b/bmw-common/src/main/java/com/ruoyi/common/enums/OnlineStatus.java @@ -1,24 +1,24 @@ -package com.ruoyi.common.enums; - -/** - * 用户会话 - * - * @author ruoyi - */ -public enum OnlineStatus -{ - /** 用户状态 */ - on_line("在线"), off_line("离线"); - - private final String info; - - private OnlineStatus(String info) - { - this.info = info; - } - - public String getInfo() - { - return info; - } -} +package com.ruoyi.common.enums; + +/** + * 用户会话 + * + * @author ruoyi + */ +public enum OnlineStatus +{ + /** 用户状态 */ + on_line("在线"), off_line("离线"); + + private final String info; + + private OnlineStatus(String info) + { + this.info = info; + } + + public String getInfo() + { + return info; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java b/bmw-common/src/main/java/com/ruoyi/common/enums/OperatorType.java similarity index 91% rename from ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java rename to bmw-common/src/main/java/com/ruoyi/common/enums/OperatorType.java index 06532af8f..bdd143c1c 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java +++ b/bmw-common/src/main/java/com/ruoyi/common/enums/OperatorType.java @@ -1,24 +1,24 @@ -package com.ruoyi.common.enums; - -/** - * 操作人类别 - * - * @author ruoyi - */ -public enum OperatorType -{ - /** - * 其它 - */ - OTHER, - - /** - * 后台用户 - */ - MANAGE, - - /** - * 手机端用户 - */ - MOBILE -} +package com.ruoyi.common.enums; + +/** + * 操作人类别 + * + * @author ruoyi + */ +public enum OperatorType +{ + /** + * 其它 + */ + OTHER, + + /** + * 后台用户 + */ + MANAGE, + + /** + * 手机端用户 + */ + MOBILE +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java b/bmw-common/src/main/java/com/ruoyi/common/enums/UserStatus.java similarity index 93% rename from ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java rename to bmw-common/src/main/java/com/ruoyi/common/enums/UserStatus.java index a4613ff9c..d7ff44a98 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java +++ b/bmw-common/src/main/java/com/ruoyi/common/enums/UserStatus.java @@ -1,30 +1,30 @@ -package com.ruoyi.common.enums; - -/** - * 用户状态 - * - * @author ruoyi - */ -public enum UserStatus -{ - OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除"); - - private final String code; - private final String info; - - UserStatus(String code, String info) - { - this.code = code; - this.info = info; - } - - public String getCode() - { - return code; - } - - public String getInfo() - { - return info; - } -} +package com.ruoyi.common.enums; + +/** + * 用户状态 + * + * @author ruoyi + */ +public enum UserStatus +{ + OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除"); + + private final String code; + private final String info; + + UserStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/BusinessException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/BusinessException.java similarity index 100% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/BusinessException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/BusinessException.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java index 57bffc47b..f6ad2ab49 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java @@ -1,15 +1,15 @@ -package com.ruoyi.common.exception; - -/** - * 演示模式异常 - * - * @author ruoyi - */ -public class DemoModeException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public DemoModeException() - { - } -} +package com.ruoyi.common.exception; + +/** + * 演示模式异常 + * + * @author ruoyi + */ +public class DemoModeException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + public DemoModeException() + { + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java index 3dd2c1ee7..b55d72e18 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java @@ -1,97 +1,97 @@ -package com.ruoyi.common.exception.base; - -import com.ruoyi.common.utils.MessageUtils; -import com.ruoyi.common.utils.StringUtils; - -/** - * 基础异常 - * - * @author ruoyi - */ -public class BaseException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - /** - * 所属模块 - */ - private String module; - - /** - * 错误码 - */ - private String code; - - /** - * 错误码对应的参数 - */ - private Object[] args; - - /** - * 错误消息 - */ - private String defaultMessage; - - public BaseException(String module, String code, Object[] args, String defaultMessage) - { - this.module = module; - this.code = code; - this.args = args; - this.defaultMessage = defaultMessage; - } - - public BaseException(String module, String code, Object[] args) - { - this(module, code, args, null); - } - - public BaseException(String module, String defaultMessage) - { - this(module, null, null, defaultMessage); - } - - public BaseException(String code, Object[] args) - { - this(null, code, args, null); - } - - public BaseException(String defaultMessage) - { - this(null, null, null, defaultMessage); - } - - @Override - public String getMessage() - { - String message = null; - if (!StringUtils.isEmpty(code)) - { - message = MessageUtils.message(code, args); - } - if (message == null) - { - message = defaultMessage; - } - return message; - } - - public String getModule() - { - return module; - } - - public String getCode() - { - return code; - } - - public Object[] getArgs() - { - return args; - } - - public String getDefaultMessage() - { - return defaultMessage; - } -} +package com.ruoyi.common.exception.base; + +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.common.utils.StringUtils; + +/** + * 基础异常 + * + * @author ruoyi + */ +public class BaseException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** + * 所属模块 + */ + private String module; + + /** + * 错误码 + */ + private String code; + + /** + * 错误码对应的参数 + */ + private Object[] args; + + /** + * 错误消息 + */ + private String defaultMessage; + + public BaseException(String module, String code, Object[] args, String defaultMessage) + { + this.module = module; + this.code = code; + this.args = args; + this.defaultMessage = defaultMessage; + } + + public BaseException(String module, String code, Object[] args) + { + this(module, code, args, null); + } + + public BaseException(String module, String defaultMessage) + { + this(module, null, null, defaultMessage); + } + + public BaseException(String code, Object[] args) + { + this(null, code, args, null); + } + + public BaseException(String defaultMessage) + { + this(null, null, null, defaultMessage); + } + + @Override + public String getMessage() + { + String message = null; + if (!StringUtils.isEmpty(code)) + { + message = MessageUtils.message(code, args); + } + if (message == null) + { + message = defaultMessage; + } + return message; + } + + public String getModule() + { + return module; + } + + public String getCode() + { + return code; + } + + public Object[] getArgs() + { + return args; + } + + public String getDefaultMessage() + { + return defaultMessage; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/file/FileException.java similarity index 100% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/file/FileException.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java index 44941b8bc..70e0ec9b1 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.file; - -/** - * 文件名称超长限制异常类 - * - * @author ruoyi - */ -public class FileNameLengthLimitExceededException extends FileException -{ - private static final long serialVersionUID = 1L; - - public FileNameLengthLimitExceededException(int defaultFileNameLength) - { - super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }); - } -} +package com.ruoyi.common.exception.file; + +/** + * 文件名称超长限制异常类 + * + * @author ruoyi + */ +public class FileNameLengthLimitExceededException extends FileException +{ + private static final long serialVersionUID = 1L; + + public FileNameLengthLimitExceededException(int defaultFileNameLength) + { + super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java similarity index 100% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java index 81cd78b81..8f63a799c 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java @@ -1,71 +1,71 @@ -package com.ruoyi.common.exception.file; - -import java.util.Arrays; -import org.apache.commons.fileupload.FileUploadException; - -/** - * 文件上传 误异常类 - * - * @author ruoyi - */ -public class InvalidExtensionException extends FileUploadException -{ - private static final long serialVersionUID = 1L; - - private String[] allowedExtension; - private String extension; - private String filename; - - public InvalidExtensionException(String[] allowedExtension, String extension, String filename) - { - super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]"); - this.allowedExtension = allowedExtension; - this.extension = extension; - this.filename = filename; - } - - public String[] getAllowedExtension() - { - return allowedExtension; - } - - public String getExtension() - { - return extension; - } - - public String getFilename() - { - return filename; - } - - public static class InvalidImageExtensionException extends InvalidExtensionException - { - private static final long serialVersionUID = 1L; - - public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) - { - super(allowedExtension, extension, filename); - } - } - - public static class InvalidFlashExtensionException extends InvalidExtensionException - { - private static final long serialVersionUID = 1L; - - public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) - { - super(allowedExtension, extension, filename); - } - } - - public static class InvalidMediaExtensionException extends InvalidExtensionException - { - private static final long serialVersionUID = 1L; - - public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) - { - super(allowedExtension, extension, filename); - } - } -} +package com.ruoyi.common.exception.file; + +import java.util.Arrays; +import org.apache.commons.fileupload.FileUploadException; + +/** + * 文件上传 误异常类 + * + * @author ruoyi + */ +public class InvalidExtensionException extends FileUploadException +{ + private static final long serialVersionUID = 1L; + + private String[] allowedExtension; + private String extension; + private String filename; + + public InvalidExtensionException(String[] allowedExtension, String extension, String filename) + { + super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]"); + this.allowedExtension = allowedExtension; + this.extension = extension; + this.filename = filename; + } + + public String[] getAllowedExtension() + { + return allowedExtension; + } + + public String getExtension() + { + return extension; + } + + public String getFilename() + { + return filename; + } + + public static class InvalidImageExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidFlashExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } + + public static class InvalidMediaExtensionException extends InvalidExtensionException + { + private static final long serialVersionUID = 1L; + + public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) + { + super(allowedExtension, extension, filename); + } + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java index 14b2361d0..a567b408b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java @@ -1,34 +1,34 @@ -package com.ruoyi.common.exception.job; - -/** - * 计划策略异常 - * - * @author ruoyi - */ -public class TaskException extends Exception -{ - private static final long serialVersionUID = 1L; - - private Code code; - - public TaskException(String msg, Code code) - { - this(msg, code, null); - } - - public TaskException(String msg, Code code, Exception nestedEx) - { - super(msg, nestedEx); - this.code = code; - } - - public Code getCode() - { - return code; - } - - public enum Code - { - TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE - } +package com.ruoyi.common.exception.job; + +/** + * 计划策略异常 + * + * @author ruoyi + */ +public class TaskException extends Exception +{ + private static final long serialVersionUID = 1L; + + private Code code; + + public TaskException(String msg, Code code) + { + this(msg, code, null); + } + + public TaskException(String msg, Code code, Exception nestedEx) + { + super(msg, nestedEx); + this.code = code; + } + + public Code getCode() + { + return code; + } + + public enum Code + { + TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java index e3334ae37..389dbc753 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.user; - -/** - * 验证码错误异常类 - * - * @author ruoyi - */ -public class CaptchaException extends UserException -{ - private static final long serialVersionUID = 1L; - - public CaptchaException() - { - super("user.jcaptcha.error", null); - } -} +package com.ruoyi.common.exception.user; + +/** + * 验证码错误异常类 + * + * @author ruoyi + */ +public class CaptchaException extends UserException +{ + private static final long serialVersionUID = 1L; + + public CaptchaException() + { + super("user.jcaptcha.error", null); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/RoleBlockedException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/RoleBlockedException.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/RoleBlockedException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/RoleBlockedException.java index e11624426..1c4fd4a18 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/RoleBlockedException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/RoleBlockedException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.user; - -/** - * 角色锁定异常类 - * - * @author ruoyi - */ -public class RoleBlockedException extends UserException -{ - private static final long serialVersionUID = 1L; - - public RoleBlockedException() - { - super("role.blocked", null); - } -} +package com.ruoyi.common.exception.user; + +/** + * 角色锁定异常类 + * + * @author ruoyi + */ +public class RoleBlockedException extends UserException +{ + private static final long serialVersionUID = 1L; + + public RoleBlockedException() + { + super("role.blocked", null); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserBlockedException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserBlockedException.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserBlockedException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/UserBlockedException.java index 8feb8493e..5150f52f8 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserBlockedException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserBlockedException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.user; - -/** - * 用户锁定异常类 - * - * @author ruoyi - */ -public class UserBlockedException extends UserException -{ - private static final long serialVersionUID = 1L; - - public UserBlockedException() - { - super("user.blocked", null); - } -} +package com.ruoyi.common.exception.user; + +/** + * 用户锁定异常类 + * + * @author ruoyi + */ +public class UserBlockedException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserBlockedException() + { + super("user.blocked", null); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserDeleteException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserDeleteException.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserDeleteException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/UserDeleteException.java index cf0724228..352003080 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserDeleteException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserDeleteException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.user; - -/** - * 用户账号已被删除 - * - * @author ruoyi - */ -public class UserDeleteException extends UserException -{ - private static final long serialVersionUID = 1L; - - public UserDeleteException() - { - super("user.password.delete", null); - } -} +package com.ruoyi.common.exception.user; + +/** + * 用户账号已被删除 + * + * @author ruoyi + */ +public class UserDeleteException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserDeleteException() + { + super("user.password.delete", null); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserException.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/UserException.java index 79160d861..c292d70ed 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserException.java @@ -1,18 +1,18 @@ -package com.ruoyi.common.exception.user; - -import com.ruoyi.common.exception.base.BaseException; - -/** - * 用户信息异常类 - * - * @author ruoyi - */ -public class UserException extends BaseException -{ - private static final long serialVersionUID = 1L; - - public UserException(String code, Object[] args) - { - super("user", code, args, null); - } -} +package com.ruoyi.common.exception.user; + +import com.ruoyi.common.exception.base.BaseException; + +/** + * 用户信息异常类 + * + * @author ruoyi + */ +public class UserException extends BaseException +{ + private static final long serialVersionUID = 1L; + + public UserException(String code, Object[] args) + { + super("user", code, args, null); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserNotExistsException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserNotExistsException.java similarity index 94% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserNotExistsException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/UserNotExistsException.java index ed4bea3ac..eff818121 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserNotExistsException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserNotExistsException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.user; - -/** - * 用户不存在异常类 - * - * @author ruoyi - */ -public class UserNotExistsException extends UserException -{ - private static final long serialVersionUID = 1L; - - public UserNotExistsException() - { - super("user.not.exists", null); - } -} +package com.ruoyi.common.exception.user; + +/** + * 用户不存在异常类 + * + * @author ruoyi + */ +public class UserNotExistsException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserNotExistsException() + { + super("user.not.exists", null); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java index 71449e293..a7f3e5ffe 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.user; - -/** - * 用户密码不正确或不符合规范异常类 - * - * @author ruoyi - */ -public class UserPasswordNotMatchException extends UserException -{ - private static final long serialVersionUID = 1L; - - public UserPasswordNotMatchException() - { - super("user.password.not.match", null); - } -} +package com.ruoyi.common.exception.user; + +/** + * 用户密码不正确或不符合规范异常类 + * + * @author ruoyi + */ +public class UserPasswordNotMatchException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserPasswordNotMatchException() + { + super("user.password.not.match", null); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitCountException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitCountException.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitCountException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitCountException.java index 4222135f5..7ead89b6d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitCountException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitCountException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.user; - -/** - * 用户错误记数异常类 - * - * @author ruoyi - */ -public class UserPasswordRetryLimitCountException extends UserException -{ - private static final long serialVersionUID = 1L; - - public UserPasswordRetryLimitCountException(int retryLimitCount) - { - super("user.password.retry.limit.count", new Object[] { retryLimitCount }); - } -} +package com.ruoyi.common.exception.user; + +/** + * 用户错误记数异常类 + * + * @author ruoyi + */ +public class UserPasswordRetryLimitCountException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserPasswordRetryLimitCountException(int retryLimitCount) + { + super("user.password.retry.limit.count", new Object[] { retryLimitCount }); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitExceedException.java b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitExceedException.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitExceedException.java rename to bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitExceedException.java index b48c40657..b5ccfb97e 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitExceedException.java +++ b/bmw-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitExceedException.java @@ -1,16 +1,16 @@ -package com.ruoyi.common.exception.user; - -/** - * 用户错误最大次数异常类 - * - * @author ruoyi - */ -public class UserPasswordRetryLimitExceedException extends UserException -{ - private static final long serialVersionUID = 1L; - - public UserPasswordRetryLimitExceedException(int retryLimitCount) - { - super("user.password.retry.limit.exceed", new Object[] { retryLimitCount }); - } -} +package com.ruoyi.common.exception.user; + +/** + * 用户错误最大次数异常类 + * + * @author ruoyi + */ +public class UserPasswordRetryLimitExceedException extends UserException +{ + private static final long serialVersionUID = 1L; + + public UserPasswordRetryLimitExceedException(int retryLimitCount) + { + super("user.password.retry.limit.exceed", new Object[] { retryLimitCount }); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/json/JSON.java b/bmw-common/src/main/java/com/ruoyi/common/json/JSON.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/json/JSON.java rename to bmw-common/src/main/java/com/ruoyi/common/json/JSON.java index 119147b6a..1e5b928b0 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/json/JSON.java +++ b/bmw-common/src/main/java/com/ruoyi/common/json/JSON.java @@ -1,187 +1,187 @@ -package com.ruoyi.common.json; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; - -/** - * JSON解析处理 - * - * @author ruoyi - */ -public class JSON -{ - public static final String DEFAULT_FAIL = "\"Parse failed\""; - private static final ObjectMapper objectMapper = new ObjectMapper(); - private static final ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter(); - - public static void marshal(File file, Object value) throws Exception - { - try - { - objectWriter.writeValue(file, value); - } - catch (JsonGenerationException e) - { - throw new Exception(e); - } - catch (JsonMappingException e) - { - throw new Exception(e); - } - catch (IOException e) - { - throw new Exception(e); - } - } - - public static void marshal(OutputStream os, Object value) throws Exception - { - try - { - objectWriter.writeValue(os, value); - } - catch (JsonGenerationException e) - { - throw new Exception(e); - } - catch (JsonMappingException e) - { - throw new Exception(e); - } - catch (IOException e) - { - throw new Exception(e); - } - } - - public static String marshal(Object value) throws Exception - { - try - { - return objectWriter.writeValueAsString(value); - } - catch (JsonGenerationException e) - { - throw new Exception(e); - } - catch (JsonMappingException e) - { - throw new Exception(e); - } - catch (IOException e) - { - throw new Exception(e); - } - } - - public static byte[] marshalBytes(Object value) throws Exception - { - try - { - return objectWriter.writeValueAsBytes(value); - } - catch (JsonGenerationException e) - { - throw new Exception(e); - } - catch (JsonMappingException e) - { - throw new Exception(e); - } - catch (IOException e) - { - throw new Exception(e); - } - } - - public static T unmarshal(File file, Class valueType) throws Exception - { - try - { - return objectMapper.readValue(file, valueType); - } - catch (JsonParseException e) - { - throw new Exception(e); - } - catch (JsonMappingException e) - { - throw new Exception(e); - } - catch (IOException e) - { - throw new Exception(e); - } - } - - public static T unmarshal(InputStream is, Class valueType) throws Exception - { - try - { - return objectMapper.readValue(is, valueType); - } - catch (JsonParseException e) - { - throw new Exception(e); - } - catch (JsonMappingException e) - { - throw new Exception(e); - } - catch (IOException e) - { - throw new Exception(e); - } - } - - public static T unmarshal(String str, Class valueType) throws Exception - { - try - { - return objectMapper.readValue(str, valueType); - } - catch (JsonParseException e) - { - throw new Exception(e); - } - catch (JsonMappingException e) - { - throw new Exception(e); - } - catch (IOException e) - { - throw new Exception(e); - } - } - - public static T unmarshal(byte[] bytes, Class valueType) throws Exception - { - try - { - if (bytes == null) - { - bytes = new byte[0]; - } - return objectMapper.readValue(bytes, 0, bytes.length, valueType); - } - catch (JsonParseException e) - { - throw new Exception(e); - } - catch (JsonMappingException e) - { - throw new Exception(e); - } - catch (IOException e) - { - throw new Exception(e); - } - } -} +package com.ruoyi.common.json; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; + +/** + * JSON解析处理 + * + * @author ruoyi + */ +public class JSON +{ + public static final String DEFAULT_FAIL = "\"Parse failed\""; + private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter(); + + public static void marshal(File file, Object value) throws Exception + { + try + { + objectWriter.writeValue(file, value); + } + catch (JsonGenerationException e) + { + throw new Exception(e); + } + catch (JsonMappingException e) + { + throw new Exception(e); + } + catch (IOException e) + { + throw new Exception(e); + } + } + + public static void marshal(OutputStream os, Object value) throws Exception + { + try + { + objectWriter.writeValue(os, value); + } + catch (JsonGenerationException e) + { + throw new Exception(e); + } + catch (JsonMappingException e) + { + throw new Exception(e); + } + catch (IOException e) + { + throw new Exception(e); + } + } + + public static String marshal(Object value) throws Exception + { + try + { + return objectWriter.writeValueAsString(value); + } + catch (JsonGenerationException e) + { + throw new Exception(e); + } + catch (JsonMappingException e) + { + throw new Exception(e); + } + catch (IOException e) + { + throw new Exception(e); + } + } + + public static byte[] marshalBytes(Object value) throws Exception + { + try + { + return objectWriter.writeValueAsBytes(value); + } + catch (JsonGenerationException e) + { + throw new Exception(e); + } + catch (JsonMappingException e) + { + throw new Exception(e); + } + catch (IOException e) + { + throw new Exception(e); + } + } + + public static T unmarshal(File file, Class valueType) throws Exception + { + try + { + return objectMapper.readValue(file, valueType); + } + catch (JsonParseException e) + { + throw new Exception(e); + } + catch (JsonMappingException e) + { + throw new Exception(e); + } + catch (IOException e) + { + throw new Exception(e); + } + } + + public static T unmarshal(InputStream is, Class valueType) throws Exception + { + try + { + return objectMapper.readValue(is, valueType); + } + catch (JsonParseException e) + { + throw new Exception(e); + } + catch (JsonMappingException e) + { + throw new Exception(e); + } + catch (IOException e) + { + throw new Exception(e); + } + } + + public static T unmarshal(String str, Class valueType) throws Exception + { + try + { + return objectMapper.readValue(str, valueType); + } + catch (JsonParseException e) + { + throw new Exception(e); + } + catch (JsonMappingException e) + { + throw new Exception(e); + } + catch (IOException e) + { + throw new Exception(e); + } + } + + public static T unmarshal(byte[] bytes, Class valueType) throws Exception + { + try + { + if (bytes == null) + { + bytes = new byte[0]; + } + return objectMapper.readValue(bytes, 0, bytes.length, valueType); + } + catch (JsonParseException e) + { + throw new Exception(e); + } + catch (JsonMappingException e) + { + throw new Exception(e); + } + catch (IOException e) + { + throw new Exception(e); + } + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/json/JSONObject.java b/bmw-common/src/main/java/com/ruoyi/common/json/JSONObject.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/json/JSONObject.java rename to bmw-common/src/main/java/com/ruoyi/common/json/JSONObject.java index 24ef6ccb7..2f4afe710 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/json/JSONObject.java +++ b/bmw-common/src/main/java/com/ruoyi/common/json/JSONObject.java @@ -1,749 +1,749 @@ -package com.ruoyi.common.json; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ruoyi.common.utils.StringUtils; - -/** - * 通用消息对象,基于Map实现的可嵌套数据结构。 支持JSON数据结构。 - * - * @author ruoyi - */ -public class JSONObject extends LinkedHashMap -{ - private static final long serialVersionUID = 1L; - private static final Pattern arrayNamePattern = Pattern.compile("(\\w+)((\\[\\d+\\])+)"); - private static final ObjectMapper objectMapper = new ObjectMapper(); - - /** - * 数组结构。 - */ - public static class JSONArray extends ArrayList - { - private static final long serialVersionUID = 1L; - - public JSONArray() - { - super(); - } - - public JSONArray(int size) - { - super(size); - } - - @Override - public String toString() - { - try - { - return JSON.marshal(this); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - @Override - public Object set(int index, Object element) - { - return super.set(index, transfer(element)); - } - - @Override - public boolean add(Object element) - { - return super.add(transfer(element)); - } - - @Override - public void add(int index, Object element) - { - super.add(index, transfer(element)); - } - } - - public JSONObject() - { - super(); - } - - public JSONObject(final JSONObject other) - { - super(other); - } - - @Override - public String toString() - { - try - { - return JSON.marshal(this); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - /** - * 转换为紧凑格式的字符串。 - * - * @return 返回本对象紧凑格式字符串。 - */ - public String toCompactString() - { - try - { - return objectMapper.writeValueAsString(this); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - /** - * 获取指定字段的整数值。如果字段不存在,或者无法转换为整数,返回null。 - * - * @param name 字段名,支持多级。 - * @return 返回指定的整数值,或者null。 - */ - public Integer intValue(final String name) - { - return valueAsInt(value(name)); - } - - /** - * 获取指定字段的整数值。如果字段不存在,或者无法转换为整数,返回defaultValue。 - * - * @param name 字段名,支持多级。 - * @param defaultValue 查询失败时,返回的值。 - * @return 返回指定的整数值,或者defaultValue。 - */ - public Integer intValue(final String name, final Integer defaultValue) - { - return StringUtils.nvl(intValue(name), defaultValue); - } - - /** - * 获取指定字段的长整数值。如果字段不存在,或者无法转换为长整数,返回null。 - * - * @param name 字段名,支持多级。 - * @return 返回指定的长整数值,或者null。 - */ - public Long longValue(final String name) - { - return valueAsLong(value(name)); - } - - /** - * 获取指定字段的长整数值。如果字段不存在,或者无法转换为长整数,返回defaultValue。 - * - * @param name 字段名,支持多级。 - * @param defaultValue 查询失败时,返回的值。 - * @return 返回指定的长整数值,或者defaultValue。 - */ - public Long longValue(final String name, final Long defaultValue) - { - return StringUtils.nvl(longValue(name), defaultValue); - } - - /** - * 获取指定字段的布尔值。如果字段不存在,或者无法转换为布尔型,返回null。 - * - * @param name 字段名,支持多级。 - * @return 返回指定的布尔值,或者null。 - */ - public Boolean boolValue(final String name) - { - return valueAsBool(value(name)); - } - - /** - * 获取指定字段的布尔值。如果字段不存在,或者无法转换为布尔型,返回defaultValue。 - * - * @param name 字段名,支持多级。 - * @param defaultValue 查询失败时,返回的值。 - * @return 返回指定的布尔值,或者defaultValue。 - */ - public Boolean boolValue(final String name, final Boolean defaultValue) - { - return StringUtils.nvl(boolValue(name), defaultValue); - } - - /** - * 获取指定字段的字符串值。如果字段不存在,返回null。 - * - * @param name 字段名,支持多级。 - * @return 返回指定的字符串值,或者null。 - */ - public String strValue(final String name) - { - return valueAsStr(value(name)); - } - - /** - * 获取指定字段的字符串值。如果字段不存在,返回defaultValue。 - * - * @param name 字段名,支持多级。 - * @param defaultValue 查询失败时,返回的值。 - * @return 返回指定的字符串值,或者defaultValue。 - */ - public String strValue(final String name, final String defaultValue) - { - return StringUtils.nvl(strValue(name), defaultValue); - } - - /** - * 获取指定字段的值。 - * - * @param name 字段名,支持多级,支持数组下标。 - * @return 返回指定字段的值。 - */ - public Object value(final String name) - { - final int indexDot = name.indexOf('.'); - if (indexDot >= 0) - { - return obj(name.substring(0, indexDot)).value(name.substring(indexDot + 1)); - } - else - { - final Matcher matcher = arrayNamePattern.matcher(name); - if (matcher.find()) - { - return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback() - { - @Override - public Object callback(JSONArray arr, int index) - { - return elementAt(arr, index); - } - }); - } - else - { - return get(name); - } - } - } - - /** - * 设置指定字段的值。 - * - * @param name 字段名,支持多级,支持数组下标。 - * @param value 字段值。 - * @return 返回本对象。 - */ - public JSONObject value(final String name, final Object value) - { - final int indexDot = name.indexOf('.'); - if (indexDot >= 0) - { - obj(name.substring(0, indexDot)).value(name.substring(indexDot + 1), value); - } - else - { - final Matcher matcher = arrayNamePattern.matcher(name); - if (matcher.find()) - { - endArray(matcher.group(1), matcher.group(2), new EndArrayCallback() - { - @Override - public Void callback(JSONArray arr, int index) - { - elementAt(arr, index, value); - return null; - } - }); - } - else - { - set(name, value); - } - } - return this; - } - - /** - * 获取对象(非标量类型)字段。返回的数据是一个结构体。当不存在指定对象时,则为指定的名字创建一个空的MessageObject对象。 - * - * @param name 字段名。不支持多级名字,支持数组下标。 - * @return 返回指定的对象。如果对象不存在,则为指定的名字创建一个空的MessageObject对象。 - */ - public JSONObject obj(final String name) - { - final Matcher matcher = arrayNamePattern.matcher(name); - if (matcher.find()) - { - return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback() - { - @Override - public JSONObject callback(JSONArray arr, int index) - { - return objAt(arr, index); - } - }); - } - else - { - JSONObject obj = getObj(name); - if (obj == null) - { - obj = new JSONObject(); - put(name, obj); - } - return obj; - } - } - - /** - * 获取数组字段。将名字对应的对象以数组对象返回,当指定的字段不存在时,创建一个空的数组。 - * - * @param name 字段名。不支持多级名字,不支持下标。 - * @return 返回一个数组(List)。 - */ - public JSONArray arr(final String name) - { - JSONArray arr = getArr(name); - if (arr == null) - { - arr = new JSONArray(); - put(name, arr); - } - return arr; - } - - /** - * 获取对象(非标量类型)字段。返回的数据是一个结构体。 - * - * @param name 字段名。 - * @return 返回指定的对象字段。 - */ - public JSONObject getObj(final String name) - { - return (JSONObject) get(name); - } - - /** - * 获取数组类型字段。 - * - * @param name 字段名。 - * @return 返回数组类型字段。 - */ - public JSONArray getArr(final String name) - { - return (JSONArray) get(name); - } - - /** - * 返回字段整数值。如果不存在,返回null。 - * - * @param name 字段名。 - * @return 返回指定字段整数值。 - */ - public Integer getInt(final String name) - { - return valueAsInt(get(name)); - } - - /** - * 返回字段整数值。如果不存在,返回defaultValue。 - * - * @param name 字段名。 - * @param defaultValue 字段不存在时,返回的值。 - * @return 返回指定字段整数值。 - */ - public Integer getInt(final String name, Integer defaultValue) - { - return StringUtils.nvl(getInt(name), defaultValue); - } - - /** - * 返回字段长整数值。如果不存在,返回null。 - * - * @param name 字段名。 - * @return 返回指定字段长整数值。 - */ - public Long getLong(final String name) - { - return valueAsLong(get(name)); - } - - /** - * 返回字段长整数值。如果不存在,返回defaultValue。 - * - * @param name 字段名。 - * @param defaultValue 字段不存在时,返回的值。 - * @return 返回指定字段长整数值。 - */ - public Long getLong(final String name, Long defaultValue) - { - return StringUtils.nvl(getLong(name), defaultValue); - } - - /** - * 返回字段字符串值。如果不存在,返回null。 - * - * @param name 字段名。 - * @return 返回指定字段字符串值。 - */ - public String getStr(final String name) - { - return valueAsStr(get(name)); - } - - /** - * 返回字段字符串值。如果不存在,返回defaultValue。 - * - * @param name 字段名。 - * @param defaultValue 字段不存在时,返回的值。 - * @return 返回指定字段字符串值。 - */ - public String getStr(final String name, final String defaultValue) - { - return StringUtils.nvl(getStr(name), defaultValue); - } - - /** - * 字段值按照布尔类型返回。如果不存在,返回null。 - * - * @param name 字段名。 - * @return 字段值。 - */ - public Boolean getBool(final String name) - { - return valueAsBool(get(name)); - } - - /** - * 字段值按照布尔类型返回。如果不存在,返回defaultValue。 - * - * @param name 字段名。 - * @param defaultValue 字段不存在时,返回的值。 - * @return 字段值。 - */ - public Boolean getBool(final String name, final Boolean defaultValue) - { - return StringUtils.nvl(getBool(name), defaultValue); - } - - /** - * 设置字段值 - * - * @param name 字段名 - * @param value 字段值(标量:数字、字符串、布尔型;结构体:MessageObject)。 如果是Map类型同时非MessageObject类型,则自动转换为MessageObject类型再存入 - * (此时,再修改Map中的数据,将不会体现到本对象中)。 - * @return 返回本对象 - */ - public JSONObject set(final String name, final Object value) - { - put(name, value); - return this; - } - - /** - * 将本对象转换为Java Bean。 - * - * @param beanClass Java Bean的类对象。 - * @return 返回转换后的Java Bean。 - */ - public T asBean(Class beanClass) - { - try - { - return JSON.unmarshal(JSON.marshal(this), beanClass); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - /** - * 重载基类的方法。如果 value 是 Map 类型,但不是 MessageObject 类型,则创建一个包含内容等同于原 Map 的 MessageObject 作为 value(注意:此后再更改 Map 的内容,将不会反映到 - * MessageObject 中)。 重载此方法的目的是为了使JSON能够正确地解析为MessageObject对象。不建议直接调用此方法,请使用 set(name, value)方法设置字段值。 - */ - @Override - public Object put(String key, Object value) - { - return super.put(key, transfer(value)); - } - - public static Integer valueAsInt(Object value) - { - if (value instanceof Integer) - { - return (Integer) value; - } - else if (value instanceof Number) - { - return ((Number) value).intValue(); - } - else if (value instanceof String) - { - return Integer.valueOf((String) value); - } - else if (value instanceof Boolean) - { - return ((Boolean) value) ? 1 : 0; - } - else - { - return null; - } - } - - public static Long valueAsLong(Object value) - { - if (value instanceof Long) - { - return (Long) value; - } - else if (value instanceof Number) - { - return ((Number) value).longValue(); - } - else if (value instanceof String) - { - return Long.valueOf((String) value); - } - else if (value instanceof Boolean) - { - return ((Boolean) value) ? 1L : 0L; - } - else - { - return null; - } - } - - public static String valueAsStr(Object value) - { - if (value instanceof String) - { - return (String) value; - } - else if (value != null) - { - return value.toString(); - } - else - { - return null; - } - } - - public static Boolean valueAsBool(Object value) - { - if (value instanceof Boolean) - { - return (Boolean) value; - } - else if (value instanceof Number) - { - return ((Number) value).doubleValue() != 0.0; - } - else if (value instanceof String) - { - return Boolean.valueOf((String) value); - } - else - { - return null; - } - } - - /** - * 将所有层次中凡是Map类型同时又不是MessageObject的类型,转换为MessageObject类型。 - * - * @param value 值。 - * @return 返回转换后的值。 - */ - @SuppressWarnings("unchecked") - private static Object transfer(final Object value) - { - if (!(value instanceof JSONObject) && value instanceof Map) - { - return toObj((Map) value); - } - else if (!(value instanceof JSONArray) && value instanceof Collection) - { - return toArr((Collection) value); - } - else - { - return value; - } - } - - private static JSONArray toArr(final Collection list) - { - final JSONArray arr = new JSONArray(list.size()); - for (final Object element : list) - { - arr.add(element); - } - return arr; - } - - private static JSONObject toObj(final Map map) - { - final JSONObject obj = new JSONObject(); - for (final Map.Entry ent : map.entrySet()) - { - obj.put(ent.getKey(), transfer(ent.getValue())); - } - return obj; - } - - /** - * 将指定下标元素作为数组返回,如果不存在,则在该位置创建一个空的数组。 - * - * @param arr 当前数组。 - * @param index 下标。 - * @return 返回当前数组指定下标的元素,该元素应该是一个数组。 - */ - private static JSONArray arrayAt(JSONArray arr, int index) - { - expand(arr, index); - if (arr.get(index) == null) - { - arr.set(index, new JSONArray()); - } - return (JSONArray) arr.get(index); - } - - /** - * 将指定下标元素作为结构体返回,如果不存在,则在该位置创建一个空的结构体。 - * - * @param arr 当前数组。 - * @param index 下标。 - * @return 返回当前数组指定下标元素,该元素是一个结构体。 - */ - private static JSONObject objAt(final JSONArray arr, int index) - { - expand(arr, index); - if (arr.get(index) == null) - { - arr.set(index, new JSONObject()); - } - return (JSONObject) arr.get(index); - } - - /** - * 设置数组指定下标位置的值。 - * - * @param arr 数组。 - * @param index 下标。 - * @param value 值。 - */ - private static void elementAt(final JSONArray arr, final int index, final Object value) - { - expand(arr, index).set(index, value); - } - - /** - * 获取数组指定下标元素的值。 - * - * @param arr 数组。 - * @param index 下标。 - * @return 值。 - */ - private static Object elementAt(final JSONArray arr, final int index) - { - return expand(arr, index).get(index); - } - - /** - * 扩展数组到指定下标,以防止访问时下标越界。 - * - * @param arr 数组 - * @param index 下标 - * @return 返回传入的数组 - */ - private static JSONArray expand(final JSONArray arr, final int index) - { - while (arr.size() <= index) - { - arr.add(null); - } - return arr; - } - - /** - * 最后数组回调。 - * - * @author Mike - * - * @param 回调返回数据类型。 - */ - private interface EndArrayCallback - { - /** - * 当定位到最后一级数组,将调用本方法。 - * - * @param arr 最后一级数组对象。 - * @param index 最后一级索引。 - * @return 返回回调的返回值。 - */ - T callback(JSONArray arr, int index); - } - - /** - * 处理多维数组的工具函数(包括一维数组)。多维数组的名字如:arrary[1][2][3], 则name=array,indexStr=[1][2][3],在callback中,endArr将是 - * array[1][2]指定的对象,indexe=3。 - * - * @param name 不带下标的名字,不支持多级名字。 - * @param indexesStr 索引部分的字符串,如:[1][2][3] - * @param callback 回调函数。 - * @return 返回回调函数的返回值。 - */ - private T endArray(final String name, final String indexesStr, final EndArrayCallback callback) - { - JSONArray endArr = arr(name); - final int[] indexes = parseIndexes(indexesStr); - int i = 0; - while (i < indexes.length - 1) - { - endArr = arrayAt(endArr, indexes[i++]); - } - return callback.callback(endArr, indexes[i]); - } - - private static int[] parseIndexes(final String s) - { - int[] indexes = null; - List list = new ArrayList(); - - final StringTokenizer st = new StringTokenizer(s, "[]"); - while (st.hasMoreTokens()) - { - final int index = Integer.valueOf(st.nextToken()); - if (index < 0) - { - throw new RuntimeException(String.format("Illegal index %1$d in \"%2$s\"", index, s)); - } - - list.add(index); - } - - indexes = new int[list.size()]; - int i = 0; - for (Integer tmp : list.toArray(new Integer[list.size()])) - { - indexes[i++] = tmp; - } - - return indexes; - } -} +package com.ruoyi.common.json; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ruoyi.common.utils.StringUtils; + +/** + * 通用消息对象,基于Map实现的可嵌套数据结构。 支持JSON数据结构。 + * + * @author ruoyi + */ +public class JSONObject extends LinkedHashMap +{ + private static final long serialVersionUID = 1L; + private static final Pattern arrayNamePattern = Pattern.compile("(\\w+)((\\[\\d+\\])+)"); + private static final ObjectMapper objectMapper = new ObjectMapper(); + + /** + * 数组结构。 + */ + public static class JSONArray extends ArrayList + { + private static final long serialVersionUID = 1L; + + public JSONArray() + { + super(); + } + + public JSONArray(int size) + { + super(size); + } + + @Override + public String toString() + { + try + { + return JSON.marshal(this); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + @Override + public Object set(int index, Object element) + { + return super.set(index, transfer(element)); + } + + @Override + public boolean add(Object element) + { + return super.add(transfer(element)); + } + + @Override + public void add(int index, Object element) + { + super.add(index, transfer(element)); + } + } + + public JSONObject() + { + super(); + } + + public JSONObject(final JSONObject other) + { + super(other); + } + + @Override + public String toString() + { + try + { + return JSON.marshal(this); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + /** + * 转换为紧凑格式的字符串。 + * + * @return 返回本对象紧凑格式字符串。 + */ + public String toCompactString() + { + try + { + return objectMapper.writeValueAsString(this); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + /** + * 获取指定字段的整数值。如果字段不存在,或者无法转换为整数,返回null。 + * + * @param name 字段名,支持多级。 + * @return 返回指定的整数值,或者null。 + */ + public Integer intValue(final String name) + { + return valueAsInt(value(name)); + } + + /** + * 获取指定字段的整数值。如果字段不存在,或者无法转换为整数,返回defaultValue。 + * + * @param name 字段名,支持多级。 + * @param defaultValue 查询失败时,返回的值。 + * @return 返回指定的整数值,或者defaultValue。 + */ + public Integer intValue(final String name, final Integer defaultValue) + { + return StringUtils.nvl(intValue(name), defaultValue); + } + + /** + * 获取指定字段的长整数值。如果字段不存在,或者无法转换为长整数,返回null。 + * + * @param name 字段名,支持多级。 + * @return 返回指定的长整数值,或者null。 + */ + public Long longValue(final String name) + { + return valueAsLong(value(name)); + } + + /** + * 获取指定字段的长整数值。如果字段不存在,或者无法转换为长整数,返回defaultValue。 + * + * @param name 字段名,支持多级。 + * @param defaultValue 查询失败时,返回的值。 + * @return 返回指定的长整数值,或者defaultValue。 + */ + public Long longValue(final String name, final Long defaultValue) + { + return StringUtils.nvl(longValue(name), defaultValue); + } + + /** + * 获取指定字段的布尔值。如果字段不存在,或者无法转换为布尔型,返回null。 + * + * @param name 字段名,支持多级。 + * @return 返回指定的布尔值,或者null。 + */ + public Boolean boolValue(final String name) + { + return valueAsBool(value(name)); + } + + /** + * 获取指定字段的布尔值。如果字段不存在,或者无法转换为布尔型,返回defaultValue。 + * + * @param name 字段名,支持多级。 + * @param defaultValue 查询失败时,返回的值。 + * @return 返回指定的布尔值,或者defaultValue。 + */ + public Boolean boolValue(final String name, final Boolean defaultValue) + { + return StringUtils.nvl(boolValue(name), defaultValue); + } + + /** + * 获取指定字段的字符串值。如果字段不存在,返回null。 + * + * @param name 字段名,支持多级。 + * @return 返回指定的字符串值,或者null。 + */ + public String strValue(final String name) + { + return valueAsStr(value(name)); + } + + /** + * 获取指定字段的字符串值。如果字段不存在,返回defaultValue。 + * + * @param name 字段名,支持多级。 + * @param defaultValue 查询失败时,返回的值。 + * @return 返回指定的字符串值,或者defaultValue。 + */ + public String strValue(final String name, final String defaultValue) + { + return StringUtils.nvl(strValue(name), defaultValue); + } + + /** + * 获取指定字段的值。 + * + * @param name 字段名,支持多级,支持数组下标。 + * @return 返回指定字段的值。 + */ + public Object value(final String name) + { + final int indexDot = name.indexOf('.'); + if (indexDot >= 0) + { + return obj(name.substring(0, indexDot)).value(name.substring(indexDot + 1)); + } + else + { + final Matcher matcher = arrayNamePattern.matcher(name); + if (matcher.find()) + { + return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback() + { + @Override + public Object callback(JSONArray arr, int index) + { + return elementAt(arr, index); + } + }); + } + else + { + return get(name); + } + } + } + + /** + * 设置指定字段的值。 + * + * @param name 字段名,支持多级,支持数组下标。 + * @param value 字段值。 + * @return 返回本对象。 + */ + public JSONObject value(final String name, final Object value) + { + final int indexDot = name.indexOf('.'); + if (indexDot >= 0) + { + obj(name.substring(0, indexDot)).value(name.substring(indexDot + 1), value); + } + else + { + final Matcher matcher = arrayNamePattern.matcher(name); + if (matcher.find()) + { + endArray(matcher.group(1), matcher.group(2), new EndArrayCallback() + { + @Override + public Void callback(JSONArray arr, int index) + { + elementAt(arr, index, value); + return null; + } + }); + } + else + { + set(name, value); + } + } + return this; + } + + /** + * 获取对象(非标量类型)字段。返回的数据是一个结构体。当不存在指定对象时,则为指定的名字创建一个空的MessageObject对象。 + * + * @param name 字段名。不支持多级名字,支持数组下标。 + * @return 返回指定的对象。如果对象不存在,则为指定的名字创建一个空的MessageObject对象。 + */ + public JSONObject obj(final String name) + { + final Matcher matcher = arrayNamePattern.matcher(name); + if (matcher.find()) + { + return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback() + { + @Override + public JSONObject callback(JSONArray arr, int index) + { + return objAt(arr, index); + } + }); + } + else + { + JSONObject obj = getObj(name); + if (obj == null) + { + obj = new JSONObject(); + put(name, obj); + } + return obj; + } + } + + /** + * 获取数组字段。将名字对应的对象以数组对象返回,当指定的字段不存在时,创建一个空的数组。 + * + * @param name 字段名。不支持多级名字,不支持下标。 + * @return 返回一个数组(List)。 + */ + public JSONArray arr(final String name) + { + JSONArray arr = getArr(name); + if (arr == null) + { + arr = new JSONArray(); + put(name, arr); + } + return arr; + } + + /** + * 获取对象(非标量类型)字段。返回的数据是一个结构体。 + * + * @param name 字段名。 + * @return 返回指定的对象字段。 + */ + public JSONObject getObj(final String name) + { + return (JSONObject) get(name); + } + + /** + * 获取数组类型字段。 + * + * @param name 字段名。 + * @return 返回数组类型字段。 + */ + public JSONArray getArr(final String name) + { + return (JSONArray) get(name); + } + + /** + * 返回字段整数值。如果不存在,返回null。 + * + * @param name 字段名。 + * @return 返回指定字段整数值。 + */ + public Integer getInt(final String name) + { + return valueAsInt(get(name)); + } + + /** + * 返回字段整数值。如果不存在,返回defaultValue。 + * + * @param name 字段名。 + * @param defaultValue 字段不存在时,返回的值。 + * @return 返回指定字段整数值。 + */ + public Integer getInt(final String name, Integer defaultValue) + { + return StringUtils.nvl(getInt(name), defaultValue); + } + + /** + * 返回字段长整数值。如果不存在,返回null。 + * + * @param name 字段名。 + * @return 返回指定字段长整数值。 + */ + public Long getLong(final String name) + { + return valueAsLong(get(name)); + } + + /** + * 返回字段长整数值。如果不存在,返回defaultValue。 + * + * @param name 字段名。 + * @param defaultValue 字段不存在时,返回的值。 + * @return 返回指定字段长整数值。 + */ + public Long getLong(final String name, Long defaultValue) + { + return StringUtils.nvl(getLong(name), defaultValue); + } + + /** + * 返回字段字符串值。如果不存在,返回null。 + * + * @param name 字段名。 + * @return 返回指定字段字符串值。 + */ + public String getStr(final String name) + { + return valueAsStr(get(name)); + } + + /** + * 返回字段字符串值。如果不存在,返回defaultValue。 + * + * @param name 字段名。 + * @param defaultValue 字段不存在时,返回的值。 + * @return 返回指定字段字符串值。 + */ + public String getStr(final String name, final String defaultValue) + { + return StringUtils.nvl(getStr(name), defaultValue); + } + + /** + * 字段值按照布尔类型返回。如果不存在,返回null。 + * + * @param name 字段名。 + * @return 字段值。 + */ + public Boolean getBool(final String name) + { + return valueAsBool(get(name)); + } + + /** + * 字段值按照布尔类型返回。如果不存在,返回defaultValue。 + * + * @param name 字段名。 + * @param defaultValue 字段不存在时,返回的值。 + * @return 字段值。 + */ + public Boolean getBool(final String name, final Boolean defaultValue) + { + return StringUtils.nvl(getBool(name), defaultValue); + } + + /** + * 设置字段值 + * + * @param name 字段名 + * @param value 字段值(标量:数字、字符串、布尔型;结构体:MessageObject)。 如果是Map类型同时非MessageObject类型,则自动转换为MessageObject类型再存入 + * (此时,再修改Map中的数据,将不会体现到本对象中)。 + * @return 返回本对象 + */ + public JSONObject set(final String name, final Object value) + { + put(name, value); + return this; + } + + /** + * 将本对象转换为Java Bean。 + * + * @param beanClass Java Bean的类对象。 + * @return 返回转换后的Java Bean。 + */ + public T asBean(Class beanClass) + { + try + { + return JSON.unmarshal(JSON.marshal(this), beanClass); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + /** + * 重载基类的方法。如果 value 是 Map 类型,但不是 MessageObject 类型,则创建一个包含内容等同于原 Map 的 MessageObject 作为 value(注意:此后再更改 Map 的内容,将不会反映到 + * MessageObject 中)。 重载此方法的目的是为了使JSON能够正确地解析为MessageObject对象。不建议直接调用此方法,请使用 set(name, value)方法设置字段值。 + */ + @Override + public Object put(String key, Object value) + { + return super.put(key, transfer(value)); + } + + public static Integer valueAsInt(Object value) + { + if (value instanceof Integer) + { + return (Integer) value; + } + else if (value instanceof Number) + { + return ((Number) value).intValue(); + } + else if (value instanceof String) + { + return Integer.valueOf((String) value); + } + else if (value instanceof Boolean) + { + return ((Boolean) value) ? 1 : 0; + } + else + { + return null; + } + } + + public static Long valueAsLong(Object value) + { + if (value instanceof Long) + { + return (Long) value; + } + else if (value instanceof Number) + { + return ((Number) value).longValue(); + } + else if (value instanceof String) + { + return Long.valueOf((String) value); + } + else if (value instanceof Boolean) + { + return ((Boolean) value) ? 1L : 0L; + } + else + { + return null; + } + } + + public static String valueAsStr(Object value) + { + if (value instanceof String) + { + return (String) value; + } + else if (value != null) + { + return value.toString(); + } + else + { + return null; + } + } + + public static Boolean valueAsBool(Object value) + { + if (value instanceof Boolean) + { + return (Boolean) value; + } + else if (value instanceof Number) + { + return ((Number) value).doubleValue() != 0.0; + } + else if (value instanceof String) + { + return Boolean.valueOf((String) value); + } + else + { + return null; + } + } + + /** + * 将所有层次中凡是Map类型同时又不是MessageObject的类型,转换为MessageObject类型。 + * + * @param value 值。 + * @return 返回转换后的值。 + */ + @SuppressWarnings("unchecked") + private static Object transfer(final Object value) + { + if (!(value instanceof JSONObject) && value instanceof Map) + { + return toObj((Map) value); + } + else if (!(value instanceof JSONArray) && value instanceof Collection) + { + return toArr((Collection) value); + } + else + { + return value; + } + } + + private static JSONArray toArr(final Collection list) + { + final JSONArray arr = new JSONArray(list.size()); + for (final Object element : list) + { + arr.add(element); + } + return arr; + } + + private static JSONObject toObj(final Map map) + { + final JSONObject obj = new JSONObject(); + for (final Map.Entry ent : map.entrySet()) + { + obj.put(ent.getKey(), transfer(ent.getValue())); + } + return obj; + } + + /** + * 将指定下标元素作为数组返回,如果不存在,则在该位置创建一个空的数组。 + * + * @param arr 当前数组。 + * @param index 下标。 + * @return 返回当前数组指定下标的元素,该元素应该是一个数组。 + */ + private static JSONArray arrayAt(JSONArray arr, int index) + { + expand(arr, index); + if (arr.get(index) == null) + { + arr.set(index, new JSONArray()); + } + return (JSONArray) arr.get(index); + } + + /** + * 将指定下标元素作为结构体返回,如果不存在,则在该位置创建一个空的结构体。 + * + * @param arr 当前数组。 + * @param index 下标。 + * @return 返回当前数组指定下标元素,该元素是一个结构体。 + */ + private static JSONObject objAt(final JSONArray arr, int index) + { + expand(arr, index); + if (arr.get(index) == null) + { + arr.set(index, new JSONObject()); + } + return (JSONObject) arr.get(index); + } + + /** + * 设置数组指定下标位置的值。 + * + * @param arr 数组。 + * @param index 下标。 + * @param value 值。 + */ + private static void elementAt(final JSONArray arr, final int index, final Object value) + { + expand(arr, index).set(index, value); + } + + /** + * 获取数组指定下标元素的值。 + * + * @param arr 数组。 + * @param index 下标。 + * @return 值。 + */ + private static Object elementAt(final JSONArray arr, final int index) + { + return expand(arr, index).get(index); + } + + /** + * 扩展数组到指定下标,以防止访问时下标越界。 + * + * @param arr 数组 + * @param index 下标 + * @return 返回传入的数组 + */ + private static JSONArray expand(final JSONArray arr, final int index) + { + while (arr.size() <= index) + { + arr.add(null); + } + return arr; + } + + /** + * 最后数组回调。 + * + * @author Mike + * + * @param 回调返回数据类型。 + */ + private interface EndArrayCallback + { + /** + * 当定位到最后一级数组,将调用本方法。 + * + * @param arr 最后一级数组对象。 + * @param index 最后一级索引。 + * @return 返回回调的返回值。 + */ + T callback(JSONArray arr, int index); + } + + /** + * 处理多维数组的工具函数(包括一维数组)。多维数组的名字如:arrary[1][2][3], 则name=array,indexStr=[1][2][3],在callback中,endArr将是 + * array[1][2]指定的对象,indexe=3。 + * + * @param name 不带下标的名字,不支持多级名字。 + * @param indexesStr 索引部分的字符串,如:[1][2][3] + * @param callback 回调函数。 + * @return 返回回调函数的返回值。 + */ + private T endArray(final String name, final String indexesStr, final EndArrayCallback callback) + { + JSONArray endArr = arr(name); + final int[] indexes = parseIndexes(indexesStr); + int i = 0; + while (i < indexes.length - 1) + { + endArr = arrayAt(endArr, indexes[i++]); + } + return callback.callback(endArr, indexes[i]); + } + + private static int[] parseIndexes(final String s) + { + int[] indexes = null; + List list = new ArrayList(); + + final StringTokenizer st = new StringTokenizer(s, "[]"); + while (st.hasMoreTokens()) + { + final int index = Integer.valueOf(st.nextToken()); + if (index < 0) + { + throw new RuntimeException(String.format("Illegal index %1$d in \"%2$s\"", index, s)); + } + + list.add(index); + } + + indexes = new int[list.size()]; + int i = 0; + for (Integer tmp : list.toArray(new Integer[list.size()])) + { + indexes[i++] = tmp; + } + + return indexes; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/AddressUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/AddressUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/AddressUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/AddressUtils.java index 437137dea..6caeade4b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/AddressUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/AddressUtils.java @@ -1,54 +1,54 @@ -package com.ruoyi.common.utils; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.config.Global; -import com.ruoyi.common.json.JSON; -import com.ruoyi.common.json.JSONObject; -import com.ruoyi.common.utils.http.HttpUtils; - -/** - * 获取地址类 - * - * @author ruoyi - */ -public class AddressUtils -{ - private static final Logger log = LoggerFactory.getLogger(AddressUtils.class); - - public static final String IP_URL = "http://ip.taobao.com/service/getIpInfo.php"; - - public static String getRealAddressByIP(String ip) - { - String address = "XX XX"; - - // 内网不查询 - if (IpUtils.internalIp(ip)) - { - return "内网IP"; - } - if (Global.isAddressEnabled()) - { - String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip); - if (StringUtils.isEmpty(rspStr)) - { - log.error("获取地理位置异常 {}", ip); - return address; - } - JSONObject obj; - try - { - obj = JSON.unmarshal(rspStr, JSONObject.class); - JSONObject data = obj.getObj("data"); - String region = data.getStr("region"); - String city = data.getStr("city"); - address = region + " " + city; - } - catch (Exception e) - { - log.error("获取地理位置异常 {}", ip); - } - } - return address; - } -} +package com.ruoyi.common.utils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.config.Global; +import com.ruoyi.common.json.JSON; +import com.ruoyi.common.json.JSONObject; +import com.ruoyi.common.utils.http.HttpUtils; + +/** + * 获取地址类 + * + * @author ruoyi + */ +public class AddressUtils +{ + private static final Logger log = LoggerFactory.getLogger(AddressUtils.class); + + public static final String IP_URL = "http://ip.taobao.com/service/getIpInfo.php"; + + public static String getRealAddressByIP(String ip) + { + String address = "XX XX"; + + // 内网不查询 + if (IpUtils.internalIp(ip)) + { + return "内网IP"; + } + if (Global.isAddressEnabled()) + { + String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip); + if (StringUtils.isEmpty(rspStr)) + { + log.error("获取地理位置异常 {}", ip); + return address; + } + JSONObject obj; + try + { + obj = JSON.unmarshal(rspStr, JSONObject.class); + JSONObject data = obj.getObj("data"); + String region = data.getStr("region"); + String city = data.getStr("city"); + address = region + " " + city; + } + catch (Exception e) + { + log.error("获取地理位置异常 {}", ip); + } + } + return address; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java b/bmw-common/src/main/java/com/ruoyi/common/utils/Arith.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/Arith.java index 866831977..48a650e89 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/Arith.java @@ -1,114 +1,114 @@ -package com.ruoyi.common.utils; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -/** - * 精确的浮点数运算 - * - * @author ruoyi - */ -public class Arith -{ - - /** 默认除法运算精度 */ - private static final int DEF_DIV_SCALE = 10; - - /** 这个类不能实例化 */ - private Arith() - { - } - - /** - * 提供精确的加法运算。 - * @param v1 被加数 - * @param v2 加数 - * @return 两个参数的和 - */ - public static double add(double v1, double v2) - { - BigDecimal b1 = new BigDecimal(Double.toString(v1)); - BigDecimal b2 = new BigDecimal(Double.toString(v2)); - return b1.add(b2).doubleValue(); - } - - /** - * 提供精确的减法运算。 - * @param v1 被减数 - * @param v2 减数 - * @return 两个参数的差 - */ - public static double sub(double v1, double v2) - { - BigDecimal b1 = new BigDecimal(Double.toString(v1)); - BigDecimal b2 = new BigDecimal(Double.toString(v2)); - return b1.subtract(b2).doubleValue(); - } - - /** - * 提供精确的乘法运算。 - * @param v1 被乘数 - * @param v2 乘数 - * @return 两个参数的积 - */ - public static double mul(double v1, double v2) - { - BigDecimal b1 = new BigDecimal(Double.toString(v1)); - BigDecimal b2 = new BigDecimal(Double.toString(v2)); - return b1.multiply(b2).doubleValue(); - } - - /** - * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 - * 小数点以后10位,以后的数字四舍五入。 - * @param v1 被除数 - * @param v2 除数 - * @return 两个参数的商 - */ - public static double div(double v1, double v2) - { - return div(v1, v2, DEF_DIV_SCALE); - } - - /** - * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 - * 定精度,以后的数字四舍五入。 - * @param v1 被除数 - * @param v2 除数 - * @param scale 表示表示需要精确到小数点以后几位。 - * @return 两个参数的商 - */ - public static double div(double v1, double v2, int scale) - { - if (scale < 0) - { - throw new IllegalArgumentException( - "The scale must be a positive integer or zero"); - } - BigDecimal b1 = new BigDecimal(Double.toString(v1)); - BigDecimal b2 = new BigDecimal(Double.toString(v2)); - if (b1.compareTo(BigDecimal.ZERO) == 0) - { - return BigDecimal.ZERO.doubleValue(); - } - return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue(); - } - - /** - * 提供精确的小数位四舍五入处理。 - * @param v 需要四舍五入的数字 - * @param scale 小数点后保留几位 - * @return 四舍五入后的结果 - */ - public static double round(double v, int scale) - { - if (scale < 0) - { - throw new IllegalArgumentException( - "The scale must be a positive integer or zero"); - } - BigDecimal b = new BigDecimal(Double.toString(v)); - BigDecimal one = new BigDecimal("1"); - return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue(); - } -} +package com.ruoyi.common.utils; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +/** + * 精确的浮点数运算 + * + * @author ruoyi + */ +public class Arith +{ + + /** 默认除法运算精度 */ + private static final int DEF_DIV_SCALE = 10; + + /** 这个类不能实例化 */ + private Arith() + { + } + + /** + * 提供精确的加法运算。 + * @param v1 被加数 + * @param v2 加数 + * @return 两个参数的和 + */ + public static double add(double v1, double v2) + { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.add(b2).doubleValue(); + } + + /** + * 提供精确的减法运算。 + * @param v1 被减数 + * @param v2 减数 + * @return 两个参数的差 + */ + public static double sub(double v1, double v2) + { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.subtract(b2).doubleValue(); + } + + /** + * 提供精确的乘法运算。 + * @param v1 被乘数 + * @param v2 乘数 + * @return 两个参数的积 + */ + public static double mul(double v1, double v2) + { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.multiply(b2).doubleValue(); + } + + /** + * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 + * 小数点以后10位,以后的数字四舍五入。 + * @param v1 被除数 + * @param v2 除数 + * @return 两个参数的商 + */ + public static double div(double v1, double v2) + { + return div(v1, v2, DEF_DIV_SCALE); + } + + /** + * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 + * 定精度,以后的数字四舍五入。 + * @param v1 被除数 + * @param v2 除数 + * @param scale 表示表示需要精确到小数点以后几位。 + * @return 两个参数的商 + */ + public static double div(double v1, double v2, int scale) + { + if (scale < 0) + { + throw new IllegalArgumentException( + "The scale must be a positive integer or zero"); + } + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + if (b1.compareTo(BigDecimal.ZERO) == 0) + { + return BigDecimal.ZERO.doubleValue(); + } + return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue(); + } + + /** + * 提供精确的小数位四舍五入处理。 + * @param v 需要四舍五入的数字 + * @param scale 小数点后保留几位 + * @return 四舍五入后的结果 + */ + public static double round(double v, int scale) + { + if (scale < 0) + { + throw new IllegalArgumentException( + "The scale must be a positive integer or zero"); + } + BigDecimal b = new BigDecimal(Double.toString(v)); + BigDecimal one = new BigDecimal("1"); + return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue(); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/DateUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/DateUtils.java index 8ff95f1b7..536cb3cf0 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -1,155 +1,155 @@ -package com.ruoyi.common.utils; - -import java.lang.management.ManagementFactory; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import org.apache.commons.lang3.time.DateFormatUtils; - -/** - * 时间工具类 - * - * @author ruoyi - */ -public class DateUtils extends org.apache.commons.lang3.time.DateUtils -{ - public static String YYYY = "yyyy"; - - public static String YYYY_MM = "yyyy-MM"; - - public static String YYYY_MM_DD = "yyyy-MM-dd"; - - public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; - - public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; - - private static String[] parsePatterns = { - "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", - "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", - "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; - - /** - * 获取当前Date型日期 - * - * @return Date() 当前日期 - */ - public static Date getNowDate() - { - return new Date(); - } - - /** - * 获取当前日期, 默认格式为yyyy-MM-dd - * - * @return String - */ - public static String getDate() - { - return dateTimeNow(YYYY_MM_DD); - } - - public static final String getTime() - { - return dateTimeNow(YYYY_MM_DD_HH_MM_SS); - } - - public static final String dateTimeNow() - { - return dateTimeNow(YYYYMMDDHHMMSS); - } - - public static final String dateTimeNow(final String format) - { - return parseDateToStr(format, new Date()); - } - - public static final String dateTime(final Date date) - { - return parseDateToStr(YYYY_MM_DD, date); - } - - public static final String parseDateToStr(final String format, final Date date) - { - return new SimpleDateFormat(format).format(date); - } - - public static final Date dateTime(final String format, final String ts) - { - try - { - return new SimpleDateFormat(format).parse(ts); - } - catch (ParseException e) - { - throw new RuntimeException(e); - } - } - - /** - * 日期路径 即年/月/日 如2018/08/08 - */ - public static final String datePath() - { - Date now = new Date(); - return DateFormatUtils.format(now, "yyyy/MM/dd"); - } - - /** - * 日期路径 即年/月/日 如20180808 - */ - public static final String dateTime() - { - Date now = new Date(); - return DateFormatUtils.format(now, "yyyyMMdd"); - } - - /** - * 日期型字符串转化为日期 格式 - */ - public static Date parseDate(Object str) - { - if (str == null) - { - return null; - } - try - { - return parseDate(str.toString(), parsePatterns); - } - catch (ParseException e) - { - return null; - } - } - - /** - * 获取服务器启动时间 - */ - public static Date getServerStartDate() - { - long time = ManagementFactory.getRuntimeMXBean().getStartTime(); - return new Date(time); - } - - /** - * 计算两个时间差 - */ - public static String getDatePoor(Date endDate, Date nowDate) - { - long nd = 1000 * 24 * 60 * 60; - long nh = 1000 * 60 * 60; - long nm = 1000 * 60; - // long ns = 1000; - // 获得两个时间的毫秒时间差异 - long diff = endDate.getTime() - nowDate.getTime(); - // 计算差多少天 - long day = diff / nd; - // 计算差多少小时 - long hour = diff % nd / nh; - // 计算差多少分钟 - long min = diff % nd % nh / nm; - // 计算差多少秒//输出结果 - // long sec = diff % nd % nh % nm / ns; - return day + "天" + hour + "小时" + min + "分钟"; - } -} +package com.ruoyi.common.utils; + +import java.lang.management.ManagementFactory; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import org.apache.commons.lang3.time.DateFormatUtils; + +/** + * 时间工具类 + * + * @author ruoyi + */ +public class DateUtils extends org.apache.commons.lang3.time.DateUtils +{ + public static String YYYY = "yyyy"; + + public static String YYYY_MM = "yyyy-MM"; + + public static String YYYY_MM_DD = "yyyy-MM-dd"; + + public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; + + public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; + + private static String[] parsePatterns = { + "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", + "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", + "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; + + /** + * 获取当前Date型日期 + * + * @return Date() 当前日期 + */ + public static Date getNowDate() + { + return new Date(); + } + + /** + * 获取当前日期, 默认格式为yyyy-MM-dd + * + * @return String + */ + public static String getDate() + { + return dateTimeNow(YYYY_MM_DD); + } + + public static final String getTime() + { + return dateTimeNow(YYYY_MM_DD_HH_MM_SS); + } + + public static final String dateTimeNow() + { + return dateTimeNow(YYYYMMDDHHMMSS); + } + + public static final String dateTimeNow(final String format) + { + return parseDateToStr(format, new Date()); + } + + public static final String dateTime(final Date date) + { + return parseDateToStr(YYYY_MM_DD, date); + } + + public static final String parseDateToStr(final String format, final Date date) + { + return new SimpleDateFormat(format).format(date); + } + + public static final Date dateTime(final String format, final String ts) + { + try + { + return new SimpleDateFormat(format).parse(ts); + } + catch (ParseException e) + { + throw new RuntimeException(e); + } + } + + /** + * 日期路径 即年/月/日 如2018/08/08 + */ + public static final String datePath() + { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyy/MM/dd"); + } + + /** + * 日期路径 即年/月/日 如20180808 + */ + public static final String dateTime() + { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyyMMdd"); + } + + /** + * 日期型字符串转化为日期 格式 + */ + public static Date parseDate(Object str) + { + if (str == null) + { + return null; + } + try + { + return parseDate(str.toString(), parsePatterns); + } + catch (ParseException e) + { + return null; + } + } + + /** + * 获取服务器启动时间 + */ + public static Date getServerStartDate() + { + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + return new Date(time); + } + + /** + * 计算两个时间差 + */ + public static String getDatePoor(Date endDate, Date nowDate) + { + long nd = 1000 * 24 * 60 * 60; + long nh = 1000 * 60 * 60; + long nm = 1000 * 60; + // long ns = 1000; + // 获得两个时间的毫秒时间差异 + long diff = endDate.getTime() - nowDate.getTime(); + // 计算差多少天 + long day = diff / nd; + // 计算差多少小时 + long hour = diff % nd / nh; + // 计算差多少分钟 + long min = diff % nd % nh / nm; + // 计算差多少秒//输出结果 + // long sec = diff % nd % nh % nm / ns; + return day + "天" + hour + "小时" + min + "分钟"; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java b/bmw-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java index 4ca52838a..ad57439b7 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java @@ -1,40 +1,40 @@ -package com.ruoyi.common.utils; - -import java.io.PrintWriter; -import java.io.StringWriter; -import org.apache.commons.lang3.exception.ExceptionUtils; - -/** - * 错误信息处理类。 - * - * @author ruoyi - */ -public class ExceptionUtil -{ - /** - * 获取exception的详细错误信息。 - */ - public static String getExceptionMessage(Throwable e) - { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw, true)); - String str = sw.toString(); - return str; - } - - public static String getRootErrorMseeage(Exception e) - { - Throwable root = ExceptionUtils.getRootCause(e); - root = (root == null ? e : root); - if (root == null) - { - return ""; - } - String msg = root.getMessage(); - if (msg == null) - { - return "null"; - } - return StringUtils.defaultString(msg); - } -} +package com.ruoyi.common.utils; + +import java.io.PrintWriter; +import java.io.StringWriter; +import org.apache.commons.lang3.exception.ExceptionUtils; + +/** + * 错误信息处理类。 + * + * @author ruoyi + */ +public class ExceptionUtil +{ + /** + * 获取exception的详细错误信息。 + */ + public static String getExceptionMessage(Throwable e) + { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw, true)); + String str = sw.toString(); + return str; + } + + public static String getRootErrorMseeage(Exception e) + { + Throwable root = ExceptionUtils.getRootCause(e); + root = (root == null ? e : root); + if (root == null) + { + return ""; + } + String msg = root.getMessage(); + if (msg == null) + { + return "null"; + } + return StringUtils.defaultString(msg); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/IpUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/IpUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/IpUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/IpUtils.java index a2a7011b0..6ef0c43f9 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/IpUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/IpUtils.java @@ -1,188 +1,188 @@ -package com.ruoyi.common.utils; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import javax.servlet.http.HttpServletRequest; - -/** - * 获取IP方法 - * - * @author ruoyi - */ -public class IpUtils -{ - public static String getIpAddr(HttpServletRequest request) - { - if (request == null) - { - return "unknown"; - } - String ip = request.getHeader("x-forwarded-for"); - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { - ip = request.getHeader("Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { - ip = request.getHeader("X-Forwarded-For"); - } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { - ip = request.getHeader("X-Real-IP"); - } - - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) - { - ip = request.getRemoteAddr(); - } - - return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip; - } - - public static boolean internalIp(String ip) - { - byte[] addr = textToNumericFormatV4(ip); - return internalIp(addr) || "127.0.0.1".equals(ip); - } - - private static boolean internalIp(byte[] addr) - { - if (StringUtils.isNull(addr) || addr.length < 2) - { - return true; - } - final byte b0 = addr[0]; - final byte b1 = addr[1]; - // 10.x.x.x/8 - final byte SECTION_1 = 0x0A; - // 172.16.x.x/12 - final byte SECTION_2 = (byte) 0xAC; - final byte SECTION_3 = (byte) 0x10; - final byte SECTION_4 = (byte) 0x1F; - // 192.168.x.x/16 - final byte SECTION_5 = (byte) 0xC0; - final byte SECTION_6 = (byte) 0xA8; - switch (b0) - { - case SECTION_1: - return true; - case SECTION_2: - if (b1 >= SECTION_3 && b1 <= SECTION_4) - { - return true; - } - case SECTION_5: - switch (b1) - { - case SECTION_6: - return true; - } - default: - return false; - } - } - - /** - * 将IPv4地址转换成字节 - * - * @param text IPv4地址 - * @return byte 字节 - */ - public static byte[] textToNumericFormatV4(String text) - { - if (text.length() == 0) - { - return null; - } - - byte[] bytes = new byte[4]; - String[] elements = text.split("\\.", -1); - try - { - long l; - int i; - switch (elements.length) - { - case 1: - l = Long.parseLong(elements[0]); - if ((l < 0L) || (l > 4294967295L)) - return null; - bytes[0] = (byte) (int) (l >> 24 & 0xFF); - bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF); - bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); - bytes[3] = (byte) (int) (l & 0xFF); - break; - case 2: - l = Integer.parseInt(elements[0]); - if ((l < 0L) || (l > 255L)) - return null; - bytes[0] = (byte) (int) (l & 0xFF); - l = Integer.parseInt(elements[1]); - if ((l < 0L) || (l > 16777215L)) - return null; - bytes[1] = (byte) (int) (l >> 16 & 0xFF); - bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); - bytes[3] = (byte) (int) (l & 0xFF); - break; - case 3: - for (i = 0; i < 2; ++i) - { - l = Integer.parseInt(elements[i]); - if ((l < 0L) || (l > 255L)) - return null; - bytes[i] = (byte) (int) (l & 0xFF); - } - l = Integer.parseInt(elements[2]); - if ((l < 0L) || (l > 65535L)) - return null; - bytes[2] = (byte) (int) (l >> 8 & 0xFF); - bytes[3] = (byte) (int) (l & 0xFF); - break; - case 4: - for (i = 0; i < 4; ++i) - { - l = Integer.parseInt(elements[i]); - if ((l < 0L) || (l > 255L)) - return null; - bytes[i] = (byte) (int) (l & 0xFF); - } - break; - default: - return null; - } - } - catch (NumberFormatException e) - { - return null; - } - return bytes; - } - - public static String getHostIp() - { - try - { - return InetAddress.getLocalHost().getHostAddress(); - } - catch (UnknownHostException e) - { - } - return "127.0.0.1"; - } - - public static String getHostName() - { - try - { - return InetAddress.getLocalHost().getHostName(); - } - catch (UnknownHostException e) - { - } - return "未知"; - } +package com.ruoyi.common.utils; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import javax.servlet.http.HttpServletRequest; + +/** + * 获取IP方法 + * + * @author ruoyi + */ +public class IpUtils +{ + public static String getIpAddr(HttpServletRequest request) + { + if (request == null) + { + return "unknown"; + } + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getHeader("X-Forwarded-For"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getHeader("X-Real-IP"); + } + + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) + { + ip = request.getRemoteAddr(); + } + + return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip; + } + + public static boolean internalIp(String ip) + { + byte[] addr = textToNumericFormatV4(ip); + return internalIp(addr) || "127.0.0.1".equals(ip); + } + + private static boolean internalIp(byte[] addr) + { + if (StringUtils.isNull(addr) || addr.length < 2) + { + return true; + } + final byte b0 = addr[0]; + final byte b1 = addr[1]; + // 10.x.x.x/8 + final byte SECTION_1 = 0x0A; + // 172.16.x.x/12 + final byte SECTION_2 = (byte) 0xAC; + final byte SECTION_3 = (byte) 0x10; + final byte SECTION_4 = (byte) 0x1F; + // 192.168.x.x/16 + final byte SECTION_5 = (byte) 0xC0; + final byte SECTION_6 = (byte) 0xA8; + switch (b0) + { + case SECTION_1: + return true; + case SECTION_2: + if (b1 >= SECTION_3 && b1 <= SECTION_4) + { + return true; + } + case SECTION_5: + switch (b1) + { + case SECTION_6: + return true; + } + default: + return false; + } + } + + /** + * 将IPv4地址转换成字节 + * + * @param text IPv4地址 + * @return byte 字节 + */ + public static byte[] textToNumericFormatV4(String text) + { + if (text.length() == 0) + { + return null; + } + + byte[] bytes = new byte[4]; + String[] elements = text.split("\\.", -1); + try + { + long l; + int i; + switch (elements.length) + { + case 1: + l = Long.parseLong(elements[0]); + if ((l < 0L) || (l > 4294967295L)) + return null; + bytes[0] = (byte) (int) (l >> 24 & 0xFF); + bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF); + bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); + bytes[3] = (byte) (int) (l & 0xFF); + break; + case 2: + l = Integer.parseInt(elements[0]); + if ((l < 0L) || (l > 255L)) + return null; + bytes[0] = (byte) (int) (l & 0xFF); + l = Integer.parseInt(elements[1]); + if ((l < 0L) || (l > 16777215L)) + return null; + bytes[1] = (byte) (int) (l >> 16 & 0xFF); + bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); + bytes[3] = (byte) (int) (l & 0xFF); + break; + case 3: + for (i = 0; i < 2; ++i) + { + l = Integer.parseInt(elements[i]); + if ((l < 0L) || (l > 255L)) + return null; + bytes[i] = (byte) (int) (l & 0xFF); + } + l = Integer.parseInt(elements[2]); + if ((l < 0L) || (l > 65535L)) + return null; + bytes[2] = (byte) (int) (l >> 8 & 0xFF); + bytes[3] = (byte) (int) (l & 0xFF); + break; + case 4: + for (i = 0; i < 4; ++i) + { + l = Integer.parseInt(elements[i]); + if ((l < 0L) || (l > 255L)) + return null; + bytes[i] = (byte) (int) (l & 0xFF); + } + break; + default: + return null; + } + } + catch (NumberFormatException e) + { + return null; + } + return bytes; + } + + public static String getHostIp() + { + try + { + return InetAddress.getLocalHost().getHostAddress(); + } + catch (UnknownHostException e) + { + } + return "127.0.0.1"; + } + + public static String getHostName() + { + try + { + return InetAddress.getLocalHost().getHostName(); + } + catch (UnknownHostException e) + { + } + return "未知"; + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapDataUtil.java b/bmw-common/src/main/java/com/ruoyi/common/utils/MapDataUtil.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/MapDataUtil.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/MapDataUtil.java index d750df45d..4ca326e7d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapDataUtil.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/MapDataUtil.java @@ -1,50 +1,50 @@ -package com.ruoyi.common.utils; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import javax.servlet.http.HttpServletRequest; - -/** - * Map通用处理方法 - * - * @author ruoyi - */ -public class MapDataUtil -{ - public static Map convertDataMap(HttpServletRequest request) - { - Map properties = request.getParameterMap(); - Map returnMap = new HashMap(); - Iterator entries = properties.entrySet().iterator(); - Map.Entry entry; - String name = ""; - String value = ""; - while (entries.hasNext()) - { - entry = (Entry) entries.next(); - name = (String) entry.getKey(); - Object valueObj = entry.getValue(); - if (null == valueObj) - { - value = ""; - } - else if (valueObj instanceof String[]) - { - String[] values = (String[]) valueObj; - for (int i = 0; i < values.length; i++) - { - value = values[i] + ","; - } - value = value.substring(0, value.length() - 1); - } - else - { - value = valueObj.toString(); - } - returnMap.put(name, value); - } - return returnMap; - } -} +package com.ruoyi.common.utils; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import javax.servlet.http.HttpServletRequest; + +/** + * Map通用处理方法 + * + * @author ruoyi + */ +public class MapDataUtil +{ + public static Map convertDataMap(HttpServletRequest request) + { + Map properties = request.getParameterMap(); + Map returnMap = new HashMap(); + Iterator entries = properties.entrySet().iterator(); + Map.Entry entry; + String name = ""; + String value = ""; + while (entries.hasNext()) + { + entry = (Entry) entries.next(); + name = (String) entry.getKey(); + Object valueObj = entry.getValue(); + if (null == valueObj) + { + value = ""; + } + else if (valueObj instanceof String[]) + { + String[] values = (String[]) valueObj; + for (int i = 0; i < values.length; i++) + { + value = values[i] + ","; + } + value = value.substring(0, value.length() - 1); + } + else + { + value = valueObj.toString(); + } + returnMap.put(name, value); + } + return returnMap; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java index 5f2d9ea24..7dac75a3b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java @@ -1,26 +1,26 @@ -package com.ruoyi.common.utils; - -import org.springframework.context.MessageSource; -import org.springframework.context.i18n.LocaleContextHolder; -import com.ruoyi.common.utils.spring.SpringUtils; - -/** - * 获取i18n资源文件 - * - * @author ruoyi - */ -public class MessageUtils -{ - /** - * 根据消息键和参数 获取消息 委托给spring messageSource - * - * @param code 消息键 - * @param args 参数 - * @return 获取国际化翻译值 - */ - public static String message(String code, Object... args) - { - MessageSource messageSource = SpringUtils.getBean(MessageSource.class); - return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); - } -} +package com.ruoyi.common.utils; + +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; +import com.ruoyi.common.utils.spring.SpringUtils; + +/** + * 获取i18n资源文件 + * + * @author ruoyi + */ +public class MessageUtils +{ + /** + * 根据消息键和参数 获取消息 委托给spring messageSource + * + * @param code 消息键 + * @param args 参数 + * @return 获取国际化翻译值 + */ + public static String message(String code, Object... args) + { + MessageSource messageSource = SpringUtils.getBean(MessageSource.class); + return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java index 451b180fe..3b1f5c848 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java @@ -1,135 +1,135 @@ -package com.ruoyi.common.utils; - -import java.io.IOException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import com.ruoyi.common.core.text.Convert; - -/** - * 客户端工具类 - * - * @author ruoyi - */ -public class ServletUtils -{ - /** - * 获取String参数 - */ - public static String getParameter(String name) - { - return getRequest().getParameter(name); - } - - /** - * 获取String参数 - */ - public static String getParameter(String name, String defaultValue) - { - return Convert.toStr(getRequest().getParameter(name), defaultValue); - } - - /** - * 获取Integer参数 - */ - public static Integer getParameterToInt(String name) - { - return Convert.toInt(getRequest().getParameter(name)); - } - - /** - * 获取Integer参数 - */ - public static Integer getParameterToInt(String name, Integer defaultValue) - { - return Convert.toInt(getRequest().getParameter(name), defaultValue); - } - - /** - * 获取request - */ - public static HttpServletRequest getRequest() - { - return getRequestAttributes().getRequest(); - } - - /** - * 获取response - */ - public static HttpServletResponse getResponse() - { - return getRequestAttributes().getResponse(); - } - - /** - * 获取session - */ - public static HttpSession getSession() - { - return getRequest().getSession(); - } - - public static ServletRequestAttributes getRequestAttributes() - { - RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); - return (ServletRequestAttributes) attributes; - } - - /** - * 将字符串渲染到客户端 - * - * @param response 渲染对象 - * @param string 待渲染的字符串 - * @return null - */ - public static String renderString(HttpServletResponse response, String string) - { - try - { - response.setContentType("application/json"); - response.setCharacterEncoding("utf-8"); - response.getWriter().print(string); - } - catch (IOException e) - { - e.printStackTrace(); - } - return null; - } - - /** - * 是否是Ajax异步请求 - * - * @param request - */ - public static boolean isAjaxRequest(HttpServletRequest request) - { - String accept = request.getHeader("accept"); - if (accept != null && accept.indexOf("application/json") != -1) - { - return true; - } - - String xRequestedWith = request.getHeader("X-Requested-With"); - if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) - { - return true; - } - - String uri = request.getRequestURI(); - if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) - { - return true; - } - - String ajax = request.getParameter("__ajax"); - if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) - { - return true; - } - return false; - } -} +package com.ruoyi.common.utils; + +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import com.ruoyi.common.core.text.Convert; + +/** + * 客户端工具类 + * + * @author ruoyi + */ +public class ServletUtils +{ + /** + * 获取String参数 + */ + public static String getParameter(String name) + { + return getRequest().getParameter(name); + } + + /** + * 获取String参数 + */ + public static String getParameter(String name, String defaultValue) + { + return Convert.toStr(getRequest().getParameter(name), defaultValue); + } + + /** + * 获取Integer参数 + */ + public static Integer getParameterToInt(String name) + { + return Convert.toInt(getRequest().getParameter(name)); + } + + /** + * 获取Integer参数 + */ + public static Integer getParameterToInt(String name, Integer defaultValue) + { + return Convert.toInt(getRequest().getParameter(name), defaultValue); + } + + /** + * 获取request + */ + public static HttpServletRequest getRequest() + { + return getRequestAttributes().getRequest(); + } + + /** + * 获取response + */ + public static HttpServletResponse getResponse() + { + return getRequestAttributes().getResponse(); + } + + /** + * 获取session + */ + public static HttpSession getSession() + { + return getRequest().getSession(); + } + + public static ServletRequestAttributes getRequestAttributes() + { + RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); + return (ServletRequestAttributes) attributes; + } + + /** + * 将字符串渲染到客户端 + * + * @param response 渲染对象 + * @param string 待渲染的字符串 + * @return null + */ + public static String renderString(HttpServletResponse response, String string) + { + try + { + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + response.getWriter().print(string); + } + catch (IOException e) + { + e.printStackTrace(); + } + return null; + } + + /** + * 是否是Ajax异步请求 + * + * @param request + */ + public static boolean isAjaxRequest(HttpServletRequest request) + { + String accept = request.getHeader("accept"); + if (accept != null && accept.indexOf("application/json") != -1) + { + return true; + } + + String xRequestedWith = request.getHeader("X-Requested-With"); + if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) + { + return true; + } + + String uri = request.getRequestURI(); + if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) + { + return true; + } + + String ajax = request.getParameter("__ajax"); + if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) + { + return true; + } + return false; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/StringUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/StringUtils.java index f7e667c90..fe39c1a93 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/StringUtils.java @@ -1,365 +1,365 @@ -package com.ruoyi.common.utils; - -import java.util.Collection; -import java.util.Map; -import com.ruoyi.common.core.text.StrFormatter; - -/** - * 字符串工具类 - * - * @author ruoyi - */ -public class StringUtils extends org.apache.commons.lang3.StringUtils -{ - /** 空字符串 */ - private static final String NULLSTR = ""; - - /** 下划线 */ - private static final char SEPARATOR = '_'; - - /** - * 获取参数不为空值 - * - * @param value defaultValue 要判断的value - * @return value 返回值 - */ - public static T nvl(T value, T defaultValue) - { - return value != null ? value : defaultValue; - } - - /** - * * 判断一个Collection是否为空, 包含List,Set,Queue - * - * @param coll 要判断的Collection - * @return true:为空 false:非空 - */ - public static boolean isEmpty(Collection coll) - { - return isNull(coll) || coll.isEmpty(); - } - - /** - * * 判断一个Collection是否非空,包含List,Set,Queue - * - * @param coll 要判断的Collection - * @return true:非空 false:空 - */ - public static boolean isNotEmpty(Collection coll) - { - return !isEmpty(coll); - } - - /** - * * 判断一个对象数组是否为空 - * - * @param objects 要判断的对象数组 - ** @return true:为空 false:非空 - */ - public static boolean isEmpty(Object[] objects) - { - return isNull(objects) || (objects.length == 0); - } - - /** - * * 判断一个对象数组是否非空 - * - * @param objects 要判断的对象数组 - * @return true:非空 false:空 - */ - public static boolean isNotEmpty(Object[] objects) - { - return !isEmpty(objects); - } - - /** - * * 判断一个Map是否为空 - * - * @param map 要判断的Map - * @return true:为空 false:非空 - */ - public static boolean isEmpty(Map map) - { - return isNull(map) || map.isEmpty(); - } - - /** - * * 判断一个Map是否为空 - * - * @param map 要判断的Map - * @return true:非空 false:空 - */ - public static boolean isNotEmpty(Map map) - { - return !isEmpty(map); - } - - /** - * * 判断一个字符串是否为空串 - * - * @param str String - * @return true:为空 false:非空 - */ - public static boolean isEmpty(String str) - { - return isNull(str) || NULLSTR.equals(str.trim()); - } - - /** - * * 判断一个字符串是否为非空串 - * - * @param str String - * @return true:非空串 false:空串 - */ - public static boolean isNotEmpty(String str) - { - return !isEmpty(str); - } - - /** - * * 判断一个对象是否为空 - * - * @param object Object - * @return true:为空 false:非空 - */ - public static boolean isNull(Object object) - { - return object == null; - } - - /** - * * 判断一个对象是否非空 - * - * @param object Object - * @return true:非空 false:空 - */ - public static boolean isNotNull(Object object) - { - return !isNull(object); - } - - /** - * * 判断一个对象是否是数组类型(Java基本型别的数组) - * - * @param object 对象 - * @return true:是数组 false:不是数组 - */ - public static boolean isArray(Object object) - { - return isNotNull(object) && object.getClass().isArray(); - } - - /** - * 去空格 - */ - public static String trim(String str) - { - return (str == null ? "" : str.trim()); - } - - /** - * 截取字符串 - * - * @param str 字符串 - * @param start 开始 - * @return 结果 - */ - public static String substring(final String str, int start) - { - if (str == null) - { - return NULLSTR; - } - - if (start < 0) - { - start = str.length() + start; - } - - if (start < 0) - { - start = 0; - } - if (start > str.length()) - { - return NULLSTR; - } - - return str.substring(start); - } - - /** - * 截取字符串 - * - * @param str 字符串 - * @param start 开始 - * @param end 结束 - * @return 结果 - */ - public static String substring(final String str, int start, int end) - { - if (str == null) - { - return NULLSTR; - } - - if (end < 0) - { - end = str.length() + end; - } - if (start < 0) - { - start = str.length() + start; - } - - if (end > str.length()) - { - end = str.length(); - } - - if (start > end) - { - return NULLSTR; - } - - if (start < 0) - { - start = 0; - } - if (end < 0) - { - end = 0; - } - - return str.substring(start, end); - } - - /** - * 格式化文本, {} 表示占位符
                            - * 此方法只是简单将占位符 {} 按照顺序替换为参数
                            - * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
                            - * 例:
                            - * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
                            - * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
                            - * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
                            - * - * @param template 文本模板,被替换的部分用 {} 表示 - * @param params 参数值 - * @return 格式化后的文本 - */ - public static String format(String template, Object... params) - { - if (isEmpty(params) || isEmpty(template)) - { - return template; - } - return StrFormatter.format(template, params); - } - - /** - * 下划线转驼峰命名 - */ - public static String toUnderScoreCase(String str) - { - if (str == null) - { - return null; - } - StringBuilder sb = new StringBuilder(); - // 前置字符是否大写 - boolean preCharIsUpperCase = true; - // 当前字符是否大写 - boolean curreCharIsUpperCase = true; - // 下一字符是否大写 - boolean nexteCharIsUpperCase = true; - for (int i = 0; i < str.length(); i++) - { - char c = str.charAt(i); - if (i > 0) - { - preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); - } - else - { - preCharIsUpperCase = false; - } - - curreCharIsUpperCase = Character.isUpperCase(c); - - if (i < (str.length() - 1)) - { - nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); - } - - if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) - { - sb.append(SEPARATOR); - } - else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) - { - sb.append(SEPARATOR); - } - sb.append(Character.toLowerCase(c)); - } - - return sb.toString(); - } - - /** - * 是否包含字符串 - * - * @param str 验证字符串 - * @param strs 字符串组 - * @return 包含返回true - */ - public static boolean inStringIgnoreCase(String str, String... strs) - { - if (str != null && strs != null) - { - for (String s : strs) - { - if (str.equalsIgnoreCase(trim(s))) - { - return true; - } - } - } - return false; - } - - /** - * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld - * - * @param name 转换前的下划线大写方式命名的字符串 - * @return 转换后的驼峰式命名的字符串 - */ - public static String convertToCamelCase(String name) - { - StringBuilder result = new StringBuilder(); - // 快速检查 - if (name == null || name.isEmpty()) - { - // 没必要转换 - return ""; - } - else if (!name.contains("_")) - { - // 不含下划线,仅将首字母大写 - return name.substring(0, 1).toUpperCase() + name.substring(1); - } - // 用下划线将原始字符串分割 - String[] camels = name.split("_"); - for (String camel : camels) - { - // 跳过原始字符串中开头、结尾的下换线或双重下划线 - if (camel.isEmpty()) - { - continue; - } - // 首字母大写 - result.append(camel.substring(0, 1).toUpperCase()); - result.append(camel.substring(1).toLowerCase()); - } - return result.toString(); - } +package com.ruoyi.common.utils; + +import java.util.Collection; +import java.util.Map; +import com.ruoyi.common.core.text.StrFormatter; + +/** + * 字符串工具类 + * + * @author ruoyi + */ +public class StringUtils extends org.apache.commons.lang3.StringUtils +{ + /** 空字符串 */ + private static final String NULLSTR = ""; + + /** 下划线 */ + private static final char SEPARATOR = '_'; + + /** + * 获取参数不为空值 + * + * @param value defaultValue 要判断的value + * @return value 返回值 + */ + public static T nvl(T value, T defaultValue) + { + return value != null ? value : defaultValue; + } + + /** + * * 判断一个Collection是否为空, 包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Collection coll) + { + return isNull(coll) || coll.isEmpty(); + } + + /** + * * 判断一个Collection是否非空,包含List,Set,Queue + * + * @param coll 要判断的Collection + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Collection coll) + { + return !isEmpty(coll); + } + + /** + * * 判断一个对象数组是否为空 + * + * @param objects 要判断的对象数组 + ** @return true:为空 false:非空 + */ + public static boolean isEmpty(Object[] objects) + { + return isNull(objects) || (objects.length == 0); + } + + /** + * * 判断一个对象数组是否非空 + * + * @param objects 要判断的对象数组 + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Object[] objects) + { + return !isEmpty(objects); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:为空 false:非空 + */ + public static boolean isEmpty(Map map) + { + return isNull(map) || map.isEmpty(); + } + + /** + * * 判断一个Map是否为空 + * + * @param map 要判断的Map + * @return true:非空 false:空 + */ + public static boolean isNotEmpty(Map map) + { + return !isEmpty(map); + } + + /** + * * 判断一个字符串是否为空串 + * + * @param str String + * @return true:为空 false:非空 + */ + public static boolean isEmpty(String str) + { + return isNull(str) || NULLSTR.equals(str.trim()); + } + + /** + * * 判断一个字符串是否为非空串 + * + * @param str String + * @return true:非空串 false:空串 + */ + public static boolean isNotEmpty(String str) + { + return !isEmpty(str); + } + + /** + * * 判断一个对象是否为空 + * + * @param object Object + * @return true:为空 false:非空 + */ + public static boolean isNull(Object object) + { + return object == null; + } + + /** + * * 判断一个对象是否非空 + * + * @param object Object + * @return true:非空 false:空 + */ + public static boolean isNotNull(Object object) + { + return !isNull(object); + } + + /** + * * 判断一个对象是否是数组类型(Java基本型别的数组) + * + * @param object 对象 + * @return true:是数组 false:不是数组 + */ + public static boolean isArray(Object object) + { + return isNotNull(object) && object.getClass().isArray(); + } + + /** + * 去空格 + */ + public static String trim(String str) + { + return (str == null ? "" : str.trim()); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @return 结果 + */ + public static String substring(final String str, int start) + { + if (str == null) + { + return NULLSTR; + } + + if (start < 0) + { + start = str.length() + start; + } + + if (start < 0) + { + start = 0; + } + if (start > str.length()) + { + return NULLSTR; + } + + return str.substring(start); + } + + /** + * 截取字符串 + * + * @param str 字符串 + * @param start 开始 + * @param end 结束 + * @return 结果 + */ + public static String substring(final String str, int start, int end) + { + if (str == null) + { + return NULLSTR; + } + + if (end < 0) + { + end = str.length() + end; + } + if (start < 0) + { + start = str.length() + start; + } + + if (end > str.length()) + { + end = str.length(); + } + + if (start > end) + { + return NULLSTR; + } + + if (start < 0) + { + start = 0; + } + if (end < 0) + { + end = 0; + } + + return str.substring(start, end); + } + + /** + * 格式化文本, {} 表示占位符
                            + * 此方法只是简单将占位符 {} 按照顺序替换为参数
                            + * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
                            + * 例:
                            + * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b
                            + * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
                            + * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b
                            + * + * @param template 文本模板,被替换的部分用 {} 表示 + * @param params 参数值 + * @return 格式化后的文本 + */ + public static String format(String template, Object... params) + { + if (isEmpty(params) || isEmpty(template)) + { + return template; + } + return StrFormatter.format(template, params); + } + + /** + * 下划线转驼峰命名 + */ + public static String toUnderScoreCase(String str) + { + if (str == null) + { + return null; + } + StringBuilder sb = new StringBuilder(); + // 前置字符是否大写 + boolean preCharIsUpperCase = true; + // 当前字符是否大写 + boolean curreCharIsUpperCase = true; + // 下一字符是否大写 + boolean nexteCharIsUpperCase = true; + for (int i = 0; i < str.length(); i++) + { + char c = str.charAt(i); + if (i > 0) + { + preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); + } + else + { + preCharIsUpperCase = false; + } + + curreCharIsUpperCase = Character.isUpperCase(c); + + if (i < (str.length() - 1)) + { + nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); + } + + if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) + { + sb.append(SEPARATOR); + } + else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) + { + sb.append(SEPARATOR); + } + sb.append(Character.toLowerCase(c)); + } + + return sb.toString(); + } + + /** + * 是否包含字符串 + * + * @param str 验证字符串 + * @param strs 字符串组 + * @return 包含返回true + */ + public static boolean inStringIgnoreCase(String str, String... strs) + { + if (str != null && strs != null) + { + for (String s : strs) + { + if (str.equalsIgnoreCase(trim(s))) + { + return true; + } + } + } + return false; + } + + /** + * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld + * + * @param name 转换前的下划线大写方式命名的字符串 + * @return 转换后的驼峰式命名的字符串 + */ + public static String convertToCamelCase(String name) + { + StringBuilder result = new StringBuilder(); + // 快速检查 + if (name == null || name.isEmpty()) + { + // 没必要转换 + return ""; + } + else if (!name.contains("_")) + { + // 不含下划线,仅将首字母大写 + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + // 用下划线将原始字符串分割 + String[] camels = name.split("_"); + for (String camel : camels) + { + // 跳过原始字符串中开头、结尾的下换线或双重下划线 + if (camel.isEmpty()) + { + continue; + } + // 首字母大写 + result.append(camel.substring(0, 1).toUpperCase()); + result.append(camel.substring(1).toLowerCase()); + } + return result.toString(); + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java b/bmw-common/src/main/java/com/ruoyi/common/utils/Threads.java similarity index 100% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/Threads.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/YamlUtil.java b/bmw-common/src/main/java/com/ruoyi/common/utils/YamlUtil.java similarity index 97% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/YamlUtil.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/YamlUtil.java index bb8a4ed68..d908233b4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/YamlUtil.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/YamlUtil.java @@ -1,87 +1,87 @@ -package com.ruoyi.common.utils; - -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedHashMap; -import java.util.Map; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.Yaml; -import com.ruoyi.common.utils.StringUtils; - -/** - * 配置处理工具类 - * - * @author yml - */ -public class YamlUtil -{ - public static Map loadYaml(String fileName) throws FileNotFoundException - { - InputStream in = YamlUtil.class.getClassLoader().getResourceAsStream(fileName); - return StringUtils.isNotEmpty(fileName) ? (LinkedHashMap) new Yaml().load(in) : null; - } - - public static void dumpYaml(String fileName, Map map) throws IOException - { - if (StringUtils.isNotEmpty(fileName)) - { - FileWriter fileWriter = new FileWriter(YamlUtil.class.getResource(fileName).getFile()); - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - Yaml yaml = new Yaml(options); - yaml.dump(map, fileWriter); - } - } - - public static Object getProperty(Map map, Object qualifiedKey) - { - if (map != null && !map.isEmpty() && qualifiedKey != null) - { - String input = String.valueOf(qualifiedKey); - if (!"".equals(input)) - { - if (input.contains(".")) - { - int index = input.indexOf("."); - String left = input.substring(0, index); - String right = input.substring(index + 1, input.length()); - return getProperty((Map) map.get(left), right); - } - else if (map.containsKey(input)) - { - return map.get(input); - } - else - { - return null; - } - } - } - return null; - } - - @SuppressWarnings("unchecked") - public static void setProperty(Map map, Object qualifiedKey, Object value) - { - if (map != null && !map.isEmpty() && qualifiedKey != null) - { - String input = String.valueOf(qualifiedKey); - if (!input.equals("")) - { - if (input.contains(".")) - { - int index = input.indexOf("."); - String left = input.substring(0, index); - String right = input.substring(index + 1, input.length()); - setProperty((Map) map.get(left), right, value); - } - else - { - ((Map) map).put(qualifiedKey, value); - } - } - } - } +package com.ruoyi.common.utils; + +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.util.LinkedHashMap; +import java.util.Map; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.Yaml; +import com.ruoyi.common.utils.StringUtils; + +/** + * 配置处理工具类 + * + * @author yml + */ +public class YamlUtil +{ + public static Map loadYaml(String fileName) throws FileNotFoundException + { + InputStream in = YamlUtil.class.getClassLoader().getResourceAsStream(fileName); + return StringUtils.isNotEmpty(fileName) ? (LinkedHashMap) new Yaml().load(in) : null; + } + + public static void dumpYaml(String fileName, Map map) throws IOException + { + if (StringUtils.isNotEmpty(fileName)) + { + FileWriter fileWriter = new FileWriter(YamlUtil.class.getResource(fileName).getFile()); + DumperOptions options = new DumperOptions(); + options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + Yaml yaml = new Yaml(options); + yaml.dump(map, fileWriter); + } + } + + public static Object getProperty(Map map, Object qualifiedKey) + { + if (map != null && !map.isEmpty() && qualifiedKey != null) + { + String input = String.valueOf(qualifiedKey); + if (!"".equals(input)) + { + if (input.contains(".")) + { + int index = input.indexOf("."); + String left = input.substring(0, index); + String right = input.substring(index + 1, input.length()); + return getProperty((Map) map.get(left), right); + } + else if (map.containsKey(input)) + { + return map.get(input); + } + else + { + return null; + } + } + } + return null; + } + + @SuppressWarnings("unchecked") + public static void setProperty(Map map, Object qualifiedKey, Object value) + { + if (map != null && !map.isEmpty() && qualifiedKey != null) + { + String input = String.valueOf(qualifiedKey); + if (!input.equals("")) + { + if (input.contains(".")) + { + int index = input.indexOf("."); + String left = input.substring(0, index); + String right = input.substring(index + 1, input.length()); + setProperty((Map) map.get(left), right, value); + } + else + { + ((Map) map).put(qualifiedKey, value); + } + } + } + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java index 51cdc2fb1..4463662d4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java @@ -1,110 +1,110 @@ -package com.ruoyi.common.utils.bean; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Bean 工具类 - * - * @author ruoyi - */ -public class BeanUtils extends org.springframework.beans.BeanUtils -{ - /** Bean方法名中属性名开始的下标 */ - private static final int BEAN_METHOD_PROP_INDEX = 3; - - /** * 匹配getter方法的正则表达式 */ - private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); - - /** * 匹配setter方法的正则表达式 */ - private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); - - /** - * Bean属性复制工具方法。 - * - * @param dest 目标对象 - * @param src 源对象 - */ - public static void copyBeanProp(Object dest, Object src) - { - try - { - copyProperties(src, dest); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - /** - * 获取对象的setter方法。 - * - * @param obj 对象 - * @return 对象的setter方法列表 - */ - public static List getSetterMethods(Object obj) - { - // setter方法列表 - List setterMethods = new ArrayList(); - - // 获取所有方法 - Method[] methods = obj.getClass().getMethods(); - - // 查找setter方法 - - for (Method method : methods) - { - Matcher m = SET_PATTERN.matcher(method.getName()); - if (m.matches() && (method.getParameterTypes().length == 1)) - { - setterMethods.add(method); - } - } - // 返回setter方法列表 - return setterMethods; - } - - /** - * 获取对象的getter方法。 - * - * @param obj 对象 - * @return 对象的getter方法列表 - */ - - public static List getGetterMethods(Object obj) - { - // getter方法列表 - List getterMethods = new ArrayList(); - // 获取所有方法 - Method[] methods = obj.getClass().getMethods(); - // 查找getter方法 - for (Method method : methods) - { - Matcher m = GET_PATTERN.matcher(method.getName()); - if (m.matches() && (method.getParameterTypes().length == 0)) - { - getterMethods.add(method); - } - } - // 返回getter方法列表 - return getterMethods; - } - - /** - * 检查Bean方法名中的属性名是否相等。
                            - * 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。 - * - * @param m1 方法名1 - * @param m2 方法名2 - * @return 属性名一样返回true,否则返回false - */ - - public static boolean isMethodPropEquals(String m1, String m2) - { - return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); - } -} +package com.ruoyi.common.utils.bean; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Bean 工具类 + * + * @author ruoyi + */ +public class BeanUtils extends org.springframework.beans.BeanUtils +{ + /** Bean方法名中属性名开始的下标 */ + private static final int BEAN_METHOD_PROP_INDEX = 3; + + /** * 匹配getter方法的正则表达式 */ + private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); + + /** * 匹配setter方法的正则表达式 */ + private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); + + /** + * Bean属性复制工具方法。 + * + * @param dest 目标对象 + * @param src 源对象 + */ + public static void copyBeanProp(Object dest, Object src) + { + try + { + copyProperties(src, dest); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * 获取对象的setter方法。 + * + * @param obj 对象 + * @return 对象的setter方法列表 + */ + public static List getSetterMethods(Object obj) + { + // setter方法列表 + List setterMethods = new ArrayList(); + + // 获取所有方法 + Method[] methods = obj.getClass().getMethods(); + + // 查找setter方法 + + for (Method method : methods) + { + Matcher m = SET_PATTERN.matcher(method.getName()); + if (m.matches() && (method.getParameterTypes().length == 1)) + { + setterMethods.add(method); + } + } + // 返回setter方法列表 + return setterMethods; + } + + /** + * 获取对象的getter方法。 + * + * @param obj 对象 + * @return 对象的getter方法列表 + */ + + public static List getGetterMethods(Object obj) + { + // getter方法列表 + List getterMethods = new ArrayList(); + // 获取所有方法 + Method[] methods = obj.getClass().getMethods(); + // 查找getter方法 + for (Method method : methods) + { + Matcher m = GET_PATTERN.matcher(method.getName()); + if (m.matches() && (method.getParameterTypes().length == 0)) + { + getterMethods.add(method); + } + } + // 返回getter方法列表 + return getterMethods; + } + + /** + * 检查Bean方法名中的属性名是否相等。
                            + * 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。 + * + * @param m1 方法名1 + * @param m2 方法名2 + * @return 属性名一样返回true,否则返回false + */ + + public static boolean isMethodPropEquals(String m1, String m2) + { + return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index 6190a566b..dfe7e17eb 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -1,242 +1,242 @@ -package com.ruoyi.common.utils.file; - -import java.io.File; -import java.io.IOException; -import org.apache.commons.io.FilenameUtils; -import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.common.config.Global; -import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException; -import com.ruoyi.common.exception.file.FileSizeLimitExceededException; -import com.ruoyi.common.exception.file.InvalidExtensionException; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.security.Md5Utils; - -/** - * 文件上传工具类 - * - * @author ruoyi - */ -public class FileUploadUtils -{ - /** - * 默认大小 50M - */ - public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024; - - /** - * 默认的文件名最大长度 100 - */ - public static final int DEFAULT_FILE_NAME_LENGTH = 100; - - /** - * 默认上传的地址 - */ - private static String defaultBaseDir = Global.getProfile(); - - private static int counter = 0; - - public static void setDefaultBaseDir(String defaultBaseDir) - { - FileUploadUtils.defaultBaseDir = defaultBaseDir; - } - - public static String getDefaultBaseDir() - { - return defaultBaseDir; - } - - /** - * 以默认配置进行文件上传 - * - * @param file 上传的文件 - * @return 文件名称 - * @throws Exception - */ - public static final String upload(MultipartFile file) throws IOException - { - try - { - return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); - } - catch (Exception e) - { - throw new IOException(e.getMessage(), e); - } - } - - /** - * 根据文件路径上传 - * - * @param baseDir 相对应用的基目录 - * @param file 上传的文件 - * @return 文件名称 - * @throws IOException - */ - public static final String upload(String baseDir, MultipartFile file) throws IOException - { - try - { - return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); - } - catch (Exception e) - { - throw new IOException(e.getMessage(), e); - } - } - - /** - * 文件上传 - * - * @param baseDir 相对应用的基目录 - * @param file 上传的文件 - * @param extension 上传文件类型 - * @return 返回上传成功的文件名 - * @throws FileSizeLimitExceededException 如果超出最大大小 - * @throws FileNameLengthLimitExceededException 文件名太长 - * @throws IOException 比如读写文件出错时 - * @throws InvalidExtensionException 文件校验异常 - */ - public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) - throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, - InvalidExtensionException - { - int fileNamelength = file.getOriginalFilename().length(); - if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) - { - throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); - } - - assertAllowed(file, allowedExtension); - - String fileName = extractFilename(file); - - File desc = getAbsoluteFile(baseDir, fileName); - file.transferTo(desc); - String pathFileName = getPathFileName(baseDir, fileName); - return pathFileName; - } - - /** - * 编码文件名 - */ - public static final String extractFilename(MultipartFile file) - { - String fileName = file.getOriginalFilename(); - String extension = getExtension(file); - fileName = DateUtils.datePath() + "/" + encodingFilename(fileName) + "." + extension; - return fileName; - } - - private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException - { - File desc = new File(uploadDir + File.separator + fileName); - - if (!desc.getParentFile().exists()) - { - desc.getParentFile().mkdirs(); - } - if (!desc.exists()) - { - desc.createNewFile(); - } - return desc; - } - - private static final String getPathFileName(String uploadDir, String fileName) throws IOException - { - int dirLastIndex = uploadDir.lastIndexOf("/") + 1; - String currentDir = StringUtils.substring(uploadDir, dirLastIndex); - String pathFileName = "/profile/" + currentDir + "/" + fileName; - return pathFileName; - } - - /** - * 编码文件名 - */ - private static final String encodingFilename(String fileName) - { - fileName = fileName.replace("_", " "); - fileName = Md5Utils.hash(fileName + System.nanoTime() + counter++); - return fileName; - } - - /** - * 文件大小校验 - * - * @param file 上传的文件 - * @return - * @throws FileSizeLimitExceededException 如果超出最大大小 - * @throws InvalidExtensionException - */ - public static final void assertAllowed(MultipartFile file, String[] allowedExtension) - throws FileSizeLimitExceededException, InvalidExtensionException - { - long size = file.getSize(); - if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE) - { - throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); - } - - String fileName = file.getOriginalFilename(); - String extension = getExtension(file); - if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) - { - if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) - { - throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, - fileName); - } - else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) - { - throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, - fileName); - } - else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) - { - throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, - fileName); - } - else - { - throw new InvalidExtensionException(allowedExtension, extension, fileName); - } - } - - } - - /** - * 判断MIME类型是否是允许的MIME类型 - * - * @param extension - * @param allowedExtension - * @return - */ - public static final boolean isAllowedExtension(String extension, String[] allowedExtension) - { - for (String str : allowedExtension) - { - if (str.equalsIgnoreCase(extension)) - { - return true; - } - } - return false; - } - - /** - * 获取文件名的后缀 - * - * @param file 表单文件 - * @return 后缀名 - */ - public static final String getExtension(MultipartFile file) - { - String extension = FilenameUtils.getExtension(file.getOriginalFilename()); - if (StringUtils.isEmpty(extension)) - { - extension = MimeTypeUtils.getExtension(file.getContentType()); - } - return extension; - } +package com.ruoyi.common.utils.file; + +import java.io.File; +import java.io.IOException; +import org.apache.commons.io.FilenameUtils; +import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.config.Global; +import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException; +import com.ruoyi.common.exception.file.FileSizeLimitExceededException; +import com.ruoyi.common.exception.file.InvalidExtensionException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.security.Md5Utils; + +/** + * 文件上传工具类 + * + * @author ruoyi + */ +public class FileUploadUtils +{ + /** + * 默认大小 50M + */ + public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024; + + /** + * 默认的文件名最大长度 100 + */ + public static final int DEFAULT_FILE_NAME_LENGTH = 100; + + /** + * 默认上传的地址 + */ + private static String defaultBaseDir = Global.getProfile(); + + private static int counter = 0; + + public static void setDefaultBaseDir(String defaultBaseDir) + { + FileUploadUtils.defaultBaseDir = defaultBaseDir; + } + + public static String getDefaultBaseDir() + { + return defaultBaseDir; + } + + /** + * 以默认配置进行文件上传 + * + * @param file 上传的文件 + * @return 文件名称 + * @throws Exception + */ + public static final String upload(MultipartFile file) throws IOException + { + try + { + return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } + catch (Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 根据文件路径上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @return 文件名称 + * @throws IOException + */ + public static final String upload(String baseDir, MultipartFile file) throws IOException + { + try + { + return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + } + catch (Exception e) + { + throw new IOException(e.getMessage(), e); + } + } + + /** + * 文件上传 + * + * @param baseDir 相对应用的基目录 + * @param file 上传的文件 + * @param extension 上传文件类型 + * @return 返回上传成功的文件名 + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws FileNameLengthLimitExceededException 文件名太长 + * @throws IOException 比如读写文件出错时 + * @throws InvalidExtensionException 文件校验异常 + */ + public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) + throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, + InvalidExtensionException + { + int fileNamelength = file.getOriginalFilename().length(); + if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) + { + throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); + } + + assertAllowed(file, allowedExtension); + + String fileName = extractFilename(file); + + File desc = getAbsoluteFile(baseDir, fileName); + file.transferTo(desc); + String pathFileName = getPathFileName(baseDir, fileName); + return pathFileName; + } + + /** + * 编码文件名 + */ + public static final String extractFilename(MultipartFile file) + { + String fileName = file.getOriginalFilename(); + String extension = getExtension(file); + fileName = DateUtils.datePath() + "/" + encodingFilename(fileName) + "." + extension; + return fileName; + } + + private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException + { + File desc = new File(uploadDir + File.separator + fileName); + + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + if (!desc.exists()) + { + desc.createNewFile(); + } + return desc; + } + + private static final String getPathFileName(String uploadDir, String fileName) throws IOException + { + int dirLastIndex = uploadDir.lastIndexOf("/") + 1; + String currentDir = StringUtils.substring(uploadDir, dirLastIndex); + String pathFileName = "/profile/" + currentDir + "/" + fileName; + return pathFileName; + } + + /** + * 编码文件名 + */ + private static final String encodingFilename(String fileName) + { + fileName = fileName.replace("_", " "); + fileName = Md5Utils.hash(fileName + System.nanoTime() + counter++); + return fileName; + } + + /** + * 文件大小校验 + * + * @param file 上传的文件 + * @return + * @throws FileSizeLimitExceededException 如果超出最大大小 + * @throws InvalidExtensionException + */ + public static final void assertAllowed(MultipartFile file, String[] allowedExtension) + throws FileSizeLimitExceededException, InvalidExtensionException + { + long size = file.getSize(); + if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE) + { + throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); + } + + String fileName = file.getOriginalFilename(); + String extension = getExtension(file); + if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) + { + if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) + { + throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, + fileName); + } + else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) + { + throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, + fileName); + } + else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) + { + throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, + fileName); + } + else + { + throw new InvalidExtensionException(allowedExtension, extension, fileName); + } + } + + } + + /** + * 判断MIME类型是否是允许的MIME类型 + * + * @param extension + * @param allowedExtension + * @return + */ + public static final boolean isAllowedExtension(String extension, String[] allowedExtension) + { + for (String str : allowedExtension) + { + if (str.equalsIgnoreCase(extension)) + { + return true; + } + } + return false; + } + + /** + * 获取文件名的后缀 + * + * @param file 表单文件 + * @return 后缀名 + */ + public static final String getExtension(MultipartFile file) + { + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + if (StringUtils.isEmpty(extension)) + { + extension = MimeTypeUtils.getExtension(file.getContentType()); + } + return extension; + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java index 03f5aa2a2..04d4703f8 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -1,142 +1,142 @@ -package com.ruoyi.common.utils.file; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import javax.servlet.http.HttpServletRequest; - -/** - * 文件处理工具类 - * - * @author ruoyi - */ -public class FileUtils -{ - public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; - - /** - * 输出指定文件的byte数组 - * - * @param filePath 文件路径 - * @param os 输出流 - * @return - */ - public static void writeBytes(String filePath, OutputStream os) throws IOException - { - FileInputStream fis = null; - try - { - File file = new File(filePath); - if (!file.exists()) - { - throw new FileNotFoundException(filePath); - } - fis = new FileInputStream(file); - byte[] b = new byte[1024]; - int length; - while ((length = fis.read(b)) > 0) - { - os.write(b, 0, length); - } - } - catch (IOException e) - { - throw e; - } - finally - { - if (os != null) - { - try - { - os.close(); - } - catch (IOException e1) - { - e1.printStackTrace(); - } - } - if (fis != null) - { - try - { - fis.close(); - } - catch (IOException e1) - { - e1.printStackTrace(); - } - } - } - } - - /** - * 删除文件 - * - * @param filePath 文件 - * @return - */ - public static boolean deleteFile(String filePath) - { - boolean flag = false; - File file = new File(filePath); - // 路径为文件且不为空则进行删除 - if (file.isFile() && file.exists()) - { - file.delete(); - flag = true; - } - return flag; - } - - /** - * 文件名称验证 - * - * @param filename 文件名称 - * @return true 正常 false 非法 - */ - public static boolean isValidFilename(String filename) - { - return filename.matches(FILENAME_PATTERN); - } - - /** - * 下载文件名重新编码 - * - * @param request 请求对象 - * @param fileName 文件名 - * @return 编码后的文件名 - */ - public static String setFileDownloadHeader(HttpServletRequest request, String fileName) - throws UnsupportedEncodingException - { - final String agent = request.getHeader("USER-AGENT"); - String filename = fileName; - if (agent.contains("MSIE")) - { - // IE浏览器 - filename = URLEncoder.encode(filename, "utf-8"); - filename = filename.replace("+", " "); - } - else if (agent.contains("Firefox")) - { - // 火狐浏览器 - filename = new String(fileName.getBytes(), "ISO8859-1"); - } - else if (agent.contains("Chrome")) - { - // google浏览器 - filename = URLEncoder.encode(filename, "utf-8"); - } - else - { - // 其它浏览器 - filename = URLEncoder.encode(filename, "utf-8"); - } - return filename; - } -} +package com.ruoyi.common.utils.file; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import javax.servlet.http.HttpServletRequest; + +/** + * 文件处理工具类 + * + * @author ruoyi + */ +public class FileUtils +{ + public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; + + /** + * 输出指定文件的byte数组 + * + * @param filePath 文件路径 + * @param os 输出流 + * @return + */ + public static void writeBytes(String filePath, OutputStream os) throws IOException + { + FileInputStream fis = null; + try + { + File file = new File(filePath); + if (!file.exists()) + { + throw new FileNotFoundException(filePath); + } + fis = new FileInputStream(file); + byte[] b = new byte[1024]; + int length; + while ((length = fis.read(b)) > 0) + { + os.write(b, 0, length); + } + } + catch (IOException e) + { + throw e; + } + finally + { + if (os != null) + { + try + { + os.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + } + if (fis != null) + { + try + { + fis.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + } + } + } + + /** + * 删除文件 + * + * @param filePath 文件 + * @return + */ + public static boolean deleteFile(String filePath) + { + boolean flag = false; + File file = new File(filePath); + // 路径为文件且不为空则进行删除 + if (file.isFile() && file.exists()) + { + file.delete(); + flag = true; + } + return flag; + } + + /** + * 文件名称验证 + * + * @param filename 文件名称 + * @return true 正常 false 非法 + */ + public static boolean isValidFilename(String filename) + { + return filename.matches(FILENAME_PATTERN); + } + + /** + * 下载文件名重新编码 + * + * @param request 请求对象 + * @param fileName 文件名 + * @return 编码后的文件名 + */ + public static String setFileDownloadHeader(HttpServletRequest request, String fileName) + throws UnsupportedEncodingException + { + final String agent = request.getHeader("USER-AGENT"); + String filename = fileName; + if (agent.contains("MSIE")) + { + // IE浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + filename = filename.replace("+", " "); + } + else if (agent.contains("Firefox")) + { + // 火狐浏览器 + filename = new String(fileName.getBytes(), "ISO8859-1"); + } + else if (agent.contains("Chrome")) + { + // google浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + } + else + { + // 其它浏览器 + filename = URLEncoder.encode(filename, "utf-8"); + } + return filename; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java similarity index 100% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java similarity index 97% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java index 323dbc1a3..a0275185b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java @@ -1,248 +1,248 @@ -package com.ruoyi.common.utils.http; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.net.ConnectException; -import java.net.SocketTimeoutException; -import java.net.URL; -import java.net.URLConnection; -import java.security.cert.X509Certificate; -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 通用http发送方法 - * - * @author ruoyi - */ -public class HttpUtils -{ - private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); - - /** - * 向指定 URL 发送GET方法的请求 - * - * @param url 发送请求的 URL - * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 - * @return 所代表远程资源的响应结果 - */ - public static String sendGet(String url, String param) - { - StringBuilder result = new StringBuilder(); - BufferedReader in = null; - try - { - String urlNameString = url + "?" + param; - log.info("sendGet - {}", urlNameString); - URL realUrl = new URL(urlNameString); - URLConnection connection = realUrl.openConnection(); - connection.setRequestProperty("accept", "*/*"); - connection.setRequestProperty("connection", "Keep-Alive"); - connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); - connection.connect(); - in = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String line; - while ((line = in.readLine()) != null) - { - result.append(line); - } - log.info("recv - {}", result); - } - catch (ConnectException e) - { - log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { - log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { - log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { - log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e); - } - finally - { - try - { - if (in != null) - { - in.close(); - } - } - catch (Exception ex) - { - log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); - } - } - return result.toString(); - } - - /** - * 向指定 URL 发送POST方法的请求 - * - * @param url 发送请求的 URL - * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 - * @return 所代表远程资源的响应结果 - */ - public static String sendPost(String url, String param) - { - PrintWriter out = null; - BufferedReader in = null; - StringBuilder result = new StringBuilder(); - try - { - String urlNameString = url + "?" + param; - log.info("sendPost - {}", urlNameString); - URL realUrl = new URL(urlNameString); - URLConnection conn = realUrl.openConnection(); - conn.setRequestProperty("accept", "*/*"); - conn.setRequestProperty("connection", "Keep-Alive"); - conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); - conn.setRequestProperty("Accept-Charset", "utf-8"); - conn.setRequestProperty("contentType", "utf-8"); - conn.setDoOutput(true); - conn.setDoInput(true); - out = new PrintWriter(conn.getOutputStream()); - out.print(param); - out.flush(); - in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); - String line; - while ((line = in.readLine()) != null) - { - result.append(line); - } - log.info("recv - {}", result); - } - catch (ConnectException e) - { - log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { - log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { - log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { - log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); - } - finally - { - try - { - if (out != null) - { - out.close(); - } - if (in != null) - { - in.close(); - } - } - catch (IOException ex) - { - log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); - } - } - return result.toString(); - } - - public static String sendSSLPost(String url, String param) - { - StringBuilder result = new StringBuilder(); - String urlNameString = url + "?" + param; - try - { - log.info("sendSSLPost - {}", urlNameString); - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); - URL console = new URL(urlNameString); - HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); - conn.setRequestProperty("accept", "*/*"); - conn.setRequestProperty("connection", "Keep-Alive"); - conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); - conn.setRequestProperty("Accept-Charset", "utf-8"); - conn.setRequestProperty("contentType", "utf-8"); - conn.setDoOutput(true); - conn.setDoInput(true); - - conn.setSSLSocketFactory(sc.getSocketFactory()); - conn.setHostnameVerifier(new TrustAnyHostnameVerifier()); - conn.connect(); - InputStream is = conn.getInputStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - String ret = ""; - while ((ret = br.readLine()) != null) - { - if (ret != null && !ret.trim().equals("")) - { - result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8")); - } - } - log.info("recv - {}", result); - conn.disconnect(); - br.close(); - } - catch (ConnectException e) - { - log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e); - } - catch (SocketTimeoutException e) - { - log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e); - } - catch (IOException e) - { - log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e); - } - catch (Exception e) - { - log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e); - } - return result.toString(); - } - - private static class TrustAnyTrustManager implements X509TrustManager - { - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) - { - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) - { - } - - @Override - public X509Certificate[] getAcceptedIssuers() - { - return new X509Certificate[] {}; - } - } - - private static class TrustAnyHostnameVerifier implements HostnameVerifier - { - @Override - public boolean verify(String hostname, SSLSession session) - { - return true; - } - } +package com.ruoyi.common.utils.http; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.ConnectException; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.net.URLConnection; +import java.security.cert.X509Certificate; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 通用http发送方法 + * + * @author ruoyi + */ +public class HttpUtils +{ + private static final Logger log = LoggerFactory.getLogger(HttpUtils.class); + + /** + * 向指定 URL 发送GET方法的请求 + * + * @param url 发送请求的 URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) + { + StringBuilder result = new StringBuilder(); + BufferedReader in = null; + try + { + String urlNameString = url + "?" + param; + log.info("sendGet - {}", urlNameString); + URL realUrl = new URL(urlNameString); + URLConnection connection = realUrl.openConnection(); + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + connection.connect(); + in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) + { + result.append(line); + } + log.info("recv - {}", result); + } + catch (ConnectException e) + { + log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) + { + log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) + { + log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) + { + log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e); + } + finally + { + try + { + if (in != null) + { + in.close(); + } + } + catch (Exception ex) + { + log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); + } + } + return result.toString(); + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url 发送请求的 URL + * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) + { + PrintWriter out = null; + BufferedReader in = null; + StringBuilder result = new StringBuilder(); + try + { + String urlNameString = url + "?" + param; + log.info("sendPost - {}", urlNameString); + URL realUrl = new URL(urlNameString); + URLConnection conn = realUrl.openConnection(); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + conn.setRequestProperty("Accept-Charset", "utf-8"); + conn.setRequestProperty("contentType", "utf-8"); + conn.setDoOutput(true); + conn.setDoInput(true); + out = new PrintWriter(conn.getOutputStream()); + out.print(param); + out.flush(); + in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); + String line; + while ((line = in.readLine()) != null) + { + result.append(line); + } + log.info("recv - {}", result); + } + catch (ConnectException e) + { + log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) + { + log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) + { + log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) + { + log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e); + } + finally + { + try + { + if (out != null) + { + out.close(); + } + if (in != null) + { + in.close(); + } + } + catch (IOException ex) + { + log.error("调用in.close Exception, url=" + url + ",param=" + param, ex); + } + } + return result.toString(); + } + + public static String sendSSLPost(String url, String param) + { + StringBuilder result = new StringBuilder(); + String urlNameString = url + "?" + param; + try + { + log.info("sendSSLPost - {}", urlNameString); + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); + URL console = new URL(urlNameString); + HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + conn.setRequestProperty("Accept-Charset", "utf-8"); + conn.setRequestProperty("contentType", "utf-8"); + conn.setDoOutput(true); + conn.setDoInput(true); + + conn.setSSLSocketFactory(sc.getSocketFactory()); + conn.setHostnameVerifier(new TrustAnyHostnameVerifier()); + conn.connect(); + InputStream is = conn.getInputStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String ret = ""; + while ((ret = br.readLine()) != null) + { + if (ret != null && !ret.trim().equals("")) + { + result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8")); + } + } + log.info("recv - {}", result); + conn.disconnect(); + br.close(); + } + catch (ConnectException e) + { + log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e); + } + catch (SocketTimeoutException e) + { + log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e); + } + catch (IOException e) + { + log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e); + } + catch (Exception e) + { + log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e); + } + return result.toString(); + } + + private static class TrustAnyTrustManager implements X509TrustManager + { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) + { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) + { + } + + @Override + public X509Certificate[] getAcceptedIssuers() + { + return new X509Certificate[] {}; + } + } + + private static class TrustAnyHostnameVerifier implements HostnameVerifier + { + @Override + public boolean verify(String hostname, SSLSession session) + { + return true; + } + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/bmw-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index bb47fba37..3cd26e1a9 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -1,825 +1,825 @@ -package com.ruoyi.common.utils.poi; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; -import org.apache.poi.hssf.usermodel.HSSFFont; -import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.DataValidation; -import org.apache.poi.ss.usermodel.DataValidationConstraint; -import org.apache.poi.ss.usermodel.DataValidationHelper; -import org.apache.poi.ss.usermodel.DateUtil; -import org.apache.poi.ss.usermodel.FillPatternType; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.HorizontalAlignment; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.VerticalAlignment; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.apache.poi.ss.util.CellRangeAddressList; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.apache.poi.xssf.usermodel.XSSFDataValidation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.annotation.Excel.Type; -import com.ruoyi.common.annotation.Excels; -import com.ruoyi.common.config.Global; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.reflect.ReflectUtils; - -/** - * Excel相关处理 - * - * @author ruoyi - */ -public class ExcelUtil -{ - private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); - - /** - * Excel sheet最大行数,默认65536 - */ - public static final int sheetSize = 65536; - - /** - * 工作表名称 - */ - private String sheetName; - - /** - * 导出类型(EXPORT:导出数据;IMPORT:导入模板) - */ - private Type type; - - /** - * 工作薄对象 - */ - private Workbook wb; - - /** - * 工作表对象 - */ - private Sheet sheet; - - /** - * 导入导出数据列表 - */ - private List list; - - /** - * 注解列表 - */ - private List fields; - - /** - * 实体对象 - */ - public Class clazz; - - public ExcelUtil(Class clazz) - { - this.clazz = clazz; - } - - public void init(List list, String sheetName, Type type) - { - if (list == null) - { - list = new ArrayList(); - } - this.list = list; - this.sheetName = sheetName; - this.type = type; - createExcelField(); - createWorkbook(); - } - - /** - * 对excel表单默认第一个索引名转换成list - * - * @param input 输入流 - * @return 转换后集合 - */ - public List importExcel(InputStream is) throws Exception - { - return importExcel(StringUtils.EMPTY, is); - } - - /** - * 对excel表单指定表格索引名转换成list - * - * @param sheetName 表格索引名 - * @param input 输入流 - * @return 转换后集合 - */ - public List importExcel(String sheetName, InputStream is) throws Exception - { - this.type = Type.IMPORT; - this.wb = WorkbookFactory.create(is); - List list = new ArrayList(); - Sheet sheet = null; - if (StringUtils.isNotEmpty(sheetName)) - { - // 如果指定sheet名,则取指定sheet中的内容. - sheet = wb.getSheet(sheetName); - } - else - { - // 如果传入的sheet名不存在则默认指向第1个sheet. - sheet = wb.getSheetAt(0); - } - - if (sheet == null) - { - throw new IOException("文件sheet不存在"); - } - - int rows = sheet.getPhysicalNumberOfRows(); - - if (rows > 0) - { - // 定义一个map用于存放excel列的序号和field. - Map cellMap = new HashMap(); - // 获取表头 - Row heard = sheet.getRow(0); - for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) - { - Cell cell = heard.getCell(i); - if (StringUtils.isNotNull(cell != null)) - { - String value = this.getCellValue(heard, i).toString(); - cellMap.put(value, i); - } - else - { - cellMap.put(null, i); - } - } - // 有数据时才处理 得到类的所有field. - Field[] allFields = clazz.getDeclaredFields(); - // 定义一个map用于存放列的序号和field. - Map fieldsMap = new HashMap(); - for (int col = 0; col < allFields.length; col++) - { - Field field = allFields[col]; - Excel attr = field.getAnnotation(Excel.class); - if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) - { - // 设置类的私有字段属性可访问. - field.setAccessible(true); - Integer column = cellMap.get(attr.name()); - fieldsMap.put(column, field); - } - } - for (int i = 1; i < rows; i++) - { - // 从第2行开始取数据,默认第一行是表头. - Row row = sheet.getRow(i); - T entity = null; - for (Map.Entry entry : fieldsMap.entrySet()) - { - Object val = this.getCellValue(row, entry.getKey()); - - // 如果不存在实例则新建. - entity = (entity == null ? clazz.newInstance() : entity); - // 从map中得到对应列的field. - Field field = fieldsMap.get(entry.getKey()); - // 取得类型,并根据对象类型设置值. - Class fieldType = field.getType(); - if (String.class == fieldType) - { - String s = Convert.toStr(val); - if (StringUtils.endsWith(s, ".0")) - { - val = StringUtils.substringBefore(s, ".0"); - } - else - { - val = Convert.toStr(val); - } - } - else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) - { - val = Convert.toInt(val); - } - else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) - { - val = Convert.toLong(val); - } - else if ((Double.TYPE == fieldType) || (Double.class == fieldType)) - { - val = Convert.toDouble(val); - } - else if ((Float.TYPE == fieldType) || (Float.class == fieldType)) - { - val = Convert.toFloat(val); - } - else if (BigDecimal.class == fieldType) - { - val = Convert.toBigDecimal(val); - } - else if (Date.class == fieldType) - { - if (val instanceof String) - { - val = DateUtils.parseDate(val); - } - else if (val instanceof Double) - { - val = DateUtil.getJavaDate((Double) val); - } - } - if (StringUtils.isNotNull(fieldType)) - { - Excel attr = field.getAnnotation(Excel.class); - String propertyName = field.getName(); - if (StringUtils.isNotEmpty(attr.targetAttr())) - { - propertyName = field.getName() + "." + attr.targetAttr(); - } - else if (StringUtils.isNotEmpty(attr.readConverterExp())) - { - val = reverseByExp(String.valueOf(val), attr.readConverterExp()); - } - ReflectUtils.invokeSetter(entity, propertyName, val); - } - } - list.add(entity); - } - } - return list; - } - - /** - * 对list数据源将其里面的数据导入到excel表单 - * - * @param list 导出数据集合 - * @param sheetName 工作表的名称 - * @return 结果 - */ - public AjaxResult exportExcel(List list, String sheetName) - { - this.init(list, sheetName, Type.EXPORT); - return exportExcel(); - } - - /** - * 对list数据源将其里面的数据导入到excel表单 - * - * @param sheetName 工作表的名称 - * @return 结果 - */ - public AjaxResult importTemplateExcel(String sheetName) - { - this.init(null, sheetName, Type.IMPORT); - return exportExcel(); - } - - /** - * 对list数据源将其里面的数据导入到excel表单 - * - * @return 结果 - */ - public AjaxResult exportExcel() - { - OutputStream out = null; - try - { - // 取出一共有多少个sheet. - double sheetNo = Math.ceil(list.size() / sheetSize); - for (int index = 0; index <= sheetNo; index++) - { - createSheet(sheetNo, index); - - // 产生一行 - Row row = sheet.createRow(0); - int column = 0; - // 写入各个字段的列头名称 - for (Object[] os : fields) - { - Excel excel = (Excel) os[1]; - this.createCell(excel, row, column++); - } - if (Type.EXPORT.equals(type)) - { - fillExcelData(index, row); - } - } - String filename = encodingFilename(sheetName); - out = new FileOutputStream(getAbsoluteFile(filename)); - wb.write(out); - return AjaxResult.success(filename); - } - catch (Exception e) - { - log.error("导出Excel异常{}", e.getMessage()); - throw new BusinessException("导出Excel失败,请联系网站管理员!"); - } - finally - { - if (wb != null) - { - try - { - wb.close(); - } - catch (IOException e1) - { - e1.printStackTrace(); - } - } - if (out != null) - { - try - { - out.close(); - } - catch (IOException e1) - { - e1.printStackTrace(); - } - } - } - } - - /** - * 填充excel数据 - * - * @param index 序号 - * @param row 单元格行 - * @param cell 类型单元格 - */ - public void fillExcelData(int index, Row row) - { - int startNo = index * sheetSize; - int endNo = Math.min(startNo + sheetSize, list.size()); - // 写入各条记录,每条记录对应excel表中的一行 - CellStyle cs = wb.createCellStyle(); - cs.setAlignment(HorizontalAlignment.CENTER); - cs.setVerticalAlignment(VerticalAlignment.CENTER); - for (int i = startNo; i < endNo; i++) - { - row = sheet.createRow(i + 1 - startNo); - // 得到导出对象. - T vo = (T) list.get(i); - int column = 0; - for (Object[] os : fields) - { - Field field = (Field) os[0]; - Excel excel = (Excel) os[1]; - // 设置实体类私有属性可访问 - field.setAccessible(true); - this.addCell(excel, row, vo, field, column++, cs); - } - } - } - - /** - * 创建单元格 - */ - public Cell createCell(Excel attr, Row row, int column) - { - // 创建列 - Cell cell = row.createCell(column); - // 设置列中写入内容为String类型 - cell.setCellType(CellType.STRING); - // 写入列名 - cell.setCellValue(attr.name()); - CellStyle cellStyle = createStyle(attr, row, column); - cell.setCellStyle(cellStyle); - return cell; - } - - /** - * 创建表格样式 - */ - public CellStyle createStyle(Excel attr, Row row, int column) - { - CellStyle cellStyle = wb.createCellStyle(); - cellStyle.setAlignment(HorizontalAlignment.CENTER); - cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); - if (attr.name().indexOf("注:") >= 0) - { - Font font = wb.createFont(); - font.setColor(HSSFFont.COLOR_RED); - cellStyle.setFont(font); - cellStyle.setFillForegroundColor(HSSFColorPredefined.YELLOW.getIndex()); - sheet.setColumnWidth(column, 6000); - } - else - { - Font font = wb.createFont(); - // 粗体显示 - font.setBold(true); - // 选择需要用到的字体格式 - cellStyle.setFont(font); - cellStyle.setFillForegroundColor(HSSFColorPredefined.LIGHT_YELLOW.getIndex()); - // 设置列宽 - sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); - row.setHeight((short) (attr.height() * 20)); - } - cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); - cellStyle.setWrapText(true); - // 如果设置了提示信息则鼠标放上去提示. - if (StringUtils.isNotEmpty(attr.prompt())) - { - // 这里默认设了2-101列提示. - setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column); - } - // 如果设置了combo属性则本列只能选择不能输入 - if (attr.combo().length > 0) - { - // 这里默认设了2-101列只能选择不能输入. - setXSSFValidation(sheet, attr.combo(), 1, 100, column, column); - } - return cellStyle; - } - - /** - * 添加单元格 - */ - public Cell addCell(Excel attr, Row row, T vo, Field field, int column, CellStyle cs) - { - Cell cell = null; - try - { - // 设置行高 - row.setHeight((short) (attr.height() * 20)); - // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. - if (attr.isExport()) - { - // 创建cell - cell = row.createCell(column); - cell.setCellStyle(cs); - - // 用于读取对象中的属性 - Object value = getTargetValue(vo, field, attr); - String dateFormat = attr.dateFormat(); - String readConverterExp = attr.readConverterExp(); - if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) - { - cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value)); - } - else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) - { - cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp)); - } - else - { - cell.setCellType(CellType.STRING); - // 如果数据存在就填入,不存在填入空格. - cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix()); - } - } - } - catch (Exception e) - { - log.error("导出Excel失败{}", e); - } - return cell; - } - - /** - * 设置 POI XSSFSheet 单元格提示 - * - * @param sheet 表单 - * @param promptTitle 提示标题 - * @param promptContent 提示内容 - * @param firstRow 开始行 - * @param endRow 结束行 - * @param firstCol 开始列 - * @param endCol 结束列 - */ - public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, - int firstCol, int endCol) - { - DataValidationHelper helper = sheet.getDataValidationHelper(); - DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); - CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); - DataValidation dataValidation = helper.createValidation(constraint, regions); - dataValidation.createPromptBox(promptTitle, promptContent); - dataValidation.setShowPromptBox(true); - sheet.addValidationData(dataValidation); - } - - /** - * 设置某些列的值只能输入预制的数据,显示下拉框. - * - * @param sheet 要设置的sheet. - * @param textlist 下拉框显示的内容 - * @param firstRow 开始行 - * @param endRow 结束行 - * @param firstCol 开始列 - * @param endCol 结束列 - * @return 设置好的sheet. - */ - public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) - { - DataValidationHelper helper = sheet.getDataValidationHelper(); - // 加载下拉列表内容 - DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); - // 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列 - CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); - // 数据有效性对象 - DataValidation dataValidation = helper.createValidation(constraint, regions); - // 处理Excel兼容性问题 - if (dataValidation instanceof XSSFDataValidation) - { - dataValidation.setSuppressDropDownArrow(true); - dataValidation.setShowErrorBox(true); - } - else - { - dataValidation.setSuppressDropDownArrow(false); - } - - sheet.addValidationData(dataValidation); - } - - /** - * 解析导出值 0=男,1=女,2=未知 - * - * @param propertyValue 参数值 - * @param converterExp 翻译注解 - * @return 解析后值 - * @throws Exception - */ - public static String convertByExp(String propertyValue, String converterExp) throws Exception - { - try - { - String[] convertSource = converterExp.split(","); - for (String item : convertSource) - { - String[] itemArray = item.split("="); - if (itemArray[0].equals(propertyValue)) - { - return itemArray[1]; - } - } - } - catch (Exception e) - { - throw e; - } - return propertyValue; - } - - /** - * 反向解析值 男=0,女=1,未知=2 - * - * @param propertyValue 参数值 - * @param converterExp 翻译注解 - * @return 解析后值 - * @throws Exception - */ - public static String reverseByExp(String propertyValue, String converterExp) throws Exception - { - try - { - String[] convertSource = converterExp.split(","); - for (String item : convertSource) - { - String[] itemArray = item.split("="); - if (itemArray[1].equals(propertyValue)) - { - return itemArray[0]; - } - } - } - catch (Exception e) - { - throw e; - } - return propertyValue; - } - - /** - * 编码文件名 - */ - public String encodingFilename(String filename) - { - filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; - return filename; - } - - /** - * 获取下载路径 - * - * @param filename 文件名称 - */ - public String getAbsoluteFile(String filename) - { - String downloadPath = Global.getDownloadPath() + filename; - File desc = new File(downloadPath); - if (!desc.getParentFile().exists()) - { - desc.getParentFile().mkdirs(); - } - return downloadPath; - } - - /** - * 获取bean中的属性值 - * - * @param vo 实体对象 - * @param field 字段 - * @param excel 注解 - * @return 最终的属性值 - * @throws Exception - */ - private Object getTargetValue(T vo, Field field, Excel excel) throws Exception - { - Object o = field.get(vo); - if (StringUtils.isNotEmpty(excel.targetAttr())) - { - String target = excel.targetAttr(); - if (target.indexOf(".") > -1) - { - String[] targets = target.split("[.]"); - for (String name : targets) - { - o = getValue(o, name); - } - } - else - { - o = getValue(o, target); - } - } - return o; - } - - /** - * 以类的属性的get方法方法形式获取值 - * - * @param o - * @param name - * @return value - * @throws Exception - */ - private Object getValue(Object o, String name) throws Exception - { - if (StringUtils.isNotEmpty(name)) - { - Class clazz = o.getClass(); - String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); - Method method = clazz.getMethod(methodName); - o = method.invoke(o); - } - return o; - } - - /** - * 得到所有定义字段 - */ - private void createExcelField() - { - this.fields = new ArrayList(); - List tempFields = new ArrayList<>(); - tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); - tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); - for (Field field : tempFields) - { - // 单注解 - if (field.isAnnotationPresent(Excel.class)) - { - putToField(field, field.getAnnotation(Excel.class)); - } - - // 多注解 - if (field.isAnnotationPresent(Excels.class)) - { - Excels attrs = field.getAnnotation(Excels.class); - Excel[] excels = attrs.value(); - for (Excel excel : excels) - { - putToField(field, excel); - } - } - } - } - - /** - * 放到字段集合中 - */ - private void putToField(Field field, Excel attr) - { - if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) - { - this.fields.add(new Object[] { field, attr }); - } - } - - /** - * 创建一个工作簿 - */ - public void createWorkbook() - { - this.wb = new SXSSFWorkbook(500); - } - - /** - * 创建工作表 - * - * @param sheetName,指定Sheet名称 - * @param sheetNo sheet数量 - * @param index 序号 - */ - public void createSheet(double sheetNo, int index) - { - this.sheet = wb.createSheet(); - // 设置工作表的名称. - if (sheetNo == 0) - { - wb.setSheetName(index, sheetName); - } - else - { - wb.setSheetName(index, sheetName + index); - } - } - - /** - * 获取单元格值 - * - * @param row 获取的行 - * @param column 获取单元格列号 - * @return 单元格值 - */ - public Object getCellValue(Row row, int column) - { - if (row == null) - { - return row; - } - Object val = ""; - try - { - Cell cell = row.getCell(column); - if (cell != null) - { - if (cell.getCellTypeEnum() == CellType.NUMERIC) - { - val = cell.getNumericCellValue(); - if (HSSFDateUtil.isCellDateFormatted(cell)) - { - val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换 - } - else - { - if ((Double) val % 1 > 0) - { - val = new DecimalFormat("0.00").format(val); - } - else - { - val = new DecimalFormat("0").format(val); - } - } - } - else if (cell.getCellTypeEnum() == CellType.STRING) - { - val = cell.getStringCellValue(); - } - else if (cell.getCellTypeEnum() == CellType.BOOLEAN) - { - val = cell.getBooleanCellValue(); - } - else if (cell.getCellTypeEnum() == CellType.ERROR) - { - val = cell.getErrorCellValue(); - } - - } - } - catch (Exception e) - { - return val; - } - return val; - } +package com.ruoyi.common.utils.poi; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.DataValidation; +import org.apache.poi.ss.usermodel.DataValidationConstraint; +import org.apache.poi.ss.usermodel.DataValidationHelper; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.apache.poi.xssf.usermodel.XSSFDataValidation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.Type; +import com.ruoyi.common.annotation.Excels; +import com.ruoyi.common.config.Global; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.reflect.ReflectUtils; + +/** + * Excel相关处理 + * + * @author ruoyi + */ +public class ExcelUtil +{ + private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); + + /** + * Excel sheet最大行数,默认65536 + */ + public static final int sheetSize = 65536; + + /** + * 工作表名称 + */ + private String sheetName; + + /** + * 导出类型(EXPORT:导出数据;IMPORT:导入模板) + */ + private Type type; + + /** + * 工作薄对象 + */ + private Workbook wb; + + /** + * 工作表对象 + */ + private Sheet sheet; + + /** + * 导入导出数据列表 + */ + private List list; + + /** + * 注解列表 + */ + private List fields; + + /** + * 实体对象 + */ + public Class clazz; + + public ExcelUtil(Class clazz) + { + this.clazz = clazz; + } + + public void init(List list, String sheetName, Type type) + { + if (list == null) + { + list = new ArrayList(); + } + this.list = list; + this.sheetName = sheetName; + this.type = type; + createExcelField(); + createWorkbook(); + } + + /** + * 对excel表单默认第一个索引名转换成list + * + * @param input 输入流 + * @return 转换后集合 + */ + public List importExcel(InputStream is) throws Exception + { + return importExcel(StringUtils.EMPTY, is); + } + + /** + * 对excel表单指定表格索引名转换成list + * + * @param sheetName 表格索引名 + * @param input 输入流 + * @return 转换后集合 + */ + public List importExcel(String sheetName, InputStream is) throws Exception + { + this.type = Type.IMPORT; + this.wb = WorkbookFactory.create(is); + List list = new ArrayList(); + Sheet sheet = null; + if (StringUtils.isNotEmpty(sheetName)) + { + // 如果指定sheet名,则取指定sheet中的内容. + sheet = wb.getSheet(sheetName); + } + else + { + // 如果传入的sheet名不存在则默认指向第1个sheet. + sheet = wb.getSheetAt(0); + } + + if (sheet == null) + { + throw new IOException("文件sheet不存在"); + } + + int rows = sheet.getPhysicalNumberOfRows(); + + if (rows > 0) + { + // 定义一个map用于存放excel列的序号和field. + Map cellMap = new HashMap(); + // 获取表头 + Row heard = sheet.getRow(0); + for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) + { + Cell cell = heard.getCell(i); + if (StringUtils.isNotNull(cell != null)) + { + String value = this.getCellValue(heard, i).toString(); + cellMap.put(value, i); + } + else + { + cellMap.put(null, i); + } + } + // 有数据时才处理 得到类的所有field. + Field[] allFields = clazz.getDeclaredFields(); + // 定义一个map用于存放列的序号和field. + Map fieldsMap = new HashMap(); + for (int col = 0; col < allFields.length; col++) + { + Field field = allFields[col]; + Excel attr = field.getAnnotation(Excel.class); + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + { + // 设置类的私有字段属性可访问. + field.setAccessible(true); + Integer column = cellMap.get(attr.name()); + fieldsMap.put(column, field); + } + } + for (int i = 1; i < rows; i++) + { + // 从第2行开始取数据,默认第一行是表头. + Row row = sheet.getRow(i); + T entity = null; + for (Map.Entry entry : fieldsMap.entrySet()) + { + Object val = this.getCellValue(row, entry.getKey()); + + // 如果不存在实例则新建. + entity = (entity == null ? clazz.newInstance() : entity); + // 从map中得到对应列的field. + Field field = fieldsMap.get(entry.getKey()); + // 取得类型,并根据对象类型设置值. + Class fieldType = field.getType(); + if (String.class == fieldType) + { + String s = Convert.toStr(val); + if (StringUtils.endsWith(s, ".0")) + { + val = StringUtils.substringBefore(s, ".0"); + } + else + { + val = Convert.toStr(val); + } + } + else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) + { + val = Convert.toInt(val); + } + else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) + { + val = Convert.toLong(val); + } + else if ((Double.TYPE == fieldType) || (Double.class == fieldType)) + { + val = Convert.toDouble(val); + } + else if ((Float.TYPE == fieldType) || (Float.class == fieldType)) + { + val = Convert.toFloat(val); + } + else if (BigDecimal.class == fieldType) + { + val = Convert.toBigDecimal(val); + } + else if (Date.class == fieldType) + { + if (val instanceof String) + { + val = DateUtils.parseDate(val); + } + else if (val instanceof Double) + { + val = DateUtil.getJavaDate((Double) val); + } + } + if (StringUtils.isNotNull(fieldType)) + { + Excel attr = field.getAnnotation(Excel.class); + String propertyName = field.getName(); + if (StringUtils.isNotEmpty(attr.targetAttr())) + { + propertyName = field.getName() + "." + attr.targetAttr(); + } + else if (StringUtils.isNotEmpty(attr.readConverterExp())) + { + val = reverseByExp(String.valueOf(val), attr.readConverterExp()); + } + ReflectUtils.invokeSetter(entity, propertyName, val); + } + } + list.add(entity); + } + } + return list; + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @return 结果 + */ + public AjaxResult exportExcel(List list, String sheetName) + { + this.init(list, sheetName, Type.EXPORT); + return exportExcel(); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @return 结果 + */ + public AjaxResult importTemplateExcel(String sheetName) + { + this.init(null, sheetName, Type.IMPORT); + return exportExcel(); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @return 结果 + */ + public AjaxResult exportExcel() + { + OutputStream out = null; + try + { + // 取出一共有多少个sheet. + double sheetNo = Math.ceil(list.size() / sheetSize); + for (int index = 0; index <= sheetNo; index++) + { + createSheet(sheetNo, index); + + // 产生一行 + Row row = sheet.createRow(0); + int column = 0; + // 写入各个字段的列头名称 + for (Object[] os : fields) + { + Excel excel = (Excel) os[1]; + this.createCell(excel, row, column++); + } + if (Type.EXPORT.equals(type)) + { + fillExcelData(index, row); + } + } + String filename = encodingFilename(sheetName); + out = new FileOutputStream(getAbsoluteFile(filename)); + wb.write(out); + return AjaxResult.success(filename); + } + catch (Exception e) + { + log.error("导出Excel异常{}", e.getMessage()); + throw new BusinessException("导出Excel失败,请联系网站管理员!"); + } + finally + { + if (wb != null) + { + try + { + wb.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + } + if (out != null) + { + try + { + out.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + } + } + } + + /** + * 填充excel数据 + * + * @param index 序号 + * @param row 单元格行 + * @param cell 类型单元格 + */ + public void fillExcelData(int index, Row row) + { + int startNo = index * sheetSize; + int endNo = Math.min(startNo + sheetSize, list.size()); + // 写入各条记录,每条记录对应excel表中的一行 + CellStyle cs = wb.createCellStyle(); + cs.setAlignment(HorizontalAlignment.CENTER); + cs.setVerticalAlignment(VerticalAlignment.CENTER); + for (int i = startNo; i < endNo; i++) + { + row = sheet.createRow(i + 1 - startNo); + // 得到导出对象. + T vo = (T) list.get(i); + int column = 0; + for (Object[] os : fields) + { + Field field = (Field) os[0]; + Excel excel = (Excel) os[1]; + // 设置实体类私有属性可访问 + field.setAccessible(true); + this.addCell(excel, row, vo, field, column++, cs); + } + } + } + + /** + * 创建单元格 + */ + public Cell createCell(Excel attr, Row row, int column) + { + // 创建列 + Cell cell = row.createCell(column); + // 设置列中写入内容为String类型 + cell.setCellType(CellType.STRING); + // 写入列名 + cell.setCellValue(attr.name()); + CellStyle cellStyle = createStyle(attr, row, column); + cell.setCellStyle(cellStyle); + return cell; + } + + /** + * 创建表格样式 + */ + public CellStyle createStyle(Excel attr, Row row, int column) + { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + if (attr.name().indexOf("注:") >= 0) + { + Font font = wb.createFont(); + font.setColor(HSSFFont.COLOR_RED); + cellStyle.setFont(font); + cellStyle.setFillForegroundColor(HSSFColorPredefined.YELLOW.getIndex()); + sheet.setColumnWidth(column, 6000); + } + else + { + Font font = wb.createFont(); + // 粗体显示 + font.setBold(true); + // 选择需要用到的字体格式 + cellStyle.setFont(font); + cellStyle.setFillForegroundColor(HSSFColorPredefined.LIGHT_YELLOW.getIndex()); + // 设置列宽 + sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); + row.setHeight((short) (attr.height() * 20)); + } + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + cellStyle.setWrapText(true); + // 如果设置了提示信息则鼠标放上去提示. + if (StringUtils.isNotEmpty(attr.prompt())) + { + // 这里默认设了2-101列提示. + setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column); + } + // 如果设置了combo属性则本列只能选择不能输入 + if (attr.combo().length > 0) + { + // 这里默认设了2-101列只能选择不能输入. + setXSSFValidation(sheet, attr.combo(), 1, 100, column, column); + } + return cellStyle; + } + + /** + * 添加单元格 + */ + public Cell addCell(Excel attr, Row row, T vo, Field field, int column, CellStyle cs) + { + Cell cell = null; + try + { + // 设置行高 + row.setHeight((short) (attr.height() * 20)); + // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. + if (attr.isExport()) + { + // 创建cell + cell = row.createCell(column); + cell.setCellStyle(cs); + + // 用于读取对象中的属性 + Object value = getTargetValue(vo, field, attr); + String dateFormat = attr.dateFormat(); + String readConverterExp = attr.readConverterExp(); + if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) + { + cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value)); + } + else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) + { + cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp)); + } + else + { + cell.setCellType(CellType.STRING); + // 如果数据存在就填入,不存在填入空格. + cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix()); + } + } + } + catch (Exception e) + { + log.error("导出Excel失败{}", e); + } + return cell; + } + + /** + * 设置 POI XSSFSheet 单元格提示 + * + * @param sheet 表单 + * @param promptTitle 提示标题 + * @param promptContent 提示内容 + * @param firstRow 开始行 + * @param endRow 结束行 + * @param firstCol 开始列 + * @param endCol 结束列 + */ + public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, + int firstCol, int endCol) + { + DataValidationHelper helper = sheet.getDataValidationHelper(); + DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + DataValidation dataValidation = helper.createValidation(constraint, regions); + dataValidation.createPromptBox(promptTitle, promptContent); + dataValidation.setShowPromptBox(true); + sheet.addValidationData(dataValidation); + } + + /** + * 设置某些列的值只能输入预制的数据,显示下拉框. + * + * @param sheet 要设置的sheet. + * @param textlist 下拉框显示的内容 + * @param firstRow 开始行 + * @param endRow 结束行 + * @param firstCol 开始列 + * @param endCol 结束列 + * @return 设置好的sheet. + */ + public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) + { + DataValidationHelper helper = sheet.getDataValidationHelper(); + // 加载下拉列表内容 + DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); + // 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列 + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + // 数据有效性对象 + DataValidation dataValidation = helper.createValidation(constraint, regions); + // 处理Excel兼容性问题 + if (dataValidation instanceof XSSFDataValidation) + { + dataValidation.setSuppressDropDownArrow(true); + dataValidation.setShowErrorBox(true); + } + else + { + dataValidation.setSuppressDropDownArrow(false); + } + + sheet.addValidationData(dataValidation); + } + + /** + * 解析导出值 0=男,1=女,2=未知 + * + * @param propertyValue 参数值 + * @param converterExp 翻译注解 + * @return 解析后值 + * @throws Exception + */ + public static String convertByExp(String propertyValue, String converterExp) throws Exception + { + try + { + String[] convertSource = converterExp.split(","); + for (String item : convertSource) + { + String[] itemArray = item.split("="); + if (itemArray[0].equals(propertyValue)) + { + return itemArray[1]; + } + } + } + catch (Exception e) + { + throw e; + } + return propertyValue; + } + + /** + * 反向解析值 男=0,女=1,未知=2 + * + * @param propertyValue 参数值 + * @param converterExp 翻译注解 + * @return 解析后值 + * @throws Exception + */ + public static String reverseByExp(String propertyValue, String converterExp) throws Exception + { + try + { + String[] convertSource = converterExp.split(","); + for (String item : convertSource) + { + String[] itemArray = item.split("="); + if (itemArray[1].equals(propertyValue)) + { + return itemArray[0]; + } + } + } + catch (Exception e) + { + throw e; + } + return propertyValue; + } + + /** + * 编码文件名 + */ + public String encodingFilename(String filename) + { + filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; + return filename; + } + + /** + * 获取下载路径 + * + * @param filename 文件名称 + */ + public String getAbsoluteFile(String filename) + { + String downloadPath = Global.getDownloadPath() + filename; + File desc = new File(downloadPath); + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + return downloadPath; + } + + /** + * 获取bean中的属性值 + * + * @param vo 实体对象 + * @param field 字段 + * @param excel 注解 + * @return 最终的属性值 + * @throws Exception + */ + private Object getTargetValue(T vo, Field field, Excel excel) throws Exception + { + Object o = field.get(vo); + if (StringUtils.isNotEmpty(excel.targetAttr())) + { + String target = excel.targetAttr(); + if (target.indexOf(".") > -1) + { + String[] targets = target.split("[.]"); + for (String name : targets) + { + o = getValue(o, name); + } + } + else + { + o = getValue(o, target); + } + } + return o; + } + + /** + * 以类的属性的get方法方法形式获取值 + * + * @param o + * @param name + * @return value + * @throws Exception + */ + private Object getValue(Object o, String name) throws Exception + { + if (StringUtils.isNotEmpty(name)) + { + Class clazz = o.getClass(); + String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); + Method method = clazz.getMethod(methodName); + o = method.invoke(o); + } + return o; + } + + /** + * 得到所有定义字段 + */ + private void createExcelField() + { + this.fields = new ArrayList(); + List tempFields = new ArrayList<>(); + tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); + tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); + for (Field field : tempFields) + { + // 单注解 + if (field.isAnnotationPresent(Excel.class)) + { + putToField(field, field.getAnnotation(Excel.class)); + } + + // 多注解 + if (field.isAnnotationPresent(Excels.class)) + { + Excels attrs = field.getAnnotation(Excels.class); + Excel[] excels = attrs.value(); + for (Excel excel : excels) + { + putToField(field, excel); + } + } + } + } + + /** + * 放到字段集合中 + */ + private void putToField(Field field, Excel attr) + { + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + { + this.fields.add(new Object[] { field, attr }); + } + } + + /** + * 创建一个工作簿 + */ + public void createWorkbook() + { + this.wb = new SXSSFWorkbook(500); + } + + /** + * 创建工作表 + * + * @param sheetName,指定Sheet名称 + * @param sheetNo sheet数量 + * @param index 序号 + */ + public void createSheet(double sheetNo, int index) + { + this.sheet = wb.createSheet(); + // 设置工作表的名称. + if (sheetNo == 0) + { + wb.setSheetName(index, sheetName); + } + else + { + wb.setSheetName(index, sheetName + index); + } + } + + /** + * 获取单元格值 + * + * @param row 获取的行 + * @param column 获取单元格列号 + * @return 单元格值 + */ + public Object getCellValue(Row row, int column) + { + if (row == null) + { + return row; + } + Object val = ""; + try + { + Cell cell = row.getCell(column); + if (cell != null) + { + if (cell.getCellTypeEnum() == CellType.NUMERIC) + { + val = cell.getNumericCellValue(); + if (HSSFDateUtil.isCellDateFormatted(cell)) + { + val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换 + } + else + { + if ((Double) val % 1 > 0) + { + val = new DecimalFormat("0.00").format(val); + } + else + { + val = new DecimalFormat("0").format(val); + } + } + } + else if (cell.getCellTypeEnum() == CellType.STRING) + { + val = cell.getStringCellValue(); + } + else if (cell.getCellTypeEnum() == CellType.BOOLEAN) + { + val = cell.getBooleanCellValue(); + } + else if (cell.getCellTypeEnum() == CellType.ERROR) + { + val = cell.getErrorCellValue(); + } + + } + } + catch (Exception e) + { + return val; + } + return val; + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java similarity index 100% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java similarity index 95% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java index 40e80304a..2bb1a8b20 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java @@ -1,66 +1,66 @@ -package com.ruoyi.common.utils.security; - -import java.security.MessageDigest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Md5加密方法 - * - * @author ruoyi - */ -public class Md5Utils -{ - private static final Logger log = LoggerFactory.getLogger(Md5Utils.class); - - private static byte[] md5(String s) - { - MessageDigest algorithm; - try - { - algorithm = MessageDigest.getInstance("MD5"); - algorithm.reset(); - algorithm.update(s.getBytes("UTF-8")); - byte[] messageDigest = algorithm.digest(); - return messageDigest; - } - catch (Exception e) - { - log.error("MD5 Error...", e); - } - return null; - } - - private static final String toHex(byte hash[]) - { - if (hash == null) - { - return null; - } - StringBuffer buf = new StringBuffer(hash.length * 2); - int i; - - for (i = 0; i < hash.length; i++) - { - if ((hash[i] & 0xff) < 0x10) - { - buf.append("0"); - } - buf.append(Long.toString(hash[i] & 0xff, 16)); - } - return buf.toString(); - } - - public static String hash(String s) - { - try - { - return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8"); - } - catch (Exception e) - { - log.error("not supported charset...{}", e); - return s; - } - } -} +package com.ruoyi.common.utils.security; + +import java.security.MessageDigest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Md5加密方法 + * + * @author ruoyi + */ +public class Md5Utils +{ + private static final Logger log = LoggerFactory.getLogger(Md5Utils.class); + + private static byte[] md5(String s) + { + MessageDigest algorithm; + try + { + algorithm = MessageDigest.getInstance("MD5"); + algorithm.reset(); + algorithm.update(s.getBytes("UTF-8")); + byte[] messageDigest = algorithm.digest(); + return messageDigest; + } + catch (Exception e) + { + log.error("MD5 Error...", e); + } + return null; + } + + private static final String toHex(byte hash[]) + { + if (hash == null) + { + return null; + } + StringBuffer buf = new StringBuffer(hash.length * 2); + int i; + + for (i = 0; i < hash.length; i++) + { + if ((hash[i] & 0xff) < 0x10) + { + buf.append("0"); + } + buf.append(Long.toString(hash[i] & 0xff, 16)); + } + return buf.toString(); + } + + public static String hash(String s) + { + try + { + return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8"); + } + catch (Exception e) + { + log.error("not supported charset...{}", e); + return s; + } + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java index 3b6f098ca..296f2ca5d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java @@ -1,118 +1,118 @@ -package com.ruoyi.common.utils.security; - -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.subject.Subject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.constant.PermissionConstants; -import com.ruoyi.common.utils.MessageUtils; - -/** - * permission 工具类 - * - * @author ruoyi - */ -public class PermissionUtils -{ - private static final Logger log = LoggerFactory.getLogger(PermissionUtils.class); - - /** - * 查看数据的权限 - */ - public static final String VIEW_PERMISSION = "no.view.permission"; - - /** - * 创建数据的权限 - */ - public static final String CREATE_PERMISSION = "no.create.permission"; - - /** - * 修改数据的权限 - */ - public static final String UPDATE_PERMISSION = "no.update.permission"; - - /** - * 删除数据的权限 - */ - public static final String DELETE_PERMISSION = "no.delete.permission"; - - /** - * 导出数据的权限 - */ - public static final String EXPORT_PERMISSION = "no.export.permission"; - - /** - * 其他数据的权限 - */ - public static final String PERMISSION = "no.permission"; - - /** - * 权限错误消息提醒 - * - * @param permissionsStr 错误信息 - * @return 提示信息 - */ - public static String getMsg(String permissionsStr) - { - String permission = StringUtils.substringBetween(permissionsStr, "[", "]"); - String msg = MessageUtils.message(PERMISSION, permission); - if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION)) - { - msg = MessageUtils.message(CREATE_PERMISSION, permission); - } - else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION)) - { - msg = MessageUtils.message(UPDATE_PERMISSION, permission); - } - else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION)) - { - msg = MessageUtils.message(DELETE_PERMISSION, permission); - } - else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION)) - { - msg = MessageUtils.message(EXPORT_PERMISSION, permission); - } - else if (StringUtils.endsWithAny(permission, - new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION })) - { - msg = MessageUtils.message(VIEW_PERMISSION, permission); - } - return msg; - } - - /** - * 返回用户属性值 - * - * @param property 属性名称 - * @return 用户属性值 - */ - public static Object getPrincipalProperty(String property) - { - Subject subject = SecurityUtils.getSubject(); - if (subject != null) - { - Object principal = subject.getPrincipal(); - try - { - BeanInfo bi = Introspector.getBeanInfo(principal.getClass()); - for (PropertyDescriptor pd : bi.getPropertyDescriptors()) - { - if (pd.getName().equals(property) == true) - { - return pd.getReadMethod().invoke(principal, (Object[]) null); - } - } - } - catch (Exception e) - { - log.error("Error reading property [{}] from principal of type [{}]", property, - principal.getClass().getName()); - } - } - return null; - } -} +package com.ruoyi.common.utils.security; + +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.subject.Subject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.constant.PermissionConstants; +import com.ruoyi.common.utils.MessageUtils; + +/** + * permission 工具类 + * + * @author ruoyi + */ +public class PermissionUtils +{ + private static final Logger log = LoggerFactory.getLogger(PermissionUtils.class); + + /** + * 查看数据的权限 + */ + public static final String VIEW_PERMISSION = "no.view.permission"; + + /** + * 创建数据的权限 + */ + public static final String CREATE_PERMISSION = "no.create.permission"; + + /** + * 修改数据的权限 + */ + public static final String UPDATE_PERMISSION = "no.update.permission"; + + /** + * 删除数据的权限 + */ + public static final String DELETE_PERMISSION = "no.delete.permission"; + + /** + * 导出数据的权限 + */ + public static final String EXPORT_PERMISSION = "no.export.permission"; + + /** + * 其他数据的权限 + */ + public static final String PERMISSION = "no.permission"; + + /** + * 权限错误消息提醒 + * + * @param permissionsStr 错误信息 + * @return 提示信息 + */ + public static String getMsg(String permissionsStr) + { + String permission = StringUtils.substringBetween(permissionsStr, "[", "]"); + String msg = MessageUtils.message(PERMISSION, permission); + if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION)) + { + msg = MessageUtils.message(CREATE_PERMISSION, permission); + } + else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION)) + { + msg = MessageUtils.message(UPDATE_PERMISSION, permission); + } + else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION)) + { + msg = MessageUtils.message(DELETE_PERMISSION, permission); + } + else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION)) + { + msg = MessageUtils.message(EXPORT_PERMISSION, permission); + } + else if (StringUtils.endsWithAny(permission, + new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION })) + { + msg = MessageUtils.message(VIEW_PERMISSION, permission); + } + return msg; + } + + /** + * 返回用户属性值 + * + * @param property 属性名称 + * @return 用户属性值 + */ + public static Object getPrincipalProperty(String property) + { + Subject subject = SecurityUtils.getSubject(); + if (subject != null) + { + Object principal = subject.getPrincipal(); + try + { + BeanInfo bi = Introspector.getBeanInfo(principal.getClass()); + for (PropertyDescriptor pd : bi.getPropertyDescriptors()) + { + if (pd.getName().equals(property) == true) + { + return pd.getReadMethod().invoke(principal, (Object[]) null); + } + } + } + catch (Exception e) + { + log.error("Error reading property [{}] from principal of type [{}]", property, + principal.getClass().getName()); + } + } + return null; + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java b/bmw-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java index e0311595a..19bd77ef3 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java +++ b/bmw-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java @@ -1,114 +1,114 @@ -package com.ruoyi.common.utils.spring; - -import org.springframework.aop.framework.AopContext; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.stereotype.Component; - -/** - * spring工具类 方便在非spring管理环境中获取bean - * - * @author ruoyi - */ -@Component -public final class SpringUtils implements BeanFactoryPostProcessor -{ - /** Spring应用上下文环境 */ - private static ConfigurableListableBeanFactory beanFactory; - - @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException - { - SpringUtils.beanFactory = beanFactory; - } - - /** - * 获取对象 - * - * @param name - * @return Object 一个以所给名字注册的bean的实例 - * @throws org.springframework.beans.BeansException - * - */ - @SuppressWarnings("unchecked") - public static T getBean(String name) throws BeansException - { - return (T) beanFactory.getBean(name); - } - - /** - * 获取类型为requiredType的对象 - * - * @param clz - * @return - * @throws org.springframework.beans.BeansException - * - */ - public static T getBean(Class clz) throws BeansException - { - T result = (T) beanFactory.getBean(clz); - return result; - } - - /** - * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true - * - * @param name - * @return boolean - */ - public static boolean containsBean(String name) - { - return beanFactory.containsBean(name); - } - - /** - * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) - * - * @param name - * @return boolean - * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * - */ - public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException - { - return beanFactory.isSingleton(name); - } - - /** - * @param name - * @return Class 注册对象的类型 - * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * - */ - public static Class getType(String name) throws NoSuchBeanDefinitionException - { - return beanFactory.getType(name); - } - - /** - * 如果给定的bean名字在bean定义中有别名,则返回这些别名 - * - * @param name - * @return - * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException - * - */ - public static String[] getAliases(String name) throws NoSuchBeanDefinitionException - { - return beanFactory.getAliases(name); - } - - /** - * 获取aop代理对象 - * - * @param invoker - * @return - */ - @SuppressWarnings("unchecked") - public static T getAopProxy(T invoker) - { - return (T) AopContext.currentProxy(); - } -} +package com.ruoyi.common.utils.spring; + +import org.springframework.aop.framework.AopContext; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.stereotype.Component; + +/** + * spring工具类 方便在非spring管理环境中获取bean + * + * @author ruoyi + */ +@Component +public final class SpringUtils implements BeanFactoryPostProcessor +{ + /** Spring应用上下文环境 */ + private static ConfigurableListableBeanFactory beanFactory; + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException + { + SpringUtils.beanFactory = beanFactory; + } + + /** + * 获取对象 + * + * @param name + * @return Object 一个以所给名字注册的bean的实例 + * @throws org.springframework.beans.BeansException + * + */ + @SuppressWarnings("unchecked") + public static T getBean(String name) throws BeansException + { + return (T) beanFactory.getBean(name); + } + + /** + * 获取类型为requiredType的对象 + * + * @param clz + * @return + * @throws org.springframework.beans.BeansException + * + */ + public static T getBean(Class clz) throws BeansException + { + T result = (T) beanFactory.getBean(clz); + return result; + } + + /** + * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true + * + * @param name + * @return boolean + */ + public static boolean containsBean(String name) + { + return beanFactory.containsBean(name); + } + + /** + * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) + * + * @param name + * @return boolean + * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException + * + */ + public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.isSingleton(name); + } + + /** + * @param name + * @return Class 注册对象的类型 + * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException + * + */ + public static Class getType(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.getType(name); + } + + /** + * 如果给定的bean名字在bean定义中有别名,则返回这些别名 + * + * @param name + * @return + * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException + * + */ + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException + { + return beanFactory.getAliases(name); + } + + /** + * 获取aop代理对象 + * + * @param invoker + * @return + */ + @SuppressWarnings("unchecked") + public static T getAopProxy(T invoker) + { + return (T) AopContext.currentProxy(); + } +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java b/bmw-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java similarity index 100% rename from ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java rename to bmw-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/xss/XssFilter.java b/bmw-common/src/main/java/com/ruoyi/common/xss/XssFilter.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/xss/XssFilter.java rename to bmw-common/src/main/java/com/ruoyi/common/xss/XssFilter.java index d307fbc9f..931040256 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/xss/XssFilter.java +++ b/bmw-common/src/main/java/com/ruoyi/common/xss/XssFilter.java @@ -1,97 +1,97 @@ -package com.ruoyi.common.xss; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import com.ruoyi.common.utils.StringUtils; - -/** - * 防止XSS攻击的过滤器 - * - * @author ruoyi - */ -public class XssFilter implements Filter -{ - /** - * 排除链接 - */ - public List excludes = new ArrayList<>(); - - /** - * xss过滤开关 - */ - public boolean enabled = false; - - @Override - public void init(FilterConfig filterConfig) throws ServletException - { - String tempExcludes = filterConfig.getInitParameter("excludes"); - String tempEnabled = filterConfig.getInitParameter("enabled"); - if (StringUtils.isNotEmpty(tempExcludes)) - { - String[] url = tempExcludes.split(","); - for (int i = 0; url != null && i < url.length; i++) - { - excludes.add(url[i]); - } - } - if (StringUtils.isNotEmpty(tempEnabled)) - { - enabled = Boolean.valueOf(tempEnabled); - } - } - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException - { - HttpServletRequest req = (HttpServletRequest) request; - HttpServletResponse resp = (HttpServletResponse) response; - if (handleExcludeURL(req, resp)) - { - chain.doFilter(request, response); - return; - } - XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request); - chain.doFilter(xssRequest, response); - } - - private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) - { - if (!enabled) - { - return true; - } - if (excludes == null || excludes.isEmpty()) - { - return false; - } - String url = request.getServletPath(); - for (String pattern : excludes) - { - Pattern p = Pattern.compile("^" + pattern); - Matcher m = p.matcher(url); - if (m.find()) - { - return true; - } - } - return false; - } - - @Override - public void destroy() - { - - } +package com.ruoyi.common.xss; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.utils.StringUtils; + +/** + * 防止XSS攻击的过滤器 + * + * @author ruoyi + */ +public class XssFilter implements Filter +{ + /** + * 排除链接 + */ + public List excludes = new ArrayList<>(); + + /** + * xss过滤开关 + */ + public boolean enabled = false; + + @Override + public void init(FilterConfig filterConfig) throws ServletException + { + String tempExcludes = filterConfig.getInitParameter("excludes"); + String tempEnabled = filterConfig.getInitParameter("enabled"); + if (StringUtils.isNotEmpty(tempExcludes)) + { + String[] url = tempExcludes.split(","); + for (int i = 0; url != null && i < url.length; i++) + { + excludes.add(url[i]); + } + } + if (StringUtils.isNotEmpty(tempEnabled)) + { + enabled = Boolean.valueOf(tempEnabled); + } + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + HttpServletRequest req = (HttpServletRequest) request; + HttpServletResponse resp = (HttpServletResponse) response; + if (handleExcludeURL(req, resp)) + { + chain.doFilter(request, response); + return; + } + XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request); + chain.doFilter(xssRequest, response); + } + + private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) + { + if (!enabled) + { + return true; + } + if (excludes == null || excludes.isEmpty()) + { + return false; + } + String url = request.getServletPath(); + for (String pattern : excludes) + { + Pattern p = Pattern.compile("^" + pattern); + Matcher m = p.matcher(url); + if (m.find()) + { + return true; + } + } + return false; + } + + @Override + public void destroy() + { + + } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java b/bmw-common/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java similarity index 96% rename from ruoyi-common/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java rename to bmw-common/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java index be125f249..68ff57e40 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java +++ b/bmw-common/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java @@ -1,40 +1,40 @@ -package com.ruoyi.common.xss; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import org.jsoup.Jsoup; -import org.jsoup.safety.Whitelist; - -/** - * XSS过滤处理 - * - * @author ruoyi - */ -public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper -{ - /** - * @param request - */ - public XssHttpServletRequestWrapper(HttpServletRequest request) - { - super(request); - } - - @Override - public String[] getParameterValues(String name) - { - String[] values = super.getParameterValues(name); - if (values != null) - { - int length = values.length; - String[] escapseValues = new String[length]; - for (int i = 0; i < length; i++) - { - // 防xss攻击和过滤前后空格 - escapseValues[i] = Jsoup.clean(values[i], Whitelist.relaxed()).trim(); - } - return escapseValues; - } - return super.getParameterValues(name); - } +package com.ruoyi.common.xss; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import org.jsoup.Jsoup; +import org.jsoup.safety.Whitelist; + +/** + * XSS过滤处理 + * + * @author ruoyi + */ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper +{ + /** + * @param request + */ + public XssHttpServletRequestWrapper(HttpServletRequest request) + { + super(request); + } + + @Override + public String[] getParameterValues(String name) + { + String[] values = super.getParameterValues(name); + if (values != null) + { + int length = values.length; + String[] escapseValues = new String[length]; + for (int i = 0; i < length; i++) + { + // 防xss攻击和过滤前后空格 + escapseValues[i] = Jsoup.clean(values[i], Whitelist.relaxed()).trim(); + } + return escapseValues; + } + return super.getParameterValues(name); + } } \ No newline at end of file diff --git a/ruoyi-framework/pom.xml b/bmw-framework/pom.xml similarity index 100% rename from ruoyi-framework/pom.xml rename to bmw-framework/pom.xml diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/bmw-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java rename to bmw-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index 977ed9e96..556159d45 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -1,162 +1,162 @@ -package com.ruoyi.framework.aspectj; - -import java.lang.reflect.Method; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.Signature; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.springframework.stereotype.Component; -import com.ruoyi.common.annotation.DataScope; -import com.ruoyi.common.core.domain.BaseEntity; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.domain.SysUser; - -/** - * 数据过滤处理 - * - * @author ruoyi - */ -@Aspect -@Component -public class DataScopeAspect -{ - /** - * 全部数据权限 - */ - public static final String DATA_SCOPE_ALL = "1"; - - /** - * 自定数据权限 - */ - public static final String DATA_SCOPE_CUSTOM = "2"; - - /** - * 部门数据权限 - */ - public static final String DATA_SCOPE_DEPT = "3"; - - /** - * 部门及以下数据权限 - */ - public static final String DATA_SCOPE_DEPT_AND_CHILD = "4"; - - /** - * 仅本人数据权限 - */ - public static final String DATA_SCOPE_SELF = "5"; - - /** - * 数据权限过滤关键字 - */ - public static final String DATA_SCOPE = "dataScope"; - - // 配置织入点 - @Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)") - public void dataScopePointCut() - { - } - - @Before("dataScopePointCut()") - public void doBefore(JoinPoint point) throws Throwable - { - handleDataScope(point); - } - - protected void handleDataScope(final JoinPoint joinPoint) - { - // 获得注解 - DataScope controllerDataScope = getAnnotationLog(joinPoint); - if (controllerDataScope == null) - { - return; - } - // 获取当前的用户 - SysUser currentUser = ShiroUtils.getSysUser(); - if (currentUser != null) - { - // 如果是超级管理员,则不过滤数据 - if (!currentUser.isAdmin()) - { - dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), - controllerDataScope.userAlias()); - } - } - } - - /** - * 数据范围过滤 - * - * @param joinPoint 切点 - * @param user 用户 - * @param alias 别名 - */ - public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) - { - StringBuilder sqlString = new StringBuilder(); - - for (SysRole role : user.getRoles()) - { - String dataScope = role.getDataScope(); - if (DATA_SCOPE_ALL.equals(dataScope)) - { - sqlString = new StringBuilder(); - break; - } - else if (DATA_SCOPE_CUSTOM.equals(dataScope)) - { - sqlString.append(StringUtils.format( - " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, - role.getRoleId())); - } - else if (DATA_SCOPE_DEPT.equals(dataScope)) - { - sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); - } - else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) - { - String deptChild = user.getDept().getParentId() + "," + user.getDeptId(); - sqlString.append(StringUtils.format( - " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or ancestors LIKE '%{}%' )", - deptAlias, user.getDeptId(), deptChild)); - } - else if (DATA_SCOPE_SELF.equals(dataScope)) - { - if (StringUtils.isNotBlank(userAlias)) - { - sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId())); - } - else - { - // 数据权限为仅本人且没有userAlias别名不查询任何数据 - sqlString.append(" OR 1=0 "); - } - } - } - - if (StringUtils.isNotBlank(sqlString.toString())) - { - BaseEntity baseEntity = (BaseEntity) joinPoint.getArgs()[0]; - baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); - } - } - - /** - * 是否存在注解,如果存在就获取 - */ - private DataScope getAnnotationLog(JoinPoint joinPoint) - { - Signature signature = joinPoint.getSignature(); - MethodSignature methodSignature = (MethodSignature) signature; - Method method = methodSignature.getMethod(); - - if (method != null) - { - return method.getAnnotation(DataScope.class); - } - return null; - } -} +package com.ruoyi.framework.aspectj; + +import java.lang.reflect.Method; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.stereotype.Component; +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.domain.SysUser; + +/** + * 数据过滤处理 + * + * @author ruoyi + */ +@Aspect +@Component +public class DataScopeAspect +{ + /** + * 全部数据权限 + */ + public static final String DATA_SCOPE_ALL = "1"; + + /** + * 自定数据权限 + */ + public static final String DATA_SCOPE_CUSTOM = "2"; + + /** + * 部门数据权限 + */ + public static final String DATA_SCOPE_DEPT = "3"; + + /** + * 部门及以下数据权限 + */ + public static final String DATA_SCOPE_DEPT_AND_CHILD = "4"; + + /** + * 仅本人数据权限 + */ + public static final String DATA_SCOPE_SELF = "5"; + + /** + * 数据权限过滤关键字 + */ + public static final String DATA_SCOPE = "dataScope"; + + // 配置织入点 + @Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)") + public void dataScopePointCut() + { + } + + @Before("dataScopePointCut()") + public void doBefore(JoinPoint point) throws Throwable + { + handleDataScope(point); + } + + protected void handleDataScope(final JoinPoint joinPoint) + { + // 获得注解 + DataScope controllerDataScope = getAnnotationLog(joinPoint); + if (controllerDataScope == null) + { + return; + } + // 获取当前的用户 + SysUser currentUser = ShiroUtils.getSysUser(); + if (currentUser != null) + { + // 如果是超级管理员,则不过滤数据 + if (!currentUser.isAdmin()) + { + dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), + controllerDataScope.userAlias()); + } + } + } + + /** + * 数据范围过滤 + * + * @param joinPoint 切点 + * @param user 用户 + * @param alias 别名 + */ + public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) + { + StringBuilder sqlString = new StringBuilder(); + + for (SysRole role : user.getRoles()) + { + String dataScope = role.getDataScope(); + if (DATA_SCOPE_ALL.equals(dataScope)) + { + sqlString = new StringBuilder(); + break; + } + else if (DATA_SCOPE_CUSTOM.equals(dataScope)) + { + sqlString.append(StringUtils.format( + " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, + role.getRoleId())); + } + else if (DATA_SCOPE_DEPT.equals(dataScope)) + { + sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); + } + else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) + { + String deptChild = user.getDept().getParentId() + "," + user.getDeptId(); + sqlString.append(StringUtils.format( + " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or ancestors LIKE '%{}%' )", + deptAlias, user.getDeptId(), deptChild)); + } + else if (DATA_SCOPE_SELF.equals(dataScope)) + { + if (StringUtils.isNotBlank(userAlias)) + { + sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId())); + } + else + { + // 数据权限为仅本人且没有userAlias别名不查询任何数据 + sqlString.append(" OR 1=0 "); + } + } + } + + if (StringUtils.isNotBlank(sqlString.toString())) + { + BaseEntity baseEntity = (BaseEntity) joinPoint.getArgs()[0]; + baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); + } + } + + /** + * 是否存在注解,如果存在就获取 + */ + private DataScope getAnnotationLog(JoinPoint joinPoint) + { + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + Method method = methodSignature.getMethod(); + + if (method != null) + { + return method.getAnnotation(DataScope.class); + } + return null; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java b/bmw-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java rename to bmw-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java index 89d28facf..bf18bbc23 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java @@ -1,59 +1,59 @@ -package com.ruoyi.framework.aspectj; - -import java.lang.reflect.Method; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import com.ruoyi.common.annotation.DataSource; -import com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder; -import com.ruoyi.common.utils.StringUtils; - -/** - * 多数据源处理 - * - * @author ruoyi - */ -@Aspect -@Order(1) -@Component -public class DataSourceAspect -{ - protected Logger logger = LoggerFactory.getLogger(getClass()); - - @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)") - public void dsPointCut() - { - - } - - @Around("dsPointCut()") - public Object around(ProceedingJoinPoint point) throws Throwable - { - MethodSignature signature = (MethodSignature) point.getSignature(); - - Method method = signature.getMethod(); - - DataSource dataSource = method.getAnnotation(DataSource.class); - - if (StringUtils.isNotNull(dataSource)) - { - DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name()); - } - - try - { - return point.proceed(); - } - finally - { - // 销毁数据源 在执行方法之后 - DynamicDataSourceContextHolder.clearDataSourceType(); - } - } -} +package com.ruoyi.framework.aspectj; + +import java.lang.reflect.Method; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder; +import com.ruoyi.common.utils.StringUtils; + +/** + * 多数据源处理 + * + * @author ruoyi + */ +@Aspect +@Order(1) +@Component +public class DataSourceAspect +{ + protected Logger logger = LoggerFactory.getLogger(getClass()); + + @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)") + public void dsPointCut() + { + + } + + @Around("dsPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable + { + MethodSignature signature = (MethodSignature) point.getSignature(); + + Method method = signature.getMethod(); + + DataSource dataSource = method.getAnnotation(DataSource.class); + + if (StringUtils.isNotNull(dataSource)) + { + DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name()); + } + + try + { + return point.proceed(); + } + finally + { + // 销毁数据源 在执行方法之后 + DynamicDataSourceContextHolder.clearDataSourceType(); + } + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/bmw-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java rename to bmw-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java index a549c06e0..472c9ac95 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -1,172 +1,172 @@ -package com.ruoyi.framework.aspectj; - -import java.lang.reflect.Method; -import java.util.Map; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.Signature; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.AfterThrowing; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.enums.BusinessStatus; -import com.ruoyi.common.json.JSON; -import com.ruoyi.common.utils.ServletUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.manager.AsyncManager; -import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysOperLog; -import com.ruoyi.system.domain.SysUser; - -/** - * 操作日志记录处理 - * - * @author ruoyi - */ -@Aspect -@Component -public class LogAspect -{ - private static final Logger log = LoggerFactory.getLogger(LogAspect.class); - - // 配置织入点 - @Pointcut("@annotation(com.ruoyi.common.annotation.Log)") - public void logPointCut() - { - } - - /** - * 处理完请求后执行 - * - * @param joinPoint 切点 - */ - @AfterReturning(pointcut = "logPointCut()") - public void doAfterReturning(JoinPoint joinPoint) - { - handleLog(joinPoint, null); - } - - /** - * 拦截异常操作 - * - * @param joinPoint 切点 - * @param e 异常 - */ - @AfterThrowing(value = "logPointCut()", throwing = "e") - public void doAfterThrowing(JoinPoint joinPoint, Exception e) - { - handleLog(joinPoint, e); - } - - protected void handleLog(final JoinPoint joinPoint, final Exception e) - { - try - { - // 获得注解 - Log controllerLog = getAnnotationLog(joinPoint); - if (controllerLog == null) - { - return; - } - - // 获取当前的用户 - SysUser currentUser = ShiroUtils.getSysUser(); - - // *========数据库日志=========*// - SysOperLog operLog = new SysOperLog(); - operLog.setStatus(BusinessStatus.SUCCESS.ordinal()); - // 请求的地址 - String ip = ShiroUtils.getIp(); - operLog.setOperIp(ip); - - operLog.setOperUrl(ServletUtils.getRequest().getRequestURI()); - if (currentUser != null) - { - operLog.setOperName(currentUser.getLoginName()); - if (StringUtils.isNotNull(currentUser.getDept()) - && StringUtils.isNotEmpty(currentUser.getDept().getDeptName())) - { - operLog.setDeptName(currentUser.getDept().getDeptName()); - } - } - - if (e != null) - { - operLog.setStatus(BusinessStatus.FAIL.ordinal()); - operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); - } - // 设置方法名称 - String className = joinPoint.getTarget().getClass().getName(); - String methodName = joinPoint.getSignature().getName(); - operLog.setMethod(className + "." + methodName + "()"); - // 处理设置注解上的参数 - getControllerMethodDescription(controllerLog, operLog); - // 保存数据库 - AsyncManager.me().execute(AsyncFactory.recordOper(operLog)); - } - catch (Exception exp) - { - // 记录本地异常日志 - log.error("==前置通知异常=="); - log.error("异常信息:{}", exp.getMessage()); - exp.printStackTrace(); - } - } - - /** - * 获取注解中对方法的描述信息 用于Controller层注解 - * - * @param log 日志 - * @param operLog 操作日志 - * @throws Exception - */ - public void getControllerMethodDescription(Log log, SysOperLog operLog) throws Exception - { - // 设置action动作 - operLog.setBusinessType(log.businessType().ordinal()); - // 设置标题 - operLog.setTitle(log.title()); - // 设置操作人类别 - operLog.setOperatorType(log.operatorType().ordinal()); - // 是否需要保存request,参数和值 - if (log.isSaveRequestData()) - { - // 获取参数的信息,传入到数据库中。 - setRequestValue(operLog); - } - } - - /** - * 获取请求的参数,放到log中 - * - * @param operLog 操作日志 - * @throws Exception 异常 - */ - private void setRequestValue(SysOperLog operLog) throws Exception - { - Map map = ServletUtils.getRequest().getParameterMap(); - String params = JSON.marshal(map); - operLog.setOperParam(StringUtils.substring(params, 0, 2000)); - } - - /** - * 是否存在注解,如果存在就获取 - */ - private Log getAnnotationLog(JoinPoint joinPoint) throws Exception - { - Signature signature = joinPoint.getSignature(); - MethodSignature methodSignature = (MethodSignature) signature; - Method method = methodSignature.getMethod(); - - if (method != null) - { - return method.getAnnotation(Log.class); - } - return null; - } -} +package com.ruoyi.framework.aspectj; + +import java.lang.reflect.Method; +import java.util.Map; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessStatus; +import com.ruoyi.common.json.JSON; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.domain.SysUser; + +/** + * 操作日志记录处理 + * + * @author ruoyi + */ +@Aspect +@Component +public class LogAspect +{ + private static final Logger log = LoggerFactory.getLogger(LogAspect.class); + + // 配置织入点 + @Pointcut("@annotation(com.ruoyi.common.annotation.Log)") + public void logPointCut() + { + } + + /** + * 处理完请求后执行 + * + * @param joinPoint 切点 + */ + @AfterReturning(pointcut = "logPointCut()") + public void doAfterReturning(JoinPoint joinPoint) + { + handleLog(joinPoint, null); + } + + /** + * 拦截异常操作 + * + * @param joinPoint 切点 + * @param e 异常 + */ + @AfterThrowing(value = "logPointCut()", throwing = "e") + public void doAfterThrowing(JoinPoint joinPoint, Exception e) + { + handleLog(joinPoint, e); + } + + protected void handleLog(final JoinPoint joinPoint, final Exception e) + { + try + { + // 获得注解 + Log controllerLog = getAnnotationLog(joinPoint); + if (controllerLog == null) + { + return; + } + + // 获取当前的用户 + SysUser currentUser = ShiroUtils.getSysUser(); + + // *========数据库日志=========*// + SysOperLog operLog = new SysOperLog(); + operLog.setStatus(BusinessStatus.SUCCESS.ordinal()); + // 请求的地址 + String ip = ShiroUtils.getIp(); + operLog.setOperIp(ip); + + operLog.setOperUrl(ServletUtils.getRequest().getRequestURI()); + if (currentUser != null) + { + operLog.setOperName(currentUser.getLoginName()); + if (StringUtils.isNotNull(currentUser.getDept()) + && StringUtils.isNotEmpty(currentUser.getDept().getDeptName())) + { + operLog.setDeptName(currentUser.getDept().getDeptName()); + } + } + + if (e != null) + { + operLog.setStatus(BusinessStatus.FAIL.ordinal()); + operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); + } + // 设置方法名称 + String className = joinPoint.getTarget().getClass().getName(); + String methodName = joinPoint.getSignature().getName(); + operLog.setMethod(className + "." + methodName + "()"); + // 处理设置注解上的参数 + getControllerMethodDescription(controllerLog, operLog); + // 保存数据库 + AsyncManager.me().execute(AsyncFactory.recordOper(operLog)); + } + catch (Exception exp) + { + // 记录本地异常日志 + log.error("==前置通知异常=="); + log.error("异常信息:{}", exp.getMessage()); + exp.printStackTrace(); + } + } + + /** + * 获取注解中对方法的描述信息 用于Controller层注解 + * + * @param log 日志 + * @param operLog 操作日志 + * @throws Exception + */ + public void getControllerMethodDescription(Log log, SysOperLog operLog) throws Exception + { + // 设置action动作 + operLog.setBusinessType(log.businessType().ordinal()); + // 设置标题 + operLog.setTitle(log.title()); + // 设置操作人类别 + operLog.setOperatorType(log.operatorType().ordinal()); + // 是否需要保存request,参数和值 + if (log.isSaveRequestData()) + { + // 获取参数的信息,传入到数据库中。 + setRequestValue(operLog); + } + } + + /** + * 获取请求的参数,放到log中 + * + * @param operLog 操作日志 + * @throws Exception 异常 + */ + private void setRequestValue(SysOperLog operLog) throws Exception + { + Map map = ServletUtils.getRequest().getParameterMap(); + String params = JSON.marshal(map); + operLog.setOperParam(StringUtils.substring(params, 0, 2000)); + } + + /** + * 是否存在注解,如果存在就获取 + */ + private Log getAnnotationLog(JoinPoint joinPoint) throws Exception + { + Signature signature = joinPoint.getSignature(); + MethodSignature methodSignature = (MethodSignature) signature; + Method method = methodSignature.getMethod(); + + if (method != null) + { + return method.getAnnotation(Log.class); + } + return null; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java similarity index 98% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java index b6f80bf27..43e78aebe 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java @@ -1,83 +1,83 @@ -package com.ruoyi.framework.config; - -import java.util.Properties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import com.google.code.kaptcha.impl.DefaultKaptcha; -import com.google.code.kaptcha.util.Config; -import static com.google.code.kaptcha.Constants.*; - -/** - * 验证码配置 - * - * @author ruoyi - */ -@Configuration -public class CaptchaConfig -{ - @Bean(name = "captchaProducer") - public DefaultKaptcha getKaptchaBean() - { - DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); - Properties properties = new Properties(); - // 是否有边框 默认为true 我们可以自己设置yes,no - properties.setProperty(KAPTCHA_BORDER, "yes"); - // 验证码文本字符颜色 默认为Color.BLACK - properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "black"); - // 验证码图片宽度 默认为200 - properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); - // 验证码图片高度 默认为50 - properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); - // 验证码文本字符大小 默认为40 - properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38"); - // KAPTCHA_SESSION_KEY - properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCode"); - // 验证码文本字符长度 默认为5 - properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4"); - // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) - properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); - // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy - properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); - Config config = new Config(properties); - defaultKaptcha.setConfig(config); - return defaultKaptcha; - } - - @Bean(name = "captchaProducerMath") - public DefaultKaptcha getKaptchaBeanMath() - { - DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); - Properties properties = new Properties(); - // 是否有边框 默认为true 我们可以自己设置yes,no - properties.setProperty(KAPTCHA_BORDER, "yes"); - // 边框颜色 默认为Color.BLACK - properties.setProperty(KAPTCHA_BORDER_COLOR, "105,179,90"); - // 验证码文本字符颜色 默认为Color.BLACK - properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue"); - // 验证码图片宽度 默认为200 - properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); - // 验证码图片高度 默认为50 - properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); - // 验证码文本字符大小 默认为40 - properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "35"); - // KAPTCHA_SESSION_KEY - properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCodeMath"); - // 验证码文本生成器 - properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.ruoyi.framework.config.KaptchaTextCreator"); - // 验证码文本字符间距 默认为2 - properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "3"); - // 验证码文本字符长度 默认为5 - properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "6"); - // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) - properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); - // 验证码噪点颜色 默认为Color.BLACK - properties.setProperty(KAPTCHA_NOISE_COLOR, "white"); - // 干扰实现类 - properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise"); - // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy - properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); - Config config = new Config(properties); - defaultKaptcha.setConfig(config); - return defaultKaptcha; - } -} +package com.ruoyi.framework.config; + +import java.util.Properties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import com.google.code.kaptcha.impl.DefaultKaptcha; +import com.google.code.kaptcha.util.Config; +import static com.google.code.kaptcha.Constants.*; + +/** + * 验证码配置 + * + * @author ruoyi + */ +@Configuration +public class CaptchaConfig +{ + @Bean(name = "captchaProducer") + public DefaultKaptcha getKaptchaBean() + { + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + Properties properties = new Properties(); + // 是否有边框 默认为true 我们可以自己设置yes,no + properties.setProperty(KAPTCHA_BORDER, "yes"); + // 验证码文本字符颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "black"); + // 验证码图片宽度 默认为200 + properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); + // 验证码图片高度 默认为50 + properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); + // 验证码文本字符大小 默认为40 + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38"); + // KAPTCHA_SESSION_KEY + properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCode"); + // 验证码文本字符长度 默认为5 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4"); + // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); + // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy + properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); + Config config = new Config(properties); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } + + @Bean(name = "captchaProducerMath") + public DefaultKaptcha getKaptchaBeanMath() + { + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + Properties properties = new Properties(); + // 是否有边框 默认为true 我们可以自己设置yes,no + properties.setProperty(KAPTCHA_BORDER, "yes"); + // 边框颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_BORDER_COLOR, "105,179,90"); + // 验证码文本字符颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue"); + // 验证码图片宽度 默认为200 + properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); + // 验证码图片高度 默认为50 + properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); + // 验证码文本字符大小 默认为40 + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "35"); + // KAPTCHA_SESSION_KEY + properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCodeMath"); + // 验证码文本生成器 + properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.ruoyi.framework.config.KaptchaTextCreator"); + // 验证码文本字符间距 默认为2 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "3"); + // 验证码文本字符长度 默认为5 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "6"); + // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); + // 验证码噪点颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_NOISE_COLOR, "white"); + // 干扰实现类 + properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise"); + // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy + properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); + Config config = new Config(properties); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java index 3e4a97eff..c571d5197 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java @@ -1,106 +1,106 @@ -package com.ruoyi.framework.config; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.sql.DataSource; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import com.alibaba.druid.pool.DruidDataSource; -import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; -import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties; -import com.alibaba.druid.util.Utils; -import com.ruoyi.common.enums.DataSourceType; -import com.ruoyi.framework.config.properties.DruidProperties; -import com.ruoyi.framework.datasource.DynamicDataSource; - -/** - * druid 配置多数据源 - * - * @author ruoyi - */ -@Configuration -public class DruidConfig -{ - @Bean - @ConfigurationProperties("spring.datasource.druid.master") - public DataSource masterDataSource(DruidProperties druidProperties) - { - DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); - return druidProperties.dataSource(dataSource); - } - - @Bean - @ConfigurationProperties("spring.datasource.druid.slave") - @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true") - public DataSource slaveDataSource(DruidProperties druidProperties) - { - DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); - return druidProperties.dataSource(dataSource); - } - - @Bean(name = "dynamicDataSource") - @Primary - public DynamicDataSource dataSource(DataSource masterDataSource, DataSource slaveDataSource) - { - Map targetDataSources = new HashMap<>(); - targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); - targetDataSources.put(DataSourceType.SLAVE.name(), slaveDataSource); - return new DynamicDataSource(masterDataSource, targetDataSources); - } - - /** - * 去除监控页面底部的广告 - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Bean - @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") - public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) - { - // 获取web监控页面的参数 - DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); - // 提取common.js的配置路径 - String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*"; - String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); - final String filePath = "support/http/resources/js/common.js"; - // 创建filter进行过滤 - Filter filter = new Filter() - { - @Override - public void init(javax.servlet.FilterConfig filterConfig) throws ServletException - { - } - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException - { - chain.doFilter(request, response); - // 重置缓冲区,响应头不会被重置 - response.resetBuffer(); - // 获取common.js - String text = Utils.readFromResource(filePath); - // 正则替换banner, 除去底部的广告信息 - text = text.replaceAll("
                            ", ""); - text = text.replaceAll("powered.*?shrek.wang", ""); - response.getWriter().write(text); - } - @Override - public void destroy() - { - } - }; - FilterRegistrationBean registrationBean = new FilterRegistrationBean(); - registrationBean.setFilter(filter); - registrationBean.addUrlPatterns(commonJsPattern); - return registrationBean; - } -} +package com.ruoyi.framework.config; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.sql.DataSource; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; +import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties; +import com.alibaba.druid.util.Utils; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.framework.config.properties.DruidProperties; +import com.ruoyi.framework.datasource.DynamicDataSource; + +/** + * druid 配置多数据源 + * + * @author ruoyi + */ +@Configuration +public class DruidConfig +{ + @Bean + @ConfigurationProperties("spring.datasource.druid.master") + public DataSource masterDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + + @Bean + @ConfigurationProperties("spring.datasource.druid.slave") + @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true") + public DataSource slaveDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + + @Bean(name = "dynamicDataSource") + @Primary + public DynamicDataSource dataSource(DataSource masterDataSource, DataSource slaveDataSource) + { + Map targetDataSources = new HashMap<>(); + targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); + targetDataSources.put(DataSourceType.SLAVE.name(), slaveDataSource); + return new DynamicDataSource(masterDataSource, targetDataSources); + } + + /** + * 去除监控页面底部的广告 + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Bean + @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") + public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) + { + // 获取web监控页面的参数 + DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); + // 提取common.js的配置路径 + String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*"; + String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); + final String filePath = "support/http/resources/js/common.js"; + // 创建filter进行过滤 + Filter filter = new Filter() + { + @Override + public void init(javax.servlet.FilterConfig filterConfig) throws ServletException + { + } + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + chain.doFilter(request, response); + // 重置缓冲区,响应头不会被重置 + response.resetBuffer(); + // 获取common.js + String text = Utils.readFromResource(filePath); + // 正则替换banner, 除去底部的广告信息 + text = text.replaceAll("
                            ", ""); + text = text.replaceAll("powered.*?shrek.wang", ""); + response.getWriter().write(text); + } + @Override + public void destroy() + { + } + }; + FilterRegistrationBean registrationBean = new FilterRegistrationBean(); + registrationBean.setFilter(filter); + registrationBean.addUrlPatterns(commonJsPattern); + return registrationBean; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java index 92d010e80..478b33c03 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java @@ -1,46 +1,46 @@ -package com.ruoyi.framework.config; - -import java.util.HashMap; -import java.util.Map; -import javax.servlet.DispatcherType; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.xss.XssFilter; - -/** - * Filter配置 - * - * @author ruoyi - */ -@Configuration -public class FilterConfig -{ - @Value("${xss.enabled}") - private String enabled; - - @Value("${xss.excludes}") - private String excludes; - - @Value("${xss.urlPatterns}") - private String urlPatterns; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Bean - public FilterRegistrationBean xssFilterRegistration() - { - FilterRegistrationBean registration = new FilterRegistrationBean(); - registration.setDispatcherTypes(DispatcherType.REQUEST); - registration.setFilter(new XssFilter()); - registration.addUrlPatterns(StringUtils.split(urlPatterns, ",")); - registration.setName("xssFilter"); - registration.setOrder(Integer.MAX_VALUE); - Map initParameters = new HashMap(); - initParameters.put("excludes", excludes); - initParameters.put("enabled", enabled); - registration.setInitParameters(initParameters); - return registration; - } -} +package com.ruoyi.framework.config; + +import java.util.HashMap; +import java.util.Map; +import javax.servlet.DispatcherType; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.xss.XssFilter; + +/** + * Filter配置 + * + * @author ruoyi + */ +@Configuration +public class FilterConfig +{ + @Value("${xss.enabled}") + private String enabled; + + @Value("${xss.excludes}") + private String excludes; + + @Value("${xss.urlPatterns}") + private String urlPatterns; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Bean + public FilterRegistrationBean xssFilterRegistration() + { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setDispatcherTypes(DispatcherType.REQUEST); + registration.setFilter(new XssFilter()); + registration.addUrlPatterns(StringUtils.split(urlPatterns, ",")); + registration.setName("xssFilter"); + registration.setOrder(Integer.MAX_VALUE); + Map initParameters = new HashMap(); + initParameters.put("excludes", excludes); + initParameters.put("enabled", enabled); + registration.setInitParameters(initParameters); + return registration; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/I18nConfig.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/I18nConfig.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/I18nConfig.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/I18nConfig.java index c572e1c5c..c5c209e41 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/I18nConfig.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/config/I18nConfig.java @@ -1,43 +1,43 @@ -package com.ruoyi.framework.config; - -import java.util.Locale; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.LocaleResolver; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; -import org.springframework.web.servlet.i18n.SessionLocaleResolver; - -/** - * 资源文件配置加载 - * - * @author ruoyi - */ -@Configuration -public class I18nConfig implements WebMvcConfigurer -{ - @Bean - public LocaleResolver localeResolver() - { - SessionLocaleResolver slr = new SessionLocaleResolver(); - // 默认语言 - slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE); - return slr; - } - - @Bean - public LocaleChangeInterceptor localeChangeInterceptor() - { - LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); - // 参数名 - lci.setParamName("lang"); - return lci; - } - - @Override - public void addInterceptors(InterceptorRegistry registry) - { - registry.addInterceptor(localeChangeInterceptor()); - } +package com.ruoyi.framework.config; + +import java.util.Locale; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; +import org.springframework.web.servlet.i18n.SessionLocaleResolver; + +/** + * 资源文件配置加载 + * + * @author ruoyi + */ +@Configuration +public class I18nConfig implements WebMvcConfigurer +{ + @Bean + public LocaleResolver localeResolver() + { + SessionLocaleResolver slr = new SessionLocaleResolver(); + // 默认语言 + slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE); + return slr; + } + + @Bean + public LocaleChangeInterceptor localeChangeInterceptor() + { + LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); + // 参数名 + lci.setParamName("lang"); + return lci; + } + + @Override + public void addInterceptors(InterceptorRegistry registry) + { + registry.addInterceptor(localeChangeInterceptor()); + } } \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java index bd0dabb01..ae89d3c50 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java @@ -1,76 +1,76 @@ -package com.ruoyi.framework.config; - -import java.security.SecureRandom; -import java.util.Random; -import com.google.code.kaptcha.text.impl.DefaultTextCreator; - -/** - * 验证码文本生成器 - * - * @author ruoyi - */ -public class KaptchaTextCreator extends DefaultTextCreator -{ - private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(","); - - @Override - public String getText() - { - Integer result = 0; - Random random = new SecureRandom(); - int x = random.nextInt(10); - int y = random.nextInt(10); - StringBuilder suChinese = new StringBuilder(); - int randomoperands = (int) Math.round(Math.random() * 2); - if (randomoperands == 0) - { - result = x * y; - suChinese.append(CNUMBERS[x]); - suChinese.append("*"); - suChinese.append(CNUMBERS[y]); - } - else if (randomoperands == 1) - { - if (!(x == 0) && y % x == 0) - { - result = y / x; - suChinese.append(CNUMBERS[y]); - suChinese.append("/"); - suChinese.append(CNUMBERS[x]); - } - else - { - result = x + y; - suChinese.append(CNUMBERS[x]); - suChinese.append("+"); - suChinese.append(CNUMBERS[y]); - } - } - else if (randomoperands == 2) - { - if (x >= y) - { - result = x - y; - suChinese.append(CNUMBERS[x]); - suChinese.append("-"); - suChinese.append(CNUMBERS[y]); - } - else - { - result = y - x; - suChinese.append(CNUMBERS[y]); - suChinese.append("-"); - suChinese.append(CNUMBERS[x]); - } - } - else - { - result = x + y; - suChinese.append(CNUMBERS[x]); - suChinese.append("+"); - suChinese.append(CNUMBERS[y]); - } - suChinese.append("=?@" + result); - return suChinese.toString(); - } -} +package com.ruoyi.framework.config; + +import java.security.SecureRandom; +import java.util.Random; +import com.google.code.kaptcha.text.impl.DefaultTextCreator; + +/** + * 验证码文本生成器 + * + * @author ruoyi + */ +public class KaptchaTextCreator extends DefaultTextCreator +{ + private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(","); + + @Override + public String getText() + { + Integer result = 0; + Random random = new SecureRandom(); + int x = random.nextInt(10); + int y = random.nextInt(10); + StringBuilder suChinese = new StringBuilder(); + int randomoperands = (int) Math.round(Math.random() * 2); + if (randomoperands == 0) + { + result = x * y; + suChinese.append(CNUMBERS[x]); + suChinese.append("*"); + suChinese.append(CNUMBERS[y]); + } + else if (randomoperands == 1) + { + if (!(x == 0) && y % x == 0) + { + result = y / x; + suChinese.append(CNUMBERS[y]); + suChinese.append("/"); + suChinese.append(CNUMBERS[x]); + } + else + { + result = x + y; + suChinese.append(CNUMBERS[x]); + suChinese.append("+"); + suChinese.append(CNUMBERS[y]); + } + } + else if (randomoperands == 2) + { + if (x >= y) + { + result = x - y; + suChinese.append(CNUMBERS[x]); + suChinese.append("-"); + suChinese.append(CNUMBERS[y]); + } + else + { + result = y - x; + suChinese.append(CNUMBERS[y]); + suChinese.append("-"); + suChinese.append(CNUMBERS[x]); + } + } + else + { + result = x + y; + suChinese.append(CNUMBERS[x]); + suChinese.append("+"); + suChinese.append(CNUMBERS[y]); + } + suChinese.append("=?@" + result); + return suChinese.toString(); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java index a927e1a46..fe42d3a88 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java @@ -1,58 +1,58 @@ -package com.ruoyi.framework.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import com.ruoyi.common.config.Global; -import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; - -/** - * 通用配置 - * - * @author ruoyi - */ -@Configuration -public class ResourcesConfig implements WebMvcConfigurer -{ - /** - * 首页地址 - */ - @Value("${shiro.user.indexUrl}") - private String indexUrl; - - @Autowired - private RepeatSubmitInterceptor repeatSubmitInterceptor; - - /** - * 默认首页的设置,当输入域名是可以自动跳转到默认指定的网页 - */ - @Override - public void addViewControllers(ViewControllerRegistry registry) - { - registry.addViewController("/").setViewName("forward:" + indexUrl); - } - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) - { - /** 本地文件上传路径 */ - registry.addResourceHandler("/profile/**").addResourceLocations("file:" + Global.getProfile() + "/"); - - /** swagger配置 */ - registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - - /** - * 自定义拦截规则 - */ - @Override - public void addInterceptors(InterceptorRegistry registry) - { - registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**"); - } +package com.ruoyi.framework.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import com.ruoyi.common.config.Global; +import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; + +/** + * 通用配置 + * + * @author ruoyi + */ +@Configuration +public class ResourcesConfig implements WebMvcConfigurer +{ + /** + * 首页地址 + */ + @Value("${shiro.user.indexUrl}") + private String indexUrl; + + @Autowired + private RepeatSubmitInterceptor repeatSubmitInterceptor; + + /** + * 默认首页的设置,当输入域名是可以自动跳转到默认指定的网页 + */ + @Override + public void addViewControllers(ViewControllerRegistry registry) + { + registry.addViewController("/").setViewName("forward:" + indexUrl); + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) + { + /** 本地文件上传路径 */ + registry.addResourceHandler("/profile/**").addResourceLocations("file:" + Global.getProfile() + "/"); + + /** swagger配置 */ + registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + } + + /** + * 自定义拦截规则 + */ + @Override + public void addInterceptors(InterceptorRegistry registry) + { + registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**"); + } } \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java index 721baf37b..2867c7bf3 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java @@ -1,371 +1,371 @@ -package com.ruoyi.framework.config; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.servlet.Filter; -import org.apache.commons.io.IOUtils; -import org.apache.shiro.cache.ehcache.EhCacheManager; -import org.apache.shiro.codec.Base64; -import org.apache.shiro.config.ConfigurationException; -import org.apache.shiro.io.ResourceUtils; -import org.apache.shiro.mgt.SecurityManager; -import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; -import org.apache.shiro.spring.web.ShiroFilterFactoryBean; -import org.apache.shiro.web.mgt.CookieRememberMeManager; -import org.apache.shiro.web.mgt.DefaultWebSecurityManager; -import org.apache.shiro.web.servlet.SimpleCookie; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.shiro.realm.UserRealm; -import com.ruoyi.framework.shiro.session.OnlineSessionDAO; -import com.ruoyi.framework.shiro.session.OnlineSessionFactory; -import com.ruoyi.framework.shiro.web.filter.LogoutFilter; -import com.ruoyi.framework.shiro.web.filter.captcha.CaptchaValidateFilter; -import com.ruoyi.framework.shiro.web.filter.kickout.KickoutSessionFilter; -import com.ruoyi.framework.shiro.web.filter.online.OnlineSessionFilter; -import com.ruoyi.framework.shiro.web.filter.sync.SyncOnlineSessionFilter; -import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager; -import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler; -import at.pollux.thymeleaf.shiro.dialect.ShiroDialect; - -/** - * 权限配置加载 - * - * @author ruoyi - */ -@Configuration -public class ShiroConfig -{ - public static final String PREMISSION_STRING = "perms[\"{0}\"]"; - - // Session超时时间,单位为毫秒(默认30分钟) - @Value("${shiro.session.expireTime}") - private int expireTime; - - // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟 - @Value("${shiro.session.validationInterval}") - private int validationInterval; - - // 同一个用户最大会话数 - @Value("${shiro.session.maxSession}") - private int maxSession; - - // 踢出之前登录的/之后登录的用户,默认踢出之前登录的用户 - @Value("${shiro.session.kickoutAfter}") - private boolean kickoutAfter; - - // 验证码开关 - @Value("${shiro.user.captchaEnabled}") - private boolean captchaEnabled; - - // 验证码类型 - @Value("${shiro.user.captchaType}") - private String captchaType; - - // 设置Cookie的域名 - @Value("${shiro.cookie.domain}") - private String domain; - - // 设置cookie的有效访问路径 - @Value("${shiro.cookie.path}") - private String path; - - // 设置HttpOnly属性 - @Value("${shiro.cookie.httpOnly}") - private boolean httpOnly; - - // 设置Cookie的过期时间,秒为单位 - @Value("${shiro.cookie.maxAge}") - private int maxAge; - - // 登录地址 - @Value("${shiro.user.loginUrl}") - private String loginUrl; - - // 权限认证失败地址 - @Value("${shiro.user.unauthorizedUrl}") - private String unauthorizedUrl; - - /** - * 缓存管理器 使用Ehcache实现 - */ - @Bean - public EhCacheManager getEhCacheManager() - { - net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("ruoyi"); - EhCacheManager em = new EhCacheManager(); - if (StringUtils.isNull(cacheManager)) - { - em.setCacheManager(new net.sf.ehcache.CacheManager(getCacheManagerConfigFileInputStream())); - return em; - } - else - { - em.setCacheManager(cacheManager); - return em; - } - } - - /** - * 返回配置文件流 避免ehcache配置文件一直被占用,无法完全销毁项目重新部署 - */ - protected InputStream getCacheManagerConfigFileInputStream() - { - String configFile = "classpath:ehcache/ehcache-shiro.xml"; - InputStream inputStream = null; - try - { - inputStream = ResourceUtils.getInputStreamForPath(configFile); - byte[] b = IOUtils.toByteArray(inputStream); - InputStream in = new ByteArrayInputStream(b); - return in; - } - catch (IOException e) - { - throw new ConfigurationException( - "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e); - } - finally - { - IOUtils.closeQuietly(inputStream); - } - } - - /** - * 自定义Realm - */ - @Bean - public UserRealm userRealm(EhCacheManager cacheManager) - { - UserRealm userRealm = new UserRealm(); - userRealm.setCacheManager(cacheManager); - return userRealm; - } - - /** - * 自定义sessionDAO会话 - */ - @Bean - public OnlineSessionDAO sessionDAO() - { - OnlineSessionDAO sessionDAO = new OnlineSessionDAO(); - return sessionDAO; - } - - /** - * 自定义sessionFactory会话 - */ - @Bean - public OnlineSessionFactory sessionFactory() - { - OnlineSessionFactory sessionFactory = new OnlineSessionFactory(); - return sessionFactory; - } - - /** - * 会话管理器 - */ - @Bean - public OnlineWebSessionManager sessionManager() - { - OnlineWebSessionManager manager = new OnlineWebSessionManager(); - // 加入缓存管理器 - manager.setCacheManager(getEhCacheManager()); - // 删除过期的session - manager.setDeleteInvalidSessions(true); - // 设置全局session超时时间 - manager.setGlobalSessionTimeout(expireTime * 60 * 1000); - // 去掉 JSESSIONID - manager.setSessionIdUrlRewritingEnabled(false); - // 定义要使用的无效的Session定时调度器 - manager.setSessionValidationScheduler(SpringUtils.getBean(SpringSessionValidationScheduler.class)); - // 是否定时检查session - manager.setSessionValidationSchedulerEnabled(true); - // 自定义SessionDao - manager.setSessionDAO(sessionDAO()); - // 自定义sessionFactory - manager.setSessionFactory(sessionFactory()); - return manager; - } - - /** - * 安全管理器 - */ - @Bean - public SecurityManager securityManager(UserRealm userRealm, SpringSessionValidationScheduler springSessionValidationScheduler) - { - DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); - // 设置realm. - securityManager.setRealm(userRealm); - // 记住我 - securityManager.setRememberMeManager(rememberMeManager()); - // 注入缓存管理器; - securityManager.setCacheManager(getEhCacheManager()); - // session管理器 - securityManager.setSessionManager(sessionManager()); - return securityManager; - } - - /** - * 退出过滤器 - */ - public LogoutFilter logoutFilter() - { - LogoutFilter logoutFilter = new LogoutFilter(); - logoutFilter.setCacheManager(getEhCacheManager()); - logoutFilter.setLoginUrl(loginUrl); - return logoutFilter; - } - - /** - * Shiro过滤器配置 - */ - @Bean - public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) - { - ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); - // Shiro的核心安全接口,这个属性是必须的 - shiroFilterFactoryBean.setSecurityManager(securityManager); - // 身份认证失败,则跳转到登录页面的配置 - shiroFilterFactoryBean.setLoginUrl(loginUrl); - // 权限认证失败,则跳转到指定页面 - shiroFilterFactoryBean.setUnauthorizedUrl(unauthorizedUrl); - // Shiro连接约束配置,即过滤链的定义 - LinkedHashMap filterChainDefinitionMap = new LinkedHashMap<>(); - // 对静态资源设置匿名访问 - filterChainDefinitionMap.put("/favicon.ico**", "anon"); - filterChainDefinitionMap.put("/ruoyi.png**", "anon"); - filterChainDefinitionMap.put("/css/**", "anon"); - filterChainDefinitionMap.put("/docs/**", "anon"); - filterChainDefinitionMap.put("/fonts/**", "anon"); - filterChainDefinitionMap.put("/img/**", "anon"); - filterChainDefinitionMap.put("/ajax/**", "anon"); - filterChainDefinitionMap.put("/js/**", "anon"); - filterChainDefinitionMap.put("/ruoyi/**", "anon"); - filterChainDefinitionMap.put("/druid/**", "anon"); - filterChainDefinitionMap.put("/captcha/captchaImage**", "anon"); - // 退出 logout地址,shiro去清除session - filterChainDefinitionMap.put("/logout", "logout"); - // 不需要拦截的访问 - filterChainDefinitionMap.put("/login", "anon,captchaValidate"); - // 系统权限列表 - // filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll()); - - Map filters = new LinkedHashMap(); - filters.put("onlineSession", onlineSessionFilter()); - filters.put("syncOnlineSession", syncOnlineSessionFilter()); - filters.put("captchaValidate", captchaValidateFilter()); - filters.put("kickout", kickoutSessionFilter()); - // 注销成功,则跳转到指定页面 - filters.put("logout", logoutFilter()); - shiroFilterFactoryBean.setFilters(filters); - - // 所有请求需要认证 - filterChainDefinitionMap.put("/**", "user,kickout,onlineSession,syncOnlineSession"); - shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); - - return shiroFilterFactoryBean; - } - - /** - * 自定义在线用户处理过滤器 - */ - @Bean - public OnlineSessionFilter onlineSessionFilter() - { - OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter(); - onlineSessionFilter.setLoginUrl(loginUrl); - return onlineSessionFilter; - } - - /** - * 自定义在线用户同步过滤器 - */ - @Bean - public SyncOnlineSessionFilter syncOnlineSessionFilter() - { - SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter(); - return syncOnlineSessionFilter; - } - - /** - * 自定义验证码过滤器 - */ - @Bean - public CaptchaValidateFilter captchaValidateFilter() - { - CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter(); - captchaValidateFilter.setCaptchaEnabled(captchaEnabled); - captchaValidateFilter.setCaptchaType(captchaType); - return captchaValidateFilter; - } - - /** - * cookie 属性设置 - */ - public SimpleCookie rememberMeCookie() - { - SimpleCookie cookie = new SimpleCookie("rememberMe"); - cookie.setDomain(domain); - cookie.setPath(path); - cookie.setHttpOnly(httpOnly); - cookie.setMaxAge(maxAge * 24 * 60 * 60); - return cookie; - } - - /** - * 记住我 - */ - public CookieRememberMeManager rememberMeManager() - { - CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager(); - cookieRememberMeManager.setCookie(rememberMeCookie()); - cookieRememberMeManager.setCipherKey(Base64.decode("fCq+/xW488hMTCD+cmJ3aQ==")); - return cookieRememberMeManager; - } - - /** - * 同一个用户多设备登录限制 - */ - public KickoutSessionFilter kickoutSessionFilter() - { - KickoutSessionFilter kickoutSessionFilter = new KickoutSessionFilter(); - kickoutSessionFilter.setCacheManager(getEhCacheManager()); - kickoutSessionFilter.setSessionManager(sessionManager()); - // 同一个用户最大的会话数,默认-1无限制;比如2的意思是同一个用户允许最多同时两个人登录 - kickoutSessionFilter.setMaxSession(maxSession); - // 是否踢出后来登录的,默认是false;即后者登录的用户踢出前者登录的用户;踢出顺序 - kickoutSessionFilter.setKickoutAfter(kickoutAfter); - // 被踢出后重定向到的地址; - kickoutSessionFilter.setKickoutUrl("/login?kickout=1"); - return kickoutSessionFilter; - } - - /** - * thymeleaf模板引擎和shiro框架的整合 - */ - @Bean - public ShiroDialect shiroDialect() - { - return new ShiroDialect(); - } - - /** - * 开启Shiro注解通知器 - */ - @Bean - public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor( - @Qualifier("securityManager") SecurityManager securityManager) - { - AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); - authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); - return authorizationAttributeSourceAdvisor; - } -} +package com.ruoyi.framework.config; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.LinkedHashMap; +import java.util.Map; +import javax.servlet.Filter; +import org.apache.commons.io.IOUtils; +import org.apache.shiro.cache.ehcache.EhCacheManager; +import org.apache.shiro.codec.Base64; +import org.apache.shiro.config.ConfigurationException; +import org.apache.shiro.io.ResourceUtils; +import org.apache.shiro.mgt.SecurityManager; +import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; +import org.apache.shiro.spring.web.ShiroFilterFactoryBean; +import org.apache.shiro.web.mgt.CookieRememberMeManager; +import org.apache.shiro.web.mgt.DefaultWebSecurityManager; +import org.apache.shiro.web.servlet.SimpleCookie; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.framework.shiro.realm.UserRealm; +import com.ruoyi.framework.shiro.session.OnlineSessionDAO; +import com.ruoyi.framework.shiro.session.OnlineSessionFactory; +import com.ruoyi.framework.shiro.web.filter.LogoutFilter; +import com.ruoyi.framework.shiro.web.filter.captcha.CaptchaValidateFilter; +import com.ruoyi.framework.shiro.web.filter.kickout.KickoutSessionFilter; +import com.ruoyi.framework.shiro.web.filter.online.OnlineSessionFilter; +import com.ruoyi.framework.shiro.web.filter.sync.SyncOnlineSessionFilter; +import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager; +import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler; +import at.pollux.thymeleaf.shiro.dialect.ShiroDialect; + +/** + * 权限配置加载 + * + * @author ruoyi + */ +@Configuration +public class ShiroConfig +{ + public static final String PREMISSION_STRING = "perms[\"{0}\"]"; + + // Session超时时间,单位为毫秒(默认30分钟) + @Value("${shiro.session.expireTime}") + private int expireTime; + + // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟 + @Value("${shiro.session.validationInterval}") + private int validationInterval; + + // 同一个用户最大会话数 + @Value("${shiro.session.maxSession}") + private int maxSession; + + // 踢出之前登录的/之后登录的用户,默认踢出之前登录的用户 + @Value("${shiro.session.kickoutAfter}") + private boolean kickoutAfter; + + // 验证码开关 + @Value("${shiro.user.captchaEnabled}") + private boolean captchaEnabled; + + // 验证码类型 + @Value("${shiro.user.captchaType}") + private String captchaType; + + // 设置Cookie的域名 + @Value("${shiro.cookie.domain}") + private String domain; + + // 设置cookie的有效访问路径 + @Value("${shiro.cookie.path}") + private String path; + + // 设置HttpOnly属性 + @Value("${shiro.cookie.httpOnly}") + private boolean httpOnly; + + // 设置Cookie的过期时间,秒为单位 + @Value("${shiro.cookie.maxAge}") + private int maxAge; + + // 登录地址 + @Value("${shiro.user.loginUrl}") + private String loginUrl; + + // 权限认证失败地址 + @Value("${shiro.user.unauthorizedUrl}") + private String unauthorizedUrl; + + /** + * 缓存管理器 使用Ehcache实现 + */ + @Bean + public EhCacheManager getEhCacheManager() + { + net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("ruoyi"); + EhCacheManager em = new EhCacheManager(); + if (StringUtils.isNull(cacheManager)) + { + em.setCacheManager(new net.sf.ehcache.CacheManager(getCacheManagerConfigFileInputStream())); + return em; + } + else + { + em.setCacheManager(cacheManager); + return em; + } + } + + /** + * 返回配置文件流 避免ehcache配置文件一直被占用,无法完全销毁项目重新部署 + */ + protected InputStream getCacheManagerConfigFileInputStream() + { + String configFile = "classpath:ehcache/ehcache-shiro.xml"; + InputStream inputStream = null; + try + { + inputStream = ResourceUtils.getInputStreamForPath(configFile); + byte[] b = IOUtils.toByteArray(inputStream); + InputStream in = new ByteArrayInputStream(b); + return in; + } + catch (IOException e) + { + throw new ConfigurationException( + "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e); + } + finally + { + IOUtils.closeQuietly(inputStream); + } + } + + /** + * 自定义Realm + */ + @Bean + public UserRealm userRealm(EhCacheManager cacheManager) + { + UserRealm userRealm = new UserRealm(); + userRealm.setCacheManager(cacheManager); + return userRealm; + } + + /** + * 自定义sessionDAO会话 + */ + @Bean + public OnlineSessionDAO sessionDAO() + { + OnlineSessionDAO sessionDAO = new OnlineSessionDAO(); + return sessionDAO; + } + + /** + * 自定义sessionFactory会话 + */ + @Bean + public OnlineSessionFactory sessionFactory() + { + OnlineSessionFactory sessionFactory = new OnlineSessionFactory(); + return sessionFactory; + } + + /** + * 会话管理器 + */ + @Bean + public OnlineWebSessionManager sessionManager() + { + OnlineWebSessionManager manager = new OnlineWebSessionManager(); + // 加入缓存管理器 + manager.setCacheManager(getEhCacheManager()); + // 删除过期的session + manager.setDeleteInvalidSessions(true); + // 设置全局session超时时间 + manager.setGlobalSessionTimeout(expireTime * 60 * 1000); + // 去掉 JSESSIONID + manager.setSessionIdUrlRewritingEnabled(false); + // 定义要使用的无效的Session定时调度器 + manager.setSessionValidationScheduler(SpringUtils.getBean(SpringSessionValidationScheduler.class)); + // 是否定时检查session + manager.setSessionValidationSchedulerEnabled(true); + // 自定义SessionDao + manager.setSessionDAO(sessionDAO()); + // 自定义sessionFactory + manager.setSessionFactory(sessionFactory()); + return manager; + } + + /** + * 安全管理器 + */ + @Bean + public SecurityManager securityManager(UserRealm userRealm, SpringSessionValidationScheduler springSessionValidationScheduler) + { + DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); + // 设置realm. + securityManager.setRealm(userRealm); + // 记住我 + securityManager.setRememberMeManager(rememberMeManager()); + // 注入缓存管理器; + securityManager.setCacheManager(getEhCacheManager()); + // session管理器 + securityManager.setSessionManager(sessionManager()); + return securityManager; + } + + /** + * 退出过滤器 + */ + public LogoutFilter logoutFilter() + { + LogoutFilter logoutFilter = new LogoutFilter(); + logoutFilter.setCacheManager(getEhCacheManager()); + logoutFilter.setLoginUrl(loginUrl); + return logoutFilter; + } + + /** + * Shiro过滤器配置 + */ + @Bean + public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) + { + ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); + // Shiro的核心安全接口,这个属性是必须的 + shiroFilterFactoryBean.setSecurityManager(securityManager); + // 身份认证失败,则跳转到登录页面的配置 + shiroFilterFactoryBean.setLoginUrl(loginUrl); + // 权限认证失败,则跳转到指定页面 + shiroFilterFactoryBean.setUnauthorizedUrl(unauthorizedUrl); + // Shiro连接约束配置,即过滤链的定义 + LinkedHashMap filterChainDefinitionMap = new LinkedHashMap<>(); + // 对静态资源设置匿名访问 + filterChainDefinitionMap.put("/favicon.ico**", "anon"); + filterChainDefinitionMap.put("/ruoyi.png**", "anon"); + filterChainDefinitionMap.put("/css/**", "anon"); + filterChainDefinitionMap.put("/docs/**", "anon"); + filterChainDefinitionMap.put("/fonts/**", "anon"); + filterChainDefinitionMap.put("/img/**", "anon"); + filterChainDefinitionMap.put("/ajax/**", "anon"); + filterChainDefinitionMap.put("/js/**", "anon"); + filterChainDefinitionMap.put("/ruoyi/**", "anon"); + filterChainDefinitionMap.put("/druid/**", "anon"); + filterChainDefinitionMap.put("/captcha/captchaImage**", "anon"); + // 退出 logout地址,shiro去清除session + filterChainDefinitionMap.put("/logout", "logout"); + // 不需要拦截的访问 + filterChainDefinitionMap.put("/login", "anon,captchaValidate"); + // 系统权限列表 + // filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll()); + + Map filters = new LinkedHashMap(); + filters.put("onlineSession", onlineSessionFilter()); + filters.put("syncOnlineSession", syncOnlineSessionFilter()); + filters.put("captchaValidate", captchaValidateFilter()); + filters.put("kickout", kickoutSessionFilter()); + // 注销成功,则跳转到指定页面 + filters.put("logout", logoutFilter()); + shiroFilterFactoryBean.setFilters(filters); + + // 所有请求需要认证 + filterChainDefinitionMap.put("/**", "user,kickout,onlineSession,syncOnlineSession"); + shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); + + return shiroFilterFactoryBean; + } + + /** + * 自定义在线用户处理过滤器 + */ + @Bean + public OnlineSessionFilter onlineSessionFilter() + { + OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter(); + onlineSessionFilter.setLoginUrl(loginUrl); + return onlineSessionFilter; + } + + /** + * 自定义在线用户同步过滤器 + */ + @Bean + public SyncOnlineSessionFilter syncOnlineSessionFilter() + { + SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter(); + return syncOnlineSessionFilter; + } + + /** + * 自定义验证码过滤器 + */ + @Bean + public CaptchaValidateFilter captchaValidateFilter() + { + CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter(); + captchaValidateFilter.setCaptchaEnabled(captchaEnabled); + captchaValidateFilter.setCaptchaType(captchaType); + return captchaValidateFilter; + } + + /** + * cookie 属性设置 + */ + public SimpleCookie rememberMeCookie() + { + SimpleCookie cookie = new SimpleCookie("rememberMe"); + cookie.setDomain(domain); + cookie.setPath(path); + cookie.setHttpOnly(httpOnly); + cookie.setMaxAge(maxAge * 24 * 60 * 60); + return cookie; + } + + /** + * 记住我 + */ + public CookieRememberMeManager rememberMeManager() + { + CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager(); + cookieRememberMeManager.setCookie(rememberMeCookie()); + cookieRememberMeManager.setCipherKey(Base64.decode("fCq+/xW488hMTCD+cmJ3aQ==")); + return cookieRememberMeManager; + } + + /** + * 同一个用户多设备登录限制 + */ + public KickoutSessionFilter kickoutSessionFilter() + { + KickoutSessionFilter kickoutSessionFilter = new KickoutSessionFilter(); + kickoutSessionFilter.setCacheManager(getEhCacheManager()); + kickoutSessionFilter.setSessionManager(sessionManager()); + // 同一个用户最大的会话数,默认-1无限制;比如2的意思是同一个用户允许最多同时两个人登录 + kickoutSessionFilter.setMaxSession(maxSession); + // 是否踢出后来登录的,默认是false;即后者登录的用户踢出前者登录的用户;踢出顺序 + kickoutSessionFilter.setKickoutAfter(kickoutAfter); + // 被踢出后重定向到的地址; + kickoutSessionFilter.setKickoutUrl("/login?kickout=1"); + return kickoutSessionFilter; + } + + /** + * thymeleaf模板引擎和shiro框架的整合 + */ + @Bean + public ShiroDialect shiroDialect() + { + return new ShiroDialect(); + } + + /** + * 开启Shiro注解通知器 + */ + @Bean + public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor( + @Qualifier("securityManager") SecurityManager securityManager) + { + AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); + authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); + return authorizationAttributeSourceAdvisor; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java b/bmw-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java rename to bmw-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java b/bmw-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java rename to bmw-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java index a5f764072..94b3d0d3b 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java @@ -1,27 +1,27 @@ -package com.ruoyi.framework.datasource; - -import java.util.Map; -import javax.sql.DataSource; -import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; -import com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder; - -/** - * 动态数据源 - * - * @author ruoyi - */ -public class DynamicDataSource extends AbstractRoutingDataSource -{ - public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) - { - super.setDefaultTargetDataSource(defaultTargetDataSource); - super.setTargetDataSources(targetDataSources); - super.afterPropertiesSet(); - } - - @Override - protected Object determineCurrentLookupKey() - { - return DynamicDataSourceContextHolder.getDataSourceType(); - } +package com.ruoyi.framework.datasource; + +import java.util.Map; +import javax.sql.DataSource; +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; +import com.ruoyi.common.config.datasource.DynamicDataSourceContextHolder; + +/** + * 动态数据源 + * + * @author ruoyi + */ +public class DynamicDataSource extends AbstractRoutingDataSource +{ + public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) + { + super.setDefaultTargetDataSource(defaultTargetDataSource); + super.setTargetDataSources(targetDataSources); + super.afterPropertiesSet(); + } + + @Override + protected Object determineCurrentLookupKey() + { + return DynamicDataSourceContextHolder.getDataSourceType(); + } } \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/bmw-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java rename to bmw-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java b/bmw-framework/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java rename to bmw-framework/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/bmw-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java rename to bmw-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java b/bmw-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java similarity index 95% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java rename to bmw-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java index a30067dd9..8f7830040 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java @@ -1,55 +1,55 @@ -package com.ruoyi.framework.manager; - -import java.util.TimerTask; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import com.ruoyi.common.utils.Threads; -import com.ruoyi.common.utils.spring.SpringUtils; - -/** - * 异步任务管理器 - * - * @author liuhulu - */ -public class AsyncManager -{ - /** - * 操作延迟10毫秒 - */ - private final int OPERATE_DELAY_TIME = 10; - - /** - * 异步操作任务调度线程池 - */ - private ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService"); - - /** - * 单例模式 - */ - private AsyncManager(){} - - private static AsyncManager me = new AsyncManager(); - - public static AsyncManager me() - { - return me; - } - - /** - * 执行任务 - * - * @param task 任务 - */ - public void execute(TimerTask task) - { - executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS); - } - - /** - * 停止任务线程池 - */ - public void shutdown() - { - Threads.shutdownAndAwaitTermination(executor); - } -} +package com.ruoyi.framework.manager; + +import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import com.ruoyi.common.utils.Threads; +import com.ruoyi.common.utils.spring.SpringUtils; + +/** + * 异步任务管理器 + * + * @author liuhulu + */ +public class AsyncManager +{ + /** + * 操作延迟10毫秒 + */ + private final int OPERATE_DELAY_TIME = 10; + + /** + * 异步操作任务调度线程池 + */ + private ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService"); + + /** + * 单例模式 + */ + private AsyncManager(){} + + private static AsyncManager me = new AsyncManager(); + + public static AsyncManager me() + { + return me; + } + + /** + * 执行任务 + * + * @param task 任务 + */ + public void execute(TimerTask task) + { + executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS); + } + + /** + * 停止任务线程池 + */ + public void shutdown() + { + Threads.shutdownAndAwaitTermination(executor); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java b/bmw-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java rename to bmw-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java b/bmw-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java rename to bmw-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java index 719c380e4..76a3eabcf 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java @@ -1,135 +1,135 @@ -package com.ruoyi.framework.manager.factory; - -import java.util.TimerTask; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.utils.AddressUtils; -import com.ruoyi.common.utils.ServletUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.shiro.session.OnlineSession; -import com.ruoyi.framework.util.LogUtils; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysLogininfor; -import com.ruoyi.system.domain.SysOperLog; -import com.ruoyi.system.domain.SysUserOnline; -import com.ruoyi.system.service.ISysOperLogService; -import com.ruoyi.system.service.ISysUserOnlineService; -import com.ruoyi.system.service.impl.SysLogininforServiceImpl; -import eu.bitwalker.useragentutils.UserAgent; - -/** - * 异步工厂(产生任务用) - * - * @author liuhulu - * - */ -public class AsyncFactory -{ - private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user"); - - /** - * 同步session到数据库 - * - * @param session 在线用户会话 - * @return 任务task - */ - public static TimerTask syncSessionToDb(final OnlineSession session) - { - return new TimerTask() - { - @Override - public void run() - { - SysUserOnline online = new SysUserOnline(); - online.setSessionId(String.valueOf(session.getId())); - online.setDeptName(session.getDeptName()); - online.setLoginName(session.getLoginName()); - online.setStartTimestamp(session.getStartTimestamp()); - online.setLastAccessTime(session.getLastAccessTime()); - online.setExpireTime(session.getTimeout()); - online.setIpaddr(session.getHost()); - online.setLoginLocation(AddressUtils.getRealAddressByIP(session.getHost())); - online.setBrowser(session.getBrowser()); - online.setOs(session.getOs()); - online.setStatus(session.getStatus()); - SpringUtils.getBean(ISysUserOnlineService.class).saveOnline(online); - - } - }; - } - - /** - * 操作日志记录 - * - * @param operLog 操作日志信息 - * @return 任务task - */ - public static TimerTask recordOper(final SysOperLog operLog) - { - return new TimerTask() - { - @Override - public void run() - { - // 远程查询操作地点 - operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp())); - SpringUtils.getBean(ISysOperLogService.class).insertOperlog(operLog); - } - }; - } - - /** - * 记录登陆信息 - * - * @param username 用户名 - * @param status 状态 - * @param message 消息 - * @param args 列表 - * @return 任务task - */ - public static TimerTask recordLogininfor(final String username, final String status, final String message, final Object... args) - { - final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); - final String ip = ShiroUtils.getIp(); - return new TimerTask() - { - @Override - public void run() - { - String address = AddressUtils.getRealAddressByIP(ip); - StringBuilder s = new StringBuilder(); - s.append(LogUtils.getBlock(ip)); - s.append(address); - s.append(LogUtils.getBlock(username)); - s.append(LogUtils.getBlock(status)); - s.append(LogUtils.getBlock(message)); - // 打印信息到日志 - sys_user_logger.info(s.toString(), args); - // 获取客户端操作系统 - String os = userAgent.getOperatingSystem().getName(); - // 获取客户端浏览器 - String browser = userAgent.getBrowser().getName(); - // 封装对象 - SysLogininfor logininfor = new SysLogininfor(); - logininfor.setLoginName(username); - logininfor.setIpaddr(ip); - logininfor.setLoginLocation(address); - logininfor.setBrowser(browser); - logininfor.setOs(os); - logininfor.setMsg(message); - // 日志状态 - if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status)) - { - logininfor.setStatus(Constants.SUCCESS); - } - else if (Constants.LOGIN_FAIL.equals(status)) - { - logininfor.setStatus(Constants.FAIL); - } - // 插入数据 - SpringUtils.getBean(SysLogininforServiceImpl.class).insertLogininfor(logininfor); - } - }; - } -} +package com.ruoyi.framework.manager.factory; + +import java.util.TimerTask; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.AddressUtils; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.framework.shiro.session.OnlineSession; +import com.ruoyi.framework.util.LogUtils; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.domain.SysUserOnline; +import com.ruoyi.system.service.ISysOperLogService; +import com.ruoyi.system.service.ISysUserOnlineService; +import com.ruoyi.system.service.impl.SysLogininforServiceImpl; +import eu.bitwalker.useragentutils.UserAgent; + +/** + * 异步工厂(产生任务用) + * + * @author liuhulu + * + */ +public class AsyncFactory +{ + private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user"); + + /** + * 同步session到数据库 + * + * @param session 在线用户会话 + * @return 任务task + */ + public static TimerTask syncSessionToDb(final OnlineSession session) + { + return new TimerTask() + { + @Override + public void run() + { + SysUserOnline online = new SysUserOnline(); + online.setSessionId(String.valueOf(session.getId())); + online.setDeptName(session.getDeptName()); + online.setLoginName(session.getLoginName()); + online.setStartTimestamp(session.getStartTimestamp()); + online.setLastAccessTime(session.getLastAccessTime()); + online.setExpireTime(session.getTimeout()); + online.setIpaddr(session.getHost()); + online.setLoginLocation(AddressUtils.getRealAddressByIP(session.getHost())); + online.setBrowser(session.getBrowser()); + online.setOs(session.getOs()); + online.setStatus(session.getStatus()); + SpringUtils.getBean(ISysUserOnlineService.class).saveOnline(online); + + } + }; + } + + /** + * 操作日志记录 + * + * @param operLog 操作日志信息 + * @return 任务task + */ + public static TimerTask recordOper(final SysOperLog operLog) + { + return new TimerTask() + { + @Override + public void run() + { + // 远程查询操作地点 + operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp())); + SpringUtils.getBean(ISysOperLogService.class).insertOperlog(operLog); + } + }; + } + + /** + * 记录登陆信息 + * + * @param username 用户名 + * @param status 状态 + * @param message 消息 + * @param args 列表 + * @return 任务task + */ + public static TimerTask recordLogininfor(final String username, final String status, final String message, final Object... args) + { + final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); + final String ip = ShiroUtils.getIp(); + return new TimerTask() + { + @Override + public void run() + { + String address = AddressUtils.getRealAddressByIP(ip); + StringBuilder s = new StringBuilder(); + s.append(LogUtils.getBlock(ip)); + s.append(address); + s.append(LogUtils.getBlock(username)); + s.append(LogUtils.getBlock(status)); + s.append(LogUtils.getBlock(message)); + // 打印信息到日志 + sys_user_logger.info(s.toString(), args); + // 获取客户端操作系统 + String os = userAgent.getOperatingSystem().getName(); + // 获取客户端浏览器 + String browser = userAgent.getBrowser().getName(); + // 封装对象 + SysLogininfor logininfor = new SysLogininfor(); + logininfor.setLoginName(username); + logininfor.setIpaddr(ip); + logininfor.setLoginLocation(address); + logininfor.setBrowser(browser); + logininfor.setOs(os); + logininfor.setMsg(message); + // 日志状态 + if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status)) + { + logininfor.setStatus(Constants.SUCCESS); + } + else if (Constants.LOGIN_FAIL.equals(status)) + { + logininfor.setStatus(Constants.FAIL); + } + // 插入数据 + SpringUtils.getBean(SysLogininforServiceImpl.class).insertLogininfor(logininfor); + } + }; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java index 258efba3f..68d096029 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java @@ -1,142 +1,142 @@ -package com.ruoyi.framework.shiro.realm; - -import java.util.HashSet; -import java.util.Set; -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authc.AuthenticationException; -import org.apache.shiro.authc.AuthenticationInfo; -import org.apache.shiro.authc.AuthenticationToken; -import org.apache.shiro.authc.ExcessiveAttemptsException; -import org.apache.shiro.authc.IncorrectCredentialsException; -import org.apache.shiro.authc.LockedAccountException; -import org.apache.shiro.authc.SimpleAuthenticationInfo; -import org.apache.shiro.authc.UnknownAccountException; -import org.apache.shiro.authc.UsernamePasswordToken; -import org.apache.shiro.authz.AuthorizationInfo; -import org.apache.shiro.authz.SimpleAuthorizationInfo; -import org.apache.shiro.realm.AuthorizingRealm; -import org.apache.shiro.subject.PrincipalCollection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import com.ruoyi.common.exception.user.CaptchaException; -import com.ruoyi.common.exception.user.RoleBlockedException; -import com.ruoyi.common.exception.user.UserBlockedException; -import com.ruoyi.common.exception.user.UserNotExistsException; -import com.ruoyi.common.exception.user.UserPasswordNotMatchException; -import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException; -import com.ruoyi.framework.shiro.service.SysLoginService; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysUser; -import com.ruoyi.system.service.ISysMenuService; -import com.ruoyi.system.service.ISysRoleService; - -/** - * 自定义Realm 处理登录 权限 - * - * @author ruoyi - */ -public class UserRealm extends AuthorizingRealm -{ - private static final Logger log = LoggerFactory.getLogger(UserRealm.class); - - @Autowired - private ISysMenuService menuService; - - @Autowired - private ISysRoleService roleService; - - @Autowired - private SysLoginService loginService; - - /** - * 授权 - */ - @Override - protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) - { - SysUser user = ShiroUtils.getSysUser(); - // 角色列表 - Set roles = new HashSet(); - // 功能列表 - Set menus = new HashSet(); - SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); - // 管理员拥有所有权限 - if (user.isAdmin()) - { - info.addRole("admin"); - info.addStringPermission("*:*:*"); - } - else - { - roles = roleService.selectRoleKeys(user.getUserId()); - menus = menuService.selectPermsByUserId(user.getUserId()); - // 角色加入AuthorizationInfo认证对象 - info.setRoles(roles); - // 权限加入AuthorizationInfo认证对象 - info.setStringPermissions(menus); - } - return info; - } - - /** - * 登录认证 - */ - @Override - protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException - { - UsernamePasswordToken upToken = (UsernamePasswordToken) token; - String username = upToken.getUsername(); - String password = ""; - if (upToken.getPassword() != null) - { - password = new String(upToken.getPassword()); - } - - SysUser user = null; - try - { - user = loginService.login(username, password); - } - catch (CaptchaException e) - { - throw new AuthenticationException(e.getMessage(), e); - } - catch (UserNotExistsException e) - { - throw new UnknownAccountException(e.getMessage(), e); - } - catch (UserPasswordNotMatchException e) - { - throw new IncorrectCredentialsException(e.getMessage(), e); - } - catch (UserPasswordRetryLimitExceedException e) - { - throw new ExcessiveAttemptsException(e.getMessage(), e); - } - catch (UserBlockedException e) - { - throw new LockedAccountException(e.getMessage(), e); - } - catch (RoleBlockedException e) - { - throw new LockedAccountException(e.getMessage(), e); - } - catch (Exception e) - { - log.info("对用户[" + username + "]进行登录验证..验证未通过{}", e.getMessage()); - throw new AuthenticationException(e.getMessage(), e); - } - SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, password, getName()); - return info; - } - - /** - * 清理缓存权限 - */ - public void clearCachedAuthorizationInfo() - { - this.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals()); - } -} +package com.ruoyi.framework.shiro.realm; + +import java.util.HashSet; +import java.util.Set; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.AuthenticationInfo; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.authc.ExcessiveAttemptsException; +import org.apache.shiro.authc.IncorrectCredentialsException; +import org.apache.shiro.authc.LockedAccountException; +import org.apache.shiro.authc.SimpleAuthenticationInfo; +import org.apache.shiro.authc.UnknownAccountException; +import org.apache.shiro.authc.UsernamePasswordToken; +import org.apache.shiro.authz.AuthorizationInfo; +import org.apache.shiro.authz.SimpleAuthorizationInfo; +import org.apache.shiro.realm.AuthorizingRealm; +import org.apache.shiro.subject.PrincipalCollection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.ruoyi.common.exception.user.CaptchaException; +import com.ruoyi.common.exception.user.RoleBlockedException; +import com.ruoyi.common.exception.user.UserBlockedException; +import com.ruoyi.common.exception.user.UserNotExistsException; +import com.ruoyi.common.exception.user.UserPasswordNotMatchException; +import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException; +import com.ruoyi.framework.shiro.service.SysLoginService; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.service.ISysMenuService; +import com.ruoyi.system.service.ISysRoleService; + +/** + * 自定义Realm 处理登录 权限 + * + * @author ruoyi + */ +public class UserRealm extends AuthorizingRealm +{ + private static final Logger log = LoggerFactory.getLogger(UserRealm.class); + + @Autowired + private ISysMenuService menuService; + + @Autowired + private ISysRoleService roleService; + + @Autowired + private SysLoginService loginService; + + /** + * 授权 + */ + @Override + protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) + { + SysUser user = ShiroUtils.getSysUser(); + // 角色列表 + Set roles = new HashSet(); + // 功能列表 + Set menus = new HashSet(); + SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); + // 管理员拥有所有权限 + if (user.isAdmin()) + { + info.addRole("admin"); + info.addStringPermission("*:*:*"); + } + else + { + roles = roleService.selectRoleKeys(user.getUserId()); + menus = menuService.selectPermsByUserId(user.getUserId()); + // 角色加入AuthorizationInfo认证对象 + info.setRoles(roles); + // 权限加入AuthorizationInfo认证对象 + info.setStringPermissions(menus); + } + return info; + } + + /** + * 登录认证 + */ + @Override + protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException + { + UsernamePasswordToken upToken = (UsernamePasswordToken) token; + String username = upToken.getUsername(); + String password = ""; + if (upToken.getPassword() != null) + { + password = new String(upToken.getPassword()); + } + + SysUser user = null; + try + { + user = loginService.login(username, password); + } + catch (CaptchaException e) + { + throw new AuthenticationException(e.getMessage(), e); + } + catch (UserNotExistsException e) + { + throw new UnknownAccountException(e.getMessage(), e); + } + catch (UserPasswordNotMatchException e) + { + throw new IncorrectCredentialsException(e.getMessage(), e); + } + catch (UserPasswordRetryLimitExceedException e) + { + throw new ExcessiveAttemptsException(e.getMessage(), e); + } + catch (UserBlockedException e) + { + throw new LockedAccountException(e.getMessage(), e); + } + catch (RoleBlockedException e) + { + throw new LockedAccountException(e.getMessage(), e); + } + catch (Exception e) + { + log.info("对用户[" + username + "]进行登录验证..验证未通过{}", e.getMessage()); + throw new AuthenticationException(e.getMessage(), e); + } + SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, password, getName()); + return info; + } + + /** + * 清理缓存权限 + */ + public void clearCachedAuthorizationInfo() + { + this.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals()); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java index 92ebe89d8..a24b2470b 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/service/SysLoginService.java @@ -1,136 +1,136 @@ -package com.ruoyi.framework.shiro.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.constant.ShiroConstants; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.enums.UserStatus; -import com.ruoyi.common.exception.user.CaptchaException; -import com.ruoyi.common.exception.user.UserBlockedException; -import com.ruoyi.common.exception.user.UserDeleteException; -import com.ruoyi.common.exception.user.UserNotExistsException; -import com.ruoyi.common.exception.user.UserPasswordNotMatchException; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.MessageUtils; -import com.ruoyi.common.utils.ServletUtils; -import com.ruoyi.framework.manager.AsyncManager; -import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysUser; -import com.ruoyi.system.service.ISysUserService; - -/** - * 登录校验方法 - * - * @author ruoyi - */ -@Component -public class SysLoginService -{ - @Autowired - private SysPasswordService passwordService; - - @Autowired - private ISysUserService userService; - - /** - * 登录 - */ - public SysUser login(String username, String password) - { - // 验证码校验 - if (!StringUtils.isEmpty(ServletUtils.getRequest().getAttribute(ShiroConstants.CURRENT_CAPTCHA))) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); - throw new CaptchaException(); - } - // 用户名或密码为空 错误 - if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null"))); - throw new UserNotExistsException(); - } - // 密码如果不在指定范围内 错误 - if (password.length() < UserConstants.PASSWORD_MIN_LENGTH - || password.length() > UserConstants.PASSWORD_MAX_LENGTH) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); - throw new UserPasswordNotMatchException(); - } - - // 用户名不在指定范围内 错误 - if (username.length() < UserConstants.USERNAME_MIN_LENGTH - || username.length() > UserConstants.USERNAME_MAX_LENGTH) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); - throw new UserPasswordNotMatchException(); - } - - // 查询用户信息 - SysUser user = userService.selectUserByLoginName(username); - - if (user == null && maybeMobilePhoneNumber(username)) - { - user = userService.selectUserByPhoneNumber(username); - } - - if (user == null && maybeEmail(username)) - { - user = userService.selectUserByEmail(username); - } - - if (user == null) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.not.exists"))); - throw new UserNotExistsException(); - } - - if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.delete"))); - throw new UserDeleteException(); - } - - if (UserStatus.DISABLE.getCode().equals(user.getStatus())) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.blocked", user.getRemark()))); - throw new UserBlockedException(); - } - - passwordService.validate(user, password); - - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); - recordLoginInfo(user); - return user; - } - - private boolean maybeEmail(String username) - { - if (!username.matches(UserConstants.EMAIL_PATTERN)) - { - return false; - } - return true; - } - - private boolean maybeMobilePhoneNumber(String username) - { - if (!username.matches(UserConstants.MOBILE_PHONE_NUMBER_PATTERN)) - { - return false; - } - return true; - } - - /** - * 记录登录信息 - */ - public void recordLoginInfo(SysUser user) - { - user.setLoginIp(ShiroUtils.getIp()); - user.setLoginDate(DateUtils.getNowDate()); - userService.updateUserInfo(user); - } -} +package com.ruoyi.framework.shiro.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.enums.UserStatus; +import com.ruoyi.common.exception.user.CaptchaException; +import com.ruoyi.common.exception.user.UserBlockedException; +import com.ruoyi.common.exception.user.UserDeleteException; +import com.ruoyi.common.exception.user.UserNotExistsException; +import com.ruoyi.common.exception.user.UserPasswordNotMatchException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.service.ISysUserService; + +/** + * 登录校验方法 + * + * @author ruoyi + */ +@Component +public class SysLoginService +{ + @Autowired + private SysPasswordService passwordService; + + @Autowired + private ISysUserService userService; + + /** + * 登录 + */ + public SysUser login(String username, String password) + { + // 验证码校验 + if (!StringUtils.isEmpty(ServletUtils.getRequest().getAttribute(ShiroConstants.CURRENT_CAPTCHA))) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); + throw new CaptchaException(); + } + // 用户名或密码为空 错误 + if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null"))); + throw new UserNotExistsException(); + } + // 密码如果不在指定范围内 错误 + if (password.length() < UserConstants.PASSWORD_MIN_LENGTH + || password.length() > UserConstants.PASSWORD_MAX_LENGTH) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); + throw new UserPasswordNotMatchException(); + } + + // 用户名不在指定范围内 错误 + if (username.length() < UserConstants.USERNAME_MIN_LENGTH + || username.length() > UserConstants.USERNAME_MAX_LENGTH) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); + throw new UserPasswordNotMatchException(); + } + + // 查询用户信息 + SysUser user = userService.selectUserByLoginName(username); + + if (user == null && maybeMobilePhoneNumber(username)) + { + user = userService.selectUserByPhoneNumber(username); + } + + if (user == null && maybeEmail(username)) + { + user = userService.selectUserByEmail(username); + } + + if (user == null) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.not.exists"))); + throw new UserNotExistsException(); + } + + if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.delete"))); + throw new UserDeleteException(); + } + + if (UserStatus.DISABLE.getCode().equals(user.getStatus())) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.blocked", user.getRemark()))); + throw new UserBlockedException(); + } + + passwordService.validate(user, password); + + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); + recordLoginInfo(user); + return user; + } + + private boolean maybeEmail(String username) + { + if (!username.matches(UserConstants.EMAIL_PATTERN)) + { + return false; + } + return true; + } + + private boolean maybeMobilePhoneNumber(String username) + { + if (!username.matches(UserConstants.MOBILE_PHONE_NUMBER_PATTERN)) + { + return false; + } + return true; + } + + /** + * 记录登录信息 + */ + public void recordLoginInfo(SysUser user) + { + user.setLoginIp(ShiroUtils.getIp()); + user.setLoginDate(DateUtils.getNowDate()); + userService.updateUserInfo(user); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java index 96da6cde7..18caf65b7 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java @@ -1,86 +1,86 @@ -package com.ruoyi.framework.shiro.service; - -import java.util.concurrent.atomic.AtomicInteger; -import javax.annotation.PostConstruct; -import org.apache.shiro.cache.Cache; -import org.apache.shiro.cache.CacheManager; -import org.apache.shiro.crypto.hash.Md5Hash; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.constant.ShiroConstants; -import com.ruoyi.common.exception.user.UserPasswordNotMatchException; -import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException; -import com.ruoyi.common.utils.MessageUtils; -import com.ruoyi.framework.manager.AsyncManager; -import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.system.domain.SysUser; - -/** - * 登录密码方法 - * - * @author ruoyi - */ -@Component -public class SysPasswordService -{ - @Autowired - private CacheManager cacheManager; - - private Cache loginRecordCache; - - @Value(value = "${user.password.maxRetryCount}") - private String maxRetryCount; - - @PostConstruct - public void init() - { - loginRecordCache = cacheManager.getCache(ShiroConstants.LOGINRECORDCACHE); - } - - public void validate(SysUser user, String password) - { - String loginName = user.getLoginName(); - - AtomicInteger retryCount = loginRecordCache.get(loginName); - - if (retryCount == null) - { - retryCount = new AtomicInteger(0); - loginRecordCache.put(loginName, retryCount); - } - if (retryCount.incrementAndGet() > Integer.valueOf(maxRetryCount).intValue()) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount))); - throw new UserPasswordRetryLimitExceedException(Integer.valueOf(maxRetryCount).intValue()); - } - - if (!matches(user, password)) - { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.count", retryCount))); - loginRecordCache.put(loginName, retryCount); - throw new UserPasswordNotMatchException(); - } - else - { - clearLoginRecordCache(loginName); - } - } - - public boolean matches(SysUser user, String newPassword) - { - return user.getPassword().equals(encryptPassword(user.getLoginName(), newPassword, user.getSalt())); - } - - public void clearLoginRecordCache(String username) - { - loginRecordCache.remove(username); - } - - public String encryptPassword(String username, String password, String salt) - { - return new Md5Hash(username + password + salt).toHex().toString(); - } - -} +package com.ruoyi.framework.shiro.service; + +import java.util.concurrent.atomic.AtomicInteger; +import javax.annotation.PostConstruct; +import org.apache.shiro.cache.Cache; +import org.apache.shiro.cache.CacheManager; +import org.apache.shiro.crypto.hash.Md5Hash; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.common.exception.user.UserPasswordNotMatchException; +import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException; +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.system.domain.SysUser; + +/** + * 登录密码方法 + * + * @author ruoyi + */ +@Component +public class SysPasswordService +{ + @Autowired + private CacheManager cacheManager; + + private Cache loginRecordCache; + + @Value(value = "${user.password.maxRetryCount}") + private String maxRetryCount; + + @PostConstruct + public void init() + { + loginRecordCache = cacheManager.getCache(ShiroConstants.LOGINRECORDCACHE); + } + + public void validate(SysUser user, String password) + { + String loginName = user.getLoginName(); + + AtomicInteger retryCount = loginRecordCache.get(loginName); + + if (retryCount == null) + { + retryCount = new AtomicInteger(0); + loginRecordCache.put(loginName, retryCount); + } + if (retryCount.incrementAndGet() > Integer.valueOf(maxRetryCount).intValue()) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount))); + throw new UserPasswordRetryLimitExceedException(Integer.valueOf(maxRetryCount).intValue()); + } + + if (!matches(user, password)) + { + AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.count", retryCount))); + loginRecordCache.put(loginName, retryCount); + throw new UserPasswordNotMatchException(); + } + else + { + clearLoginRecordCache(loginName); + } + } + + public boolean matches(SysUser user, String newPassword) + { + return user.getPassword().equals(encryptPassword(user.getLoginName(), newPassword, user.getSalt())); + } + + public void clearLoginRecordCache(String username) + { + loginRecordCache.remove(username); + } + + public String encryptPassword(String username, String password, String salt) + { + return new Md5Hash(username + password + salt).toHex().toString(); + } + +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysShiroService.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/service/SysShiroService.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysShiroService.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/service/SysShiroService.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSession.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSession.java similarity index 94% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSession.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSession.java index 09b88c5ce..84cf0c0fb 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSession.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSession.java @@ -1,148 +1,148 @@ -package com.ruoyi.framework.shiro.session; - -import org.apache.shiro.session.mgt.SimpleSession; -import com.ruoyi.common.enums.OnlineStatus; - -/** - * 在线用户会话属性 - * - * @author ruoyi - */ -public class OnlineSession extends SimpleSession -{ - private static final long serialVersionUID = 1L; - - /** 用户ID */ - private Long userId; - - /** 用户名称 */ - private String loginName; - - /** 部门名称 */ - private String deptName; - - /** 用户头像 */ - private String avatar; - - /** 登录IP地址 */ - private String host; - - /** 浏览器类型 */ - private String browser; - - /** 操作系统 */ - private String os; - - /** 在线状态 */ - private OnlineStatus status = OnlineStatus.on_line; - - /** 属性是否改变 优化session数据同步 */ - private transient boolean attributeChanged = false; - - @Override - public String getHost() - { - return host; - } - - @Override - public void setHost(String host) - { - this.host = host; - } - - public String getBrowser() - { - return browser; - } - - public void setBrowser(String browser) - { - this.browser = browser; - } - - public String getOs() - { - return os; - } - - public void setOs(String os) - { - this.os = os; - } - - public Long getUserId() - { - return userId; - } - - public void setUserId(Long userId) - { - this.userId = userId; - } - - public String getLoginName() - { - return loginName; - } - - public void setLoginName(String loginName) - { - this.loginName = loginName; - } - - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - public OnlineStatus getStatus() - { - return status; - } - - public void setStatus(OnlineStatus status) - { - this.status = status; - } - - public void markAttributeChanged() - { - this.attributeChanged = true; - } - - public void resetAttributeChanged() - { - this.attributeChanged = false; - } - - public boolean isAttributeChanged() - { - return attributeChanged; - } - - public String getAvatar() { - return avatar; - } - - public void setAvatar(String avatar) { - this.avatar = avatar; - } - - @Override - public void setAttribute(Object key, Object value) - { - super.setAttribute(key, value); - } - - @Override - public Object removeAttribute(Object key) - { - return super.removeAttribute(key); - } -} +package com.ruoyi.framework.shiro.session; + +import org.apache.shiro.session.mgt.SimpleSession; +import com.ruoyi.common.enums.OnlineStatus; + +/** + * 在线用户会话属性 + * + * @author ruoyi + */ +public class OnlineSession extends SimpleSession +{ + private static final long serialVersionUID = 1L; + + /** 用户ID */ + private Long userId; + + /** 用户名称 */ + private String loginName; + + /** 部门名称 */ + private String deptName; + + /** 用户头像 */ + private String avatar; + + /** 登录IP地址 */ + private String host; + + /** 浏览器类型 */ + private String browser; + + /** 操作系统 */ + private String os; + + /** 在线状态 */ + private OnlineStatus status = OnlineStatus.on_line; + + /** 属性是否改变 优化session数据同步 */ + private transient boolean attributeChanged = false; + + @Override + public String getHost() + { + return host; + } + + @Override + public void setHost(String host) + { + this.host = host; + } + + public String getBrowser() + { + return browser; + } + + public void setBrowser(String browser) + { + this.browser = browser; + } + + public String getOs() + { + return os; + } + + public void setOs(String os) + { + this.os = os; + } + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public String getLoginName() + { + return loginName; + } + + public void setLoginName(String loginName) + { + this.loginName = loginName; + } + + public String getDeptName() + { + return deptName; + } + + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + public OnlineStatus getStatus() + { + return status; + } + + public void setStatus(OnlineStatus status) + { + this.status = status; + } + + public void markAttributeChanged() + { + this.attributeChanged = true; + } + + public void resetAttributeChanged() + { + this.attributeChanged = false; + } + + public boolean isAttributeChanged() + { + return attributeChanged; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + @Override + public void setAttribute(Object key, Object value) + { + super.setAttribute(key, value); + } + + @Override + public Object removeAttribute(Object key) + { + return super.removeAttribute(key); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java index 40ff31277..ce36b8df3 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionDAO.java @@ -1,117 +1,117 @@ -package com.ruoyi.framework.shiro.session; - -import java.io.Serializable; -import java.util.Date; -import org.apache.shiro.session.Session; -import org.apache.shiro.session.UnknownSessionException; -import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import com.ruoyi.common.enums.OnlineStatus; -import com.ruoyi.framework.manager.AsyncManager; -import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.framework.shiro.service.SysShiroService; - -/** - * 针对自定义的ShiroSession的db操作 - * - * @author ruoyi - */ -public class OnlineSessionDAO extends EnterpriseCacheSessionDAO -{ - /** - * 同步session到数据库的周期 单位为毫秒(默认1分钟) - */ - @Value("${shiro.session.dbSyncPeriod}") - private int dbSyncPeriod; - - /** - * 上次同步数据库的时间戳 - */ - private static final String LAST_SYNC_DB_TIMESTAMP = OnlineSessionDAO.class.getName() + "LAST_SYNC_DB_TIMESTAMP"; - - @Autowired - private SysShiroService sysShiroService; - - public OnlineSessionDAO() - { - super(); - } - - public OnlineSessionDAO(long expireTime) - { - super(); - } - - /** - * 根据会话ID获取会话 - * - * @param sessionId 会话ID - * @return ShiroSession - */ - @Override - protected Session doReadSession(Serializable sessionId) - { - return sysShiroService.getSession(sessionId); - } - - @Override - public void update(Session session) throws UnknownSessionException - { - super.update(session); - } - - /** - * 更新会话;如更新会话最后访问时间/停止会话/设置超时时间/设置移除属性等会调用 - */ - public void syncToDb(OnlineSession onlineSession) - { - Date lastSyncTimestamp = (Date) onlineSession.getAttribute(LAST_SYNC_DB_TIMESTAMP); - if (lastSyncTimestamp != null) - { - boolean needSync = true; - long deltaTime = onlineSession.getLastAccessTime().getTime() - lastSyncTimestamp.getTime(); - if (deltaTime < dbSyncPeriod * 60 * 1000) - { - // 时间差不足 无需同步 - needSync = false; - } - // isGuest = true 访客 - boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L; - - // session 数据变更了 同步 - if (isGuest == false && onlineSession.isAttributeChanged()) - { - needSync = true; - } - - if (needSync == false) - { - return; - } - } - // 更新上次同步数据库时间 - onlineSession.setAttribute(LAST_SYNC_DB_TIMESTAMP, onlineSession.getLastAccessTime()); - // 更新完后 重置标识 - if (onlineSession.isAttributeChanged()) - { - onlineSession.resetAttributeChanged(); - } - AsyncManager.me().execute(AsyncFactory.syncSessionToDb(onlineSession)); - } - - /** - * 当会话过期/停止(如用户退出时)属性等会调用 - */ - @Override - protected void doDelete(Session session) - { - OnlineSession onlineSession = (OnlineSession) session; - if (null == onlineSession) - { - return; - } - onlineSession.setStatus(OnlineStatus.off_line); - sysShiroService.deleteSession(onlineSession); - } -} +package com.ruoyi.framework.shiro.session; + +import java.io.Serializable; +import java.util.Date; +import org.apache.shiro.session.Session; +import org.apache.shiro.session.UnknownSessionException; +import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import com.ruoyi.common.enums.OnlineStatus; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.framework.shiro.service.SysShiroService; + +/** + * 针对自定义的ShiroSession的db操作 + * + * @author ruoyi + */ +public class OnlineSessionDAO extends EnterpriseCacheSessionDAO +{ + /** + * 同步session到数据库的周期 单位为毫秒(默认1分钟) + */ + @Value("${shiro.session.dbSyncPeriod}") + private int dbSyncPeriod; + + /** + * 上次同步数据库的时间戳 + */ + private static final String LAST_SYNC_DB_TIMESTAMP = OnlineSessionDAO.class.getName() + "LAST_SYNC_DB_TIMESTAMP"; + + @Autowired + private SysShiroService sysShiroService; + + public OnlineSessionDAO() + { + super(); + } + + public OnlineSessionDAO(long expireTime) + { + super(); + } + + /** + * 根据会话ID获取会话 + * + * @param sessionId 会话ID + * @return ShiroSession + */ + @Override + protected Session doReadSession(Serializable sessionId) + { + return sysShiroService.getSession(sessionId); + } + + @Override + public void update(Session session) throws UnknownSessionException + { + super.update(session); + } + + /** + * 更新会话;如更新会话最后访问时间/停止会话/设置超时时间/设置移除属性等会调用 + */ + public void syncToDb(OnlineSession onlineSession) + { + Date lastSyncTimestamp = (Date) onlineSession.getAttribute(LAST_SYNC_DB_TIMESTAMP); + if (lastSyncTimestamp != null) + { + boolean needSync = true; + long deltaTime = onlineSession.getLastAccessTime().getTime() - lastSyncTimestamp.getTime(); + if (deltaTime < dbSyncPeriod * 60 * 1000) + { + // 时间差不足 无需同步 + needSync = false; + } + // isGuest = true 访客 + boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L; + + // session 数据变更了 同步 + if (isGuest == false && onlineSession.isAttributeChanged()) + { + needSync = true; + } + + if (needSync == false) + { + return; + } + } + // 更新上次同步数据库时间 + onlineSession.setAttribute(LAST_SYNC_DB_TIMESTAMP, onlineSession.getLastAccessTime()); + // 更新完后 重置标识 + if (onlineSession.isAttributeChanged()) + { + onlineSession.resetAttributeChanged(); + } + AsyncManager.me().execute(AsyncFactory.syncSessionToDb(onlineSession)); + } + + /** + * 当会话过期/停止(如用户退出时)属性等会调用 + */ + @Override + protected void doDelete(Session session) + { + OnlineSession onlineSession = (OnlineSession) session; + if (null == onlineSession) + { + return; + } + onlineSession.setStatus(OnlineStatus.off_line); + sysShiroService.deleteSession(onlineSession); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionFactory.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionFactory.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionFactory.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionFactory.java index e6f6896d9..f59c5bf98 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionFactory.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/session/OnlineSessionFactory.java @@ -1,44 +1,44 @@ -package com.ruoyi.framework.shiro.session; - -import javax.servlet.http.HttpServletRequest; -import org.apache.shiro.session.Session; -import org.apache.shiro.session.mgt.SessionContext; -import org.apache.shiro.session.mgt.SessionFactory; -import org.apache.shiro.web.session.mgt.WebSessionContext; -import org.springframework.stereotype.Component; -import com.ruoyi.common.utils.IpUtils; -import com.ruoyi.common.utils.ServletUtils; - -import eu.bitwalker.useragentutils.UserAgent; - -/** - * 自定义sessionFactory会话 - * - * @author ruoyi - */ -@Component -public class OnlineSessionFactory implements SessionFactory -{ - @Override - public Session createSession(SessionContext initData) - { - OnlineSession session = new OnlineSession(); - if (initData != null && initData instanceof WebSessionContext) - { - WebSessionContext sessionContext = (WebSessionContext) initData; - HttpServletRequest request = (HttpServletRequest) sessionContext.getServletRequest(); - if (request != null) - { - UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); - // 获取客户端操作系统 - String os = userAgent.getOperatingSystem().getName(); - // 获取客户端浏览器 - String browser = userAgent.getBrowser().getName(); - session.setHost(IpUtils.getIpAddr(request)); - session.setBrowser(browser); - session.setOs(os); - } - } - return session; - } -} +package com.ruoyi.framework.shiro.session; + +import javax.servlet.http.HttpServletRequest; +import org.apache.shiro.session.Session; +import org.apache.shiro.session.mgt.SessionContext; +import org.apache.shiro.session.mgt.SessionFactory; +import org.apache.shiro.web.session.mgt.WebSessionContext; +import org.springframework.stereotype.Component; +import com.ruoyi.common.utils.IpUtils; +import com.ruoyi.common.utils.ServletUtils; + +import eu.bitwalker.useragentutils.UserAgent; + +/** + * 自定义sessionFactory会话 + * + * @author ruoyi + */ +@Component +public class OnlineSessionFactory implements SessionFactory +{ + @Override + public Session createSession(SessionContext initData) + { + OnlineSession session = new OnlineSession(); + if (initData != null && initData instanceof WebSessionContext) + { + WebSessionContext sessionContext = (WebSessionContext) initData; + HttpServletRequest request = (HttpServletRequest) sessionContext.getServletRequest(); + if (request != null) + { + UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); + // 获取客户端操作系统 + String os = userAgent.getOperatingSystem().getName(); + // 获取客户端浏览器 + String browser = userAgent.getBrowser().getName(); + session.setHost(IpUtils.getIpAddr(request)); + session.setBrowser(browser); + session.setOs(os); + } + } + return session; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/LogoutFilter.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/LogoutFilter.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/LogoutFilter.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/LogoutFilter.java index f5aa96647..a84d9cbc3 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/LogoutFilter.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/LogoutFilter.java @@ -1,102 +1,102 @@ -package com.ruoyi.framework.shiro.web.filter; - -import java.io.Serializable; -import java.util.Deque; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import org.apache.shiro.cache.Cache; -import org.apache.shiro.cache.CacheManager; -import org.apache.shiro.session.SessionException; -import org.apache.shiro.subject.Subject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.constant.ShiroConstants; -import com.ruoyi.common.utils.MessageUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.manager.AsyncManager; -import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysUser; - -/** - * 退出过滤器 - * - * @author ruoyi - */ -public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter -{ - private static final Logger log = LoggerFactory.getLogger(LogoutFilter.class); - - /** - * 退出后重定向的地址 - */ - private String loginUrl; - - private Cache> cache; - - public String getLoginUrl() - { - return loginUrl; - } - - public void setLoginUrl(String loginUrl) - { - this.loginUrl = loginUrl; - } - - @Override - protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception - { - try - { - Subject subject = getSubject(request, response); - String redirectUrl = getRedirectUrl(request, response, subject); - try - { - SysUser user = ShiroUtils.getSysUser(); - if (StringUtils.isNotNull(user)) - { - String loginName = user.getLoginName(); - // 记录用户退出日志 - AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGOUT, MessageUtils.message("user.logout.success"))); - // 清理缓存 - cache.remove(loginName); - } - // 退出登录 - subject.logout(); - } - catch (SessionException ise) - { - log.error("logout fail.", ise); - } - issueRedirect(request, response, redirectUrl); - } - catch (Exception e) - { - log.error("Encountered session exception during logout. This can generally safely be ignored.", e); - } - return false; - } - - /** - * 退出跳转URL - */ - @Override - protected String getRedirectUrl(ServletRequest request, ServletResponse response, Subject subject) - { - String url = getLoginUrl(); - if (StringUtils.isNotEmpty(url)) - { - return url; - } - return super.getRedirectUrl(request, response, subject); - } - - // 设置Cache的key的前缀 - public void setCacheManager(CacheManager cacheManager) - { - // 必须和ehcache缓存配置中的缓存name一致 - this.cache = cacheManager.getCache(ShiroConstants.SYS_USERCACHE); - } -} +package com.ruoyi.framework.shiro.web.filter; + +import java.io.Serializable; +import java.util.Deque; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import org.apache.shiro.cache.Cache; +import org.apache.shiro.cache.CacheManager; +import org.apache.shiro.session.SessionException; +import org.apache.shiro.subject.Subject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.common.utils.MessageUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.manager.AsyncManager; +import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysUser; + +/** + * 退出过滤器 + * + * @author ruoyi + */ +public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter +{ + private static final Logger log = LoggerFactory.getLogger(LogoutFilter.class); + + /** + * 退出后重定向的地址 + */ + private String loginUrl; + + private Cache> cache; + + public String getLoginUrl() + { + return loginUrl; + } + + public void setLoginUrl(String loginUrl) + { + this.loginUrl = loginUrl; + } + + @Override + protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception + { + try + { + Subject subject = getSubject(request, response); + String redirectUrl = getRedirectUrl(request, response, subject); + try + { + SysUser user = ShiroUtils.getSysUser(); + if (StringUtils.isNotNull(user)) + { + String loginName = user.getLoginName(); + // 记录用户退出日志 + AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, Constants.LOGOUT, MessageUtils.message("user.logout.success"))); + // 清理缓存 + cache.remove(loginName); + } + // 退出登录 + subject.logout(); + } + catch (SessionException ise) + { + log.error("logout fail.", ise); + } + issueRedirect(request, response, redirectUrl); + } + catch (Exception e) + { + log.error("Encountered session exception during logout. This can generally safely be ignored.", e); + } + return false; + } + + /** + * 退出跳转URL + */ + @Override + protected String getRedirectUrl(ServletRequest request, ServletResponse response, Subject subject) + { + String url = getLoginUrl(); + if (StringUtils.isNotEmpty(url)) + { + return url; + } + return super.getRedirectUrl(request, response, subject); + } + + // 设置Cache的key的前缀 + public void setCacheManager(CacheManager cacheManager) + { + // 必须和ehcache缓存配置中的缓存name一致 + this.cache = cacheManager.getCache(ShiroConstants.SYS_USERCACHE); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/captcha/CaptchaValidateFilter.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/captcha/CaptchaValidateFilter.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/captcha/CaptchaValidateFilter.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/captcha/CaptchaValidateFilter.java index 743d27933..69bd8e076 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/captcha/CaptchaValidateFilter.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/captcha/CaptchaValidateFilter.java @@ -1,77 +1,77 @@ -package com.ruoyi.framework.shiro.web.filter.captcha; - -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import org.apache.shiro.web.filter.AccessControlFilter; -import com.google.code.kaptcha.Constants; -import com.ruoyi.common.constant.ShiroConstants; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.util.ShiroUtils; - -/** - * 验证码过滤器 - * - * @author ruoyi - */ -public class CaptchaValidateFilter extends AccessControlFilter -{ - /** - * 是否开启验证码 - */ - private boolean captchaEnabled = true; - - /** - * 验证码类型 - */ - private String captchaType = "math"; - - public void setCaptchaEnabled(boolean captchaEnabled) - { - this.captchaEnabled = captchaEnabled; - } - - public void setCaptchaType(String captchaType) - { - this.captchaType = captchaType; - } - - @Override - public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception - { - request.setAttribute(ShiroConstants.CURRENT_ENABLED, captchaEnabled); - request.setAttribute(ShiroConstants.CURRENT_TYPE, captchaType); - return super.onPreHandle(request, response, mappedValue); - } - - @Override - protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) - throws Exception - { - HttpServletRequest httpServletRequest = (HttpServletRequest) request; - // 验证码禁用 或不是表单提交 允许访问 - if (captchaEnabled == false || !"post".equals(httpServletRequest.getMethod().toLowerCase())) - { - return true; - } - return validateResponse(httpServletRequest, httpServletRequest.getParameter(ShiroConstants.CURRENT_VALIDATECODE)); - } - - public boolean validateResponse(HttpServletRequest request, String validateCode) - { - Object obj = ShiroUtils.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); - String code = String.valueOf(obj != null ? obj : ""); - if (StringUtils.isEmpty(validateCode) || !validateCode.equalsIgnoreCase(code)) - { - return false; - } - return true; - } - - @Override - protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception - { - request.setAttribute(ShiroConstants.CURRENT_CAPTCHA, ShiroConstants.CAPTCHA_ERROR); - return true; - } -} +package com.ruoyi.framework.shiro.web.filter.captcha; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import org.apache.shiro.web.filter.AccessControlFilter; +import com.google.code.kaptcha.Constants; +import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.util.ShiroUtils; + +/** + * 验证码过滤器 + * + * @author ruoyi + */ +public class CaptchaValidateFilter extends AccessControlFilter +{ + /** + * 是否开启验证码 + */ + private boolean captchaEnabled = true; + + /** + * 验证码类型 + */ + private String captchaType = "math"; + + public void setCaptchaEnabled(boolean captchaEnabled) + { + this.captchaEnabled = captchaEnabled; + } + + public void setCaptchaType(String captchaType) + { + this.captchaType = captchaType; + } + + @Override + public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception + { + request.setAttribute(ShiroConstants.CURRENT_ENABLED, captchaEnabled); + request.setAttribute(ShiroConstants.CURRENT_TYPE, captchaType); + return super.onPreHandle(request, response, mappedValue); + } + + @Override + protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) + throws Exception + { + HttpServletRequest httpServletRequest = (HttpServletRequest) request; + // 验证码禁用 或不是表单提交 允许访问 + if (captchaEnabled == false || !"post".equals(httpServletRequest.getMethod().toLowerCase())) + { + return true; + } + return validateResponse(httpServletRequest, httpServletRequest.getParameter(ShiroConstants.CURRENT_VALIDATECODE)); + } + + public boolean validateResponse(HttpServletRequest request, String validateCode) + { + Object obj = ShiroUtils.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); + String code = String.valueOf(obj != null ? obj : ""); + if (StringUtils.isEmpty(validateCode) || !validateCode.equalsIgnoreCase(code)) + { + return false; + } + return true; + } + + @Override + protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception + { + request.setAttribute(ShiroConstants.CURRENT_CAPTCHA, ShiroConstants.CAPTCHA_ERROR); + return true; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/kickout/KickoutSessionFilter.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/kickout/KickoutSessionFilter.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/kickout/KickoutSessionFilter.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/kickout/KickoutSessionFilter.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java index 070d91e82..720c34142 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/online/OnlineSessionFilter.java @@ -1,96 +1,96 @@ -package com.ruoyi.framework.shiro.web.filter.online; - -import java.io.IOException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import org.apache.shiro.session.Session; -import org.apache.shiro.subject.Subject; -import org.apache.shiro.web.filter.AccessControlFilter; -import org.apache.shiro.web.util.WebUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import com.ruoyi.common.constant.ShiroConstants; -import com.ruoyi.common.enums.OnlineStatus; -import com.ruoyi.framework.shiro.session.OnlineSession; -import com.ruoyi.framework.shiro.session.OnlineSessionDAO; -import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.system.domain.SysUser; - -/** - * 自定义访问控制 - * - * @author ruoyi - */ -public class OnlineSessionFilter extends AccessControlFilter -{ - /** - * 强制退出后重定向的地址 - */ - @Value("${shiro.user.loginUrl}") - private String loginUrl; - - @Autowired - private OnlineSessionDAO onlineSessionDAO; - - /** - * 表示是否允许访问;mappedValue就是[urls]配置中拦截器参数部分,如果允许访问返回true,否则false; - */ - @Override - protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) - throws Exception - { - Subject subject = getSubject(request, response); - if (subject == null || subject.getSession() == null) - { - return true; - } - Session session = onlineSessionDAO.readSession(subject.getSession().getId()); - if (session != null && session instanceof OnlineSession) - { - OnlineSession onlineSession = (OnlineSession) session; - request.setAttribute(ShiroConstants.ONLINE_SESSION, onlineSession); - // 把user对象设置进去 - boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L; - if (isGuest == true) - { - SysUser user = ShiroUtils.getSysUser(); - if (user != null) - { - onlineSession.setUserId(user.getUserId()); - onlineSession.setLoginName(user.getLoginName()); - onlineSession.setAvatar(user.getAvatar()); - onlineSession.setDeptName(user.getDept().getDeptName()); - onlineSession.markAttributeChanged(); - } - } - - if (onlineSession.getStatus() == OnlineStatus.off_line) - { - return false; - } - } - return true; - } - - /** - * 表示当访问拒绝时是否已经处理了;如果返回true表示需要继续处理;如果返回false表示该拦截器实例已经处理了,将直接返回即可。 - */ - @Override - protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception - { - Subject subject = getSubject(request, response); - if (subject != null) - { - subject.logout(); - } - saveRequestAndRedirectToLogin(request, response); - return false; - } - - // 跳转到登录页 - @Override - protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException - { - WebUtils.issueRedirect(request, response, loginUrl); - } -} +package com.ruoyi.framework.shiro.web.filter.online; + +import java.io.IOException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; +import org.apache.shiro.web.filter.AccessControlFilter; +import org.apache.shiro.web.util.WebUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.common.enums.OnlineStatus; +import com.ruoyi.framework.shiro.session.OnlineSession; +import com.ruoyi.framework.shiro.session.OnlineSessionDAO; +import com.ruoyi.framework.util.ShiroUtils; +import com.ruoyi.system.domain.SysUser; + +/** + * 自定义访问控制 + * + * @author ruoyi + */ +public class OnlineSessionFilter extends AccessControlFilter +{ + /** + * 强制退出后重定向的地址 + */ + @Value("${shiro.user.loginUrl}") + private String loginUrl; + + @Autowired + private OnlineSessionDAO onlineSessionDAO; + + /** + * 表示是否允许访问;mappedValue就是[urls]配置中拦截器参数部分,如果允许访问返回true,否则false; + */ + @Override + protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) + throws Exception + { + Subject subject = getSubject(request, response); + if (subject == null || subject.getSession() == null) + { + return true; + } + Session session = onlineSessionDAO.readSession(subject.getSession().getId()); + if (session != null && session instanceof OnlineSession) + { + OnlineSession onlineSession = (OnlineSession) session; + request.setAttribute(ShiroConstants.ONLINE_SESSION, onlineSession); + // 把user对象设置进去 + boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L; + if (isGuest == true) + { + SysUser user = ShiroUtils.getSysUser(); + if (user != null) + { + onlineSession.setUserId(user.getUserId()); + onlineSession.setLoginName(user.getLoginName()); + onlineSession.setAvatar(user.getAvatar()); + onlineSession.setDeptName(user.getDept().getDeptName()); + onlineSession.markAttributeChanged(); + } + } + + if (onlineSession.getStatus() == OnlineStatus.off_line) + { + return false; + } + } + return true; + } + + /** + * 表示当访问拒绝时是否已经处理了;如果返回true表示需要继续处理;如果返回false表示该拦截器实例已经处理了,将直接返回即可。 + */ + @Override + protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception + { + Subject subject = getSubject(request, response); + if (subject != null) + { + subject.logout(); + } + saveRequestAndRedirectToLogin(request, response); + return false; + } + + // 跳转到登录页 + @Override + protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException + { + WebUtils.issueRedirect(request, response, loginUrl); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java index e1af32d97..8569bbb9d 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/filter/sync/SyncOnlineSessionFilter.java @@ -1,36 +1,36 @@ -package com.ruoyi.framework.shiro.web.filter.sync; - -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import org.apache.shiro.web.filter.PathMatchingFilter; -import org.springframework.beans.factory.annotation.Autowired; -import com.ruoyi.common.constant.ShiroConstants; -import com.ruoyi.framework.shiro.session.OnlineSession; -import com.ruoyi.framework.shiro.session.OnlineSessionDAO; - -/** - * 同步Session数据到Db - * - * @author ruoyi - */ -public class SyncOnlineSessionFilter extends PathMatchingFilter -{ - @Autowired - private OnlineSessionDAO onlineSessionDAO; - - /** - * 同步会话数据到DB 一次请求最多同步一次 防止过多处理 需要放到Shiro过滤器之前 - */ - @Override - protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception - { - OnlineSession session = (OnlineSession) request.getAttribute(ShiroConstants.ONLINE_SESSION); - // 如果session stop了 也不同步 - // session停止时间,如果stopTimestamp不为null,则代表已停止 - if (session != null && session.getUserId() != null && session.getStopTimestamp() == null) - { - onlineSessionDAO.syncToDb(session); - } - return true; - } -} +package com.ruoyi.framework.shiro.web.filter.sync; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import org.apache.shiro.web.filter.PathMatchingFilter; +import org.springframework.beans.factory.annotation.Autowired; +import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.framework.shiro.session.OnlineSession; +import com.ruoyi.framework.shiro.session.OnlineSessionDAO; + +/** + * 同步Session数据到Db + * + * @author ruoyi + */ +public class SyncOnlineSessionFilter extends PathMatchingFilter +{ + @Autowired + private OnlineSessionDAO onlineSessionDAO; + + /** + * 同步会话数据到DB 一次请求最多同步一次 防止过多处理 需要放到Shiro过滤器之前 + */ + @Override + protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception + { + OnlineSession session = (OnlineSession) request.getAttribute(ShiroConstants.ONLINE_SESSION); + // 如果session stop了 也不同步 + // session停止时间,如果stopTimestamp不为null,则代表已停止 + if (session != null && session.getUserId() != null && session.getStopTimestamp() == null) + { + onlineSessionDAO.syncToDb(session); + } + return true; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java similarity index 97% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java index 080567eed..26eaa9e2c 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java @@ -1,155 +1,155 @@ -package com.ruoyi.framework.shiro.web.session; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import org.apache.commons.lang3.time.DateUtils; -import org.apache.shiro.session.ExpiredSessionException; -import org.apache.shiro.session.InvalidSessionException; -import org.apache.shiro.session.Session; -import org.apache.shiro.session.mgt.DefaultSessionKey; -import org.apache.shiro.session.mgt.SessionKey; -import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.constant.ShiroConstants; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.shiro.session.OnlineSession; -import com.ruoyi.system.domain.SysUserOnline; -import com.ruoyi.system.service.ISysUserOnlineService; - -/** - * 主要是在此如果会话的属性修改了 就标识下其修改了 然后方便 OnlineSessionDao同步 - * - * @author ruoyi - */ -public class OnlineWebSessionManager extends DefaultWebSessionManager -{ - private static final Logger log = LoggerFactory.getLogger(OnlineWebSessionManager.class); - - @Override - public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) throws InvalidSessionException - { - super.setAttribute(sessionKey, attributeKey, value); - if (value != null && needMarkAttributeChanged(attributeKey)) - { - OnlineSession s = (OnlineSession) doGetSession(sessionKey); - s.markAttributeChanged(); - } - } - - private boolean needMarkAttributeChanged(Object attributeKey) - { - if (attributeKey == null) - { - return false; - } - String attributeKeyStr = attributeKey.toString(); - // 优化 flash属性没必要持久化 - if (attributeKeyStr.startsWith("org.springframework")) - { - return false; - } - if (attributeKeyStr.startsWith("javax.servlet")) - { - return false; - } - if (attributeKeyStr.equals(ShiroConstants.CURRENT_USERNAME)) - { - return false; - } - return true; - } - - @Override - public Object removeAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException - { - Object removed = super.removeAttribute(sessionKey, attributeKey); - if (removed != null) - { - OnlineSession s = (OnlineSession) doGetSession(sessionKey); - s.markAttributeChanged(); - } - - return removed; - } - - /** - * 验证session是否有效 用于删除过期session - */ - @Override - public void validateSessions() - { - if (log.isInfoEnabled()) - { - log.info("invalidation sessions..."); - } - - int invalidCount = 0; - - int timeout = (int) this.getGlobalSessionTimeout(); - Date expiredDate = DateUtils.addMilliseconds(new Date(), 0 - timeout); - ISysUserOnlineService userOnlineService = SpringUtils.getBean(ISysUserOnlineService.class); - List userOnlineList = userOnlineService.selectOnlineByExpired(expiredDate); - // 批量过期删除 - List needOfflineIdList = new ArrayList(); - for (SysUserOnline userOnline : userOnlineList) - { - try - { - SessionKey key = new DefaultSessionKey(userOnline.getSessionId()); - Session session = retrieveSession(key); - if (session != null) - { - throw new InvalidSessionException(); - } - } - catch (InvalidSessionException e) - { - if (log.isDebugEnabled()) - { - boolean expired = (e instanceof ExpiredSessionException); - String msg = "Invalidated session with id [" + userOnline.getSessionId() + "]" - + (expired ? " (expired)" : " (stopped)"); - log.debug(msg); - } - invalidCount++; - needOfflineIdList.add(userOnline.getSessionId()); - } - - } - if (needOfflineIdList.size() > 0) - { - try - { - userOnlineService.batchDeleteOnline(needOfflineIdList); - } - catch (Exception e) - { - log.error("batch delete db session error.", e); - } - } - - if (log.isInfoEnabled()) - { - String msg = "Finished invalidation session."; - if (invalidCount > 0) - { - msg += " [" + invalidCount + "] sessions were stopped."; - } - else - { - msg += " No sessions were stopped."; - } - log.info(msg); - } - - } - - @Override - protected Collection getActiveSessions() - { - throw new UnsupportedOperationException("getActiveSessions method not supported"); - } -} +package com.ruoyi.framework.shiro.web.session; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import org.apache.commons.lang3.time.DateUtils; +import org.apache.shiro.session.ExpiredSessionException; +import org.apache.shiro.session.InvalidSessionException; +import org.apache.shiro.session.Session; +import org.apache.shiro.session.mgt.DefaultSessionKey; +import org.apache.shiro.session.mgt.SessionKey; +import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.framework.shiro.session.OnlineSession; +import com.ruoyi.system.domain.SysUserOnline; +import com.ruoyi.system.service.ISysUserOnlineService; + +/** + * 主要是在此如果会话的属性修改了 就标识下其修改了 然后方便 OnlineSessionDao同步 + * + * @author ruoyi + */ +public class OnlineWebSessionManager extends DefaultWebSessionManager +{ + private static final Logger log = LoggerFactory.getLogger(OnlineWebSessionManager.class); + + @Override + public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) throws InvalidSessionException + { + super.setAttribute(sessionKey, attributeKey, value); + if (value != null && needMarkAttributeChanged(attributeKey)) + { + OnlineSession s = (OnlineSession) doGetSession(sessionKey); + s.markAttributeChanged(); + } + } + + private boolean needMarkAttributeChanged(Object attributeKey) + { + if (attributeKey == null) + { + return false; + } + String attributeKeyStr = attributeKey.toString(); + // 优化 flash属性没必要持久化 + if (attributeKeyStr.startsWith("org.springframework")) + { + return false; + } + if (attributeKeyStr.startsWith("javax.servlet")) + { + return false; + } + if (attributeKeyStr.equals(ShiroConstants.CURRENT_USERNAME)) + { + return false; + } + return true; + } + + @Override + public Object removeAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException + { + Object removed = super.removeAttribute(sessionKey, attributeKey); + if (removed != null) + { + OnlineSession s = (OnlineSession) doGetSession(sessionKey); + s.markAttributeChanged(); + } + + return removed; + } + + /** + * 验证session是否有效 用于删除过期session + */ + @Override + public void validateSessions() + { + if (log.isInfoEnabled()) + { + log.info("invalidation sessions..."); + } + + int invalidCount = 0; + + int timeout = (int) this.getGlobalSessionTimeout(); + Date expiredDate = DateUtils.addMilliseconds(new Date(), 0 - timeout); + ISysUserOnlineService userOnlineService = SpringUtils.getBean(ISysUserOnlineService.class); + List userOnlineList = userOnlineService.selectOnlineByExpired(expiredDate); + // 批量过期删除 + List needOfflineIdList = new ArrayList(); + for (SysUserOnline userOnline : userOnlineList) + { + try + { + SessionKey key = new DefaultSessionKey(userOnline.getSessionId()); + Session session = retrieveSession(key); + if (session != null) + { + throw new InvalidSessionException(); + } + } + catch (InvalidSessionException e) + { + if (log.isDebugEnabled()) + { + boolean expired = (e instanceof ExpiredSessionException); + String msg = "Invalidated session with id [" + userOnline.getSessionId() + "]" + + (expired ? " (expired)" : " (stopped)"); + log.debug(msg); + } + invalidCount++; + needOfflineIdList.add(userOnline.getSessionId()); + } + + } + if (needOfflineIdList.size() > 0) + { + try + { + userOnlineService.batchDeleteOnline(needOfflineIdList); + } + catch (Exception e) + { + log.error("batch delete db session error.", e); + } + } + + if (log.isInfoEnabled()) + { + String msg = "Finished invalidation session."; + if (invalidCount > 0) + { + msg += " [" + invalidCount + "] sessions were stopped."; + } + else + { + msg += " No sessions were stopped."; + } + log.info(msg); + } + + } + + @Override + protected Collection getActiveSessions() + { + throw new UnsupportedOperationException("getActiveSessions method not supported"); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java rename to bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java index fcb963366..790ca59f4 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java @@ -1,129 +1,129 @@ -package com.ruoyi.framework.shiro.web.session; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import org.apache.shiro.session.mgt.DefaultSessionManager; -import org.apache.shiro.session.mgt.SessionValidationScheduler; -import org.apache.shiro.session.mgt.ValidatingSessionManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import com.ruoyi.common.utils.Threads; - -/** - * 自定义任务调度器完成 - * - * @author ruoyi - */ -@Component -public class SpringSessionValidationScheduler implements SessionValidationScheduler -{ - private static final Logger log = LoggerFactory.getLogger(SpringSessionValidationScheduler.class); - - public static final long DEFAULT_SESSION_VALIDATION_INTERVAL = DefaultSessionManager.DEFAULT_SESSION_VALIDATION_INTERVAL; - - /** - * 定时器,用于处理超时的挂起请求,也用于连接断开时的重连。 - */ - @Autowired - @Qualifier("scheduledExecutorService") - private ScheduledExecutorService executorService; - - private volatile boolean enabled = false; - - /** - * 会话验证管理器 - */ - @Autowired - @Qualifier("sessionManager") - private ValidatingSessionManager sessionManager; - - // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟 - @Value("${shiro.session.validationInterval}") - private long sessionValidationInterval; - - @Override - public boolean isEnabled() - { - return this.enabled; - } - - /** - * Specifies how frequently (in milliseconds) this Scheduler will call the - * {@link org.apache.shiro.session.mgt.ValidatingSessionManager#validateSessions() - * ValidatingSessionManager#validateSessions()} method. - * - *

                            - * Unless this method is called, the default value is {@link #DEFAULT_SESSION_VALIDATION_INTERVAL}. - * - * @param sessionValidationInterval - */ - public void setSessionValidationInterval(long sessionValidationInterval) - { - this.sessionValidationInterval = sessionValidationInterval; - } - - /** - * Starts session validation by creating a spring PeriodicTrigger. - */ - @Override - public void enableSessionValidation() - { - - enabled = true; - - if (log.isDebugEnabled()) - { - log.debug("Scheduling session validation job using Spring Scheduler with " - + "session validation interval of [" + sessionValidationInterval + "]ms..."); - } - - try - { - executorService.scheduleAtFixedRate(new Runnable() - { - @Override - public void run() - { - if (enabled) - { - sessionManager.validateSessions(); - } - } - }, 1000, sessionValidationInterval * 60 * 1000, TimeUnit.MILLISECONDS); - - this.enabled = true; - - if (log.isDebugEnabled()) - { - log.debug("Session validation job successfully scheduled with Spring Scheduler."); - } - - } - catch (Exception e) - { - if (log.isErrorEnabled()) - { - log.error("Error starting the Spring Scheduler session validation job. Session validation may not occur.", e); - } - } - } - - @Override - public void disableSessionValidation() - { - if (log.isDebugEnabled()) - { - log.debug("Stopping Spring Scheduler session validation job..."); - } - - if (this.enabled) - { - Threads.shutdownAndAwaitTermination(executorService); - } - this.enabled = false; - } -} +package com.ruoyi.framework.shiro.web.session; + +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import org.apache.shiro.session.mgt.DefaultSessionManager; +import org.apache.shiro.session.mgt.SessionValidationScheduler; +import org.apache.shiro.session.mgt.ValidatingSessionManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import com.ruoyi.common.utils.Threads; + +/** + * 自定义任务调度器完成 + * + * @author ruoyi + */ +@Component +public class SpringSessionValidationScheduler implements SessionValidationScheduler +{ + private static final Logger log = LoggerFactory.getLogger(SpringSessionValidationScheduler.class); + + public static final long DEFAULT_SESSION_VALIDATION_INTERVAL = DefaultSessionManager.DEFAULT_SESSION_VALIDATION_INTERVAL; + + /** + * 定时器,用于处理超时的挂起请求,也用于连接断开时的重连。 + */ + @Autowired + @Qualifier("scheduledExecutorService") + private ScheduledExecutorService executorService; + + private volatile boolean enabled = false; + + /** + * 会话验证管理器 + */ + @Autowired + @Qualifier("sessionManager") + private ValidatingSessionManager sessionManager; + + // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟 + @Value("${shiro.session.validationInterval}") + private long sessionValidationInterval; + + @Override + public boolean isEnabled() + { + return this.enabled; + } + + /** + * Specifies how frequently (in milliseconds) this Scheduler will call the + * {@link org.apache.shiro.session.mgt.ValidatingSessionManager#validateSessions() + * ValidatingSessionManager#validateSessions()} method. + * + *

                            + * Unless this method is called, the default value is {@link #DEFAULT_SESSION_VALIDATION_INTERVAL}. + * + * @param sessionValidationInterval + */ + public void setSessionValidationInterval(long sessionValidationInterval) + { + this.sessionValidationInterval = sessionValidationInterval; + } + + /** + * Starts session validation by creating a spring PeriodicTrigger. + */ + @Override + public void enableSessionValidation() + { + + enabled = true; + + if (log.isDebugEnabled()) + { + log.debug("Scheduling session validation job using Spring Scheduler with " + + "session validation interval of [" + sessionValidationInterval + "]ms..."); + } + + try + { + executorService.scheduleAtFixedRate(new Runnable() + { + @Override + public void run() + { + if (enabled) + { + sessionManager.validateSessions(); + } + } + }, 1000, sessionValidationInterval * 60 * 1000, TimeUnit.MILLISECONDS); + + this.enabled = true; + + if (log.isDebugEnabled()) + { + log.debug("Session validation job successfully scheduled with Spring Scheduler."); + } + + } + catch (Exception e) + { + if (log.isErrorEnabled()) + { + log.error("Error starting the Spring Scheduler session validation job. Session validation may not occur.", e); + } + } + } + + @Override + public void disableSessionValidation() + { + if (log.isDebugEnabled()) + { + log.debug("Stopping Spring Scheduler session validation job..."); + } + + if (this.enabled) + { + Threads.shutdownAndAwaitTermination(executorService); + } + this.enabled = false; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/util/LogUtils.java b/bmw-framework/src/main/java/com/ruoyi/framework/util/LogUtils.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/util/LogUtils.java rename to bmw-framework/src/main/java/com/ruoyi/framework/util/LogUtils.java index 96a38eb55..7fbd30afb 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/util/LogUtils.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/util/LogUtils.java @@ -1,136 +1,136 @@ -package com.ruoyi.framework.util; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import org.apache.shiro.SecurityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.json.JSON; -import com.ruoyi.common.utils.IpUtils; - -/** - * 处理并记录日志文件 - * - * @author ruoyi - */ -public class LogUtils -{ - public static final Logger ERROR_LOG = LoggerFactory.getLogger("sys-error"); - public static final Logger ACCESS_LOG = LoggerFactory.getLogger("sys-access"); - - /** - * 记录访问日志 [username][jsessionid][ip][accept][UserAgent][url][params][Referer] - * - * @param request - * @throws Exception - */ - public static void logAccess(HttpServletRequest request) throws Exception - { - String username = getUsername(); - String jsessionId = request.getRequestedSessionId(); - String ip = IpUtils.getIpAddr(request); - String accept = request.getHeader("accept"); - String userAgent = request.getHeader("User-Agent"); - String url = request.getRequestURI(); - String params = getParams(request); - - StringBuilder s = new StringBuilder(); - s.append(getBlock(username)); - s.append(getBlock(jsessionId)); - s.append(getBlock(ip)); - s.append(getBlock(accept)); - s.append(getBlock(userAgent)); - s.append(getBlock(url)); - s.append(getBlock(params)); - s.append(getBlock(request.getHeader("Referer"))); - getAccessLog().info(s.toString()); - } - - /** - * 记录异常错误 格式 [exception] - * - * @param message - * @param e - */ - public static void logError(String message, Throwable e) - { - String username = getUsername(); - StringBuilder s = new StringBuilder(); - s.append(getBlock("exception")); - s.append(getBlock(username)); - s.append(getBlock(message)); - ERROR_LOG.error(s.toString(), e); - } - - /** - * 记录页面错误 错误日志记录 [page/eception][username][statusCode][errorMessage][servletName][uri][exceptionName][ip][exception] - * - * @param request - */ - public static void logPageError(HttpServletRequest request) - { - String username = getUsername(); - - Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); - String message = (String) request.getAttribute("javax.servlet.error.message"); - String uri = (String) request.getAttribute("javax.servlet.error.request_uri"); - Throwable t = (Throwable) request.getAttribute("javax.servlet.error.exception"); - - if (statusCode == null) - { - statusCode = 0; - } - - StringBuilder s = new StringBuilder(); - s.append(getBlock(t == null ? "page" : "exception")); - s.append(getBlock(username)); - s.append(getBlock(statusCode)); - s.append(getBlock(message)); - s.append(getBlock(IpUtils.getIpAddr(request))); - - s.append(getBlock(uri)); - s.append(getBlock(request.getHeader("Referer"))); - StringWriter sw = new StringWriter(); - - while (t != null) - { - t.printStackTrace(new PrintWriter(sw)); - t = t.getCause(); - } - s.append(getBlock(sw.toString())); - getErrorLog().error(s.toString()); - - } - - public static String getBlock(Object msg) - { - if (msg == null) - { - msg = ""; - } - return "[" + msg.toString() + "]"; - } - - protected static String getParams(HttpServletRequest request) throws Exception - { - Map params = request.getParameterMap(); - return JSON.marshal(params); - } - - protected static String getUsername() - { - return (String) SecurityUtils.getSubject().getPrincipal(); - } - - public static Logger getAccessLog() - { - return ACCESS_LOG; - } - - public static Logger getErrorLog() - { - return ERROR_LOG; - } -} +package com.ruoyi.framework.util; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import org.apache.shiro.SecurityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.json.JSON; +import com.ruoyi.common.utils.IpUtils; + +/** + * 处理并记录日志文件 + * + * @author ruoyi + */ +public class LogUtils +{ + public static final Logger ERROR_LOG = LoggerFactory.getLogger("sys-error"); + public static final Logger ACCESS_LOG = LoggerFactory.getLogger("sys-access"); + + /** + * 记录访问日志 [username][jsessionid][ip][accept][UserAgent][url][params][Referer] + * + * @param request + * @throws Exception + */ + public static void logAccess(HttpServletRequest request) throws Exception + { + String username = getUsername(); + String jsessionId = request.getRequestedSessionId(); + String ip = IpUtils.getIpAddr(request); + String accept = request.getHeader("accept"); + String userAgent = request.getHeader("User-Agent"); + String url = request.getRequestURI(); + String params = getParams(request); + + StringBuilder s = new StringBuilder(); + s.append(getBlock(username)); + s.append(getBlock(jsessionId)); + s.append(getBlock(ip)); + s.append(getBlock(accept)); + s.append(getBlock(userAgent)); + s.append(getBlock(url)); + s.append(getBlock(params)); + s.append(getBlock(request.getHeader("Referer"))); + getAccessLog().info(s.toString()); + } + + /** + * 记录异常错误 格式 [exception] + * + * @param message + * @param e + */ + public static void logError(String message, Throwable e) + { + String username = getUsername(); + StringBuilder s = new StringBuilder(); + s.append(getBlock("exception")); + s.append(getBlock(username)); + s.append(getBlock(message)); + ERROR_LOG.error(s.toString(), e); + } + + /** + * 记录页面错误 错误日志记录 [page/eception][username][statusCode][errorMessage][servletName][uri][exceptionName][ip][exception] + * + * @param request + */ + public static void logPageError(HttpServletRequest request) + { + String username = getUsername(); + + Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); + String message = (String) request.getAttribute("javax.servlet.error.message"); + String uri = (String) request.getAttribute("javax.servlet.error.request_uri"); + Throwable t = (Throwable) request.getAttribute("javax.servlet.error.exception"); + + if (statusCode == null) + { + statusCode = 0; + } + + StringBuilder s = new StringBuilder(); + s.append(getBlock(t == null ? "page" : "exception")); + s.append(getBlock(username)); + s.append(getBlock(statusCode)); + s.append(getBlock(message)); + s.append(getBlock(IpUtils.getIpAddr(request))); + + s.append(getBlock(uri)); + s.append(getBlock(request.getHeader("Referer"))); + StringWriter sw = new StringWriter(); + + while (t != null) + { + t.printStackTrace(new PrintWriter(sw)); + t = t.getCause(); + } + s.append(getBlock(sw.toString())); + getErrorLog().error(s.toString()); + + } + + public static String getBlock(Object msg) + { + if (msg == null) + { + msg = ""; + } + return "[" + msg.toString() + "]"; + } + + protected static String getParams(HttpServletRequest request) throws Exception + { + Map params = request.getParameterMap(); + return JSON.marshal(params); + } + + protected static String getUsername() + { + return (String) SecurityUtils.getSubject().getPrincipal(); + } + + public static Logger getAccessLog() + { + return ACCESS_LOG; + } + + public static Logger getErrorLog() + { + return ERROR_LOG; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/util/ShiroUtils.java b/bmw-framework/src/main/java/com/ruoyi/framework/util/ShiroUtils.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/util/ShiroUtils.java rename to bmw-framework/src/main/java/com/ruoyi/framework/util/ShiroUtils.java index a57f1197b..ae0567730 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/util/ShiroUtils.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/util/ShiroUtils.java @@ -1,97 +1,97 @@ -package com.ruoyi.framework.util; - -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.crypto.SecureRandomNumberGenerator; -import org.apache.shiro.mgt.RealmSecurityManager; -import org.apache.shiro.session.Session; -import org.apache.shiro.subject.Subject; -import org.apache.shiro.subject.PrincipalCollection; -import org.apache.shiro.subject.SimplePrincipalCollection; - -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.bean.BeanUtils; -import com.ruoyi.framework.shiro.realm.UserRealm; -import com.ruoyi.system.domain.SysUser; - -/** - * shiro 工具类 - * - * @author ruoyi - */ -public class ShiroUtils -{ - public static Subject getSubject() - { - return SecurityUtils.getSubject(); - } - - public static Session getSession() - { - return SecurityUtils.getSubject().getSession(); - } - - public static void logout() - { - getSubject().logout(); - } - - public static SysUser getSysUser() - { - SysUser user = null; - Object obj = getSubject().getPrincipal(); - if (StringUtils.isNotNull(obj)) - { - user = new SysUser(); - BeanUtils.copyBeanProp(user, obj); - } - return user; - } - - public static void setSysUser(SysUser user) - { - Subject subject = getSubject(); - PrincipalCollection principalCollection = subject.getPrincipals(); - String realmName = principalCollection.getRealmNames().iterator().next(); - PrincipalCollection newPrincipalCollection = new SimplePrincipalCollection(user, realmName); - // 重新加载Principal - subject.runAs(newPrincipalCollection); - } - - public static void clearCachedAuthorizationInfo() - { - RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager(); - UserRealm realm = (UserRealm) rsm.getRealms().iterator().next(); - realm.clearCachedAuthorizationInfo(); - } - - public static Long getUserId() - { - return getSysUser().getUserId().longValue(); - } - - public static String getLoginName() - { - return getSysUser().getLoginName(); - } - - public static String getIp() - { - return getSubject().getSession().getHost(); - } - - public static String getSessionId() - { - return String.valueOf(getSubject().getSession().getId()); - } - - /** - * 生成随机盐 - */ - public static String randomSalt() - { - // 一个Byte占两个字节,此处生成的3字节,字符串长度为6 - SecureRandomNumberGenerator secureRandom = new SecureRandomNumberGenerator(); - String hex = secureRandom.nextBytes(3).toHex(); - return hex; - } -} +package com.ruoyi.framework.util; + +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.crypto.SecureRandomNumberGenerator; +import org.apache.shiro.mgt.RealmSecurityManager; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; +import org.apache.shiro.subject.PrincipalCollection; +import org.apache.shiro.subject.SimplePrincipalCollection; + +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.framework.shiro.realm.UserRealm; +import com.ruoyi.system.domain.SysUser; + +/** + * shiro 工具类 + * + * @author ruoyi + */ +public class ShiroUtils +{ + public static Subject getSubject() + { + return SecurityUtils.getSubject(); + } + + public static Session getSession() + { + return SecurityUtils.getSubject().getSession(); + } + + public static void logout() + { + getSubject().logout(); + } + + public static SysUser getSysUser() + { + SysUser user = null; + Object obj = getSubject().getPrincipal(); + if (StringUtils.isNotNull(obj)) + { + user = new SysUser(); + BeanUtils.copyBeanProp(user, obj); + } + return user; + } + + public static void setSysUser(SysUser user) + { + Subject subject = getSubject(); + PrincipalCollection principalCollection = subject.getPrincipals(); + String realmName = principalCollection.getRealmNames().iterator().next(); + PrincipalCollection newPrincipalCollection = new SimplePrincipalCollection(user, realmName); + // 重新加载Principal + subject.runAs(newPrincipalCollection); + } + + public static void clearCachedAuthorizationInfo() + { + RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager(); + UserRealm realm = (UserRealm) rsm.getRealms().iterator().next(); + realm.clearCachedAuthorizationInfo(); + } + + public static Long getUserId() + { + return getSysUser().getUserId().longValue(); + } + + public static String getLoginName() + { + return getSysUser().getLoginName(); + } + + public static String getIp() + { + return getSubject().getSession().getHost(); + } + + public static String getSessionId() + { + return String.valueOf(getSubject().getSession().getId()); + } + + /** + * 生成随机盐 + */ + public static String randomSalt() + { + // 一个Byte占两个字节,此处生成的3字节,字符串长度为6 + SecureRandomNumberGenerator secureRandom = new SecureRandomNumberGenerator(); + String hex = secureRandom.nextBytes(3).toHex(); + return hex; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java index 26aed47db..1eb6ba974 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java @@ -1,241 +1,241 @@ -package com.ruoyi.framework.web.domain; - -import java.net.UnknownHostException; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import com.ruoyi.common.utils.Arith; -import com.ruoyi.common.utils.IpUtils; -import com.ruoyi.framework.web.domain.server.Cpu; -import com.ruoyi.framework.web.domain.server.Jvm; -import com.ruoyi.framework.web.domain.server.Mem; -import com.ruoyi.framework.web.domain.server.Sys; -import com.ruoyi.framework.web.domain.server.SysFile; -import oshi.SystemInfo; -import oshi.hardware.CentralProcessor; -import oshi.hardware.CentralProcessor.TickType; -import oshi.hardware.GlobalMemory; -import oshi.hardware.HardwareAbstractionLayer; -import oshi.software.os.FileSystem; -import oshi.software.os.OSFileStore; -import oshi.software.os.OperatingSystem; -import oshi.util.Util; - -/** - * 服务器相关信息 - * - * @author ruoyi - */ -public class Server -{ - - private static final int OSHI_WAIT_SECOND = 1000; - - /** - * CPU相关信息 - */ - private Cpu cpu = new Cpu(); - - /** - * 內存相关信息 - */ - private Mem mem = new Mem(); - - /** - * JVM相关信息 - */ - private Jvm jvm = new Jvm(); - - /** - * 服务器相关信息 - */ - private Sys sys = new Sys(); - - /** - * 磁盘相关信息 - */ - private List sysFiles = new LinkedList(); - - public Cpu getCpu() - { - return cpu; - } - - public void setCpu(Cpu cpu) - { - this.cpu = cpu; - } - - public Mem getMem() - { - return mem; - } - - public void setMem(Mem mem) - { - this.mem = mem; - } - - public Jvm getJvm() - { - return jvm; - } - - public void setJvm(Jvm jvm) - { - this.jvm = jvm; - } - - public Sys getSys() - { - return sys; - } - - public void setSys(Sys sys) - { - this.sys = sys; - } - - public List getSysFiles() - { - return sysFiles; - } - - public void setSysFiles(List sysFiles) - { - this.sysFiles = sysFiles; - } - - public void copyTo() throws Exception - { - SystemInfo si = new SystemInfo(); - HardwareAbstractionLayer hal = si.getHardware(); - - setCpuInfo(hal.getProcessor()); - - setMemInfo(hal.getMemory()); - - setSysInfo(); - - setJvmInfo(); - - setSysFiles(si.getOperatingSystem()); - } - - /** - * 设置CPU信息 - */ - private void setCpuInfo(CentralProcessor processor) - { - // CPU信息 - long[] prevTicks = processor.getSystemCpuLoadTicks(); - Util.sleep(OSHI_WAIT_SECOND); - long[] ticks = processor.getSystemCpuLoadTicks(); - long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()]; - long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()]; - long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()]; - long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()]; - long cSys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()]; - long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()]; - long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()]; - long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()]; - long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal; - cpu.setCpuNum(processor.getLogicalProcessorCount()); - cpu.setTotal(totalCpu); - cpu.setSys(cSys); - cpu.setUsed(user); - cpu.setWait(iowait); - cpu.setFree(idle); - } - - /** - * 设置内存信息 - */ - private void setMemInfo(GlobalMemory memory) - { - mem.setTotal(memory.getTotal()); - mem.setUsed(memory.getTotal() - memory.getAvailable()); - mem.setFree(memory.getAvailable()); - } - - /** - * 设置服务器信息 - */ - private void setSysInfo() - { - Properties props = System.getProperties(); - sys.setComputerName(IpUtils.getHostName()); - sys.setComputerIp(IpUtils.getHostIp()); - sys.setOsName(props.getProperty("os.name")); - sys.setOsArch(props.getProperty("os.arch")); - sys.setUserDir(props.getProperty("user.dir")); - } - - /** - * 设置Java虚拟机 - */ - private void setJvmInfo() throws UnknownHostException - { - Properties props = System.getProperties(); - jvm.setTotal(Runtime.getRuntime().totalMemory()); - jvm.setMax(Runtime.getRuntime().maxMemory()); - jvm.setFree(Runtime.getRuntime().freeMemory()); - jvm.setVersion(props.getProperty("java.version")); - jvm.setHome(props.getProperty("java.home")); - } - - /** - * 设置磁盘信息 - */ - private void setSysFiles(OperatingSystem os) - { - FileSystem fileSystem = os.getFileSystem(); - OSFileStore[] fsArray = fileSystem.getFileStores(); - for (OSFileStore fs : fsArray) - { - long free = fs.getUsableSpace(); - long total = fs.getTotalSpace(); - long used = total - free; - SysFile sysFile = new SysFile(); - sysFile.setDirName(fs.getMount()); - sysFile.setSysTypeName(fs.getType()); - sysFile.setTypeName(fs.getName()); - sysFile.setTotal(convertFileSize(total)); - sysFile.setFree(convertFileSize(free)); - sysFile.setUsed(convertFileSize(used)); - sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100)); - sysFiles.add(sysFile); - } - } - - /** - * 字节转换 - * - * @param size 字节大小 - * @return 转换后值 - */ - public String convertFileSize(long size) - { - long kb = 1024; - long mb = kb * 1024; - long gb = mb * 1024; - if (size >= gb) - { - return String.format("%.1f GB", (float) size / gb); - } - else if (size >= mb) - { - float f = (float) size / mb; - return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f); - } - else if (size >= kb) - { - float f = (float) size / kb; - return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f); - } - else - { - return String.format("%d B", size); - } - } -} +package com.ruoyi.framework.web.domain; + +import java.net.UnknownHostException; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; +import com.ruoyi.common.utils.Arith; +import com.ruoyi.common.utils.IpUtils; +import com.ruoyi.framework.web.domain.server.Cpu; +import com.ruoyi.framework.web.domain.server.Jvm; +import com.ruoyi.framework.web.domain.server.Mem; +import com.ruoyi.framework.web.domain.server.Sys; +import com.ruoyi.framework.web.domain.server.SysFile; +import oshi.SystemInfo; +import oshi.hardware.CentralProcessor; +import oshi.hardware.CentralProcessor.TickType; +import oshi.hardware.GlobalMemory; +import oshi.hardware.HardwareAbstractionLayer; +import oshi.software.os.FileSystem; +import oshi.software.os.OSFileStore; +import oshi.software.os.OperatingSystem; +import oshi.util.Util; + +/** + * 服务器相关信息 + * + * @author ruoyi + */ +public class Server +{ + + private static final int OSHI_WAIT_SECOND = 1000; + + /** + * CPU相关信息 + */ + private Cpu cpu = new Cpu(); + + /** + * 內存相关信息 + */ + private Mem mem = new Mem(); + + /** + * JVM相关信息 + */ + private Jvm jvm = new Jvm(); + + /** + * 服务器相关信息 + */ + private Sys sys = new Sys(); + + /** + * 磁盘相关信息 + */ + private List sysFiles = new LinkedList(); + + public Cpu getCpu() + { + return cpu; + } + + public void setCpu(Cpu cpu) + { + this.cpu = cpu; + } + + public Mem getMem() + { + return mem; + } + + public void setMem(Mem mem) + { + this.mem = mem; + } + + public Jvm getJvm() + { + return jvm; + } + + public void setJvm(Jvm jvm) + { + this.jvm = jvm; + } + + public Sys getSys() + { + return sys; + } + + public void setSys(Sys sys) + { + this.sys = sys; + } + + public List getSysFiles() + { + return sysFiles; + } + + public void setSysFiles(List sysFiles) + { + this.sysFiles = sysFiles; + } + + public void copyTo() throws Exception + { + SystemInfo si = new SystemInfo(); + HardwareAbstractionLayer hal = si.getHardware(); + + setCpuInfo(hal.getProcessor()); + + setMemInfo(hal.getMemory()); + + setSysInfo(); + + setJvmInfo(); + + setSysFiles(si.getOperatingSystem()); + } + + /** + * 设置CPU信息 + */ + private void setCpuInfo(CentralProcessor processor) + { + // CPU信息 + long[] prevTicks = processor.getSystemCpuLoadTicks(); + Util.sleep(OSHI_WAIT_SECOND); + long[] ticks = processor.getSystemCpuLoadTicks(); + long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()]; + long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()]; + long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()]; + long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()]; + long cSys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()]; + long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()]; + long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()]; + long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()]; + long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal; + cpu.setCpuNum(processor.getLogicalProcessorCount()); + cpu.setTotal(totalCpu); + cpu.setSys(cSys); + cpu.setUsed(user); + cpu.setWait(iowait); + cpu.setFree(idle); + } + + /** + * 设置内存信息 + */ + private void setMemInfo(GlobalMemory memory) + { + mem.setTotal(memory.getTotal()); + mem.setUsed(memory.getTotal() - memory.getAvailable()); + mem.setFree(memory.getAvailable()); + } + + /** + * 设置服务器信息 + */ + private void setSysInfo() + { + Properties props = System.getProperties(); + sys.setComputerName(IpUtils.getHostName()); + sys.setComputerIp(IpUtils.getHostIp()); + sys.setOsName(props.getProperty("os.name")); + sys.setOsArch(props.getProperty("os.arch")); + sys.setUserDir(props.getProperty("user.dir")); + } + + /** + * 设置Java虚拟机 + */ + private void setJvmInfo() throws UnknownHostException + { + Properties props = System.getProperties(); + jvm.setTotal(Runtime.getRuntime().totalMemory()); + jvm.setMax(Runtime.getRuntime().maxMemory()); + jvm.setFree(Runtime.getRuntime().freeMemory()); + jvm.setVersion(props.getProperty("java.version")); + jvm.setHome(props.getProperty("java.home")); + } + + /** + * 设置磁盘信息 + */ + private void setSysFiles(OperatingSystem os) + { + FileSystem fileSystem = os.getFileSystem(); + OSFileStore[] fsArray = fileSystem.getFileStores(); + for (OSFileStore fs : fsArray) + { + long free = fs.getUsableSpace(); + long total = fs.getTotalSpace(); + long used = total - free; + SysFile sysFile = new SysFile(); + sysFile.setDirName(fs.getMount()); + sysFile.setSysTypeName(fs.getType()); + sysFile.setTypeName(fs.getName()); + sysFile.setTotal(convertFileSize(total)); + sysFile.setFree(convertFileSize(free)); + sysFile.setUsed(convertFileSize(used)); + sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100)); + sysFiles.add(sysFile); + } + } + + /** + * 字节转换 + * + * @param size 字节大小 + * @return 转换后值 + */ + public String convertFileSize(long size) + { + long kb = 1024; + long mb = kb * 1024; + long gb = mb * 1024; + if (size >= gb) + { + return String.format("%.1f GB", (float) size / gb); + } + else if (size >= mb) + { + float f = (float) size / mb; + return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f); + } + else if (size >= kb) + { + float f = (float) size / kb; + return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f); + } + else + { + return String.format("%d B", size); + } + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java similarity index 93% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java index cf7b46e1e..a13a66cf2 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java @@ -1,101 +1,101 @@ -package com.ruoyi.framework.web.domain.server; - -import com.ruoyi.common.utils.Arith; - -/** - * CPU相关信息 - * - * @author ruoyi - */ -public class Cpu -{ - /** - * 核心数 - */ - private int cpuNum; - - /** - * CPU总的使用率 - */ - private double total; - - /** - * CPU系统使用率 - */ - private double sys; - - /** - * CPU用户使用率 - */ - private double used; - - /** - * CPU当前等待率 - */ - private double wait; - - /** - * CPU当前空闲率 - */ - private double free; - - public int getCpuNum() - { - return cpuNum; - } - - public void setCpuNum(int cpuNum) - { - this.cpuNum = cpuNum; - } - - public double getTotal() - { - return Arith.round(Arith.mul(total, 100), 2); - } - - public void setTotal(double total) - { - this.total = total; - } - - public double getSys() - { - return Arith.round(Arith.mul(sys / total, 100), 2); - } - - public void setSys(double sys) - { - this.sys = sys; - } - - public double getUsed() - { - return Arith.round(Arith.mul(used / total, 100), 2); - } - - public void setUsed(double used) - { - this.used = used; - } - - public double getWait() - { - return Arith.round(Arith.mul(wait / total, 100), 2); - } - - public void setWait(double wait) - { - this.wait = wait; - } - - public double getFree() - { - return Arith.round(Arith.mul(free / total, 100), 2); - } - - public void setFree(double free) - { - this.free = free; - } -} +package com.ruoyi.framework.web.domain.server; + +import com.ruoyi.common.utils.Arith; + +/** + * CPU相关信息 + * + * @author ruoyi + */ +public class Cpu +{ + /** + * 核心数 + */ + private int cpuNum; + + /** + * CPU总的使用率 + */ + private double total; + + /** + * CPU系统使用率 + */ + private double sys; + + /** + * CPU用户使用率 + */ + private double used; + + /** + * CPU当前等待率 + */ + private double wait; + + /** + * CPU当前空闲率 + */ + private double free; + + public int getCpuNum() + { + return cpuNum; + } + + public void setCpuNum(int cpuNum) + { + this.cpuNum = cpuNum; + } + + public double getTotal() + { + return Arith.round(Arith.mul(total, 100), 2); + } + + public void setTotal(double total) + { + this.total = total; + } + + public double getSys() + { + return Arith.round(Arith.mul(sys / total, 100), 2); + } + + public void setSys(double sys) + { + this.sys = sys; + } + + public double getUsed() + { + return Arith.round(Arith.mul(used / total, 100), 2); + } + + public void setUsed(double used) + { + this.used = used; + } + + public double getWait() + { + return Arith.round(Arith.mul(wait / total, 100), 2); + } + + public void setWait(double wait) + { + this.wait = wait; + } + + public double getFree() + { + return Arith.round(Arith.mul(free / total, 100), 2); + } + + public void setFree(double free) + { + this.free = free; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java similarity index 94% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java index f29d2cbe6..485d201dd 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java @@ -1,122 +1,122 @@ -package com.ruoyi.framework.web.domain.server; - -import java.lang.management.ManagementFactory; -import com.ruoyi.common.utils.Arith; -import com.ruoyi.common.utils.DateUtils; - -/** - * JVM相关信息 - * - * @author ruoyi - */ -public class Jvm -{ - /** - * 当前JVM占用的内存总数(M) - */ - private double total; - - /** - * JVM最大可用内存总数(M) - */ - private double max; - - /** - * JVM空闲内存(M) - */ - private double free; - - /** - * JDK版本 - */ - private String version; - - /** - * JDK路径 - */ - private String home; - - public double getTotal() - { - return Arith.div(total, (1024 * 1024), 2); - } - - public void setTotal(double total) - { - this.total = total; - } - - public double getMax() - { - return Arith.div(max, (1024 * 1024), 2); - } - - public void setMax(double max) - { - this.max = max; - } - - public double getFree() - { - return Arith.div(free, (1024 * 1024), 2); - } - - public void setFree(double free) - { - this.free = free; - } - - public double getUsed() - { - return Arith.div(total - free, (1024 * 1024), 2); - } - - public double getUsage() - { - return Arith.mul(Arith.div(total - free, total, 4), 100); - } - - /** - * 获取JDK名称 - */ - public String getName() - { - return ManagementFactory.getRuntimeMXBean().getVmName(); - } - - public String getVersion() - { - return version; - } - - public void setVersion(String version) - { - this.version = version; - } - - public String getHome() - { - return home; - } - - public void setHome(String home) - { - this.home = home; - } - - /** - * JDK启动时间 - */ - public String getStartTime() - { - return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate()); - } - - /** - * JDK运行时间 - */ - public String getRunTime() - { - return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate()); - } -} +package com.ruoyi.framework.web.domain.server; + +import java.lang.management.ManagementFactory; +import com.ruoyi.common.utils.Arith; +import com.ruoyi.common.utils.DateUtils; + +/** + * JVM相关信息 + * + * @author ruoyi + */ +public class Jvm +{ + /** + * 当前JVM占用的内存总数(M) + */ + private double total; + + /** + * JVM最大可用内存总数(M) + */ + private double max; + + /** + * JVM空闲内存(M) + */ + private double free; + + /** + * JDK版本 + */ + private String version; + + /** + * JDK路径 + */ + private String home; + + public double getTotal() + { + return Arith.div(total, (1024 * 1024), 2); + } + + public void setTotal(double total) + { + this.total = total; + } + + public double getMax() + { + return Arith.div(max, (1024 * 1024), 2); + } + + public void setMax(double max) + { + this.max = max; + } + + public double getFree() + { + return Arith.div(free, (1024 * 1024), 2); + } + + public void setFree(double free) + { + this.free = free; + } + + public double getUsed() + { + return Arith.div(total - free, (1024 * 1024), 2); + } + + public double getUsage() + { + return Arith.mul(Arith.div(total - free, total, 4), 100); + } + + /** + * 获取JDK名称 + */ + public String getName() + { + return ManagementFactory.getRuntimeMXBean().getVmName(); + } + + public String getVersion() + { + return version; + } + + public void setVersion(String version) + { + this.version = version; + } + + public String getHome() + { + return home; + } + + public void setHome(String home) + { + this.home = home; + } + + /** + * JDK启动时间 + */ + public String getStartTime() + { + return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate()); + } + + /** + * JDK运行时间 + */ + public String getRunTime() + { + return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate()); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java similarity index 94% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java index ac715049a..13eec521a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java @@ -1,61 +1,61 @@ -package com.ruoyi.framework.web.domain.server; - -import com.ruoyi.common.utils.Arith; - -/** - * 內存相关信息 - * - * @author ruoyi - */ -public class Mem -{ - /** - * 内存总量 - */ - private double total; - - /** - * 已用内存 - */ - private double used; - - /** - * 剩余内存 - */ - private double free; - - public double getTotal() - { - return Arith.div(total, (1024 * 1024 * 1024), 2); - } - - public void setTotal(long total) - { - this.total = total; - } - - public double getUsed() - { - return Arith.div(used, (1024 * 1024 * 1024), 2); - } - - public void setUsed(long used) - { - this.used = used; - } - - public double getFree() - { - return Arith.div(free, (1024 * 1024 * 1024), 2); - } - - public void setFree(long free) - { - this.free = free; - } - - public double getUsage() - { - return Arith.mul(Arith.div(used, total, 4), 100); - } -} +package com.ruoyi.framework.web.domain.server; + +import com.ruoyi.common.utils.Arith; + +/** + * 內存相关信息 + * + * @author ruoyi + */ +public class Mem +{ + /** + * 内存总量 + */ + private double total; + + /** + * 已用内存 + */ + private double used; + + /** + * 剩余内存 + */ + private double free; + + public double getTotal() + { + return Arith.div(total, (1024 * 1024 * 1024), 2); + } + + public void setTotal(long total) + { + this.total = total; + } + + public double getUsed() + { + return Arith.div(used, (1024 * 1024 * 1024), 2); + } + + public void setUsed(long used) + { + this.used = used; + } + + public double getFree() + { + return Arith.div(free, (1024 * 1024 * 1024), 2); + } + + public void setFree(long free) + { + this.free = free; + } + + public double getUsage() + { + return Arith.mul(Arith.div(used, total, 4), 100); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java similarity index 93% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java index a5f65e46e..45d64d9cd 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java @@ -1,84 +1,84 @@ -package com.ruoyi.framework.web.domain.server; - -/** - * 系统相关信息 - * - * @author ruoyi - */ -public class Sys -{ - /** - * 服务器名称 - */ - private String computerName; - - /** - * 服务器Ip - */ - private String computerIp; - - /** - * 项目路径 - */ - private String userDir; - - /** - * 操作系统 - */ - private String osName; - - /** - * 系统架构 - */ - private String osArch; - - public String getComputerName() - { - return computerName; - } - - public void setComputerName(String computerName) - { - this.computerName = computerName; - } - - public String getComputerIp() - { - return computerIp; - } - - public void setComputerIp(String computerIp) - { - this.computerIp = computerIp; - } - - public String getUserDir() - { - return userDir; - } - - public void setUserDir(String userDir) - { - this.userDir = userDir; - } - - public String getOsName() - { - return osName; - } - - public void setOsName(String osName) - { - this.osName = osName; - } - - public String getOsArch() - { - return osArch; - } - - public void setOsArch(String osArch) - { - this.osArch = osArch; - } -} +package com.ruoyi.framework.web.domain.server; + +/** + * 系统相关信息 + * + * @author ruoyi + */ +public class Sys +{ + /** + * 服务器名称 + */ + private String computerName; + + /** + * 服务器Ip + */ + private String computerIp; + + /** + * 项目路径 + */ + private String userDir; + + /** + * 操作系统 + */ + private String osName; + + /** + * 系统架构 + */ + private String osArch; + + public String getComputerName() + { + return computerName; + } + + public void setComputerName(String computerName) + { + this.computerName = computerName; + } + + public String getComputerIp() + { + return computerIp; + } + + public void setComputerIp(String computerIp) + { + this.computerIp = computerIp; + } + + public String getUserDir() + { + return userDir; + } + + public void setUserDir(String userDir) + { + this.userDir = userDir; + } + + public String getOsName() + { + return osName; + } + + public void setOsName(String osName) + { + this.osName = osName; + } + + public String getOsArch() + { + return osArch; + } + + public void setOsArch(String osArch) + { + this.osArch = osArch; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java similarity index 93% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java index 47ecf3f3e..1320cde6e 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java @@ -1,114 +1,114 @@ -package com.ruoyi.framework.web.domain.server; - -/** - * 系统文件相关信息 - * - * @author ruoyi - */ -public class SysFile -{ - /** - * 盘符路径 - */ - private String dirName; - - /** - * 盘符类型 - */ - private String sysTypeName; - - /** - * 文件类型 - */ - private String typeName; - - /** - * 总大小 - */ - private String total; - - /** - * 剩余大小 - */ - private String free; - - /** - * 已经使用量 - */ - private String used; - - /** - * 资源的使用率 - */ - private double usage; - - public String getDirName() - { - return dirName; - } - - public void setDirName(String dirName) - { - this.dirName = dirName; - } - - public String getSysTypeName() - { - return sysTypeName; - } - - public void setSysTypeName(String sysTypeName) - { - this.sysTypeName = sysTypeName; - } - - public String getTypeName() - { - return typeName; - } - - public void setTypeName(String typeName) - { - this.typeName = typeName; - } - - public String getTotal() - { - return total; - } - - public void setTotal(String total) - { - this.total = total; - } - - public String getFree() - { - return free; - } - - public void setFree(String free) - { - this.free = free; - } - - public String getUsed() - { - return used; - } - - public void setUsed(String used) - { - this.used = used; - } - - public double getUsage() - { - return usage; - } - - public void setUsage(double usage) - { - this.usage = usage; - } -} +package com.ruoyi.framework.web.domain.server; + +/** + * 系统文件相关信息 + * + * @author ruoyi + */ +public class SysFile +{ + /** + * 盘符路径 + */ + private String dirName; + + /** + * 盘符类型 + */ + private String sysTypeName; + + /** + * 文件类型 + */ + private String typeName; + + /** + * 总大小 + */ + private String total; + + /** + * 剩余大小 + */ + private String free; + + /** + * 已经使用量 + */ + private String used; + + /** + * 资源的使用率 + */ + private double usage; + + public String getDirName() + { + return dirName; + } + + public void setDirName(String dirName) + { + this.dirName = dirName; + } + + public String getSysTypeName() + { + return sysTypeName; + } + + public void setSysTypeName(String sysTypeName) + { + this.sysTypeName = sysTypeName; + } + + public String getTypeName() + { + return typeName; + } + + public void setTypeName(String typeName) + { + this.typeName = typeName; + } + + public String getTotal() + { + return total; + } + + public void setTotal(String total) + { + this.total = total; + } + + public String getFree() + { + return free; + } + + public void setFree(String free) + { + this.free = free; + } + + public String getUsed() + { + return used; + } + + public void setUsed(String used) + { + this.used = used; + } + + public double getUsage() + { + return usage; + } + + public void setUsage(double usage) + { + this.usage = usage; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java similarity index 100% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java similarity index 95% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java index 5ee1b3d8c..010312ee7 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/service/ConfigService.java @@ -1,28 +1,28 @@ -package com.ruoyi.framework.web.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.system.service.ISysConfigService; - -/** - * RuoYi首创 html调用 thymeleaf 实现参数管理 - * - * @author ruoyi - */ -@Service("config") -public class ConfigService -{ - @Autowired - private ISysConfigService configService; - - /** - * 根据键名查询参数配置信息 - * - * @param configName 参数名称 - * @return 参数键值 - */ - public String getKey(String configKey) - { - return configService.selectConfigByKey(configKey); - } -} +package com.ruoyi.framework.web.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.service.ISysConfigService; + +/** + * RuoYi首创 html调用 thymeleaf 实现参数管理 + * + * @author ruoyi + */ +@Service("config") +public class ConfigService +{ + @Autowired + private ISysConfigService configService; + + /** + * 根据键名查询参数配置信息 + * + * @param configName 参数名称 + * @return 参数键值 + */ + public String getKey(String configKey) + { + return configService.selectConfigByKey(configKey); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/DictService.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/service/DictService.java similarity index 96% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/DictService.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/service/DictService.java index 64e7c8a0e..b8aa4baec 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/DictService.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/service/DictService.java @@ -1,42 +1,42 @@ -package com.ruoyi.framework.web.service; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.system.domain.SysDictData; -import com.ruoyi.system.service.ISysDictDataService; - -/** - * RuoYi首创 html调用 thymeleaf 实现字典读取 - * - * @author ruoyi - */ -@Service("dict") -public class DictService -{ - @Autowired - private ISysDictDataService dictDataService; - - /** - * 根据字典类型查询字典数据信息 - * - * @param dictType 字典类型 - * @return 参数键值 - */ - public List getType(String dictType) - { - return dictDataService.selectDictDataByType(dictType); - } - - /** - * 根据字典类型和字典键值查询字典数据信息 - * - * @param dictType 字典类型 - * @param dictValue 字典键值 - * @return 字典标签 - */ - public String getLabel(String dictType, String dictValue) - { - return dictDataService.selectDictLabel(dictType, dictValue); - } -} +package com.ruoyi.framework.web.service; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.domain.SysDictData; +import com.ruoyi.system.service.ISysDictDataService; + +/** + * RuoYi首创 html调用 thymeleaf 实现字典读取 + * + * @author ruoyi + */ +@Service("dict") +public class DictService +{ + @Autowired + private ISysDictDataService dictDataService; + + /** + * 根据字典类型查询字典数据信息 + * + * @param dictType 字典类型 + * @return 参数键值 + */ + public List getType(String dictType) + { + return dictDataService.selectDictDataByType(dictType); + } + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String getLabel(String dictType, String dictValue) + { + return dictDataService.selectDictLabel(dictType, dictValue); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java b/bmw-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java similarity index 95% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java rename to bmw-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java index 0123ddb1c..90bd0554d 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java +++ b/bmw-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java @@ -1,57 +1,57 @@ -package com.ruoyi.framework.web.service; - -import org.apache.shiro.SecurityUtils; -import org.springframework.stereotype.Service; -import com.ruoyi.common.utils.security.PermissionUtils; - -/** - * RuoYi首创 js调用 thymeleaf 实现按钮权限可见性 - * - * @author ruoyi - */ -@Service("permission") -public class PermissionService -{ - public String hasPermi(String permission) - { - return isPermittedOperator(permission) ? "" : "hidden"; - } - - public String hasRole(String role) - { - return hasRoleOperator(role) ? "" : "hidden"; - } - - /** - * 判断用户是否拥有某个权限 - * - * @param permission 权限字符串 - * @return 结果 - */ - private boolean isPermittedOperator(String permission) - { - return SecurityUtils.getSubject().isPermitted(permission); - } - - /** - * 判断用户是否拥有某个角色 - * - * @param role 角色字符串 - * @return 结果 - */ - private boolean hasRoleOperator(String role) - { - return SecurityUtils.getSubject().hasRole(role); - } - - /** - * 返回用户属性值 - * - * @param property 属性名称 - * @return 用户属性值 - */ - public Object getPrincipalProperty(String property) - { - return PermissionUtils.getPrincipalProperty(property); - } -} +package com.ruoyi.framework.web.service; + +import org.apache.shiro.SecurityUtils; +import org.springframework.stereotype.Service; +import com.ruoyi.common.utils.security.PermissionUtils; + +/** + * RuoYi首创 js调用 thymeleaf 实现按钮权限可见性 + * + * @author ruoyi + */ +@Service("permission") +public class PermissionService +{ + public String hasPermi(String permission) + { + return isPermittedOperator(permission) ? "" : "hidden"; + } + + public String hasRole(String role) + { + return hasRoleOperator(role) ? "" : "hidden"; + } + + /** + * 判断用户是否拥有某个权限 + * + * @param permission 权限字符串 + * @return 结果 + */ + private boolean isPermittedOperator(String permission) + { + return SecurityUtils.getSubject().isPermitted(permission); + } + + /** + * 判断用户是否拥有某个角色 + * + * @param role 角色字符串 + * @return 结果 + */ + private boolean hasRoleOperator(String role) + { + return SecurityUtils.getSubject().hasRole(role); + } + + /** + * 返回用户属性值 + * + * @param property 属性名称 + * @return 用户属性值 + */ + public Object getPrincipalProperty(String property) + { + return PermissionUtils.getPrincipalProperty(property); + } +} diff --git a/ruoyi-generator/pom.xml b/bmw-generator/pom.xml similarity index 96% rename from ruoyi-generator/pom.xml rename to bmw-generator/pom.xml index 3a26d099b..9c59323ac 100644 --- a/ruoyi-generator/pom.xml +++ b/bmw-generator/pom.xml @@ -1,34 +1,34 @@ - - - - ruoyi - com.ruoyi - 3.4 - - 4.0.0 - - ruoyi-generator - - - generator代码生成 - - - - - - - org.apache.velocity - velocity - - - - - com.ruoyi - ruoyi-common - - - - + + + + ruoyi + com.ruoyi + 3.4 + + 4.0.0 + + ruoyi-generator + + + generator代码生成 + + + + + + + org.apache.velocity + velocity + + + + + com.ruoyi + ruoyi-common + + + + \ No newline at end of file diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java b/bmw-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java similarity index 95% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java rename to bmw-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java index 49b42e7ae..2b5c801f0 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java +++ b/bmw-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java @@ -1,73 +1,73 @@ -package com.ruoyi.generator.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * 读取代码生成相关配置 - * - * @author ruoyi - */ -@Component -@ConfigurationProperties(prefix = "gen") -@PropertySource(value = { "classpath:generator.yml" }) -public class GenConfig -{ - /** 作者 */ - public static String author; - - /** 生成包路径 */ - public static String packageName; - - /** 自动去除表前缀,默认是true */ - public static String autoRemovePre; - - /** 表前缀(类名不会包含表前缀) */ - public static String tablePrefix; - - public static String getAuthor() - { - return author; - } - - @Value("${author}") - public void setAuthor(String author) - { - GenConfig.author = author; - } - - public static String getPackageName() - { - return packageName; - } - - @Value("${packageName}") - public void setPackageName(String packageName) - { - GenConfig.packageName = packageName; - } - - public static String getAutoRemovePre() - { - return autoRemovePre; - } - - @Value("${autoRemovePre}") - public void setAutoRemovePre(String autoRemovePre) - { - GenConfig.autoRemovePre = autoRemovePre; - } - - public static String getTablePrefix() - { - return tablePrefix; - } - - @Value("${tablePrefix}") - public void setTablePrefix(String tablePrefix) - { - GenConfig.tablePrefix = tablePrefix; - } -} +package com.ruoyi.generator.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +/** + * 读取代码生成相关配置 + * + * @author ruoyi + */ +@Component +@ConfigurationProperties(prefix = "gen") +@PropertySource(value = { "classpath:generator.yml" }) +public class GenConfig +{ + /** 作者 */ + public static String author; + + /** 生成包路径 */ + public static String packageName; + + /** 自动去除表前缀,默认是true */ + public static String autoRemovePre; + + /** 表前缀(类名不会包含表前缀) */ + public static String tablePrefix; + + public static String getAuthor() + { + return author; + } + + @Value("${author}") + public void setAuthor(String author) + { + GenConfig.author = author; + } + + public static String getPackageName() + { + return packageName; + } + + @Value("${packageName}") + public void setPackageName(String packageName) + { + GenConfig.packageName = packageName; + } + + public static String getAutoRemovePre() + { + return autoRemovePre; + } + + @Value("${autoRemovePre}") + public void setAutoRemovePre(String autoRemovePre) + { + GenConfig.autoRemovePre = autoRemovePre; + } + + public static String getTablePrefix() + { + return tablePrefix; + } + + @Value("${tablePrefix}") + public void setTablePrefix(String tablePrefix) + { + GenConfig.tablePrefix = tablePrefix; + } +} diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java b/bmw-generator/src/main/java/com/ruoyi/generator/controller/GenController.java similarity index 100% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java rename to bmw-generator/src/main/java/com/ruoyi/generator/controller/GenController.java diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/ColumnConfigInfo.java b/bmw-generator/src/main/java/com/ruoyi/generator/domain/ColumnConfigInfo.java similarity index 100% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/domain/ColumnConfigInfo.java rename to bmw-generator/src/main/java/com/ruoyi/generator/domain/ColumnConfigInfo.java diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/ColumnInfo.java b/bmw-generator/src/main/java/com/ruoyi/generator/domain/ColumnInfo.java similarity index 95% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/domain/ColumnInfo.java rename to bmw-generator/src/main/java/com/ruoyi/generator/domain/ColumnInfo.java index c4032a535..13c9493ab 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/ColumnInfo.java +++ b/bmw-generator/src/main/java/com/ruoyi/generator/domain/ColumnInfo.java @@ -1,125 +1,125 @@ -package com.ruoyi.generator.domain; - -import com.ruoyi.common.json.JSON; -import com.ruoyi.common.utils.StringUtils; - -/** - * ry数据库表列信息 - * - * @author ruoyi - */ -public class ColumnInfo -{ - /** 字段名称 */ - private String columnName; - - /** 字段类型 */ - private String dataType; - - /** 列描述 */ - private String columnComment; - - /** 列配置 */ - private ColumnConfigInfo configInfo; - - /** Java属性类型 */ - private String attrType; - - /** Java属性名称(第一个字母大写),如:user_name => UserName */ - private String attrName; - - /** Java属性名称(第一个字母小写),如:user_name => userName */ - private String attrname; - - /** 执行计划(包含了与索引相关的一些细节信息) */ - private String extra; - - public String getColumnName() - { - return columnName; - } - - public void setColumnName(String columnName) - { - this.columnName = columnName; - } - - public String getDataType() - { - return dataType; - } - - public void setDataType(String dataType) - { - this.dataType = dataType; - } - - public String getColumnComment() - { - return columnComment; - } - - public void setColumnComment(String columnComment) throws Exception - { - // 根据列描述解析列的配置信息 - if (StringUtils.isNotEmpty(columnComment) && columnComment.startsWith("{")) - { - this.configInfo = JSON.unmarshal(columnComment, ColumnConfigInfo.class); - this.columnComment = configInfo.getTitle(); - } - else - { - this.columnComment = columnComment; - } - } - - public String getAttrName() - { - return attrName; - } - - public void setAttrName(String attrName) - { - this.attrName = attrName; - } - - public String getAttrname() - { - return attrname; - } - - public void setAttrname(String attrname) - { - this.attrname = attrname; - } - - public String getAttrType() - { - return attrType; - } - - public void setAttrType(String attrType) - { - this.attrType = attrType; - } - - public String getExtra() - { - return extra; - } - - public void setExtra(String extra) - { - this.extra = extra; - } - - public ColumnConfigInfo getConfigInfo() - { - return configInfo; - } - - public void setConfigInfo(ColumnConfigInfo configInfo) - { - this.configInfo = configInfo; - } -} +package com.ruoyi.generator.domain; + +import com.ruoyi.common.json.JSON; +import com.ruoyi.common.utils.StringUtils; + +/** + * ry数据库表列信息 + * + * @author ruoyi + */ +public class ColumnInfo +{ + /** 字段名称 */ + private String columnName; + + /** 字段类型 */ + private String dataType; + + /** 列描述 */ + private String columnComment; + + /** 列配置 */ + private ColumnConfigInfo configInfo; + + /** Java属性类型 */ + private String attrType; + + /** Java属性名称(第一个字母大写),如:user_name => UserName */ + private String attrName; + + /** Java属性名称(第一个字母小写),如:user_name => userName */ + private String attrname; + + /** 执行计划(包含了与索引相关的一些细节信息) */ + private String extra; + + public String getColumnName() + { + return columnName; + } + + public void setColumnName(String columnName) + { + this.columnName = columnName; + } + + public String getDataType() + { + return dataType; + } + + public void setDataType(String dataType) + { + this.dataType = dataType; + } + + public String getColumnComment() + { + return columnComment; + } + + public void setColumnComment(String columnComment) throws Exception + { + // 根据列描述解析列的配置信息 + if (StringUtils.isNotEmpty(columnComment) && columnComment.startsWith("{")) + { + this.configInfo = JSON.unmarshal(columnComment, ColumnConfigInfo.class); + this.columnComment = configInfo.getTitle(); + } + else + { + this.columnComment = columnComment; + } + } + + public String getAttrName() + { + return attrName; + } + + public void setAttrName(String attrName) + { + this.attrName = attrName; + } + + public String getAttrname() + { + return attrname; + } + + public void setAttrname(String attrname) + { + this.attrname = attrname; + } + + public String getAttrType() + { + return attrType; + } + + public void setAttrType(String attrType) + { + this.attrType = attrType; + } + + public String getExtra() + { + return extra; + } + + public void setExtra(String extra) + { + this.extra = extra; + } + + public ColumnConfigInfo getConfigInfo() + { + return configInfo; + } + + public void setConfigInfo(ColumnConfigInfo configInfo) + { + this.configInfo = configInfo; + } +} diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/TableInfo.java b/bmw-generator/src/main/java/com/ruoyi/generator/domain/TableInfo.java similarity index 95% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/domain/TableInfo.java rename to bmw-generator/src/main/java/com/ruoyi/generator/domain/TableInfo.java index d6219249f..f416fb644 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/TableInfo.java +++ b/bmw-generator/src/main/java/com/ruoyi/generator/domain/TableInfo.java @@ -1,103 +1,103 @@ -package com.ruoyi.generator.domain; - -import java.util.List; -import com.ruoyi.common.core.domain.BaseEntity; -import com.ruoyi.common.utils.StringUtils; - -/** - * ry 数据库表 - * - * @author ruoyi - */ -public class TableInfo extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 表名称 */ - private String tableName; - - /** 表描述 */ - private String tableComment; - - /** 表的主键列信息 */ - private ColumnInfo primaryKey; - - /** 表的列名(不包含主键) */ - private List columns; - - /** 类名(第一个字母大写) */ - private String className; - - /** 类名(第一个字母小写) */ - private String classname; - - public String getTableName() - { - return tableName; - } - - public void setTableName(String tableName) - { - this.tableName = tableName; - } - - public String getTableComment() - { - return tableComment; - } - - public void setTableComment(String tableComment) - { - this.tableComment = tableComment; - } - - public List getColumns() - { - return columns; - } - - public ColumnInfo getColumnsLast() - { - ColumnInfo columnInfo = null; - if (StringUtils.isNotNull(columns) && columns.size() > 0) - { - columnInfo = columns.get(0); - } - return columnInfo; - } - - public void setColumns(List columns) - { - this.columns = columns; - } - - public String getClassName() - { - return className; - } - - public void setClassName(String className) - { - this.className = className; - } - - public String getClassname() - { - return classname; - } - - public void setClassname(String classname) - { - this.classname = classname; - } - - public ColumnInfo getPrimaryKey() - { - return primaryKey; - } - - public void setPrimaryKey(ColumnInfo primaryKey) - { - this.primaryKey = primaryKey; - } -} +package com.ruoyi.generator.domain; + +import java.util.List; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.StringUtils; + +/** + * ry 数据库表 + * + * @author ruoyi + */ +public class TableInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 表名称 */ + private String tableName; + + /** 表描述 */ + private String tableComment; + + /** 表的主键列信息 */ + private ColumnInfo primaryKey; + + /** 表的列名(不包含主键) */ + private List columns; + + /** 类名(第一个字母大写) */ + private String className; + + /** 类名(第一个字母小写) */ + private String classname; + + public String getTableName() + { + return tableName; + } + + public void setTableName(String tableName) + { + this.tableName = tableName; + } + + public String getTableComment() + { + return tableComment; + } + + public void setTableComment(String tableComment) + { + this.tableComment = tableComment; + } + + public List getColumns() + { + return columns; + } + + public ColumnInfo getColumnsLast() + { + ColumnInfo columnInfo = null; + if (StringUtils.isNotNull(columns) && columns.size() > 0) + { + columnInfo = columns.get(0); + } + return columnInfo; + } + + public void setColumns(List columns) + { + this.columns = columns; + } + + public String getClassName() + { + return className; + } + + public void setClassName(String className) + { + this.className = className; + } + + public String getClassname() + { + return classname; + } + + public void setClassname(String classname) + { + this.classname = classname; + } + + public ColumnInfo getPrimaryKey() + { + return primaryKey; + } + + public void setPrimaryKey(ColumnInfo primaryKey) + { + this.primaryKey = primaryKey; + } +} diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenMapper.java b/bmw-generator/src/main/java/com/ruoyi/generator/mapper/GenMapper.java similarity index 95% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenMapper.java rename to bmw-generator/src/main/java/com/ruoyi/generator/mapper/GenMapper.java index a516128a3..6233939d6 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenMapper.java +++ b/bmw-generator/src/main/java/com/ruoyi/generator/mapper/GenMapper.java @@ -1,37 +1,37 @@ -package com.ruoyi.generator.mapper; - -import java.util.List; -import com.ruoyi.generator.domain.ColumnInfo; -import com.ruoyi.generator.domain.TableInfo; - -/** - * 代码生成 数据层 - * - * @author ruoyi - */ -public interface GenMapper -{ - /** - * 查询ry数据库表信息 - * - * @param tableInfo 表信息 - * @return 数据库表列表 - */ - public List selectTableList(TableInfo tableInfo); - - /** - * 根据表名称查询信息 - * - * @param tableName 表名称 - * @return 表信息 - */ - public TableInfo selectTableByName(String tableName); - - /** - * 根据表名称查询列信息 - * - * @param tableName 表名称 - * @return 列信息 - */ - public List selectTableColumnsByName(String tableName); -} +package com.ruoyi.generator.mapper; + +import java.util.List; +import com.ruoyi.generator.domain.ColumnInfo; +import com.ruoyi.generator.domain.TableInfo; + +/** + * 代码生成 数据层 + * + * @author ruoyi + */ +public interface GenMapper +{ + /** + * 查询ry数据库表信息 + * + * @param tableInfo 表信息 + * @return 数据库表列表 + */ + public List selectTableList(TableInfo tableInfo); + + /** + * 根据表名称查询信息 + * + * @param tableName 表名称 + * @return 表信息 + */ + public TableInfo selectTableByName(String tableName); + + /** + * 根据表名称查询列信息 + * + * @param tableName 表名称 + * @return 列信息 + */ + public List selectTableColumnsByName(String tableName); +} diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenService.java b/bmw-generator/src/main/java/com/ruoyi/generator/service/IGenService.java similarity index 95% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenService.java rename to bmw-generator/src/main/java/com/ruoyi/generator/service/IGenService.java index 1dbf12afb..b5e3f374d 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenService.java +++ b/bmw-generator/src/main/java/com/ruoyi/generator/service/IGenService.java @@ -1,36 +1,36 @@ -package com.ruoyi.generator.service; - -import java.util.List; -import com.ruoyi.generator.domain.TableInfo; - -/** - * 代码生成 服务层 - * - * @author ruoyi - */ -public interface IGenService -{ - /** - * 查询ry数据库表信息 - * - * @param tableInfo 表信息 - * @return 数据库表列表 - */ - public List selectTableList(TableInfo tableInfo); - - /** - * 生成代码 - * - * @param tableName 表名称 - * @return 数据 - */ - public byte[] generatorCode(String tableName); - - /** - * 批量生成代码 - * - * @param tableNames 表数组 - * @return 数据 - */ - public byte[] generatorCode(String[] tableNames); -} +package com.ruoyi.generator.service; + +import java.util.List; +import com.ruoyi.generator.domain.TableInfo; + +/** + * 代码生成 服务层 + * + * @author ruoyi + */ +public interface IGenService +{ + /** + * 查询ry数据库表信息 + * + * @param tableInfo 表信息 + * @return 数据库表列表 + */ + public List selectTableList(TableInfo tableInfo); + + /** + * 生成代码 + * + * @param tableName 表名称 + * @return 数据 + */ + public byte[] generatorCode(String tableName); + + /** + * 批量生成代码 + * + * @param tableNames 表数组 + * @return 数据 + */ + public byte[] generatorCode(String[] tableNames); +} diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/impl/GenServiceImpl.java b/bmw-generator/src/main/java/com/ruoyi/generator/service/impl/GenServiceImpl.java similarity index 100% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/service/impl/GenServiceImpl.java rename to bmw-generator/src/main/java/com/ruoyi/generator/service/impl/GenServiceImpl.java diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java b/bmw-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java similarity index 97% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java rename to bmw-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java index 46d0a9dcf..8d23fa6be 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java +++ b/bmw-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java @@ -1,241 +1,241 @@ -package com.ruoyi.generator.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.velocity.VelocityContext; -import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.generator.config.GenConfig; -import com.ruoyi.generator.domain.ColumnInfo; -import com.ruoyi.generator.domain.TableInfo; - -/** - * 代码生成器 工具类 - * - * @author ruoyi - */ -public class GenUtils -{ - /** 项目空间路径 */ - private static final String PROJECT_PATH = getProjectPath(); - - /** mybatis空间路径 */ - private static final String MYBATIS_PATH = "main/resources/mapper"; - - /** html空间路径 */ - private static final String TEMPLATES_PATH = "main/resources/templates"; - - /** 类型转换 */ - public static Map javaTypeMap = new HashMap(); - - /** - * 设置列信息 - */ - public static List transColums(List columns) - { - // 列信息 - List columsList = new ArrayList<>(); - for (ColumnInfo column : columns) - { - // 列名转换成Java属性名 - String attrName = StringUtils.convertToCamelCase(column.getColumnName()); - column.setAttrName(attrName); - column.setAttrname(StringUtils.uncapitalize(attrName)); - column.setExtra(column.getExtra()); - - // 列的数据类型,转换成Java类型 - String attrType = javaTypeMap.get(column.getDataType()); - column.setAttrType(attrType); - - columsList.add(column); - } - return columsList; - } - - /** - * 获取模板信息 - * - * @return 模板列表 - */ - public static VelocityContext getVelocityContext(TableInfo table) - { - // java对象数据传递到模板文件vm - VelocityContext velocityContext = new VelocityContext(); - String packageName = GenConfig.getPackageName(); - velocityContext.put("tableName", table.getTableName()); - velocityContext.put("tableComment", replaceKeyword(table.getTableComment())); - velocityContext.put("primaryKey", table.getPrimaryKey()); - velocityContext.put("className", table.getClassName()); - velocityContext.put("classname", table.getClassname()); - velocityContext.put("moduleName", getModuleName(packageName)); - velocityContext.put("columns", table.getColumns()); - velocityContext.put("basePackage", getBasePackage(packageName)); - velocityContext.put("package", packageName); - velocityContext.put("author", GenConfig.getAuthor()); - velocityContext.put("datetime", DateUtils.getDate()); - return velocityContext; - } - - /** - * 获取模板信息 - * - * @return 模板列表 - */ - public static List getTemplates() - { - List templates = new ArrayList(); - templates.add("vm/java/domain.java.vm"); - templates.add("vm/java/Mapper.java.vm"); - templates.add("vm/java/Service.java.vm"); - templates.add("vm/java/ServiceImpl.java.vm"); - templates.add("vm/java/Controller.java.vm"); - templates.add("vm/xml/Mapper.xml.vm"); - templates.add("vm/html/list.html.vm"); - templates.add("vm/html/add.html.vm"); - templates.add("vm/html/edit.html.vm"); - templates.add("vm/sql/sql.vm"); - return templates; - } - - /** - * 表名转换成Java类名 - */ - public static String tableToJava(String tableName) - { - String autoRemovePre = GenConfig.getAutoRemovePre(); - String tablePrefix = GenConfig.getTablePrefix(); - if (Constants.AUTO_REOMVE_PRE.equals(autoRemovePre) && StringUtils.isNotEmpty(tablePrefix)) - { - tableName = tableName.replaceFirst(tablePrefix, ""); - } - return StringUtils.convertToCamelCase(tableName); - } - - /** - * 获取文件名 - */ - public static String getFileName(String template, TableInfo table, String moduleName) - { - // 小写类名 - String classname = table.getClassname(); - // 大写类名 - String className = table.getClassName(); - String javaPath = PROJECT_PATH; - String mybatisPath = MYBATIS_PATH + "/" + moduleName + "/" + className; - String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + classname; - - if (template.contains("domain.java.vm")) - { - return javaPath + "domain" + "/" + className + ".java"; - } - - if (template.contains("Mapper.java.vm")) - { - return javaPath + "mapper" + "/" + className + "Mapper.java"; - } - - if (template.contains("Service.java.vm")) - { - return javaPath + "service" + "/" + "I" + className + "Service.java"; - } - - if (template.contains("ServiceImpl.java.vm")) - { - return javaPath + "service" + "/impl/" + className + "ServiceImpl.java"; - } - - if (template.contains("Controller.java.vm")) - { - return javaPath + "controller" + "/" + className + "Controller.java"; - } - - if (template.contains("Mapper.xml.vm")) - { - return mybatisPath + "Mapper.xml"; - } - - if (template.contains("list.html.vm")) - { - return htmlPath + "/" + classname + ".html"; - } - if (template.contains("add.html.vm")) - { - return htmlPath + "/" + "add.html"; - } - if (template.contains("edit.html.vm")) - { - return htmlPath + "/" + "edit.html"; - } - if (template.contains("sql.vm")) - { - return classname + "Menu.sql"; - } - return null; - } - - /** - * 获取模块名 - * - * @param packageName 包名 - * @return 模块名 - */ - public static String getModuleName(String packageName) - { - int lastIndex = packageName.lastIndexOf("."); - int nameLength = packageName.length(); - String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); - return moduleName; - } - - public static String getBasePackage(String packageName) - { - int lastIndex = packageName.lastIndexOf("."); - String basePackage = StringUtils.substring(packageName, 0, lastIndex); - return basePackage; - } - - public static String getProjectPath() - { - String packageName = GenConfig.getPackageName(); - StringBuffer projectPath = new StringBuffer(); - projectPath.append("main/java/"); - projectPath.append(packageName.replace(".", "/")); - projectPath.append("/"); - return projectPath.toString(); - } - - public static String replaceKeyword(String keyword) - { - String keyName = keyword.replaceAll("(?:表|信息|管理)", ""); - return keyName; - } - - static - { - javaTypeMap.put("tinyint", "Integer"); - javaTypeMap.put("smallint", "Integer"); - javaTypeMap.put("mediumint", "Integer"); - javaTypeMap.put("int", "Integer"); - javaTypeMap.put("number", "Integer"); - javaTypeMap.put("integer", "integer"); - javaTypeMap.put("bigint", "Long"); - javaTypeMap.put("float", "Float"); - javaTypeMap.put("double", "Double"); - javaTypeMap.put("decimal", "BigDecimal"); - javaTypeMap.put("bit", "Boolean"); - javaTypeMap.put("char", "String"); - javaTypeMap.put("varchar", "String"); - javaTypeMap.put("varchar2", "String"); - javaTypeMap.put("tinytext", "String"); - javaTypeMap.put("text", "String"); - javaTypeMap.put("mediumtext", "String"); - javaTypeMap.put("longtext", "String"); - javaTypeMap.put("time", "Date"); - javaTypeMap.put("date", "Date"); - javaTypeMap.put("datetime", "Date"); - javaTypeMap.put("timestamp", "Date"); - } -} +package com.ruoyi.generator.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.velocity.VelocityContext; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.generator.config.GenConfig; +import com.ruoyi.generator.domain.ColumnInfo; +import com.ruoyi.generator.domain.TableInfo; + +/** + * 代码生成器 工具类 + * + * @author ruoyi + */ +public class GenUtils +{ + /** 项目空间路径 */ + private static final String PROJECT_PATH = getProjectPath(); + + /** mybatis空间路径 */ + private static final String MYBATIS_PATH = "main/resources/mapper"; + + /** html空间路径 */ + private static final String TEMPLATES_PATH = "main/resources/templates"; + + /** 类型转换 */ + public static Map javaTypeMap = new HashMap(); + + /** + * 设置列信息 + */ + public static List transColums(List columns) + { + // 列信息 + List columsList = new ArrayList<>(); + for (ColumnInfo column : columns) + { + // 列名转换成Java属性名 + String attrName = StringUtils.convertToCamelCase(column.getColumnName()); + column.setAttrName(attrName); + column.setAttrname(StringUtils.uncapitalize(attrName)); + column.setExtra(column.getExtra()); + + // 列的数据类型,转换成Java类型 + String attrType = javaTypeMap.get(column.getDataType()); + column.setAttrType(attrType); + + columsList.add(column); + } + return columsList; + } + + /** + * 获取模板信息 + * + * @return 模板列表 + */ + public static VelocityContext getVelocityContext(TableInfo table) + { + // java对象数据传递到模板文件vm + VelocityContext velocityContext = new VelocityContext(); + String packageName = GenConfig.getPackageName(); + velocityContext.put("tableName", table.getTableName()); + velocityContext.put("tableComment", replaceKeyword(table.getTableComment())); + velocityContext.put("primaryKey", table.getPrimaryKey()); + velocityContext.put("className", table.getClassName()); + velocityContext.put("classname", table.getClassname()); + velocityContext.put("moduleName", getModuleName(packageName)); + velocityContext.put("columns", table.getColumns()); + velocityContext.put("basePackage", getBasePackage(packageName)); + velocityContext.put("package", packageName); + velocityContext.put("author", GenConfig.getAuthor()); + velocityContext.put("datetime", DateUtils.getDate()); + return velocityContext; + } + + /** + * 获取模板信息 + * + * @return 模板列表 + */ + public static List getTemplates() + { + List templates = new ArrayList(); + templates.add("vm/java/domain.java.vm"); + templates.add("vm/java/Mapper.java.vm"); + templates.add("vm/java/Service.java.vm"); + templates.add("vm/java/ServiceImpl.java.vm"); + templates.add("vm/java/Controller.java.vm"); + templates.add("vm/xml/Mapper.xml.vm"); + templates.add("vm/html/list.html.vm"); + templates.add("vm/html/add.html.vm"); + templates.add("vm/html/edit.html.vm"); + templates.add("vm/sql/sql.vm"); + return templates; + } + + /** + * 表名转换成Java类名 + */ + public static String tableToJava(String tableName) + { + String autoRemovePre = GenConfig.getAutoRemovePre(); + String tablePrefix = GenConfig.getTablePrefix(); + if (Constants.AUTO_REOMVE_PRE.equals(autoRemovePre) && StringUtils.isNotEmpty(tablePrefix)) + { + tableName = tableName.replaceFirst(tablePrefix, ""); + } + return StringUtils.convertToCamelCase(tableName); + } + + /** + * 获取文件名 + */ + public static String getFileName(String template, TableInfo table, String moduleName) + { + // 小写类名 + String classname = table.getClassname(); + // 大写类名 + String className = table.getClassName(); + String javaPath = PROJECT_PATH; + String mybatisPath = MYBATIS_PATH + "/" + moduleName + "/" + className; + String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + classname; + + if (template.contains("domain.java.vm")) + { + return javaPath + "domain" + "/" + className + ".java"; + } + + if (template.contains("Mapper.java.vm")) + { + return javaPath + "mapper" + "/" + className + "Mapper.java"; + } + + if (template.contains("Service.java.vm")) + { + return javaPath + "service" + "/" + "I" + className + "Service.java"; + } + + if (template.contains("ServiceImpl.java.vm")) + { + return javaPath + "service" + "/impl/" + className + "ServiceImpl.java"; + } + + if (template.contains("Controller.java.vm")) + { + return javaPath + "controller" + "/" + className + "Controller.java"; + } + + if (template.contains("Mapper.xml.vm")) + { + return mybatisPath + "Mapper.xml"; + } + + if (template.contains("list.html.vm")) + { + return htmlPath + "/" + classname + ".html"; + } + if (template.contains("add.html.vm")) + { + return htmlPath + "/" + "add.html"; + } + if (template.contains("edit.html.vm")) + { + return htmlPath + "/" + "edit.html"; + } + if (template.contains("sql.vm")) + { + return classname + "Menu.sql"; + } + return null; + } + + /** + * 获取模块名 + * + * @param packageName 包名 + * @return 模块名 + */ + public static String getModuleName(String packageName) + { + int lastIndex = packageName.lastIndexOf("."); + int nameLength = packageName.length(); + String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); + return moduleName; + } + + public static String getBasePackage(String packageName) + { + int lastIndex = packageName.lastIndexOf("."); + String basePackage = StringUtils.substring(packageName, 0, lastIndex); + return basePackage; + } + + public static String getProjectPath() + { + String packageName = GenConfig.getPackageName(); + StringBuffer projectPath = new StringBuffer(); + projectPath.append("main/java/"); + projectPath.append(packageName.replace(".", "/")); + projectPath.append("/"); + return projectPath.toString(); + } + + public static String replaceKeyword(String keyword) + { + String keyName = keyword.replaceAll("(?:表|信息|管理)", ""); + return keyName; + } + + static + { + javaTypeMap.put("tinyint", "Integer"); + javaTypeMap.put("smallint", "Integer"); + javaTypeMap.put("mediumint", "Integer"); + javaTypeMap.put("int", "Integer"); + javaTypeMap.put("number", "Integer"); + javaTypeMap.put("integer", "integer"); + javaTypeMap.put("bigint", "Long"); + javaTypeMap.put("float", "Float"); + javaTypeMap.put("double", "Double"); + javaTypeMap.put("decimal", "BigDecimal"); + javaTypeMap.put("bit", "Boolean"); + javaTypeMap.put("char", "String"); + javaTypeMap.put("varchar", "String"); + javaTypeMap.put("varchar2", "String"); + javaTypeMap.put("tinytext", "String"); + javaTypeMap.put("text", "String"); + javaTypeMap.put("mediumtext", "String"); + javaTypeMap.put("longtext", "String"); + javaTypeMap.put("time", "Date"); + javaTypeMap.put("date", "Date"); + javaTypeMap.put("datetime", "Date"); + javaTypeMap.put("timestamp", "Date"); + } +} diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java b/bmw-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java similarity index 96% rename from ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java rename to bmw-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java index 6d7e5f70f..24004617b 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java +++ b/bmw-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java @@ -1,36 +1,36 @@ -package com.ruoyi.generator.util; - -import java.util.Properties; -import org.apache.velocity.app.Velocity; -import com.ruoyi.common.constant.Constants; - -/** - * VelocityEngine工厂 - * - * @author RuoYi - */ -public class VelocityInitializer -{ - /** - * 初始化vm方法 - */ - public static void initVelocity() - { - Properties p = new Properties(); - try - { - // 加载classpath目录下的vm文件 - p.setProperty("file.resource.loader.class", - "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - // 定义字符集 - p.setProperty(Velocity.ENCODING_DEFAULT, Constants.UTF8); - p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8); - // 初始化Velocity引擎,指定配置Properties - Velocity.init(p); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } -} +package com.ruoyi.generator.util; + +import java.util.Properties; +import org.apache.velocity.app.Velocity; +import com.ruoyi.common.constant.Constants; + +/** + * VelocityEngine工厂 + * + * @author RuoYi + */ +public class VelocityInitializer +{ + /** + * 初始化vm方法 + */ + public static void initVelocity() + { + Properties p = new Properties(); + try + { + // 加载classpath目录下的vm文件 + p.setProperty("file.resource.loader.class", + "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + // 定义字符集 + p.setProperty(Velocity.ENCODING_DEFAULT, Constants.UTF8); + p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8); + // 初始化Velocity引擎,指定配置Properties + Velocity.init(p); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } +} diff --git a/ruoyi-generator/src/main/resources/generator.yml b/bmw-generator/src/main/resources/generator.yml similarity index 96% rename from ruoyi-generator/src/main/resources/generator.yml rename to bmw-generator/src/main/resources/generator.yml index 9e76f23f4..94349f426 100644 --- a/ruoyi-generator/src/main/resources/generator.yml +++ b/bmw-generator/src/main/resources/generator.yml @@ -1,11 +1,11 @@ - -# 代码生成 -gen: - # 作者 - author: ruoyi - # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool - packageName: com.ruoyi.system - # 自动去除表前缀,默认是true - autoRemovePre: true - # 表前缀(类名不会包含表前缀) + +# 代码生成 +gen: + # 作者 + author: ruoyi + # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool + packageName: com.ruoyi.system + # 自动去除表前缀,默认是true + autoRemovePre: true + # 表前缀(类名不会包含表前缀) tablePrefix: sys_ \ No newline at end of file diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenMapper.xml b/bmw-generator/src/main/resources/mapper/generator/GenMapper.xml similarity index 97% rename from ruoyi-generator/src/main/resources/mapper/generator/GenMapper.xml rename to bmw-generator/src/main/resources/mapper/generator/GenMapper.xml index 45bf4bd8a..0dc1f675d 100644 --- a/ruoyi-generator/src/main/resources/mapper/generator/GenMapper.xml +++ b/bmw-generator/src/main/resources/mapper/generator/GenMapper.xml @@ -1,52 +1,52 @@ - - - - - - - - - - - - - - - - - - - select table_name, table_comment, create_time, update_time from information_schema.tables - - - - - - - - + + + + + + + + + + + + + + + + + + + select table_name, table_comment, create_time, update_time from information_schema.tables + + + + + + + + \ No newline at end of file diff --git a/ruoyi-generator/src/main/resources/templates/tool/gen/gen.html b/bmw-generator/src/main/resources/templates/tool/gen/gen.html similarity index 97% rename from ruoyi-generator/src/main/resources/templates/tool/gen/gen.html rename to bmw-generator/src/main/resources/templates/tool/gen/gen.html index 3de386a45..a67d7fdd8 100644 --- a/ruoyi-generator/src/main/resources/templates/tool/gen/gen.html +++ b/bmw-generator/src/main/resources/templates/tool/gen/gen.html @@ -1,123 +1,123 @@ - - - - - - -

                            -
                            -
                            -
                            -
                            -
                              -
                            • - 表名称: -
                            • -
                            • - 表描述: -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 表名称: +
                            • +
                            • + 表描述: +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-generator/src/main/resources/vm/html/add.html.vm b/bmw-generator/src/main/resources/vm/html/add.html.vm similarity index 96% rename from ruoyi-generator/src/main/resources/vm/html/add.html.vm rename to bmw-generator/src/main/resources/vm/html/add.html.vm index 3b9206b7b..ad4f9fc16 100644 --- a/ruoyi-generator/src/main/resources/vm/html/add.html.vm +++ b/bmw-generator/src/main/resources/vm/html/add.html.vm @@ -1,61 +1,61 @@ - - - - - - -
                            -
                            -#foreach($column in $columns) -#if($column.columnName != $primaryKey.columnName) -#if(!${column.configInfo}) -
                            - -
                            - -
                            -
                            -#else -#if(${column.configInfo.type} == "dict") -
                            - -
                            - -
                            -
                            -#elseif(${column.configInfo.type} == "date") -
                            - -
                            - -
                            -
                            -#elseif(${column.configInfo.type} == "fk") -#end -#end -#end -#end -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +#foreach($column in $columns) +#if($column.columnName != $primaryKey.columnName) +#if(!${column.configInfo}) +
                            + +
                            + +
                            +
                            +#else +#if(${column.configInfo.type} == "dict") +
                            + +
                            + +
                            +
                            +#elseif(${column.configInfo.type} == "date") +
                            + +
                            + +
                            +
                            +#elseif(${column.configInfo.type} == "fk") +#end +#end +#end +#end +
                            +
                            +
                            + + + diff --git a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm b/bmw-generator/src/main/resources/vm/html/edit.html.vm similarity index 97% rename from ruoyi-generator/src/main/resources/vm/html/edit.html.vm rename to bmw-generator/src/main/resources/vm/html/edit.html.vm index 16cdbeff3..f63ada495 100644 --- a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm +++ b/bmw-generator/src/main/resources/vm/html/edit.html.vm @@ -1,62 +1,62 @@ - - - - - - -
                            -
                            - -#foreach($column in $columns) -#if($column.columnName != $primaryKey.columnName) -#if(!${column.configInfo}) -
                            - -
                            - -
                            -
                            -#else -#if(${column.configInfo.type} == "dict") -
                            - -
                            - -
                            -
                            -#elseif(${column.configInfo.type} == "date") -
                            - -
                            - -
                            -
                            -#elseif(${column.configInfo.type} == "fk") -#end -#end -#end -#end -
                            -
                            -
                            - - - + + + + + + +
                            +
                            + +#foreach($column in $columns) +#if($column.columnName != $primaryKey.columnName) +#if(!${column.configInfo}) +
                            + +
                            + +
                            +
                            +#else +#if(${column.configInfo.type} == "dict") +
                            + +
                            + +
                            +
                            +#elseif(${column.configInfo.type} == "date") +
                            + +
                            + +
                            +
                            +#elseif(${column.configInfo.type} == "fk") +#end +#end +#end +#end +
                            +
                            +
                            + + + diff --git a/ruoyi-generator/src/main/resources/vm/html/list.html.vm b/bmw-generator/src/main/resources/vm/html/list.html.vm similarity index 97% rename from ruoyi-generator/src/main/resources/vm/html/list.html.vm rename to bmw-generator/src/main/resources/vm/html/list.html.vm index 813863583..78a81ea91 100644 --- a/ruoyi-generator/src/main/resources/vm/html/list.html.vm +++ b/bmw-generator/src/main/resources/vm/html/list.html.vm @@ -1,132 +1,132 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -#foreach($column in $columns) -#if($column.columnName != $primaryKey.columnName) -#if(!${column.configInfo}) -
                            • - ${column.columnComment}: -
                            • - -#else -#if(${column.configInfo.type} == "dict") -
                            • - ${column.columnComment}: -
                            • -#elseif(${column.configInfo.type} == "date") -
                            • - - - - - -
                            • -#elseif(${column.configInfo.type} == "fk") -#end -#end -#end -#end -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - -
                            -
                            -
                            -
                            -
                            -
                            - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +#foreach($column in $columns) +#if($column.columnName != $primaryKey.columnName) +#if(!${column.configInfo}) +
                            • + ${column.columnComment}: +
                            • + +#else +#if(${column.configInfo.type} == "dict") +
                            • + ${column.columnComment}: +
                            • +#elseif(${column.configInfo.type} == "date") +
                            • + + + - + +
                            • +#elseif(${column.configInfo.type} == "fk") +#end +#end +#end +#end +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + +
                            +
                            +
                            +
                            +
                            +
                            + + \ No newline at end of file diff --git a/ruoyi-generator/src/main/resources/vm/java/Controller.java.vm b/bmw-generator/src/main/resources/vm/java/Controller.java.vm similarity index 96% rename from ruoyi-generator/src/main/resources/vm/java/Controller.java.vm rename to bmw-generator/src/main/resources/vm/java/Controller.java.vm index a52c1b9a8..8987025e1 100644 --- a/ruoyi-generator/src/main/resources/vm/java/Controller.java.vm +++ b/bmw-generator/src/main/resources/vm/java/Controller.java.vm @@ -1,127 +1,127 @@ -package ${basePackage}.web.controller.${moduleName}; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.enums.BusinessType; -import ${package}.domain.${className}; -import ${package}.service.I${className}Service; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.utils.poi.ExcelUtil; - -/** - * ${tableComment} 信息操作处理 - * - * @author ${author} - * @date ${datetime} - */ -@Controller -@RequestMapping("/${moduleName}/${classname}") -public class ${className}Controller extends BaseController -{ - private String prefix = "${moduleName}/${classname}"; - - @Autowired - private I${className}Service ${classname}Service; - - @RequiresPermissions("${moduleName}:${classname}:view") - @GetMapping() - public String ${classname}() - { - return prefix + "/${classname}"; - } - - /** - * 查询${tableComment}列表 - */ - @RequiresPermissions("${moduleName}:${classname}:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(${className} ${classname}) - { - startPage(); - List<${className}> list = ${classname}Service.select${className}List(${classname}); - return getDataTable(list); - } - - - /** - * 导出${tableComment}列表 - */ - @RequiresPermissions("${moduleName}:${classname}:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(${className} ${classname}) - { - List<${className}> list = ${classname}Service.select${className}List(${classname}); - ExcelUtil<${className}> util = new ExcelUtil<${className}>(${className}.class); - return util.exportExcel(list, "${classname}"); - } - - /** - * 新增${tableComment} - */ - @GetMapping("/add") - public String add() - { - return prefix + "/add"; - } - - /** - * 新增保存${tableComment} - */ - @RequiresPermissions("${moduleName}:${classname}:add") - @Log(title = "${tableComment}", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(${className} ${classname}) - { - return toAjax(${classname}Service.insert${className}(${classname})); - } - - /** - * 修改${tableComment} - */ - @GetMapping("/edit/{${primaryKey.attrname}}") - public String edit(@PathVariable("${primaryKey.attrname}") ${primaryKey.attrType} ${primaryKey.attrname}, ModelMap mmap) - { - ${className} ${classname} = ${classname}Service.select${className}ById(${primaryKey.attrname}); - mmap.put("${classname}", ${classname}); - return prefix + "/edit"; - } - - /** - * 修改保存${tableComment} - */ - @RequiresPermissions("${moduleName}:${classname}:edit") - @Log(title = "${tableComment}", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(${className} ${classname}) - { - return toAjax(${classname}Service.update${className}(${classname})); - } - - /** - * 删除${tableComment} - */ - @RequiresPermissions("${moduleName}:${classname}:remove") - @Log(title = "${tableComment}", businessType = BusinessType.DELETE) - @PostMapping( "/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(${classname}Service.delete${className}ByIds(ids)); - } - -} +package ${basePackage}.web.controller.${moduleName}; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import ${package}.domain.${className}; +import ${package}.service.I${className}Service; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; + +/** + * ${tableComment} 信息操作处理 + * + * @author ${author} + * @date ${datetime} + */ +@Controller +@RequestMapping("/${moduleName}/${classname}") +public class ${className}Controller extends BaseController +{ + private String prefix = "${moduleName}/${classname}"; + + @Autowired + private I${className}Service ${classname}Service; + + @RequiresPermissions("${moduleName}:${classname}:view") + @GetMapping() + public String ${classname}() + { + return prefix + "/${classname}"; + } + + /** + * 查询${tableComment}列表 + */ + @RequiresPermissions("${moduleName}:${classname}:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(${className} ${classname}) + { + startPage(); + List<${className}> list = ${classname}Service.select${className}List(${classname}); + return getDataTable(list); + } + + + /** + * 导出${tableComment}列表 + */ + @RequiresPermissions("${moduleName}:${classname}:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(${className} ${classname}) + { + List<${className}> list = ${classname}Service.select${className}List(${classname}); + ExcelUtil<${className}> util = new ExcelUtil<${className}>(${className}.class); + return util.exportExcel(list, "${classname}"); + } + + /** + * 新增${tableComment} + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存${tableComment} + */ + @RequiresPermissions("${moduleName}:${classname}:add") + @Log(title = "${tableComment}", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(${className} ${classname}) + { + return toAjax(${classname}Service.insert${className}(${classname})); + } + + /** + * 修改${tableComment} + */ + @GetMapping("/edit/{${primaryKey.attrname}}") + public String edit(@PathVariable("${primaryKey.attrname}") ${primaryKey.attrType} ${primaryKey.attrname}, ModelMap mmap) + { + ${className} ${classname} = ${classname}Service.select${className}ById(${primaryKey.attrname}); + mmap.put("${classname}", ${classname}); + return prefix + "/edit"; + } + + /** + * 修改保存${tableComment} + */ + @RequiresPermissions("${moduleName}:${classname}:edit") + @Log(title = "${tableComment}", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(${className} ${classname}) + { + return toAjax(${classname}Service.update${className}(${classname})); + } + + /** + * 删除${tableComment} + */ + @RequiresPermissions("${moduleName}:${classname}:remove") + @Log(title = "${tableComment}", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(${classname}Service.delete${className}ByIds(ids)); + } + +} diff --git a/ruoyi-generator/src/main/resources/vm/java/Mapper.java.vm b/bmw-generator/src/main/resources/vm/java/Mapper.java.vm similarity index 96% rename from ruoyi-generator/src/main/resources/vm/java/Mapper.java.vm rename to bmw-generator/src/main/resources/vm/java/Mapper.java.vm index 076e413de..db33d28ee 100644 --- a/ruoyi-generator/src/main/resources/vm/java/Mapper.java.vm +++ b/bmw-generator/src/main/resources/vm/java/Mapper.java.vm @@ -1,62 +1,62 @@ -package ${package}.mapper; - -import ${package}.domain.${className}; -import java.util.List; - -/** - * ${tableComment} 数据层 - * - * @author ${author} - * @date ${datetime} - */ -public interface ${className}Mapper -{ - /** - * 查询${tableComment}信息 - * - * @param ${primaryKey.attrname} ${tableComment}ID - * @return ${tableComment}信息 - */ - public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname}); - - /** - * 查询${tableComment}列表 - * - * @param ${classname} ${tableComment}信息 - * @return ${tableComment}集合 - */ - public List<${className}> select${className}List(${className} ${classname}); - - /** - * 新增${tableComment} - * - * @param ${classname} ${tableComment}信息 - * @return 结果 - */ - public int insert${className}(${className} ${classname}); - - /** - * 修改${tableComment} - * - * @param ${classname} ${tableComment}信息 - * @return 结果 - */ - public int update${className}(${className} ${classname}); - - /** - * 删除${tableComment} - * - * @param ${primaryKey.attrname} ${tableComment}ID - * @return 结果 - */ - public int delete${className}ById(${primaryKey.attrType} ${primaryKey.attrname}); - - /** - * 批量删除${tableComment} - * - * @param ${primaryKey.attrname}s 需要删除的数据ID - * @return 结果 - */ - public int delete${className}ByIds(String[] ${primaryKey.attrname}s); - +package ${package}.mapper; + +import ${package}.domain.${className}; +import java.util.List; + +/** + * ${tableComment} 数据层 + * + * @author ${author} + * @date ${datetime} + */ +public interface ${className}Mapper +{ + /** + * 查询${tableComment}信息 + * + * @param ${primaryKey.attrname} ${tableComment}ID + * @return ${tableComment}信息 + */ + public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname}); + + /** + * 查询${tableComment}列表 + * + * @param ${classname} ${tableComment}信息 + * @return ${tableComment}集合 + */ + public List<${className}> select${className}List(${className} ${classname}); + + /** + * 新增${tableComment} + * + * @param ${classname} ${tableComment}信息 + * @return 结果 + */ + public int insert${className}(${className} ${classname}); + + /** + * 修改${tableComment} + * + * @param ${classname} ${tableComment}信息 + * @return 结果 + */ + public int update${className}(${className} ${classname}); + + /** + * 删除${tableComment} + * + * @param ${primaryKey.attrname} ${tableComment}ID + * @return 结果 + */ + public int delete${className}ById(${primaryKey.attrType} ${primaryKey.attrname}); + + /** + * 批量删除${tableComment} + * + * @param ${primaryKey.attrname}s 需要删除的数据ID + * @return 结果 + */ + public int delete${className}ByIds(String[] ${primaryKey.attrname}s); + } \ No newline at end of file diff --git a/ruoyi-generator/src/main/resources/vm/java/Service.java.vm b/bmw-generator/src/main/resources/vm/java/Service.java.vm similarity index 95% rename from ruoyi-generator/src/main/resources/vm/java/Service.java.vm rename to bmw-generator/src/main/resources/vm/java/Service.java.vm index 7276e6b90..12089a7e0 100644 --- a/ruoyi-generator/src/main/resources/vm/java/Service.java.vm +++ b/bmw-generator/src/main/resources/vm/java/Service.java.vm @@ -1,54 +1,54 @@ -package ${package}.service; - -import ${package}.domain.${className}; -import java.util.List; - -/** - * ${tableComment} 服务层 - * - * @author ${author} - * @date ${datetime} - */ -public interface I${className}Service -{ - /** - * 查询${tableComment}信息 - * - * @param ${primaryKey.attrname} ${tableComment}ID - * @return ${tableComment}信息 - */ - public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname}); - - /** - * 查询${tableComment}列表 - * - * @param ${classname} ${tableComment}信息 - * @return ${tableComment}集合 - */ - public List<${className}> select${className}List(${className} ${classname}); - - /** - * 新增${tableComment} - * - * @param ${classname} ${tableComment}信息 - * @return 结果 - */ - public int insert${className}(${className} ${classname}); - - /** - * 修改${tableComment} - * - * @param ${classname} ${tableComment}信息 - * @return 结果 - */ - public int update${className}(${className} ${classname}); - - /** - * 删除${tableComment}信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int delete${className}ByIds(String ids); - -} +package ${package}.service; + +import ${package}.domain.${className}; +import java.util.List; + +/** + * ${tableComment} 服务层 + * + * @author ${author} + * @date ${datetime} + */ +public interface I${className}Service +{ + /** + * 查询${tableComment}信息 + * + * @param ${primaryKey.attrname} ${tableComment}ID + * @return ${tableComment}信息 + */ + public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname}); + + /** + * 查询${tableComment}列表 + * + * @param ${classname} ${tableComment}信息 + * @return ${tableComment}集合 + */ + public List<${className}> select${className}List(${className} ${classname}); + + /** + * 新增${tableComment} + * + * @param ${classname} ${tableComment}信息 + * @return 结果 + */ + public int insert${className}(${className} ${classname}); + + /** + * 修改${tableComment} + * + * @param ${classname} ${tableComment}信息 + * @return 结果 + */ + public int update${className}(${className} ${classname}); + + /** + * 删除${tableComment}信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int delete${className}ByIds(String ids); + +} diff --git a/ruoyi-generator/src/main/resources/vm/java/ServiceImpl.java.vm b/bmw-generator/src/main/resources/vm/java/ServiceImpl.java.vm similarity index 96% rename from ruoyi-generator/src/main/resources/vm/java/ServiceImpl.java.vm rename to bmw-generator/src/main/resources/vm/java/ServiceImpl.java.vm index c0df374b1..6bb90eed5 100644 --- a/ruoyi-generator/src/main/resources/vm/java/ServiceImpl.java.vm +++ b/bmw-generator/src/main/resources/vm/java/ServiceImpl.java.vm @@ -1,83 +1,83 @@ -package ${package}.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import ${package}.mapper.${className}Mapper; -import ${package}.domain.${className}; -import ${package}.service.I${className}Service; -import com.ruoyi.common.core.text.Convert; - -/** - * ${tableComment} 服务层实现 - * - * @author ${author} - * @date ${datetime} - */ -@Service -public class ${className}ServiceImpl implements I${className}Service -{ - @Autowired - private ${className}Mapper ${classname}Mapper; - - /** - * 查询${tableComment}信息 - * - * @param ${primaryKey.attrname} ${tableComment}ID - * @return ${tableComment}信息 - */ - @Override - public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname}) - { - return ${classname}Mapper.select${className}ById(${primaryKey.attrname}); - } - - /** - * 查询${tableComment}列表 - * - * @param ${classname} ${tableComment}信息 - * @return ${tableComment}集合 - */ - @Override - public List<${className}> select${className}List(${className} ${classname}) - { - return ${classname}Mapper.select${className}List(${classname}); - } - - /** - * 新增${tableComment} - * - * @param ${classname} ${tableComment}信息 - * @return 结果 - */ - @Override - public int insert${className}(${className} ${classname}) - { - return ${classname}Mapper.insert${className}(${classname}); - } - - /** - * 修改${tableComment} - * - * @param ${classname} ${tableComment}信息 - * @return 结果 - */ - @Override - public int update${className}(${className} ${classname}) - { - return ${classname}Mapper.update${className}(${classname}); - } - - /** - * 删除${tableComment}对象 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - @Override - public int delete${className}ByIds(String ids) - { - return ${classname}Mapper.delete${className}ByIds(Convert.toStrArray(ids)); - } - -} +package ${package}.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import ${package}.mapper.${className}Mapper; +import ${package}.domain.${className}; +import ${package}.service.I${className}Service; +import com.ruoyi.common.core.text.Convert; + +/** + * ${tableComment} 服务层实现 + * + * @author ${author} + * @date ${datetime} + */ +@Service +public class ${className}ServiceImpl implements I${className}Service +{ + @Autowired + private ${className}Mapper ${classname}Mapper; + + /** + * 查询${tableComment}信息 + * + * @param ${primaryKey.attrname} ${tableComment}ID + * @return ${tableComment}信息 + */ + @Override + public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname}) + { + return ${classname}Mapper.select${className}ById(${primaryKey.attrname}); + } + + /** + * 查询${tableComment}列表 + * + * @param ${classname} ${tableComment}信息 + * @return ${tableComment}集合 + */ + @Override + public List<${className}> select${className}List(${className} ${classname}) + { + return ${classname}Mapper.select${className}List(${classname}); + } + + /** + * 新增${tableComment} + * + * @param ${classname} ${tableComment}信息 + * @return 结果 + */ + @Override + public int insert${className}(${className} ${classname}) + { + return ${classname}Mapper.insert${className}(${classname}); + } + + /** + * 修改${tableComment} + * + * @param ${classname} ${tableComment}信息 + * @return 结果 + */ + @Override + public int update${className}(${className} ${classname}) + { + return ${classname}Mapper.update${className}(${classname}); + } + + /** + * 删除${tableComment}对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int delete${className}ByIds(String ids) + { + return ${classname}Mapper.delete${className}ByIds(Convert.toStrArray(ids)); + } + +} diff --git a/ruoyi-generator/src/main/resources/vm/java/domain.java.vm b/bmw-generator/src/main/resources/vm/java/domain.java.vm similarity index 96% rename from ruoyi-generator/src/main/resources/vm/java/domain.java.vm rename to bmw-generator/src/main/resources/vm/java/domain.java.vm index 467a2e266..e2e2b4a62 100644 --- a/ruoyi-generator/src/main/resources/vm/java/domain.java.vm +++ b/bmw-generator/src/main/resources/vm/java/domain.java.vm @@ -1,57 +1,57 @@ -package ${package}.domain; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.domain.BaseEntity; -#foreach ($column in $columns) -#if($column.attrType == 'Date' && ($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark')) -import java.util.Date; -#break -#end -#end -#foreach ($column in $columns) -#if($column.attrType == 'BigDecimal') -import java.math.BigDecimal; -#break -#end -#end - -/** - * ${tableComment}表 ${tableName} - * - * @author ${author} - * @date ${datetime} - */ -public class ${className} extends BaseEntity -{ - private static final long serialVersionUID = 1L; - -#foreach ($column in $columns) -#if($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark') - /** $column.columnComment */ - private $column.attrType $column.attrname; -#end -#end - -#foreach ($column in $columns) -#if($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark') - public void set${column.attrName}($column.attrType $column.attrname) - { - this.$column.attrname = $column.attrname; - } - - public $column.attrType get${column.attrName}() - { - return $column.attrname; - } -#end -#end - - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) -#foreach ($column in $columns) - .append("${column.attrname}", get${column.attrName}()) -#end - .toString(); - } -} +package ${package}.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.domain.BaseEntity; +#foreach ($column in $columns) +#if($column.attrType == 'Date' && ($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark')) +import java.util.Date; +#break +#end +#end +#foreach ($column in $columns) +#if($column.attrType == 'BigDecimal') +import java.math.BigDecimal; +#break +#end +#end + +/** + * ${tableComment}表 ${tableName} + * + * @author ${author} + * @date ${datetime} + */ +public class ${className} extends BaseEntity +{ + private static final long serialVersionUID = 1L; + +#foreach ($column in $columns) +#if($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark') + /** $column.columnComment */ + private $column.attrType $column.attrname; +#end +#end + +#foreach ($column in $columns) +#if($column.attrname != 'createBy' && $column.attrname != 'createTime' && $column.attrname != 'updateBy' && $column.attrname != 'updateTime' && $column.attrname != 'remark') + public void set${column.attrName}($column.attrType $column.attrname) + { + this.$column.attrname = $column.attrname; + } + + public $column.attrType get${column.attrName}() + { + return $column.attrname; + } +#end +#end + + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) +#foreach ($column in $columns) + .append("${column.attrname}", get${column.attrName}()) +#end + .toString(); + } +} diff --git a/ruoyi-generator/src/main/resources/vm/sql/sql.vm b/bmw-generator/src/main/resources/vm/sql/sql.vm similarity index 98% rename from ruoyi-generator/src/main/resources/vm/sql/sql.vm rename to bmw-generator/src/main/resources/vm/sql/sql.vm index baf93dcbb..97e6c374e 100644 --- a/ruoyi-generator/src/main/resources/vm/sql/sql.vm +++ b/bmw-generator/src/main/resources/vm/sql/sql.vm @@ -1,19 +1,19 @@ --- 菜单 SQL -insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${tableComment}', '3', '1', '/${moduleName}/${classname}', 'C', '0', '${moduleName}:${classname}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${tableComment}菜单'); - --- 按钮父菜单ID -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${tableComment}查询', @parentId, '1', '#', 'F', '0', '${moduleName}:${classname}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); - -insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${tableComment}新增', @parentId, '2', '#', 'F', '0', '${moduleName}:${classname}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); - -insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${tableComment}修改', @parentId, '3', '#', 'F', '0', '${moduleName}:${classname}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); - -insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) -values('${tableComment}删除', @parentId, '4', '#', 'F', '0', '${moduleName}:${classname}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); +-- 菜单 SQL +insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${tableComment}', '3', '1', '/${moduleName}/${classname}', 'C', '0', '${moduleName}:${classname}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${tableComment}菜单'); + +-- 按钮父菜单ID +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${tableComment}查询', @parentId, '1', '#', 'F', '0', '${moduleName}:${classname}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${tableComment}新增', @parentId, '2', '#', 'F', '0', '${moduleName}:${classname}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${tableComment}修改', @parentId, '3', '#', 'F', '0', '${moduleName}:${classname}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); + +insert into sys_menu (menu_name, parent_id, order_num, url,menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${tableComment}删除', @parentId, '4', '#', 'F', '0', '${moduleName}:${classname}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); diff --git a/ruoyi-generator/src/main/resources/vm/xml/Mapper.xml.vm b/bmw-generator/src/main/resources/vm/xml/Mapper.xml.vm similarity index 97% rename from ruoyi-generator/src/main/resources/vm/xml/Mapper.xml.vm rename to bmw-generator/src/main/resources/vm/xml/Mapper.xml.vm index c87911e43..ddde80da4 100644 --- a/ruoyi-generator/src/main/resources/vm/xml/Mapper.xml.vm +++ b/bmw-generator/src/main/resources/vm/xml/Mapper.xml.vm @@ -1,72 +1,72 @@ - - - - - -#foreach ($column in $columns) - -#end - - - - select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName} - - - - - - - - insert into ${tableName} - -#foreach($column in $columns) -#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment') - $column.columnName, -#end -#end - - -#foreach($column in $columns) -#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment') - #{$column.attrname}, -#end -#end - - - - - update ${tableName} - -#foreach($column in $columns) -#if($column.columnName != $primaryKey.columnName) - $column.columnName = #{$column.attrname}, -#end -#end - - where ${primaryKey.columnName} = #{${primaryKey.attrname}} - - - - delete from ${tableName} where ${primaryKey.columnName} = #{${primaryKey.attrname}} - - - - delete from ${tableName} where ${primaryKey.columnName} in - - #{${primaryKey.attrname}} - - - + + + + + +#foreach ($column in $columns) + +#end + + + + select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName} + + + + + + + + insert into ${tableName} + +#foreach($column in $columns) +#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment') + $column.columnName, +#end +#end + + +#foreach($column in $columns) +#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment') + #{$column.attrname}, +#end +#end + + + + + update ${tableName} + +#foreach($column in $columns) +#if($column.columnName != $primaryKey.columnName) + $column.columnName = #{$column.attrname}, +#end +#end + + where ${primaryKey.columnName} = #{${primaryKey.attrname}} + + + + delete from ${tableName} where ${primaryKey.columnName} = #{${primaryKey.attrname}} + + + + delete from ${tableName} where ${primaryKey.columnName} in + + #{${primaryKey.attrname}} + + + \ No newline at end of file diff --git a/ruoyi-quartz/pom.xml b/bmw-quartz/pom.xml similarity index 96% rename from ruoyi-quartz/pom.xml rename to bmw-quartz/pom.xml index 4ec46b9aa..bfb40629e 100644 --- a/ruoyi-quartz/pom.xml +++ b/bmw-quartz/pom.xml @@ -1,40 +1,40 @@ - - - - ruoyi - com.ruoyi - 3.4 - - 4.0.0 - - ruoyi-quartz - - - quartz定时任务 - - - - - - - org.quartz-scheduler - quartz - - - com.mchange - c3p0 - - - - - - - com.ruoyi - ruoyi-common - - - - + + + + ruoyi + com.ruoyi + 3.4 + + 4.0.0 + + ruoyi-quartz + + + quartz定时任务 + + + + + + + org.quartz-scheduler + quartz + + + com.mchange + c3p0 + + + + + + + com.ruoyi + ruoyi-common + + + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java similarity index 97% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java index e466ed057..58c69bc34 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java @@ -1,57 +1,57 @@ -package com.ruoyi.quartz.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import javax.sql.DataSource; -import java.util.Properties; - -/** - * 定时任务配置 - * - * @author ruoyi - */ -@Configuration -public class ScheduleConfig -{ - @Bean - public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) - { - SchedulerFactoryBean factory = new SchedulerFactoryBean(); - factory.setDataSource(dataSource); - - // quartz参数 - Properties prop = new Properties(); - prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler"); - prop.put("org.quartz.scheduler.instanceId", "AUTO"); - // 线程池配置 - prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); - prop.put("org.quartz.threadPool.threadCount", "20"); - prop.put("org.quartz.threadPool.threadPriority", "5"); - // JobStore配置 - prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); - // 集群配置 - prop.put("org.quartz.jobStore.isClustered", "true"); - prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); - prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); - prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); - - // sqlserver 启用 - // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); - prop.put("org.quartz.jobStore.misfireThreshold", "12000"); - prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); - factory.setQuartzProperties(prop); - - factory.setSchedulerName("RuoyiScheduler"); - // 延时启动 - factory.setStartupDelay(1); - factory.setApplicationContextSchedulerContextKey("applicationContextKey"); - // 可选,QuartzScheduler - // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了 - factory.setOverwriteExistingJobs(true); - // 设置自动启动,默认为true - factory.setAutoStartup(true); - - return factory; - } -} +package com.ruoyi.quartz.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import javax.sql.DataSource; +import java.util.Properties; + +/** + * 定时任务配置 + * + * @author ruoyi + */ +@Configuration +public class ScheduleConfig +{ + @Bean + public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) + { + SchedulerFactoryBean factory = new SchedulerFactoryBean(); + factory.setDataSource(dataSource); + + // quartz参数 + Properties prop = new Properties(); + prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler"); + prop.put("org.quartz.scheduler.instanceId", "AUTO"); + // 线程池配置 + prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); + prop.put("org.quartz.threadPool.threadCount", "20"); + prop.put("org.quartz.threadPool.threadPriority", "5"); + // JobStore配置 + prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); + // 集群配置 + prop.put("org.quartz.jobStore.isClustered", "true"); + prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); + prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); + prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); + + // sqlserver 启用 + // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); + prop.put("org.quartz.jobStore.misfireThreshold", "12000"); + prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); + factory.setQuartzProperties(prop); + + factory.setSchedulerName("RuoyiScheduler"); + // 延时启动 + factory.setStartupDelay(1); + factory.setApplicationContextSchedulerContextKey("applicationContextKey"); + // 可选,QuartzScheduler + // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了 + factory.setOverwriteExistingJobs(true); + // 设置自动启动,默认为true + factory.setAutoStartup(true); + + return factory; + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java similarity index 96% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java index 4bfe4f6d8..906392d49 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java @@ -1,165 +1,165 @@ -package com.ruoyi.quartz.controller; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.quartz.domain.SysJob; -import com.ruoyi.quartz.service.ISysJobService; - -/** - * 调度任务信息操作处理 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/monitor/job") -public class SysJobController extends BaseController -{ - private String prefix = "monitor/job"; - - @Autowired - private ISysJobService jobService; - - @RequiresPermissions("monitor:job:view") - @GetMapping() - public String job() - { - return prefix + "/job"; - } - - @RequiresPermissions("monitor:job:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysJob job) - { - startPage(); - List list = jobService.selectJobList(job); - return getDataTable(list); - } - - @Log(title = "定时任务", businessType = BusinessType.EXPORT) - @RequiresPermissions("monitor:job:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysJob job) - { - List list = jobService.selectJobList(job); - ExcelUtil util = new ExcelUtil(SysJob.class); - return util.exportExcel(list, "定时任务"); - } - - @Log(title = "定时任务", businessType = BusinessType.DELETE) - @RequiresPermissions("monitor:job:remove") - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) throws SchedulerException - { - jobService.deleteJobByIds(ids); - return success(); - } - - @RequiresPermissions("monitor:job:detail") - @GetMapping("/detail/{jobId}") - public String detail(@PathVariable("jobId") Long jobId, ModelMap mmap) - { - mmap.put("name", "job"); - mmap.put("job", jobService.selectJobById(jobId)); - return prefix + "/detail"; - } - - /** - * 任务调度状态修改 - */ - @Log(title = "定时任务", businessType = BusinessType.UPDATE) - @RequiresPermissions("monitor:job:changeStatus") - @PostMapping("/changeStatus") - @ResponseBody - public AjaxResult changeStatus(SysJob job) throws SchedulerException - { - SysJob newJob = jobService.selectJobById(job.getJobId()); - newJob.setStatus(job.getStatus()); - return toAjax(jobService.changeStatus(newJob)); - } - - /** - * 任务调度立即执行一次 - */ - @Log(title = "定时任务", businessType = BusinessType.UPDATE) - @RequiresPermissions("monitor:job:changeStatus") - @PostMapping("/run") - @ResponseBody - public AjaxResult run(SysJob job) throws SchedulerException - { - jobService.run(job); - return success(); - } - - /** - * 新增调度 - */ - @GetMapping("/add") - public String add() - { - return prefix + "/add"; - } - - /** - * 新增保存调度 - */ - @Log(title = "定时任务", businessType = BusinessType.INSERT) - @RequiresPermissions("monitor:job:add") - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(@Validated SysJob job) throws SchedulerException, TaskException - { - return toAjax(jobService.insertJob(job)); - } - - /** - * 修改调度 - */ - @GetMapping("/edit/{jobId}") - public String edit(@PathVariable("jobId") Long jobId, ModelMap mmap) - { - mmap.put("job", jobService.selectJobById(jobId)); - return prefix + "/edit"; - } - - /** - * 修改保存调度 - */ - @Log(title = "定时任务", businessType = BusinessType.UPDATE) - @RequiresPermissions("monitor:job:edit") - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(@Validated SysJob job) throws SchedulerException, TaskException - { - return toAjax(jobService.updateJob(job)); - } - - /** - * 校验cron表达式是否有效 - */ - @PostMapping("/checkCronExpressionIsValid") - @ResponseBody - public boolean checkCronExpressionIsValid(SysJob job) - { - return jobService.checkCronExpressionIsValid(job.getCronExpression()); - } -} +package com.ruoyi.quartz.controller; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.service.ISysJobService; + +/** + * 调度任务信息操作处理 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/monitor/job") +public class SysJobController extends BaseController +{ + private String prefix = "monitor/job"; + + @Autowired + private ISysJobService jobService; + + @RequiresPermissions("monitor:job:view") + @GetMapping() + public String job() + { + return prefix + "/job"; + } + + @RequiresPermissions("monitor:job:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysJob job) + { + startPage(); + List list = jobService.selectJobList(job); + return getDataTable(list); + } + + @Log(title = "定时任务", businessType = BusinessType.EXPORT) + @RequiresPermissions("monitor:job:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysJob job) + { + List list = jobService.selectJobList(job); + ExcelUtil util = new ExcelUtil(SysJob.class); + return util.exportExcel(list, "定时任务"); + } + + @Log(title = "定时任务", businessType = BusinessType.DELETE) + @RequiresPermissions("monitor:job:remove") + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) throws SchedulerException + { + jobService.deleteJobByIds(ids); + return success(); + } + + @RequiresPermissions("monitor:job:detail") + @GetMapping("/detail/{jobId}") + public String detail(@PathVariable("jobId") Long jobId, ModelMap mmap) + { + mmap.put("name", "job"); + mmap.put("job", jobService.selectJobById(jobId)); + return prefix + "/detail"; + } + + /** + * 任务调度状态修改 + */ + @Log(title = "定时任务", businessType = BusinessType.UPDATE) + @RequiresPermissions("monitor:job:changeStatus") + @PostMapping("/changeStatus") + @ResponseBody + public AjaxResult changeStatus(SysJob job) throws SchedulerException + { + SysJob newJob = jobService.selectJobById(job.getJobId()); + newJob.setStatus(job.getStatus()); + return toAjax(jobService.changeStatus(newJob)); + } + + /** + * 任务调度立即执行一次 + */ + @Log(title = "定时任务", businessType = BusinessType.UPDATE) + @RequiresPermissions("monitor:job:changeStatus") + @PostMapping("/run") + @ResponseBody + public AjaxResult run(SysJob job) throws SchedulerException + { + jobService.run(job); + return success(); + } + + /** + * 新增调度 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存调度 + */ + @Log(title = "定时任务", businessType = BusinessType.INSERT) + @RequiresPermissions("monitor:job:add") + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated SysJob job) throws SchedulerException, TaskException + { + return toAjax(jobService.insertJob(job)); + } + + /** + * 修改调度 + */ + @GetMapping("/edit/{jobId}") + public String edit(@PathVariable("jobId") Long jobId, ModelMap mmap) + { + mmap.put("job", jobService.selectJobById(jobId)); + return prefix + "/edit"; + } + + /** + * 修改保存调度 + */ + @Log(title = "定时任务", businessType = BusinessType.UPDATE) + @RequiresPermissions("monitor:job:edit") + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated SysJob job) throws SchedulerException, TaskException + { + return toAjax(jobService.updateJob(job)); + } + + /** + * 校验cron表达式是否有效 + */ + @PostMapping("/checkCronExpressionIsValid") + @ResponseBody + public boolean checkCronExpressionIsValid(SysJob job) + { + return jobService.checkCronExpressionIsValid(job.getCronExpression()); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java similarity index 96% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java index 2c3d8e271..a74cf75ec 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java @@ -1,91 +1,91 @@ -package com.ruoyi.quartz.controller; - -import java.util.List; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.quartz.domain.SysJobLog; -import com.ruoyi.quartz.service.ISysJobLogService; - -/** - * 调度日志操作处理 - * - * @author ruoyi - */ -@Controller -@RequestMapping("/monitor/jobLog") -public class SysJobLogController extends BaseController -{ - private String prefix = "monitor/job"; - - @Autowired - private ISysJobLogService jobLogService; - - @RequiresPermissions("monitor:job:view") - @GetMapping() - public String jobLog() - { - return prefix + "/jobLog"; - } - - @RequiresPermissions("monitor:job:list") - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(SysJobLog jobLog) - { - startPage(); - List list = jobLogService.selectJobLogList(jobLog); - return getDataTable(list); - } - - @Log(title = "调度日志", businessType = BusinessType.EXPORT) - @RequiresPermissions("monitor:job:export") - @PostMapping("/export") - @ResponseBody - public AjaxResult export(SysJobLog jobLog) - { - List list = jobLogService.selectJobLogList(jobLog); - ExcelUtil util = new ExcelUtil(SysJobLog.class); - return util.exportExcel(list, "调度日志"); - } - - @Log(title = "调度日志", businessType = BusinessType.DELETE) - @RequiresPermissions("monitor:job:remove") - @PostMapping("/remove") - @ResponseBody - public AjaxResult remove(String ids) - { - return toAjax(jobLogService.deleteJobLogByIds(ids)); - } - - @RequiresPermissions("monitor:job:detail") - @GetMapping("/detail/{jobLogId}") - public String detail(@PathVariable("jobLogId") Long jobLogId, ModelMap mmap) - { - mmap.put("name", "jobLog"); - mmap.put("jobLog", jobLogService.selectJobLogById(jobLogId)); - return prefix + "/detail"; - } - - @Log(title = "调度日志", businessType = BusinessType.CLEAN) - @RequiresPermissions("monitor:job:remove") - @PostMapping("/clean") - @ResponseBody - public AjaxResult clean() - { - jobLogService.cleanJobLog(); - return success(); - } -} +package com.ruoyi.quartz.controller; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.quartz.domain.SysJobLog; +import com.ruoyi.quartz.service.ISysJobLogService; + +/** + * 调度日志操作处理 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/monitor/jobLog") +public class SysJobLogController extends BaseController +{ + private String prefix = "monitor/job"; + + @Autowired + private ISysJobLogService jobLogService; + + @RequiresPermissions("monitor:job:view") + @GetMapping() + public String jobLog() + { + return prefix + "/jobLog"; + } + + @RequiresPermissions("monitor:job:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysJobLog jobLog) + { + startPage(); + List list = jobLogService.selectJobLogList(jobLog); + return getDataTable(list); + } + + @Log(title = "调度日志", businessType = BusinessType.EXPORT) + @RequiresPermissions("monitor:job:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysJobLog jobLog) + { + List list = jobLogService.selectJobLogList(jobLog); + ExcelUtil util = new ExcelUtil(SysJobLog.class); + return util.exportExcel(list, "调度日志"); + } + + @Log(title = "调度日志", businessType = BusinessType.DELETE) + @RequiresPermissions("monitor:job:remove") + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(jobLogService.deleteJobLogByIds(ids)); + } + + @RequiresPermissions("monitor:job:detail") + @GetMapping("/detail/{jobLogId}") + public String detail(@PathVariable("jobLogId") Long jobLogId, ModelMap mmap) + { + mmap.put("name", "jobLog"); + mmap.put("jobLog", jobLogService.selectJobLogById(jobLogId)); + return prefix + "/detail"; + } + + @Log(title = "调度日志", businessType = BusinessType.CLEAN) + @RequiresPermissions("monitor:job:remove") + @PostMapping("/clean") + @ResponseBody + public AjaxResult clean() + { + jobLogService.cleanJobLog(); + return success(); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java similarity index 96% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java index ca8a8be30..b14295351 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java @@ -1,168 +1,168 @@ -package com.ruoyi.quartz.domain; - -import java.io.Serializable; -import java.util.Date; -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.constant.ScheduleConstants; -import com.ruoyi.common.core.domain.BaseEntity; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.quartz.util.CronUtils; - -/** - * 定时任务调度表 sys_job - * - * @author ruoyi - */ -public class SysJob extends BaseEntity implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** 任务ID */ - @Excel(name = "任务序号") - private Long jobId; - - /** 任务名称 */ - @Excel(name = "任务名称") - private String jobName; - - /** 任务组名 */ - @Excel(name = "任务组名") - private String jobGroup; - - /** 调用目标字符串 */ - @Excel(name = "调用目标字符串") - private String invokeTarget; - - /** cron执行表达式 */ - @Excel(name = "执行表达式 ") - private String cronExpression; - - /** cron计划策略 */ - @Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行") - private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; - - /** 是否并发执行(0允许 1禁止) */ - @Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止") - private String concurrent; - - /** 任务状态(0正常 1暂停) */ - @Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停") - private String status; - - public Long getJobId() - { - return jobId; - } - - public void setJobId(Long jobId) - { - this.jobId = jobId; - } - - @NotBlank(message = "任务名称不能为空") - @Size(min = 0, max = 64, message = "任务名称不能超过64个字符") - public String getJobName() - { - return jobName; - } - - public void setJobName(String jobName) - { - this.jobName = jobName; - } - - public String getJobGroup() - { - return jobGroup; - } - - public void setJobGroup(String jobGroup) - { - this.jobGroup = jobGroup; - } - - @NotBlank(message = "调用目标字符串不能为空") - @Size(min = 0, max = 1000, message = "调用目标字符串长度不能超过500个字符") - public String getInvokeTarget() - { - return invokeTarget; - } - - public void setInvokeTarget(String invokeTarget) - { - this.invokeTarget = invokeTarget; - } - - @NotBlank(message = "Cron执行表达式不能为空") - @Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符") - public String getCronExpression() - { - return cronExpression; - } - - public void setCronExpression(String cronExpression) - { - this.cronExpression = cronExpression; - } - - public Date getNextValidTime() - { - if (StringUtils.isNotEmpty(cronExpression)) - { - return CronUtils.getNextExecution(cronExpression); - } - return null; - } - - public String getMisfirePolicy() - { - return misfirePolicy; - } - - public void setMisfirePolicy(String misfirePolicy) - { - this.misfirePolicy = misfirePolicy; - } - - public String getConcurrent() - { - return concurrent; - } - - public void setConcurrent(String concurrent) - { - this.concurrent = concurrent; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobId", getJobId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("cronExpression", getCronExpression()) - .append("nextValidTime", getNextValidTime()) - .append("misfirePolicy", getMisfirePolicy()) - .append("concurrent", getConcurrent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } +package com.ruoyi.quartz.domain; + +import java.io.Serializable; +import java.util.Date; +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.quartz.util.CronUtils; + +/** + * 定时任务调度表 sys_job + * + * @author ruoyi + */ +public class SysJob extends BaseEntity implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 任务ID */ + @Excel(name = "任务序号") + private Long jobId; + + /** 任务名称 */ + @Excel(name = "任务名称") + private String jobName; + + /** 任务组名 */ + @Excel(name = "任务组名") + private String jobGroup; + + /** 调用目标字符串 */ + @Excel(name = "调用目标字符串") + private String invokeTarget; + + /** cron执行表达式 */ + @Excel(name = "执行表达式 ") + private String cronExpression; + + /** cron计划策略 */ + @Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行") + private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; + + /** 是否并发执行(0允许 1禁止) */ + @Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止") + private String concurrent; + + /** 任务状态(0正常 1暂停) */ + @Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停") + private String status; + + public Long getJobId() + { + return jobId; + } + + public void setJobId(Long jobId) + { + this.jobId = jobId; + } + + @NotBlank(message = "任务名称不能为空") + @Size(min = 0, max = 64, message = "任务名称不能超过64个字符") + public String getJobName() + { + return jobName; + } + + public void setJobName(String jobName) + { + this.jobName = jobName; + } + + public String getJobGroup() + { + return jobGroup; + } + + public void setJobGroup(String jobGroup) + { + this.jobGroup = jobGroup; + } + + @NotBlank(message = "调用目标字符串不能为空") + @Size(min = 0, max = 1000, message = "调用目标字符串长度不能超过500个字符") + public String getInvokeTarget() + { + return invokeTarget; + } + + public void setInvokeTarget(String invokeTarget) + { + this.invokeTarget = invokeTarget; + } + + @NotBlank(message = "Cron执行表达式不能为空") + @Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符") + public String getCronExpression() + { + return cronExpression; + } + + public void setCronExpression(String cronExpression) + { + this.cronExpression = cronExpression; + } + + public Date getNextValidTime() + { + if (StringUtils.isNotEmpty(cronExpression)) + { + return CronUtils.getNextExecution(cronExpression); + } + return null; + } + + public String getMisfirePolicy() + { + return misfirePolicy; + } + + public void setMisfirePolicy(String misfirePolicy) + { + this.misfirePolicy = misfirePolicy; + } + + public String getConcurrent() + { + return concurrent; + } + + public void setConcurrent(String concurrent) + { + this.concurrent = concurrent; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("jobId", getJobId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("cronExpression", getCronExpression()) + .append("nextValidTime", getNextValidTime()) + .append("misfirePolicy", getMisfirePolicy()) + .append("concurrent", getConcurrent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } } \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java similarity index 95% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java index f044aea7f..89602bde1 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java @@ -1,155 +1,155 @@ -package com.ruoyi.quartz.domain; - -import java.util.Date; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 定时任务调度日志表 sys_job_log - * - * @author ruoyi - */ -public class SysJobLog extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** ID */ - @Excel(name = "日志序号") - private Long jobLogId; - - /** 任务名称 */ - @Excel(name = "任务名称") - private String jobName; - - /** 任务组名 */ - @Excel(name = "任务组名") - private String jobGroup; - - /** 调用目标字符串 */ - @Excel(name = "调用目标字符串") - private String invokeTarget; - - /** 日志信息 */ - @Excel(name = "日志信息") - private String jobMessage; - - /** 执行状态(0正常 1失败) */ - @Excel(name = "执行状态", readConverterExp = "0=正常,1=失败") - private String status; - - /** 异常信息 */ - @Excel(name = "异常信息") - private String exceptionInfo; - - /** 开始时间 */ - private Date startTime; - - /** 结束时间 */ - private Date endTime; - - public Long getJobLogId() - { - return jobLogId; - } - - public void setJobLogId(Long jobLogId) - { - this.jobLogId = jobLogId; - } - - public String getJobName() - { - return jobName; - } - - public void setJobName(String jobName) - { - this.jobName = jobName; - } - - public String getJobGroup() - { - return jobGroup; - } - - public void setJobGroup(String jobGroup) - { - this.jobGroup = jobGroup; - } - - public String getInvokeTarget() - { - return invokeTarget; - } - - public void setInvokeTarget(String invokeTarget) - { - this.invokeTarget = invokeTarget; - } - - public String getJobMessage() - { - return jobMessage; - } - - public void setJobMessage(String jobMessage) - { - this.jobMessage = jobMessage; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getExceptionInfo() - { - return exceptionInfo; - } - - public void setExceptionInfo(String exceptionInfo) - { - this.exceptionInfo = exceptionInfo; - } - - public Date getStartTime() - { - return startTime; - } - - public void setStartTime(Date startTime) - { - this.startTime = startTime; - } - - public Date getEndTime() - { - return endTime; - } - - public void setEndTime(Date endTime) - { - this.endTime = endTime; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobLogId", getJobLogId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("jobMessage", getJobMessage()) - .append("status", getStatus()) - .append("exceptionInfo", getExceptionInfo()) - .append("startTime", getStartTime()) - .append("endTime", getEndTime()) - .toString(); - } -} +package com.ruoyi.quartz.domain; + +import java.util.Date; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 定时任务调度日志表 sys_job_log + * + * @author ruoyi + */ +public class SysJobLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** ID */ + @Excel(name = "日志序号") + private Long jobLogId; + + /** 任务名称 */ + @Excel(name = "任务名称") + private String jobName; + + /** 任务组名 */ + @Excel(name = "任务组名") + private String jobGroup; + + /** 调用目标字符串 */ + @Excel(name = "调用目标字符串") + private String invokeTarget; + + /** 日志信息 */ + @Excel(name = "日志信息") + private String jobMessage; + + /** 执行状态(0正常 1失败) */ + @Excel(name = "执行状态", readConverterExp = "0=正常,1=失败") + private String status; + + /** 异常信息 */ + @Excel(name = "异常信息") + private String exceptionInfo; + + /** 开始时间 */ + private Date startTime; + + /** 结束时间 */ + private Date endTime; + + public Long getJobLogId() + { + return jobLogId; + } + + public void setJobLogId(Long jobLogId) + { + this.jobLogId = jobLogId; + } + + public String getJobName() + { + return jobName; + } + + public void setJobName(String jobName) + { + this.jobName = jobName; + } + + public String getJobGroup() + { + return jobGroup; + } + + public void setJobGroup(String jobGroup) + { + this.jobGroup = jobGroup; + } + + public String getInvokeTarget() + { + return invokeTarget; + } + + public void setInvokeTarget(String invokeTarget) + { + this.invokeTarget = invokeTarget; + } + + public String getJobMessage() + { + return jobMessage; + } + + public void setJobMessage(String jobMessage) + { + this.jobMessage = jobMessage; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getExceptionInfo() + { + return exceptionInfo; + } + + public void setExceptionInfo(String exceptionInfo) + { + this.exceptionInfo = exceptionInfo; + } + + public Date getStartTime() + { + return startTime; + } + + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getEndTime() + { + return endTime; + } + + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("jobLogId", getJobLogId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("jobMessage", getJobMessage()) + .append("status", getStatus()) + .append("exceptionInfo", getExceptionInfo()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .toString(); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java similarity index 95% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java index ee0710cea..c2f79e62a 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java @@ -1,64 +1,64 @@ -package com.ruoyi.quartz.mapper; - -import com.ruoyi.quartz.domain.SysJobLog; -import java.util.List; - -/** - * 调度任务日志信息 数据层 - * - * @author ruoyi - */ -public interface SysJobLogMapper -{ - /** - * 获取quartz调度器日志的计划任务 - * - * @param jobLog 调度日志信息 - * @return 调度任务日志集合 - */ - public List selectJobLogList(SysJobLog jobLog); - - /** - * 查询所有调度任务日志 - * - * @return 调度任务日志列表 - */ - public List selectJobLogAll(); - - /** - * 通过调度任务日志ID查询调度信息 - * - * @param jobLogId 调度任务日志ID - * @return 调度任务日志对象信息 - */ - public SysJobLog selectJobLogById(Long jobLogId); - - /** - * 新增任务日志 - * - * @param jobLog 调度日志信息 - * @return 结果 - */ - public int insertJobLog(SysJobLog jobLog); - - /** - * 批量删除调度日志信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteJobLogByIds(String[] ids); - - /** - * 删除任务日志 - * - * @param jobId 调度日志ID - * @return 结果 - */ - public int deleteJobLogById(Long jobId); - - /** - * 清空任务日志 - */ - public void cleanJobLog(); -} +package com.ruoyi.quartz.mapper; + +import com.ruoyi.quartz.domain.SysJobLog; +import java.util.List; + +/** + * 调度任务日志信息 数据层 + * + * @author ruoyi + */ +public interface SysJobLogMapper +{ + /** + * 获取quartz调度器日志的计划任务 + * + * @param jobLog 调度日志信息 + * @return 调度任务日志集合 + */ + public List selectJobLogList(SysJobLog jobLog); + + /** + * 查询所有调度任务日志 + * + * @return 调度任务日志列表 + */ + public List selectJobLogAll(); + + /** + * 通过调度任务日志ID查询调度信息 + * + * @param jobLogId 调度任务日志ID + * @return 调度任务日志对象信息 + */ + public SysJobLog selectJobLogById(Long jobLogId); + + /** + * 新增任务日志 + * + * @param jobLog 调度日志信息 + * @return 结果 + */ + public int insertJobLog(SysJobLog jobLog); + + /** + * 批量删除调度日志信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteJobLogByIds(String[] ids); + + /** + * 删除任务日志 + * + * @param jobId 调度日志ID + * @return 结果 + */ + public int deleteJobLogById(Long jobId); + + /** + * 清空任务日志 + */ + public void cleanJobLog(); +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java similarity index 95% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java index 1e030a3d5..5207c7ae8 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java @@ -1,67 +1,67 @@ -package com.ruoyi.quartz.mapper; - -import com.ruoyi.quartz.domain.SysJob; -import java.util.List; - -/** - * 调度任务信息 数据层 - * - * @author ruoyi - */ -public interface SysJobMapper -{ - /** - * 查询调度任务日志集合 - * - * @param job 调度信息 - * @return 操作日志集合 - */ - public List selectJobList(SysJob job); - - /** - * 查询所有调度任务 - * - * @return 调度任务列表 - */ - public List selectJobAll(); - - /** - * 通过调度ID查询调度任务信息 - * - * @param jobId 调度ID - * @return 角色对象信息 - */ - public SysJob selectJobById(Long jobId); - - /** - * 通过调度ID删除调度任务信息 - * - * @param jobId 调度ID - * @return 结果 - */ - public int deleteJobById(Long jobId); - - /** - * 批量删除调度任务信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteJobByIds(Long[] ids); - - /** - * 修改调度任务信息 - * - * @param job 调度任务信息 - * @return 结果 - */ - public int updateJob(SysJob job); - - /** - * 新增调度任务信息 - * - * @param job 调度任务信息 - * @return 结果 - */ - public int insertJob(SysJob job); -} +package com.ruoyi.quartz.mapper; + +import com.ruoyi.quartz.domain.SysJob; +import java.util.List; + +/** + * 调度任务信息 数据层 + * + * @author ruoyi + */ +public interface SysJobMapper +{ + /** + * 查询调度任务日志集合 + * + * @param job 调度信息 + * @return 操作日志集合 + */ + public List selectJobList(SysJob job); + + /** + * 查询所有调度任务 + * + * @return 调度任务列表 + */ + public List selectJobAll(); + + /** + * 通过调度ID查询调度任务信息 + * + * @param jobId 调度ID + * @return 角色对象信息 + */ + public SysJob selectJobById(Long jobId); + + /** + * 通过调度ID删除调度任务信息 + * + * @param jobId 调度ID + * @return 结果 + */ + public int deleteJobById(Long jobId); + + /** + * 批量删除调度任务信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteJobByIds(Long[] ids); + + /** + * 修改调度任务信息 + * + * @param job 调度任务信息 + * @return 结果 + */ + public int updateJob(SysJob job); + + /** + * 新增调度任务信息 + * + * @param job 调度任务信息 + * @return 结果 + */ + public int insertJob(SysJob job); +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java similarity index 95% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java index 93ae0f77b..4e112d52b 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java @@ -1,56 +1,56 @@ -package com.ruoyi.quartz.service; - -import java.util.List; -import com.ruoyi.quartz.domain.SysJobLog; - -/** - * 定时任务调度日志信息信息 服务层 - * - * @author ruoyi - */ -public interface ISysJobLogService -{ - /** - * 获取quartz调度器日志的计划任务 - * - * @param jobLog 调度日志信息 - * @return 调度任务日志集合 - */ - public List selectJobLogList(SysJobLog jobLog); - - /** - * 通过调度任务日志ID查询调度信息 - * - * @param jobLogId 调度任务日志ID - * @return 调度任务日志对象信息 - */ - public SysJobLog selectJobLogById(Long jobLogId); - - /** - * 新增任务日志 - * - * @param jobLog 调度日志信息 - */ - public void addJobLog(SysJobLog jobLog); - - /** - * 批量删除调度日志信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteJobLogByIds(String ids); - - /** - * 删除任务日志 - * - * @param jobId 调度日志ID - * @return 结果 - */ - public int deleteJobLogById(Long jobId); - - /** - * 清空任务日志 - */ - public void cleanJobLog(); -} +package com.ruoyi.quartz.service; + +import java.util.List; +import com.ruoyi.quartz.domain.SysJobLog; + +/** + * 定时任务调度日志信息信息 服务层 + * + * @author ruoyi + */ +public interface ISysJobLogService +{ + /** + * 获取quartz调度器日志的计划任务 + * + * @param jobLog 调度日志信息 + * @return 调度任务日志集合 + */ + public List selectJobLogList(SysJobLog jobLog); + + /** + * 通过调度任务日志ID查询调度信息 + * + * @param jobLogId 调度任务日志ID + * @return 调度任务日志对象信息 + */ + public SysJobLog selectJobLogById(Long jobLogId); + + /** + * 新增任务日志 + * + * @param jobLog 调度日志信息 + */ + public void addJobLog(SysJobLog jobLog); + + /** + * 批量删除调度日志信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteJobLogByIds(String ids); + + /** + * 删除任务日志 + * + * @param jobId 调度日志ID + * @return 结果 + */ + public int deleteJobLogById(Long jobId); + + /** + * 清空任务日志 + */ + public void cleanJobLog(); +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java similarity index 95% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java index ce4953290..785669710 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java @@ -1,102 +1,102 @@ -package com.ruoyi.quartz.service; - -import java.util.List; -import org.quartz.SchedulerException; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.quartz.domain.SysJob; - -/** - * 定时任务调度信息信息 服务层 - * - * @author ruoyi - */ -public interface ISysJobService -{ - /** - * 获取quartz调度器的计划任务 - * - * @param job 调度信息 - * @return 调度任务集合 - */ - public List selectJobList(SysJob job); - - /** - * 通过调度任务ID查询调度信息 - * - * @param jobId 调度任务ID - * @return 调度任务对象信息 - */ - public SysJob selectJobById(Long jobId); - - /** - * 暂停任务 - * - * @param job 调度信息 - * @return 结果 - */ - public int pauseJob(SysJob job) throws SchedulerException; - - /** - * 恢复任务 - * - * @param job 调度信息 - * @return 结果 - */ - public int resumeJob(SysJob job) throws SchedulerException; - - /** - * 删除任务后,所对应的trigger也将被删除 - * - * @param job 调度信息 - * @return 结果 - */ - public int deleteJob(SysJob job) throws SchedulerException; - - /** - * 批量删除调度信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public void deleteJobByIds(String ids) throws SchedulerException; - - /** - * 任务调度状态修改 - * - * @param job 调度信息 - * @return 结果 - */ - public int changeStatus(SysJob job) throws SchedulerException; - - /** - * 立即运行任务 - * - * @param job 调度信息 - * @return 结果 - */ - public void run(SysJob job) throws SchedulerException; - - /** - * 新增任务 - * - * @param job 调度信息 - * @return 结果 - */ - public int insertJob(SysJob job) throws SchedulerException, TaskException; - - /** - * 更新任务 - * - * @param job 调度信息 - * @return 结果 - */ - public int updateJob(SysJob job) throws SchedulerException, TaskException; - - /** - * 校验cron表达式是否有效 - * - * @param cronExpression 表达式 - * @return 结果 - */ - public boolean checkCronExpressionIsValid(String cronExpression); +package com.ruoyi.quartz.service; + +import java.util.List; +import org.quartz.SchedulerException; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 定时任务调度信息信息 服务层 + * + * @author ruoyi + */ +public interface ISysJobService +{ + /** + * 获取quartz调度器的计划任务 + * + * @param job 调度信息 + * @return 调度任务集合 + */ + public List selectJobList(SysJob job); + + /** + * 通过调度任务ID查询调度信息 + * + * @param jobId 调度任务ID + * @return 调度任务对象信息 + */ + public SysJob selectJobById(Long jobId); + + /** + * 暂停任务 + * + * @param job 调度信息 + * @return 结果 + */ + public int pauseJob(SysJob job) throws SchedulerException; + + /** + * 恢复任务 + * + * @param job 调度信息 + * @return 结果 + */ + public int resumeJob(SysJob job) throws SchedulerException; + + /** + * 删除任务后,所对应的trigger也将被删除 + * + * @param job 调度信息 + * @return 结果 + */ + public int deleteJob(SysJob job) throws SchedulerException; + + /** + * 批量删除调度信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public void deleteJobByIds(String ids) throws SchedulerException; + + /** + * 任务调度状态修改 + * + * @param job 调度信息 + * @return 结果 + */ + public int changeStatus(SysJob job) throws SchedulerException; + + /** + * 立即运行任务 + * + * @param job 调度信息 + * @return 结果 + */ + public void run(SysJob job) throws SchedulerException; + + /** + * 新增任务 + * + * @param job 调度信息 + * @return 结果 + */ + public int insertJob(SysJob job) throws SchedulerException, TaskException; + + /** + * 更新任务 + * + * @param job 调度信息 + * @return 结果 + */ + public int updateJob(SysJob job) throws SchedulerException, TaskException; + + /** + * 校验cron表达式是否有效 + * + * @param cronExpression 表达式 + * @return 结果 + */ + public boolean checkCronExpressionIsValid(String cronExpression); } \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java similarity index 95% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java index cc31bea21..387fb3e3f 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java @@ -1,88 +1,88 @@ -package com.ruoyi.quartz.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.quartz.domain.SysJobLog; -import com.ruoyi.quartz.mapper.SysJobLogMapper; -import com.ruoyi.quartz.service.ISysJobLogService; - -/** - * 定时任务调度日志信息 服务层 - * - * @author ruoyi - */ -@Service -public class SysJobLogServiceImpl implements ISysJobLogService -{ - @Autowired - private SysJobLogMapper jobLogMapper; - - /** - * 获取quartz调度器日志的计划任务 - * - * @param jobLog 调度日志信息 - * @return 调度任务日志集合 - */ - @Override - public List selectJobLogList(SysJobLog jobLog) - { - return jobLogMapper.selectJobLogList(jobLog); - } - - /** - * 通过调度任务日志ID查询调度信息 - * - * @param jobId 调度任务日志ID - * @return 调度任务日志对象信息 - */ - @Override - public SysJobLog selectJobLogById(Long jobLogId) - { - return jobLogMapper.selectJobLogById(jobLogId); - } - - /** - * 新增任务日志 - * - * @param jobLog 调度日志信息 - */ - @Override - public void addJobLog(SysJobLog jobLog) - { - jobLogMapper.insertJobLog(jobLog); - } - - /** - * 批量删除调度日志信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - @Override - public int deleteJobLogByIds(String ids) - { - return jobLogMapper.deleteJobLogByIds(Convert.toStrArray(ids)); - } - - /** - * 删除任务日志 - * - * @param jobId 调度日志ID - */ - @Override - public int deleteJobLogById(Long jobId) - { - return jobLogMapper.deleteJobLogById(jobId); - } - - /** - * 清空任务日志 - */ - @Override - public void cleanJobLog() - { - jobLogMapper.cleanJobLog(); - } -} +package com.ruoyi.quartz.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.quartz.domain.SysJobLog; +import com.ruoyi.quartz.mapper.SysJobLogMapper; +import com.ruoyi.quartz.service.ISysJobLogService; + +/** + * 定时任务调度日志信息 服务层 + * + * @author ruoyi + */ +@Service +public class SysJobLogServiceImpl implements ISysJobLogService +{ + @Autowired + private SysJobLogMapper jobLogMapper; + + /** + * 获取quartz调度器日志的计划任务 + * + * @param jobLog 调度日志信息 + * @return 调度任务日志集合 + */ + @Override + public List selectJobLogList(SysJobLog jobLog) + { + return jobLogMapper.selectJobLogList(jobLog); + } + + /** + * 通过调度任务日志ID查询调度信息 + * + * @param jobId 调度任务日志ID + * @return 调度任务日志对象信息 + */ + @Override + public SysJobLog selectJobLogById(Long jobLogId) + { + return jobLogMapper.selectJobLogById(jobLogId); + } + + /** + * 新增任务日志 + * + * @param jobLog 调度日志信息 + */ + @Override + public void addJobLog(SysJobLog jobLog) + { + jobLogMapper.insertJobLog(jobLog); + } + + /** + * 批量删除调度日志信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteJobLogByIds(String ids) + { + return jobLogMapper.deleteJobLogByIds(Convert.toStrArray(ids)); + } + + /** + * 删除任务日志 + * + * @param jobId 调度日志ID + */ + @Override + public int deleteJobLogById(Long jobId) + { + return jobLogMapper.deleteJobLogById(jobId); + } + + /** + * 清空任务日志 + */ + @Override + public void cleanJobLog() + { + jobLogMapper.cleanJobLog(); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java similarity index 96% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java index 29a9eb540..d18b75ac0 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java @@ -1,256 +1,256 @@ -package com.ruoyi.quartz.service.impl; - -import java.util.List; -import javax.annotation.PostConstruct; -import org.quartz.JobDataMap; -import org.quartz.JobKey; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.common.constant.ScheduleConstants; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.quartz.domain.SysJob; -import com.ruoyi.quartz.mapper.SysJobMapper; -import com.ruoyi.quartz.service.ISysJobService; -import com.ruoyi.quartz.util.CronUtils; -import com.ruoyi.quartz.util.ScheduleUtils; - -/** - * 定时任务调度信息 服务层 - * - * @author ruoyi - */ -@Service -public class SysJobServiceImpl implements ISysJobService -{ - @Autowired - private Scheduler scheduler; - - @Autowired - private SysJobMapper jobMapper; - - /** - * 项目启动时,初始化定时器 - * 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据) - */ - @PostConstruct - public void init() throws SchedulerException, TaskException - { - List jobList = jobMapper.selectJobAll(); - for (SysJob job : jobList) - { - updateSchedulerJob(job, job.getJobGroup()); - } - } - - /** - * 获取quartz调度器的计划任务列表 - * - * @param job 调度信息 - * @return - */ - @Override - public List selectJobList(SysJob job) - { - return jobMapper.selectJobList(job); - } - - /** - * 通过调度任务ID查询调度信息 - * - * @param jobId 调度任务ID - * @return 调度任务对象信息 - */ - @Override - public SysJob selectJobById(Long jobId) - { - return jobMapper.selectJobById(jobId); - } - - /** - * 暂停任务 - * - * @param job 调度信息 - */ - @Override - @Transactional - public int pauseJob(SysJob job) throws SchedulerException - { - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { - scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); - } - return rows; - } - - /** - * 恢复任务 - * - * @param job 调度信息 - */ - @Override - @Transactional - public int resumeJob(SysJob job) throws SchedulerException - { - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { - scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); - } - return rows; - } - - /** - * 删除任务后,所对应的trigger也将被删除 - * - * @param job 调度信息 - */ - @Override - @Transactional - public int deleteJob(SysJob job) throws SchedulerException - { - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - int rows = jobMapper.deleteJobById(jobId); - if (rows > 0) - { - scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); - } - return rows; - } - - /** - * 批量删除调度信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - @Override - @Transactional - public void deleteJobByIds(String ids) throws SchedulerException - { - Long[] jobIds = Convert.toLongArray(ids); - for (Long jobId : jobIds) - { - SysJob job = jobMapper.selectJobById(jobId); - deleteJob(job); - } - } - - /** - * 任务调度状态修改 - * - * @param job 调度信息 - */ - @Override - @Transactional - public int changeStatus(SysJob job) throws SchedulerException - { - int rows = 0; - String status = job.getStatus(); - if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) - { - rows = resumeJob(job); - } - else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) - { - rows = pauseJob(job); - } - return rows; - } - - /** - * 立即运行任务 - * - * @param job 调度信息 - */ - @Override - @Transactional - public void run(SysJob job) throws SchedulerException - { - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - SysJob properties = selectJobById(job.getJobId()); - // 参数 - JobDataMap dataMap = new JobDataMap(); - dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties); - scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap); - } - - /** - * 新增任务 - * - * @param job 调度信息 调度信息 - */ - @Override - @Transactional - public int insertJob(SysJob job) throws SchedulerException, TaskException - { - job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); - int rows = jobMapper.insertJob(job); - if (rows > 0) - { - ScheduleUtils.createScheduleJob(scheduler, job); - } - return rows; - } - - /** - * 更新任务的时间表达式 - * - * @param job 调度信息 - */ - @Override - @Transactional - public int updateJob(SysJob job) throws SchedulerException, TaskException - { - SysJob properties = selectJobById(job.getJobId()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { - updateSchedulerJob(job, properties.getJobGroup()); - } - return rows; - } - - /** - * 更新任务 - * - * @param job 任务对象 - * @param jobGroup 任务组名 - */ - public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException - { - Long jobId = job.getJobId(); - // 判断是否存在 - JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); - if (scheduler.checkExists(jobKey)) - { - // 防止创建时存在数据问题 先移除,然后在执行创建操作 - scheduler.deleteJob(jobKey); - } - ScheduleUtils.createScheduleJob(scheduler, job); - } - - /** - * 校验cron表达式是否有效 - * - * @param cronExpression 表达式 - * @return 结果 - */ - @Override - public boolean checkCronExpressionIsValid(String cronExpression) - { - return CronUtils.isValid(cronExpression); - } +package com.ruoyi.quartz.service.impl; + +import java.util.List; +import javax.annotation.PostConstruct; +import org.quartz.JobDataMap; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.mapper.SysJobMapper; +import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.quartz.util.CronUtils; +import com.ruoyi.quartz.util.ScheduleUtils; + +/** + * 定时任务调度信息 服务层 + * + * @author ruoyi + */ +@Service +public class SysJobServiceImpl implements ISysJobService +{ + @Autowired + private Scheduler scheduler; + + @Autowired + private SysJobMapper jobMapper; + + /** + * 项目启动时,初始化定时器 + * 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据) + */ + @PostConstruct + public void init() throws SchedulerException, TaskException + { + List jobList = jobMapper.selectJobAll(); + for (SysJob job : jobList) + { + updateSchedulerJob(job, job.getJobGroup()); + } + } + + /** + * 获取quartz调度器的计划任务列表 + * + * @param job 调度信息 + * @return + */ + @Override + public List selectJobList(SysJob job) + { + return jobMapper.selectJobList(job); + } + + /** + * 通过调度任务ID查询调度信息 + * + * @param jobId 调度任务ID + * @return 调度任务对象信息 + */ + @Override + public SysJob selectJobById(Long jobId) + { + return jobMapper.selectJobById(jobId); + } + + /** + * 暂停任务 + * + * @param job 调度信息 + */ + @Override + @Transactional + public int pauseJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 恢复任务 + * + * @param job 调度信息 + */ + @Override + @Transactional + public int resumeJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 删除任务后,所对应的trigger也将被删除 + * + * @param job 调度信息 + */ + @Override + @Transactional + public int deleteJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + int rows = jobMapper.deleteJobById(jobId); + if (rows > 0) + { + scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 批量删除调度信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + @Transactional + public void deleteJobByIds(String ids) throws SchedulerException + { + Long[] jobIds = Convert.toLongArray(ids); + for (Long jobId : jobIds) + { + SysJob job = jobMapper.selectJobById(jobId); + deleteJob(job); + } + } + + /** + * 任务调度状态修改 + * + * @param job 调度信息 + */ + @Override + @Transactional + public int changeStatus(SysJob job) throws SchedulerException + { + int rows = 0; + String status = job.getStatus(); + if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) + { + rows = resumeJob(job); + } + else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) + { + rows = pauseJob(job); + } + return rows; + } + + /** + * 立即运行任务 + * + * @param job 调度信息 + */ + @Override + @Transactional + public void run(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + SysJob properties = selectJobById(job.getJobId()); + // 参数 + JobDataMap dataMap = new JobDataMap(); + dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties); + scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap); + } + + /** + * 新增任务 + * + * @param job 调度信息 调度信息 + */ + @Override + @Transactional + public int insertJob(SysJob job) throws SchedulerException, TaskException + { + job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); + int rows = jobMapper.insertJob(job); + if (rows > 0) + { + ScheduleUtils.createScheduleJob(scheduler, job); + } + return rows; + } + + /** + * 更新任务的时间表达式 + * + * @param job 调度信息 + */ + @Override + @Transactional + public int updateJob(SysJob job) throws SchedulerException, TaskException + { + SysJob properties = selectJobById(job.getJobId()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + updateSchedulerJob(job, properties.getJobGroup()); + } + return rows; + } + + /** + * 更新任务 + * + * @param job 任务对象 + * @param jobGroup 任务组名 + */ + public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException + { + Long jobId = job.getJobId(); + // 判断是否存在 + JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); + if (scheduler.checkExists(jobKey)) + { + // 防止创建时存在数据问题 先移除,然后在执行创建操作 + scheduler.deleteJob(jobKey); + } + ScheduleUtils.createScheduleJob(scheduler, job); + } + + /** + * 校验cron表达式是否有效 + * + * @param cronExpression 表达式 + * @return 结果 + */ + @Override + public boolean checkCronExpressionIsValid(String cronExpression) + { + return CronUtils.isValid(cronExpression); + } } \ No newline at end of file diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java similarity index 96% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java index 25d1ddd02..853243baf 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java @@ -1,28 +1,28 @@ -package com.ruoyi.quartz.task; - -import org.springframework.stereotype.Component; -import com.ruoyi.common.utils.StringUtils; - -/** - * 定时任务调度测试 - * - * @author ruoyi - */ -@Component("ryTask") -public class RyTask -{ - public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) - { - System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); - } - - public void ryParams(String params) - { - System.out.println("执行有参方法:" + params); - } - - public void ryNoParams() - { - System.out.println("执行无参方法"); - } -} +package com.ruoyi.quartz.task; + +import org.springframework.stereotype.Component; +import com.ruoyi.common.utils.StringUtils; + +/** + * 定时任务调度测试 + * + * @author ruoyi + */ +@Component("ryTask") +public class RyTask +{ + public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) + { + System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); + } + + public void ryParams(String params) + { + System.out.println("执行有参方法:" + params); + } + + public void ryNoParams() + { + System.out.println("执行无参方法"); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java similarity index 96% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java index a6f3dc4ee..2cc926613 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java @@ -1,107 +1,107 @@ -package com.ruoyi.quartz.util; - -import java.util.Date; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.constant.ScheduleConstants; -import com.ruoyi.common.utils.ExceptionUtil; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.bean.BeanUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.quartz.domain.SysJob; -import com.ruoyi.quartz.domain.SysJobLog; -import com.ruoyi.quartz.service.ISysJobLogService; - -/** - * 抽象quartz调用 - * - * @author ruoyi - */ -public abstract class AbstractQuartzJob implements Job -{ - private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class); - - /** - * 线程本地变量 - */ - private static ThreadLocal threadLocal = new ThreadLocal<>(); - - @Override - public void execute(JobExecutionContext context) throws JobExecutionException - { - SysJob sysJob = new SysJob(); - BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); - try - { - before(context, sysJob); - if (sysJob != null) - { - doExecute(context, sysJob); - } - after(context, sysJob, null); - } - catch (Exception e) - { - log.error("任务执行异常 - :", e); - after(context, sysJob, e); - } - } - - /** - * 执行前 - * - * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 - */ - protected void before(JobExecutionContext context, SysJob sysJob) - { - threadLocal.set(new Date()); - } - - /** - * 执行后 - * - * @param context 工作执行上下文对象 - * @param sysScheduleJob 系统计划任务 - */ - protected void after(JobExecutionContext context, SysJob sysJob, Exception e) - { - Date startTime = threadLocal.get(); - threadLocal.remove(); - - final SysJobLog sysJobLog = new SysJobLog(); - sysJobLog.setJobName(sysJob.getJobName()); - sysJobLog.setJobGroup(sysJob.getJobGroup()); - sysJobLog.setInvokeTarget(sysJob.getInvokeTarget()); - sysJobLog.setStartTime(startTime); - sysJobLog.setEndTime(new Date()); - long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime(); - sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒"); - if (e != null) - { - sysJobLog.setStatus(Constants.FAIL); - String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000); - sysJobLog.setExceptionInfo(errorMsg); - } - else - { - sysJobLog.setStatus(Constants.SUCCESS); - } - - // 写入数据库当中 - SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog); - } - - /** - * 执行方法,由子类重载 - * - * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 - * @throws Exception 执行过程中的异常 - */ - protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception; -} +package com.ruoyi.quartz.util; + +import java.util.Date; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.utils.ExceptionUtil; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.domain.SysJobLog; +import com.ruoyi.quartz.service.ISysJobLogService; + +/** + * 抽象quartz调用 + * + * @author ruoyi + */ +public abstract class AbstractQuartzJob implements Job +{ + private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class); + + /** + * 线程本地变量 + */ + private static ThreadLocal threadLocal = new ThreadLocal<>(); + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException + { + SysJob sysJob = new SysJob(); + BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); + try + { + before(context, sysJob); + if (sysJob != null) + { + doExecute(context, sysJob); + } + after(context, sysJob, null); + } + catch (Exception e) + { + log.error("任务执行异常 - :", e); + after(context, sysJob, e); + } + } + + /** + * 执行前 + * + * @param context 工作执行上下文对象 + * @param sysJob 系统计划任务 + */ + protected void before(JobExecutionContext context, SysJob sysJob) + { + threadLocal.set(new Date()); + } + + /** + * 执行后 + * + * @param context 工作执行上下文对象 + * @param sysScheduleJob 系统计划任务 + */ + protected void after(JobExecutionContext context, SysJob sysJob, Exception e) + { + Date startTime = threadLocal.get(); + threadLocal.remove(); + + final SysJobLog sysJobLog = new SysJobLog(); + sysJobLog.setJobName(sysJob.getJobName()); + sysJobLog.setJobGroup(sysJob.getJobGroup()); + sysJobLog.setInvokeTarget(sysJob.getInvokeTarget()); + sysJobLog.setStartTime(startTime); + sysJobLog.setEndTime(new Date()); + long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime(); + sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒"); + if (e != null) + { + sysJobLog.setStatus(Constants.FAIL); + String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000); + sysJobLog.setExceptionInfo(errorMsg); + } + else + { + sysJobLog.setStatus(Constants.SUCCESS); + } + + // 写入数据库当中 + SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog); + } + + /** + * 执行方法,由子类重载 + * + * @param context 工作执行上下文对象 + * @param sysJob 系统计划任务 + * @throws Exception 执行过程中的异常 + */ + protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception; +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java similarity index 100% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java similarity index 96% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java index 5519c672f..40a19bdea 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java @@ -1,182 +1,182 @@ -package com.ruoyi.quartz.util; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.LinkedList; -import java.util.List; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.quartz.domain.SysJob; - -/** - * 任务执行工具 - * - * @author ruoyi - */ -public class JobInvokeUtil -{ - /** - * 执行方法 - * - * @param sysJob 系统任务 - */ - public static void invokeMethod(SysJob sysJob) throws Exception - { - String invokeTarget = sysJob.getInvokeTarget(); - String beanName = getBeanName(invokeTarget); - String methodName = getMethodName(invokeTarget); - List methodParams = getMethodParams(invokeTarget); - - if (!isValidClassName(beanName)) - { - Object bean = SpringUtils.getBean(beanName); - invokeMethod(bean, methodName, methodParams); - } - else - { - Object bean = Class.forName(beanName).newInstance(); - invokeMethod(bean, methodName, methodParams); - } - } - - /** - * 调用任务方法 - * - * @param bean 目标对象 - * @param methodName 方法名称 - * @param methodParams 方法参数 - */ - private static void invokeMethod(Object bean, String methodName, List methodParams) - throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, - InvocationTargetException - { - if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) - { - Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams)); - method.invoke(bean, getMethodParamsValue(methodParams)); - } - else - { - Method method = bean.getClass().getDeclaredMethod(methodName); - method.invoke(bean); - } - } - - /** - * 校验是否为为class包名 - * - * @param str 名称 - * @return true是 false否 - */ - public static boolean isValidClassName(String invokeTarget) - { - return StringUtils.countMatches(invokeTarget, ".") > 1; - } - - /** - * 获取bean名称 - * - * @param invokeTarget 目标字符串 - * @return bean名称 - */ - public static String getBeanName(String invokeTarget) - { - String beanName = StringUtils.substringBefore(invokeTarget, "("); - return StringUtils.substringBeforeLast(beanName, "."); - } - - /** - * 获取bean方法 - * - * @param invokeTarget 目标字符串 - * @return method方法 - */ - public static String getMethodName(String invokeTarget) - { - String methodName = StringUtils.substringBefore(invokeTarget, "("); - return StringUtils.substringAfterLast(methodName, "."); - } - - /** - * 获取method方法参数相关列表 - * - * @param invokeTarget 目标字符串 - * @return method方法相关参数列表 - */ - public static List getMethodParams(String invokeTarget) - { - String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")"); - if (StringUtils.isEmpty(methodStr)) - { - return null; - } - String[] methodParams = methodStr.split(","); - List classs = new LinkedList<>(); - for (int i = 0; i < methodParams.length; i++) - { - String str = StringUtils.trimToEmpty(methodParams[i]); - // String字符串类型,包含' - if (StringUtils.contains(str, "'")) - { - classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class }); - } - // boolean布尔类型,等于true或者false - else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) - { - classs.add(new Object[] { Boolean.valueOf(str), Boolean.class }); - } - // long长整形,包含L - else if (StringUtils.containsIgnoreCase(str, "L")) - { - classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class }); - } - // double浮点类型,包含D - else if (StringUtils.containsIgnoreCase(str, "D")) - { - classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class }); - } - // 其他类型归类为整形 - else - { - classs.add(new Object[] { Integer.valueOf(str), Integer.class }); - } - } - return classs; - } - - /** - * 获取参数类型 - * - * @param methodParams 参数相关列表 - * @return 参数类型列表 - */ - public static Class[] getMethodParamsType(List methodParams) - { - Class[] classs = new Class[methodParams.size()]; - int index = 0; - for (Object[] os : methodParams) - { - classs[index] = (Class) os[1]; - index++; - } - return classs; - } - - /** - * 获取参数值 - * - * @param methodParams 参数相关列表 - * @return 参数值列表 - */ - public static Object[] getMethodParamsValue(List methodParams) - { - Object[] classs = new Object[methodParams.size()]; - int index = 0; - for (Object[] os : methodParams) - { - classs[index] = (Object) os[0]; - index++; - } - return classs; - } -} +package com.ruoyi.quartz.util; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.LinkedList; +import java.util.List; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 任务执行工具 + * + * @author ruoyi + */ +public class JobInvokeUtil +{ + /** + * 执行方法 + * + * @param sysJob 系统任务 + */ + public static void invokeMethod(SysJob sysJob) throws Exception + { + String invokeTarget = sysJob.getInvokeTarget(); + String beanName = getBeanName(invokeTarget); + String methodName = getMethodName(invokeTarget); + List methodParams = getMethodParams(invokeTarget); + + if (!isValidClassName(beanName)) + { + Object bean = SpringUtils.getBean(beanName); + invokeMethod(bean, methodName, methodParams); + } + else + { + Object bean = Class.forName(beanName).newInstance(); + invokeMethod(bean, methodName, methodParams); + } + } + + /** + * 调用任务方法 + * + * @param bean 目标对象 + * @param methodName 方法名称 + * @param methodParams 方法参数 + */ + private static void invokeMethod(Object bean, String methodName, List methodParams) + throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, + InvocationTargetException + { + if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) + { + Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams)); + method.invoke(bean, getMethodParamsValue(methodParams)); + } + else + { + Method method = bean.getClass().getDeclaredMethod(methodName); + method.invoke(bean); + } + } + + /** + * 校验是否为为class包名 + * + * @param str 名称 + * @return true是 false否 + */ + public static boolean isValidClassName(String invokeTarget) + { + return StringUtils.countMatches(invokeTarget, ".") > 1; + } + + /** + * 获取bean名称 + * + * @param invokeTarget 目标字符串 + * @return bean名称 + */ + public static String getBeanName(String invokeTarget) + { + String beanName = StringUtils.substringBefore(invokeTarget, "("); + return StringUtils.substringBeforeLast(beanName, "."); + } + + /** + * 获取bean方法 + * + * @param invokeTarget 目标字符串 + * @return method方法 + */ + public static String getMethodName(String invokeTarget) + { + String methodName = StringUtils.substringBefore(invokeTarget, "("); + return StringUtils.substringAfterLast(methodName, "."); + } + + /** + * 获取method方法参数相关列表 + * + * @param invokeTarget 目标字符串 + * @return method方法相关参数列表 + */ + public static List getMethodParams(String invokeTarget) + { + String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")"); + if (StringUtils.isEmpty(methodStr)) + { + return null; + } + String[] methodParams = methodStr.split(","); + List classs = new LinkedList<>(); + for (int i = 0; i < methodParams.length; i++) + { + String str = StringUtils.trimToEmpty(methodParams[i]); + // String字符串类型,包含' + if (StringUtils.contains(str, "'")) + { + classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class }); + } + // boolean布尔类型,等于true或者false + else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) + { + classs.add(new Object[] { Boolean.valueOf(str), Boolean.class }); + } + // long长整形,包含L + else if (StringUtils.containsIgnoreCase(str, "L")) + { + classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class }); + } + // double浮点类型,包含D + else if (StringUtils.containsIgnoreCase(str, "D")) + { + classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class }); + } + // 其他类型归类为整形 + else + { + classs.add(new Object[] { Integer.valueOf(str), Integer.class }); + } + } + return classs; + } + + /** + * 获取参数类型 + * + * @param methodParams 参数相关列表 + * @return 参数类型列表 + */ + public static Class[] getMethodParamsType(List methodParams) + { + Class[] classs = new Class[methodParams.size()]; + int index = 0; + for (Object[] os : methodParams) + { + classs[index] = (Class) os[1]; + index++; + } + return classs; + } + + /** + * 获取参数值 + * + * @param methodParams 参数相关列表 + * @return 参数值列表 + */ + public static Object[] getMethodParamsValue(List methodParams) + { + Object[] classs = new Object[methodParams.size()]; + int index = 0; + for (Object[] os : methodParams) + { + classs[index] = (Object) os[0]; + index++; + } + return classs; + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java similarity index 95% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java index 96a6dcf8e..5e135580b 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java @@ -1,21 +1,21 @@ -package com.ruoyi.quartz.util; - -import org.quartz.DisallowConcurrentExecution; -import org.quartz.JobExecutionContext; -import com.ruoyi.quartz.domain.SysJob; - -/** - * 定时任务处理(禁止并发执行) - * - * @author ruoyi - * - */ -@DisallowConcurrentExecution -public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob -{ - @Override - protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception - { - JobInvokeUtil.invokeMethod(sysJob); - } -} +package com.ruoyi.quartz.util; + +import org.quartz.DisallowConcurrentExecution; +import org.quartz.JobExecutionContext; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 定时任务处理(禁止并发执行) + * + * @author ruoyi + * + */ +@DisallowConcurrentExecution +public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob +{ + @Override + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception + { + JobInvokeUtil.invokeMethod(sysJob); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java similarity index 95% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java index 87a06bc13..e97532617 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java @@ -1,19 +1,19 @@ -package com.ruoyi.quartz.util; - -import org.quartz.JobExecutionContext; -import com.ruoyi.quartz.domain.SysJob; - -/** - * 定时任务处理(允许并发执行) - * - * @author ruoyi - * - */ -public class QuartzJobExecution extends AbstractQuartzJob -{ - @Override - protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception - { - JobInvokeUtil.invokeMethod(sysJob); - } -} +package com.ruoyi.quartz.util; + +import org.quartz.JobExecutionContext; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 定时任务处理(允许并发执行) + * + * @author ruoyi + * + */ +public class QuartzJobExecution extends AbstractQuartzJob +{ + @Override + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception + { + JobInvokeUtil.invokeMethod(sysJob); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java similarity index 97% rename from ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java rename to bmw-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java index b7c2f5365..073629a8b 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java +++ b/bmw-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java @@ -1,113 +1,113 @@ -package com.ruoyi.quartz.util; - -import org.quartz.CronScheduleBuilder; -import org.quartz.CronTrigger; -import org.quartz.Job; -import org.quartz.JobBuilder; -import org.quartz.JobDetail; -import org.quartz.JobKey; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.TriggerBuilder; -import org.quartz.TriggerKey; -import com.ruoyi.common.constant.ScheduleConstants; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.common.exception.job.TaskException.Code; -import com.ruoyi.quartz.domain.SysJob; - -/** - * 定时任务工具类 - * - * @author ruoyi - * - */ -public class ScheduleUtils -{ - /** - * 得到quartz任务类 - * - * @param sysJob 执行计划 - * @return 具体执行任务类 - */ - private static Class getQuartzJobClass(SysJob sysJob) - { - boolean isConcurrent = "0".equals(sysJob.getConcurrent()); - return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class; - } - - /** - * 构建任务触发对象 - */ - public static TriggerKey getTriggerKey(Long jobId, String jobGroup) - { - return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); - } - - /** - * 构建任务键对象 - */ - public static JobKey getJobKey(Long jobId, String jobGroup) - { - return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); - } - - /** - * 创建定时任务 - */ - public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException - { - Class jobClass = getQuartzJobClass(job); - // 构建job信息 - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build(); - - // 表达式调度构建器 - CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); - cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); - - // 按新的cronExpression表达式构建一个新的trigger - CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)) - .withSchedule(cronScheduleBuilder).build(); - - // 放入参数,运行时的方法可以获取 - jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); - - // 判断是否存在 - if (scheduler.checkExists(getJobKey(jobId, jobGroup))) - { - // 防止创建时存在数据问题 先移除,然后在执行创建操作 - scheduler.deleteJob(getJobKey(jobId, jobGroup)); - } - - scheduler.scheduleJob(jobDetail, trigger); - - // 暂停任务 - if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) - { - scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); - } - } - - /** - * 设置定时任务策略 - */ - public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) - throws TaskException - { - switch (job.getMisfirePolicy()) - { - case ScheduleConstants.MISFIRE_DEFAULT: - return cb; - case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: - return cb.withMisfireHandlingInstructionIgnoreMisfires(); - case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: - return cb.withMisfireHandlingInstructionFireAndProceed(); - case ScheduleConstants.MISFIRE_DO_NOTHING: - return cb.withMisfireHandlingInstructionDoNothing(); - default: - throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() - + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); - } - } +package com.ruoyi.quartz.util; + +import org.quartz.CronScheduleBuilder; +import org.quartz.CronTrigger; +import org.quartz.Job; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.common.exception.job.TaskException.Code; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 定时任务工具类 + * + * @author ruoyi + * + */ +public class ScheduleUtils +{ + /** + * 得到quartz任务类 + * + * @param sysJob 执行计划 + * @return 具体执行任务类 + */ + private static Class getQuartzJobClass(SysJob sysJob) + { + boolean isConcurrent = "0".equals(sysJob.getConcurrent()); + return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class; + } + + /** + * 构建任务触发对象 + */ + public static TriggerKey getTriggerKey(Long jobId, String jobGroup) + { + return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); + } + + /** + * 构建任务键对象 + */ + public static JobKey getJobKey(Long jobId, String jobGroup) + { + return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); + } + + /** + * 创建定时任务 + */ + public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException + { + Class jobClass = getQuartzJobClass(job); + // 构建job信息 + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build(); + + // 表达式调度构建器 + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); + cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); + + // 按新的cronExpression表达式构建一个新的trigger + CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)) + .withSchedule(cronScheduleBuilder).build(); + + // 放入参数,运行时的方法可以获取 + jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); + + // 判断是否存在 + if (scheduler.checkExists(getJobKey(jobId, jobGroup))) + { + // 防止创建时存在数据问题 先移除,然后在执行创建操作 + scheduler.deleteJob(getJobKey(jobId, jobGroup)); + } + + scheduler.scheduleJob(jobDetail, trigger); + + // 暂停任务 + if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) + { + scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + } + + /** + * 设置定时任务策略 + */ + public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) + throws TaskException + { + switch (job.getMisfirePolicy()) + { + case ScheduleConstants.MISFIRE_DEFAULT: + return cb; + case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: + return cb.withMisfireHandlingInstructionIgnoreMisfires(); + case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: + return cb.withMisfireHandlingInstructionFireAndProceed(); + case ScheduleConstants.MISFIRE_DO_NOTHING: + return cb.withMisfireHandlingInstructionDoNothing(); + default: + throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); + } + } } \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml b/bmw-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml similarity index 97% rename from ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml rename to bmw-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml index 745bed364..b412976fb 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml +++ b/bmw-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml @@ -1,93 +1,93 @@ - - - - - - - - - - - - - - - - - select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time - from sys_job_log - - - - - - - - - - delete from sys_job_log where job_log_id = #{jobLogId} - - - - delete from sys_job_log where job_log_id in - - #{jobLogId} - - - - - truncate table sys_job_log - - - - insert into sys_job_log( - job_log_id, - job_name, - job_group, - invoke_target, - job_message, - status, - exception_info, - create_time - )values( - #{jobLogId}, - #{jobName}, - #{jobGroup}, - #{invokeTarget}, - #{jobMessage}, - #{status}, - #{exceptionInfo}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time + from sys_job_log + + + + + + + + + + delete from sys_job_log where job_log_id = #{jobLogId} + + + + delete from sys_job_log where job_log_id in + + #{jobLogId} + + + + + truncate table sys_job_log + + + + insert into sys_job_log( + job_log_id, + job_name, + job_group, + invoke_target, + job_message, + status, + exception_info, + create_time + )values( + #{jobLogId}, + #{jobName}, + #{jobGroup}, + #{invokeTarget}, + #{jobMessage}, + #{status}, + #{exceptionInfo}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml b/bmw-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml similarity index 97% rename from ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml rename to bmw-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml index 69233bdf7..5605c4445 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml +++ b/bmw-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml @@ -1,111 +1,111 @@ - - - - - - - - - - - - - - - - - - - - - - select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark - from sys_job - - - - - - - - - - delete from sys_job where job_id = #{jobId} - - - - delete from sys_job where job_id in - - #{jobId} - - - - - update sys_job - - job_name = #{jobName}, - job_group = #{jobGroup}, - invoke_target = #{invokeTarget}, - cron_expression = #{cronExpression}, - misfire_policy = #{misfirePolicy}, - concurrent = #{concurrent}, - status = #{status}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = sysdate() - - where job_id = #{jobId} - - - - insert into sys_job( - job_id, - job_name, - job_group, - invoke_target, - cron_expression, - misfire_policy, - concurrent, - status, - remark, - create_by, - create_time - )values( - #{jobId}, - #{jobName}, - #{jobGroup}, - #{invokeTarget}, - #{cronExpression}, - #{misfirePolicy}, - #{concurrent}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + + + + + + select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark + from sys_job + + + + + + + + + + delete from sys_job where job_id = #{jobId} + + + + delete from sys_job where job_id in + + #{jobId} + + + + + update sys_job + + job_name = #{jobName}, + job_group = #{jobGroup}, + invoke_target = #{invokeTarget}, + cron_expression = #{cronExpression}, + misfire_policy = #{misfirePolicy}, + concurrent = #{concurrent}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where job_id = #{jobId} + + + + insert into sys_job( + job_id, + job_name, + job_group, + invoke_target, + cron_expression, + misfire_policy, + concurrent, + status, + remark, + create_by, + create_time + )values( + #{jobId}, + #{jobName}, + #{jobGroup}, + #{invokeTarget}, + #{cronExpression}, + #{misfirePolicy}, + #{concurrent}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/add.html b/bmw-quartz/src/main/resources/templates/monitor/job/add.html similarity index 97% rename from ruoyi-quartz/src/main/resources/templates/monitor/job/add.html rename to bmw-quartz/src/main/resources/templates/monitor/job/add.html index d15cedf32..9cb48c51f 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/add.html +++ b/bmw-quartz/src/main/resources/templates/monitor/job/add.html @@ -1,109 +1,109 @@ - - - - - - -
                            -
                            - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - Bean调用示例:ryTask.ryParams('ry') - Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry') - 参数说明:支持字符串,布尔类型,长整型,浮点型,整型 -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - - -
                            -
                            -
                            - -
                            - - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + Bean调用示例:ryTask.ryParams('ry') + Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry') + 参数说明:支持字符串,布尔类型,长整型,浮点型,整型 +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + + +
                            +
                            +
                            + +
                            + + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/detail.html b/bmw-quartz/src/main/resources/templates/monitor/job/detail.html similarity index 97% rename from ruoyi-quartz/src/main/resources/templates/monitor/job/detail.html rename to bmw-quartz/src/main/resources/templates/monitor/job/detail.html index e360eecad..28c3aefbd 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/detail.html +++ b/bmw-quartz/src/main/resources/templates/monitor/job/detail.html @@ -1,99 +1,99 @@ - - - - - - -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            默认策略
                            -
                            立即执行
                            -
                            执行一次
                            -
                            放弃执行
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            -
                            -
                            -
                            - -
                            - + + + + + + +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            默认策略
                            +
                            立即执行
                            +
                            执行一次
                            +
                            放弃执行
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            +
                            +
                            +
                            + +
                            + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html b/bmw-quartz/src/main/resources/templates/monitor/job/edit.html similarity index 97% rename from ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html rename to bmw-quartz/src/main/resources/templates/monitor/job/edit.html index 2f26ec24b..19f5acffe 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html +++ b/bmw-quartz/src/main/resources/templates/monitor/job/edit.html @@ -1,111 +1,111 @@ - - - - - - -
                            -
                            - - -
                            - -
                            - -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - Bean调用示例:ryTask.ryParams('ry') - Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry') - 参数说明:支持字符串,布尔类型,长整型,浮点型,整型 -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            - -
                            - - - -
                            -
                            -
                            - -
                            - - -
                            -
                            -
                            - -
                            -
                            - - -
                            -
                            -
                            -
                            - -
                            - -
                            -
                            -
                            -
                            - - - - + + + + + + +
                            +
                            + + +
                            + +
                            + +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + Bean调用示例:ryTask.ryParams('ry') + Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry') + 参数说明:支持字符串,布尔类型,长整型,浮点型,整型 +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            + +
                            + + + +
                            +
                            +
                            + +
                            + + +
                            +
                            +
                            + +
                            +
                            + + +
                            +
                            +
                            +
                            + +
                            + +
                            +
                            +
                            +
                            + + + + diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/job.html b/bmw-quartz/src/main/resources/templates/monitor/job/job.html similarity index 97% rename from ruoyi-quartz/src/main/resources/templates/monitor/job/job.html rename to bmw-quartz/src/main/resources/templates/monitor/job/job.html index c6727e1b3..f5d206aae 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/job.html +++ b/bmw-quartz/src/main/resources/templates/monitor/job/job.html @@ -1,173 +1,173 @@ - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 任务名称: -
                            • -
                            • - 任务分组: -
                            • -
                            • - 任务状态: -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 任务名称: +
                            • +
                            • + 任务分组: +
                            • +
                            • + 任务状态: +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/jobLog.html b/bmw-quartz/src/main/resources/templates/monitor/job/jobLog.html similarity index 97% rename from ruoyi-quartz/src/main/resources/templates/monitor/job/jobLog.html rename to bmw-quartz/src/main/resources/templates/monitor/job/jobLog.html index 8d0d53620..16714148e 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/jobLog.html +++ b/bmw-quartz/src/main/resources/templates/monitor/job/jobLog.html @@ -1,134 +1,134 @@ - - - - - - - -
                            -
                            -
                            -
                            -
                            -
                              -
                            • - 任务名称: -
                            • -
                            • - 任务分组: -
                            • -
                            • - 执行状态: -
                            • -
                            • - - - - - -
                            • -
                            • -  搜索 -  重置 -
                            • -
                            -
                            -
                            -
                            - - - -
                            -
                            -
                            -
                            -
                            - - - + + + + + + + +
                            +
                            +
                            +
                            +
                            +
                              +
                            • + 任务名称: +
                            • +
                            • + 任务分组: +
                            • +
                            • + 执行状态: +
                            • +
                            • + + + - + +
                            • +
                            • +  搜索 +  重置 +
                            • +
                            +
                            +
                            +
                            + + + +
                            +
                            +
                            +
                            +
                            + + + \ No newline at end of file diff --git a/ruoyi-system/pom.xml b/bmw-system/pom.xml similarity index 96% rename from ruoyi-system/pom.xml rename to bmw-system/pom.xml index a44fa2fde..da541b830 100644 --- a/ruoyi-system/pom.xml +++ b/bmw-system/pom.xml @@ -1,34 +1,34 @@ - - - - ruoyi - com.ruoyi - 3.4 - - 4.0.0 - - ruoyi-system - - - system系统模块 - - - - - - - mysql - mysql-connector-java - - - - - com.ruoyi - ruoyi-common - - - - + + + + ruoyi + com.ruoyi + 3.4 + + 4.0.0 + + ruoyi-system + + + system系统模块 + + + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-common + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysConfig.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysConfig.java index 25d0e6926..5eeb73362 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysConfig.java @@ -1,109 +1,109 @@ -package com.ruoyi.system.domain; - -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 参数配置表 sys_config - * - * @author ruoyi - */ -public class SysConfig extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 参数主键 */ - @Excel(name = "参数主键") - private Long configId; - - /** 参数名称 */ - @Excel(name = "参数名称") - private String configName; - - /** 参数键名 */ - @Excel(name = "参数键名") - private String configKey; - - /** 参数键值 */ - @Excel(name = "参数键值") - private String configValue; - - /** 系统内置(Y是 N否) */ - @Excel(name = "系统内置", readConverterExp = "Y=是,N=否") - private String configType; - - public Long getConfigId() - { - return configId; - } - - public void setConfigId(Long configId) - { - this.configId = configId; - } - - @NotBlank(message = "参数名称不能为空") - @Size(min = 0, max = 100, message = "参数名称不能超过100个字符") - public String getConfigName() - { - return configName; - } - - public void setConfigName(String configName) - { - this.configName = configName; - } - - @NotBlank(message = "参数键名长度不能为空") - @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符") - public String getConfigKey() - { - return configKey; - } - - public void setConfigKey(String configKey) - { - this.configKey = configKey; - } - - @NotBlank(message = "参数键值不能为空") - @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符") - public String getConfigValue() - { - return configValue; - } - - public void setConfigValue(String configValue) - { - this.configValue = configValue; - } - - public String getConfigType() - { - return configType; - } - - public void setConfigType(String configType) - { - this.configType = configType; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("configId", getConfigId()) - .append("configName", getConfigName()) - .append("configKey", getConfigKey()) - .append("configValue", getConfigValue()) - .append("configType", getConfigType()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 参数配置表 sys_config + * + * @author ruoyi + */ +public class SysConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 参数主键 */ + @Excel(name = "参数主键") + private Long configId; + + /** 参数名称 */ + @Excel(name = "参数名称") + private String configName; + + /** 参数键名 */ + @Excel(name = "参数键名") + private String configKey; + + /** 参数键值 */ + @Excel(name = "参数键值") + private String configValue; + + /** 系统内置(Y是 N否) */ + @Excel(name = "系统内置", readConverterExp = "Y=是,N=否") + private String configType; + + public Long getConfigId() + { + return configId; + } + + public void setConfigId(Long configId) + { + this.configId = configId; + } + + @NotBlank(message = "参数名称不能为空") + @Size(min = 0, max = 100, message = "参数名称不能超过100个字符") + public String getConfigName() + { + return configName; + } + + public void setConfigName(String configName) + { + this.configName = configName; + } + + @NotBlank(message = "参数键名长度不能为空") + @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符") + public String getConfigKey() + { + return configKey; + } + + public void setConfigKey(String configKey) + { + this.configKey = configKey; + } + + @NotBlank(message = "参数键值不能为空") + @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符") + public String getConfigValue() + { + return configValue; + } + + public void setConfigValue(String configValue) + { + this.configValue = configValue; + } + + public String getConfigType() + { + return configType; + } + + public void setConfigType(String configType) + { + this.configType = configType; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("configId", getConfigId()) + .append("configName", getConfigName()) + .append("configKey", getConfigKey()) + .append("configValue", getConfigValue()) + .append("configType", getConfigType()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDept.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysDept.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDept.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysDept.java index 4d86400d1..1e7bd7301 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDept.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysDept.java @@ -1,185 +1,185 @@ -package com.ruoyi.system.domain; - -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 部门表 sys_dept - * - * @author ruoyi - */ -public class SysDept extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 部门ID */ - private Long deptId; - - /** 父部门ID */ - private Long parentId; - - /** 祖级列表 */ - private String ancestors; - - /** 部门名称 */ - private String deptName; - - /** 显示顺序 */ - private String orderNum; - - /** 负责人 */ - private String leader; - - /** 联系电话 */ - private String phone; - - /** 邮箱 */ - private String email; - - /** 部门状态:0正常,1停用 */ - private String status; - - /** 删除标志(0代表存在 2代表删除) */ - private String delFlag; - - /** 父部门名称 */ - private String parentName; - - public Long getDeptId() - { - return deptId; - } - - public void setDeptId(Long deptId) - { - this.deptId = deptId; - } - - public Long getParentId() - { - return parentId; - } - - public void setParentId(Long parentId) - { - this.parentId = parentId; - } - - public String getAncestors() - { - return ancestors; - } - - public void setAncestors(String ancestors) - { - this.ancestors = ancestors; - } - - @NotBlank(message = "部门名称不能为空") - @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - @NotBlank(message = "显示顺序不能为空") - public String getOrderNum() - { - return orderNum; - } - - public void setOrderNum(String orderNum) - { - this.orderNum = orderNum; - } - - public String getLeader() - { - return leader; - } - - public void setLeader(String leader) - { - this.leader = leader; - } - - @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") - public String getPhone() - { - return phone; - } - - public void setPhone(String phone) - { - this.phone = phone; - } - - @Email(message = "邮箱格式不正确") - @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { - return email; - } - - public void setEmail(String email) - { - this.email = email; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getDelFlag() - { - return delFlag; - } - - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public String getParentName() - { - return parentName; - } - - public void setParentName(String parentName) - { - this.parentName = parentName; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("deptId", getDeptId()) - .append("parentId", getParentId()) - .append("ancestors", getAncestors()) - .append("deptName", getDeptName()) - .append("orderNum", getOrderNum()) - .append("leader", getLeader()) - .append("phone", getPhone()) - .append("email", getEmail()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 部门表 sys_dept + * + * @author ruoyi + */ +public class SysDept extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 部门ID */ + private Long deptId; + + /** 父部门ID */ + private Long parentId; + + /** 祖级列表 */ + private String ancestors; + + /** 部门名称 */ + private String deptName; + + /** 显示顺序 */ + private String orderNum; + + /** 负责人 */ + private String leader; + + /** 联系电话 */ + private String phone; + + /** 邮箱 */ + private String email; + + /** 部门状态:0正常,1停用 */ + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + /** 父部门名称 */ + private String parentName; + + public Long getDeptId() + { + return deptId; + } + + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + public Long getParentId() + { + return parentId; + } + + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + public String getAncestors() + { + return ancestors; + } + + public void setAncestors(String ancestors) + { + this.ancestors = ancestors; + } + + @NotBlank(message = "部门名称不能为空") + @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") + public String getDeptName() + { + return deptName; + } + + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + @NotBlank(message = "显示顺序不能为空") + public String getOrderNum() + { + return orderNum; + } + + public void setOrderNum(String orderNum) + { + this.orderNum = orderNum; + } + + public String getLeader() + { + return leader; + } + + public void setLeader(String leader) + { + this.leader = leader; + } + + @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") + public String getPhone() + { + return phone; + } + + public void setPhone(String phone) + { + this.phone = phone; + } + + @Email(message = "邮箱格式不正确") + @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getParentName() + { + return parentName; + } + + public void setParentName(String parentName) + { + this.parentName = parentName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("deptId", getDeptId()) + .append("parentId", getParentId()) + .append("ancestors", getAncestors()) + .append("deptName", getDeptName()) + .append("orderNum", getOrderNum()) + .append("leader", getLeader()) + .append("phone", getPhone()) + .append("email", getEmail()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictData.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysDictData.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictData.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysDictData.java index d87dbee0f..6a37bf882 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictData.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysDictData.java @@ -1,175 +1,175 @@ -package com.ruoyi.system.domain; - -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 字典数据表 sys_dict_data - * - * @author ruoyi - */ -public class SysDictData extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 字典编码 */ - @Excel(name = "字典编码") - private Long dictCode; - - /** 字典排序 */ - @Excel(name = "字典排序") - private Long dictSort; - - /** 字典标签 */ - @Excel(name = "字典标签") - private String dictLabel; - - /** 字典键值 */ - @Excel(name = "字典键值") - private String dictValue; - - /** 字典类型 */ - @Excel(name = "字典类型") - private String dictType; - - /** 样式属性(其他样式扩展) */ - @Excel(name = "字典样式") - private String cssClass; - - /** 表格字典样式 */ - private String listClass; - - /** 是否默认(Y是 N否) */ - @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") - private String isDefault; - - /** 状态(0正常 1停用) */ - @Excel(name = "状态", readConverterExp = "0=正常,1=停用") - private String status; - - public Long getDictCode() - { - return dictCode; - } - - public void setDictCode(Long dictCode) - { - this.dictCode = dictCode; - } - - public Long getDictSort() - { - return dictSort; - } - - public void setDictSort(Long dictSort) - { - this.dictSort = dictSort; - } - - @NotBlank(message = "字典标签不能为空") - @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") - public String getDictLabel() - { - return dictLabel; - } - - public void setDictLabel(String dictLabel) - { - this.dictLabel = dictLabel; - } - - @NotBlank(message = "字典键值不能为空") - @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") - public String getDictValue() - { - return dictValue; - } - - public void setDictValue(String dictValue) - { - this.dictValue = dictValue; - } - - @NotBlank(message = "字典类型不能为空") - @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") - public String getDictType() - { - return dictType; - } - - public void setDictType(String dictType) - { - this.dictType = dictType; - } - - @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") - public String getCssClass() - { - return cssClass; - } - - public void setCssClass(String cssClass) - { - this.cssClass = cssClass; - } - - public String getListClass() - { - return listClass; - } - - public void setListClass(String listClass) - { - this.listClass = listClass; - } - - public boolean getDefault() - { - return UserConstants.YES.equals(this.isDefault) ? true : false; - } - - public String getIsDefault() - { - return isDefault; - } - - public void setIsDefault(String isDefault) - { - this.isDefault = isDefault; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("dictCode", getDictCode()) - .append("dictSort", getDictSort()) - .append("dictLabel", getDictLabel()) - .append("dictValue", getDictValue()) - .append("dictType", getDictType()) - .append("cssClass", getCssClass()) - .append("listClass", getListClass()) - .append("isDefault", getIsDefault()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 字典数据表 sys_dict_data + * + * @author ruoyi + */ +public class SysDictData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 字典编码 */ + @Excel(name = "字典编码") + private Long dictCode; + + /** 字典排序 */ + @Excel(name = "字典排序") + private Long dictSort; + + /** 字典标签 */ + @Excel(name = "字典标签") + private String dictLabel; + + /** 字典键值 */ + @Excel(name = "字典键值") + private String dictValue; + + /** 字典类型 */ + @Excel(name = "字典类型") + private String dictType; + + /** 样式属性(其他样式扩展) */ + @Excel(name = "字典样式") + private String cssClass; + + /** 表格字典样式 */ + private String listClass; + + /** 是否默认(Y是 N否) */ + @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") + private String isDefault; + + /** 状态(0正常 1停用) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + public Long getDictCode() + { + return dictCode; + } + + public void setDictCode(Long dictCode) + { + this.dictCode = dictCode; + } + + public Long getDictSort() + { + return dictSort; + } + + public void setDictSort(Long dictSort) + { + this.dictSort = dictSort; + } + + @NotBlank(message = "字典标签不能为空") + @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") + public String getDictLabel() + { + return dictLabel; + } + + public void setDictLabel(String dictLabel) + { + this.dictLabel = dictLabel; + } + + @NotBlank(message = "字典键值不能为空") + @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") + public String getDictValue() + { + return dictValue; + } + + public void setDictValue(String dictValue) + { + this.dictValue = dictValue; + } + + @NotBlank(message = "字典类型不能为空") + @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") + public String getDictType() + { + return dictType; + } + + public void setDictType(String dictType) + { + this.dictType = dictType; + } + + @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") + public String getCssClass() + { + return cssClass; + } + + public void setCssClass(String cssClass) + { + this.cssClass = cssClass; + } + + public String getListClass() + { + return listClass; + } + + public void setListClass(String listClass) + { + this.listClass = listClass; + } + + public boolean getDefault() + { + return UserConstants.YES.equals(this.isDefault) ? true : false; + } + + public String getIsDefault() + { + return isDefault; + } + + public void setIsDefault(String isDefault) + { + this.isDefault = isDefault; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("dictCode", getDictCode()) + .append("dictSort", getDictSort()) + .append("dictLabel", getDictLabel()) + .append("dictValue", getDictValue()) + .append("dictType", getDictType()) + .append("cssClass", getCssClass()) + .append("listClass", getListClass()) + .append("isDefault", getIsDefault()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictType.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysDictType.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictType.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysDictType.java index 3b927401f..e83bdc4b1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysDictType.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysDictType.java @@ -1,92 +1,92 @@ -package com.ruoyi.system.domain; - -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 字典类型表 sys_dict_type - * - * @author ruoyi - */ -public class SysDictType extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 字典主键 */ - @Excel(name = "字典主键") - private Long dictId; - - /** 字典名称 */ - @Excel(name = "字典名称") - private String dictName; - - /** 字典类型 */ - @Excel(name = "字典类型 ") - private String dictType; - - /** 状态(0正常 1停用) */ - @Excel(name = "状态", readConverterExp = "0=正常,1=停用") - private String status; - - public Long getDictId() - { - return dictId; - } - - public void setDictId(Long dictId) - { - this.dictId = dictId; - } - - @NotBlank(message = "字典名称不能为空") - @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") - public String getDictName() - { - return dictName; - } - - public void setDictName(String dictName) - { - this.dictName = dictName; - } - - @NotBlank(message = "字典类型不能为空") - @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") - public String getDictType() - { - return dictType; - } - - public void setDictType(String dictType) - { - this.dictType = dictType; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("dictId", getDictId()) - .append("dictName", getDictName()) - .append("dictType", getDictType()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 字典类型表 sys_dict_type + * + * @author ruoyi + */ +public class SysDictType extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 字典主键 */ + @Excel(name = "字典主键") + private Long dictId; + + /** 字典名称 */ + @Excel(name = "字典名称") + private String dictName; + + /** 字典类型 */ + @Excel(name = "字典类型 ") + private String dictType; + + /** 状态(0正常 1停用) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + public Long getDictId() + { + return dictId; + } + + public void setDictId(Long dictId) + { + this.dictId = dictId; + } + + @NotBlank(message = "字典名称不能为空") + @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") + public String getDictName() + { + return dictName; + } + + public void setDictName(String dictName) + { + this.dictName = dictName; + } + + @NotBlank(message = "字典类型不能为空") + @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") + public String getDictType() + { + return dictType; + } + + public void setDictType(String dictType) + { + this.dictType = dictType; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("dictId", getDictId()) + .append("dictName", getDictName()) + .append("dictType", getDictType()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java index 9c466c6df..436488594 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java @@ -1,158 +1,158 @@ -package com.ruoyi.system.domain; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import java.util.Date; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 系统访问记录表 sys_logininfor - * - * @author ruoyi - */ -public class SysLogininfor extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** ID */ - @Excel(name = "序号") - private Long infoId; - - /** 用户账号 */ - @Excel(name = "用户账号") - private String loginName; - - /** 登录状态 0成功 1失败 */ - @Excel(name = "登录状态", readConverterExp = "0=成功,1=失败") - private String status; - - /** 登录IP地址 */ - @Excel(name = "登录地址") - private String ipaddr; - - /** 登录地点 */ - @Excel(name = "登录地点") - private String loginLocation; - - /** 浏览器类型 */ - @Excel(name = "浏览器") - private String browser; - - /** 操作系统 */ - @Excel(name = "操作系统 ") - private String os; - - /** 提示消息 */ - @Excel(name = "提示消息") - private String msg; - - /** 访问时间 */ - @Excel(name = "访问时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") - private Date loginTime; - - public Long getInfoId() - { - return infoId; - } - - public void setInfoId(Long infoId) - { - this.infoId = infoId; - } - - public String getLoginName() - { - return loginName; - } - - public void setLoginName(String loginName) - { - this.loginName = loginName; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getIpaddr() - { - return ipaddr; - } - - public void setIpaddr(String ipaddr) - { - this.ipaddr = ipaddr; - } - - public String getLoginLocation() - { - return loginLocation; - } - - public void setLoginLocation(String loginLocation) - { - this.loginLocation = loginLocation; - } - - public String getBrowser() - { - return browser; - } - - public void setBrowser(String browser) - { - this.browser = browser; - } - - public String getOs() - { - return os; - } - - public void setOs(String os) - { - this.os = os; - } - - public String getMsg() - { - return msg; - } - - public void setMsg(String msg) - { - this.msg = msg; - } - - public Date getLoginTime() - { - return loginTime; - } - - public void setLoginTime(Date loginTime) - { - this.loginTime = loginTime; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("infoId", getInfoId()) - .append("loginName", getLoginName()) - .append("ipaddr", getIpaddr()) - .append("loginLocation", getLoginLocation()) - .append("browser", getBrowser()) - .append("os", getOs()) - .append("status", getStatus()) - .append("msg", getMsg()) - .append("loginTime", getLoginTime()) - .toString(); - } +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import java.util.Date; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 系统访问记录表 sys_logininfor + * + * @author ruoyi + */ +public class SysLogininfor extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** ID */ + @Excel(name = "序号") + private Long infoId; + + /** 用户账号 */ + @Excel(name = "用户账号") + private String loginName; + + /** 登录状态 0成功 1失败 */ + @Excel(name = "登录状态", readConverterExp = "0=成功,1=失败") + private String status; + + /** 登录IP地址 */ + @Excel(name = "登录地址") + private String ipaddr; + + /** 登录地点 */ + @Excel(name = "登录地点") + private String loginLocation; + + /** 浏览器类型 */ + @Excel(name = "浏览器") + private String browser; + + /** 操作系统 */ + @Excel(name = "操作系统 ") + private String os; + + /** 提示消息 */ + @Excel(name = "提示消息") + private String msg; + + /** 访问时间 */ + @Excel(name = "访问时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date loginTime; + + public Long getInfoId() + { + return infoId; + } + + public void setInfoId(Long infoId) + { + this.infoId = infoId; + } + + public String getLoginName() + { + return loginName; + } + + public void setLoginName(String loginName) + { + this.loginName = loginName; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getIpaddr() + { + return ipaddr; + } + + public void setIpaddr(String ipaddr) + { + this.ipaddr = ipaddr; + } + + public String getLoginLocation() + { + return loginLocation; + } + + public void setLoginLocation(String loginLocation) + { + this.loginLocation = loginLocation; + } + + public String getBrowser() + { + return browser; + } + + public void setBrowser(String browser) + { + this.browser = browser; + } + + public String getOs() + { + return os; + } + + public void setOs(String os) + { + this.os = os; + } + + public String getMsg() + { + return msg; + } + + public void setMsg(String msg) + { + this.msg = msg; + } + + public Date getLoginTime() + { + return loginTime; + } + + public void setLoginTime(Date loginTime) + { + this.loginTime = loginTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("infoId", getInfoId()) + .append("loginName", getLoginName()) + .append("ipaddr", getIpaddr()) + .append("loginLocation", getLoginLocation()) + .append("browser", getBrowser()) + .append("os", getOs()) + .append("status", getStatus()) + .append("msg", getMsg()) + .append("loginTime", getLoginTime()) + .toString(); + } } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysMenu.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysMenu.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysMenu.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysMenu.java index 8a0f83f44..03a938d8e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysMenu.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysMenu.java @@ -1,201 +1,201 @@ -package com.ruoyi.system.domain; - -import java.util.List; -import java.util.ArrayList; -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 菜单权限表 sys_menu - * - * @author ruoyi - */ -public class SysMenu extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 菜单ID */ - private Long menuId; - - /** 菜单名称 */ - private String menuName; - - /** 父菜单名称 */ - private String parentName; - - /** 父菜单ID */ - private Long parentId; - - /** 显示顺序 */ - private String orderNum; - - /** 菜单URL */ - private String url; - - /** 打开方式:menuItem页签 menuBlank新窗口 */ - private String target; - - /** 类型:0目录,1菜单,2按钮 */ - private String menuType; - - /** 菜单状态:0显示,1隐藏 */ - private String visible; - - /** 权限字符串 */ - private String perms; - - /** 菜单图标 */ - private String icon; - - /** 子菜单 */ - private List children = new ArrayList(); - - public Long getMenuId() - { - return menuId; - } - - public void setMenuId(Long menuId) - { - this.menuId = menuId; - } - - @NotBlank(message = "菜单名称不能为空") - @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符") - public String getMenuName() - { - return menuName; - } - - public void setMenuName(String menuName) - { - this.menuName = menuName; - } - - public String getParentName() - { - return parentName; - } - - public void setParentName(String parentName) - { - this.parentName = parentName; - } - - public Long getParentId() - { - return parentId; - } - - public void setParentId(Long parentId) - { - this.parentId = parentId; - } - - @NotBlank(message = "显示顺序不能为空") - public String getOrderNum() - { - return orderNum; - } - - public void setOrderNum(String orderNum) - { - this.orderNum = orderNum; - } - - @Size(min = 0, max = 200, message = "请求地址不能超过200个字符") - public String getUrl() - { - return url; - } - - public void setUrl(String url) - { - this.url = url; - } - - public String getTarget() - { - return target; - } - - public void setTarget(String target) - { - this.target = target; - } - - @NotBlank(message = "菜单类型不能为空") - public String getMenuType() - { - return menuType; - } - - public void setMenuType(String menuType) - { - this.menuType = menuType; - } - - public String getVisible() - { - return visible; - } - - public void setVisible(String visible) - { - this.visible = visible; - } - - @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符") - public String getPerms() - { - return perms; - } - - public void setPerms(String perms) - { - this.perms = perms; - } - - public String getIcon() - { - return icon; - } - - public void setIcon(String icon) - { - this.icon = icon; - } - - public List getChildren() - { - return children; - } - - public void setChildren(List children) - { - this.children = children; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("menuId", getMenuId()) - .append("menuName", getMenuName()) - .append("parentId", getParentId()) - .append("orderNum", getOrderNum()) - .append("url", getUrl()) - .append("target", getTarget()) - .append("menuType", getMenuType()) - .append("visible", getVisible()) - .append("perms", getPerms()) - .append("icon", getIcon()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import java.util.List; +import java.util.ArrayList; +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 菜单权限表 sys_menu + * + * @author ruoyi + */ +public class SysMenu extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 菜单ID */ + private Long menuId; + + /** 菜单名称 */ + private String menuName; + + /** 父菜单名称 */ + private String parentName; + + /** 父菜单ID */ + private Long parentId; + + /** 显示顺序 */ + private String orderNum; + + /** 菜单URL */ + private String url; + + /** 打开方式:menuItem页签 menuBlank新窗口 */ + private String target; + + /** 类型:0目录,1菜单,2按钮 */ + private String menuType; + + /** 菜单状态:0显示,1隐藏 */ + private String visible; + + /** 权限字符串 */ + private String perms; + + /** 菜单图标 */ + private String icon; + + /** 子菜单 */ + private List children = new ArrayList(); + + public Long getMenuId() + { + return menuId; + } + + public void setMenuId(Long menuId) + { + this.menuId = menuId; + } + + @NotBlank(message = "菜单名称不能为空") + @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符") + public String getMenuName() + { + return menuName; + } + + public void setMenuName(String menuName) + { + this.menuName = menuName; + } + + public String getParentName() + { + return parentName; + } + + public void setParentName(String parentName) + { + this.parentName = parentName; + } + + public Long getParentId() + { + return parentId; + } + + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + @NotBlank(message = "显示顺序不能为空") + public String getOrderNum() + { + return orderNum; + } + + public void setOrderNum(String orderNum) + { + this.orderNum = orderNum; + } + + @Size(min = 0, max = 200, message = "请求地址不能超过200个字符") + public String getUrl() + { + return url; + } + + public void setUrl(String url) + { + this.url = url; + } + + public String getTarget() + { + return target; + } + + public void setTarget(String target) + { + this.target = target; + } + + @NotBlank(message = "菜单类型不能为空") + public String getMenuType() + { + return menuType; + } + + public void setMenuType(String menuType) + { + this.menuType = menuType; + } + + public String getVisible() + { + return visible; + } + + public void setVisible(String visible) + { + this.visible = visible; + } + + @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符") + public String getPerms() + { + return perms; + } + + public void setPerms(String perms) + { + this.perms = perms; + } + + public String getIcon() + { + return icon; + } + + public void setIcon(String icon) + { + this.icon = icon; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("menuId", getMenuId()) + .append("menuName", getMenuName()) + .append("parentId", getParentId()) + .append("orderNum", getOrderNum()) + .append("url", getUrl()) + .append("target", getTarget()) + .append("menuType", getMenuType()) + .append("visible", getVisible()) + .append("perms", getPerms()) + .append("icon", getIcon()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysNotice.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysNotice.java index 7de4d9460..520d3f815 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysNotice.java @@ -1,99 +1,99 @@ -package com.ruoyi.system.domain; - -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 通知公告表 sys_notice - * - * @author ruoyi - */ -public class SysNotice extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 公告ID */ - private Long noticeId; - - /** 公告标题 */ - private String noticeTitle; - - /** 公告类型(1通知 2公告) */ - private String noticeType; - - /** 公告内容 */ - private String noticeContent; - - /** 公告状态(0正常 1关闭) */ - private String status; - - public Long getNoticeId() - { - return noticeId; - } - - public void setNoticeId(Long noticeId) - { - this.noticeId = noticeId; - } - - public void setNoticeTitle(String noticeTitle) - { - this.noticeTitle = noticeTitle; - } - - @NotBlank(message = "公告标题不能为空") - @Size(min = 0, max = 50, message = "公告标题不能超过50个字符") - public String getNoticeTitle() - { - return noticeTitle; - } - - public void setNoticeType(String noticeType) - { - this.noticeType = noticeType; - } - - public String getNoticeType() - { - return noticeType; - } - - public void setNoticeContent(String noticeContent) - { - this.noticeContent = noticeContent; - } - - public String getNoticeContent() - { - return noticeContent; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("noticeId", getNoticeId()) - .append("noticeTitle", getNoticeTitle()) - .append("noticeType", getNoticeType()) - .append("noticeContent", getNoticeContent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 通知公告表 sys_notice + * + * @author ruoyi + */ +public class SysNotice extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 公告ID */ + private Long noticeId; + + /** 公告标题 */ + private String noticeTitle; + + /** 公告类型(1通知 2公告) */ + private String noticeType; + + /** 公告内容 */ + private String noticeContent; + + /** 公告状态(0正常 1关闭) */ + private String status; + + public Long getNoticeId() + { + return noticeId; + } + + public void setNoticeId(Long noticeId) + { + this.noticeId = noticeId; + } + + public void setNoticeTitle(String noticeTitle) + { + this.noticeTitle = noticeTitle; + } + + @NotBlank(message = "公告标题不能为空") + @Size(min = 0, max = 50, message = "公告标题不能超过50个字符") + public String getNoticeTitle() + { + return noticeTitle; + } + + public void setNoticeType(String noticeType) + { + this.noticeType = noticeType; + } + + public String getNoticeType() + { + return noticeType; + } + + public void setNoticeContent(String noticeContent) + { + this.noticeContent = noticeContent; + } + + public String getNoticeContent() + { + return noticeContent; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getStatus() + { + return status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("noticeId", getNoticeId()) + .append("noticeTitle", getNoticeTitle()) + .append("noticeType", getNoticeType()) + .append("noticeContent", getNoticeContent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java index d735e15a1..74f25b516 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java @@ -1,247 +1,247 @@ -package com.ruoyi.system.domain; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import java.util.Date; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 操作日志记录表 oper_log - * - * @author ruoyi - */ -public class SysOperLog extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 日志主键 */ - @Excel(name = "操作序号") - private Long operId; - - /** 操作模块 */ - @Excel(name = "操作模块") - private String title; - - /** 业务类型(0其它 1新增 2修改 3删除) */ - @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") - private Integer businessType; - - /** 业务类型数组 */ - private Integer[] businessTypes; - - /** 请求方法 */ - @Excel(name = "请求方法") - private String method; - - /** 操作类别(0其它 1后台用户 2手机端用户) */ - @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") - private Integer operatorType; - - /** 操作人员 */ - @Excel(name = "操作人员") - private String operName; - - /** 部门名称 */ - @Excel(name = "部门名称") - private String deptName; - - /** 请求url */ - @Excel(name = "请求地址") - private String operUrl; - - /** 操作地址 */ - @Excel(name = "操作地址") - private String operIp; - - /** 操作地点 */ - @Excel(name = "操作地点") - private String operLocation; - - /** 请求参数 */ - @Excel(name = "请求参数") - private String operParam; - - /** 操作状态(0正常 1异常) */ - @Excel(name = "状态", readConverterExp = "0=正常,1=异常") - private Integer status; - - /** 错误消息 */ - @Excel(name = "错误消息") - private String errorMsg; - - /** 操作时间 */ - @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") - private Date operTime; - - public Long getOperId() - { - return operId; - } - - public void setOperId(Long operId) - { - this.operId = operId; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public Integer getBusinessType() - { - return businessType; - } - - public void setBusinessType(Integer businessType) - { - this.businessType = businessType; - } - - public Integer[] getBusinessTypes() - { - return businessTypes; - } - - public void setBusinessTypes(Integer[] businessTypes) - { - this.businessTypes = businessTypes; - } - - public String getMethod() - { - return method; - } - - public void setMethod(String method) - { - this.method = method; - } - - public Integer getOperatorType() - { - return operatorType; - } - - public void setOperatorType(Integer operatorType) - { - this.operatorType = operatorType; - } - - public String getOperName() - { - return operName; - } - - public void setOperName(String operName) - { - this.operName = operName; - } - - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - public String getOperUrl() - { - return operUrl; - } - - public void setOperUrl(String operUrl) - { - this.operUrl = operUrl; - } - - public String getOperIp() - { - return operIp; - } - - public void setOperIp(String operIp) - { - this.operIp = operIp; - } - - public String getOperLocation() - { - return operLocation; - } - - public void setOperLocation(String operLocation) - { - this.operLocation = operLocation; - } - - public String getOperParam() - { - return operParam; - } - - public void setOperParam(String operParam) - { - this.operParam = operParam; - } - - public Integer getStatus() - { - return status; - } - - public void setStatus(Integer status) - { - this.status = status; - } - - public String getErrorMsg() - { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) - { - this.errorMsg = errorMsg; - } - - public Date getOperTime() - { - return operTime; - } - - public void setOperTime(Date operTime) - { - this.operTime = operTime; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("operId", getOperId()) - .append("title", getTitle()) - .append("businessType", getBusinessType()) - .append("businessTypes", getBusinessTypes()) - .append("method", getMethod()) - .append("operatorType", getOperatorType()) - .append("operName", getOperName()) - .append("deptName", getDeptName()) - .append("operUrl", getOperUrl()) - .append("operIp", getOperIp()) - .append("operLocation", getOperLocation()) - .append("operParam", getOperParam()) - .append("status", getStatus()) - .append("errorMsg", getErrorMsg()) - .append("operTime", getOperTime()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import java.util.Date; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 操作日志记录表 oper_log + * + * @author ruoyi + */ +public class SysOperLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 日志主键 */ + @Excel(name = "操作序号") + private Long operId; + + /** 操作模块 */ + @Excel(name = "操作模块") + private String title; + + /** 业务类型(0其它 1新增 2修改 3删除) */ + @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") + private Integer businessType; + + /** 业务类型数组 */ + private Integer[] businessTypes; + + /** 请求方法 */ + @Excel(name = "请求方法") + private String method; + + /** 操作类别(0其它 1后台用户 2手机端用户) */ + @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") + private Integer operatorType; + + /** 操作人员 */ + @Excel(name = "操作人员") + private String operName; + + /** 部门名称 */ + @Excel(name = "部门名称") + private String deptName; + + /** 请求url */ + @Excel(name = "请求地址") + private String operUrl; + + /** 操作地址 */ + @Excel(name = "操作地址") + private String operIp; + + /** 操作地点 */ + @Excel(name = "操作地点") + private String operLocation; + + /** 请求参数 */ + @Excel(name = "请求参数") + private String operParam; + + /** 操作状态(0正常 1异常) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=异常") + private Integer status; + + /** 错误消息 */ + @Excel(name = "错误消息") + private String errorMsg; + + /** 操作时间 */ + @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date operTime; + + public Long getOperId() + { + return operId; + } + + public void setOperId(Long operId) + { + this.operId = operId; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public Integer getBusinessType() + { + return businessType; + } + + public void setBusinessType(Integer businessType) + { + this.businessType = businessType; + } + + public Integer[] getBusinessTypes() + { + return businessTypes; + } + + public void setBusinessTypes(Integer[] businessTypes) + { + this.businessTypes = businessTypes; + } + + public String getMethod() + { + return method; + } + + public void setMethod(String method) + { + this.method = method; + } + + public Integer getOperatorType() + { + return operatorType; + } + + public void setOperatorType(Integer operatorType) + { + this.operatorType = operatorType; + } + + public String getOperName() + { + return operName; + } + + public void setOperName(String operName) + { + this.operName = operName; + } + + public String getDeptName() + { + return deptName; + } + + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + public String getOperUrl() + { + return operUrl; + } + + public void setOperUrl(String operUrl) + { + this.operUrl = operUrl; + } + + public String getOperIp() + { + return operIp; + } + + public void setOperIp(String operIp) + { + this.operIp = operIp; + } + + public String getOperLocation() + { + return operLocation; + } + + public void setOperLocation(String operLocation) + { + this.operLocation = operLocation; + } + + public String getOperParam() + { + return operParam; + } + + public void setOperParam(String operParam) + { + this.operParam = operParam; + } + + public Integer getStatus() + { + return status; + } + + public void setStatus(Integer status) + { + this.status = status; + } + + public String getErrorMsg() + { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) + { + this.errorMsg = errorMsg; + } + + public Date getOperTime() + { + return operTime; + } + + public void setOperTime(Date operTime) + { + this.operTime = operTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("operId", getOperId()) + .append("title", getTitle()) + .append("businessType", getBusinessType()) + .append("businessTypes", getBusinessTypes()) + .append("method", getMethod()) + .append("operatorType", getOperatorType()) + .append("operName", getOperName()) + .append("deptName", getDeptName()) + .append("operUrl", getOperUrl()) + .append("operIp", getOperIp()) + .append("operLocation", getOperLocation()) + .append("operParam", getOperParam()) + .append("status", getStatus()) + .append("errorMsg", getErrorMsg()) + .append("operTime", getOperTime()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysPost.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysPost.java index f279028a3..45c25cc62 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysPost.java @@ -1,121 +1,121 @@ -package com.ruoyi.system.domain; - -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 岗位表 sys_post - * - * @author ruoyi - */ -public class SysPost extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 岗位序号 */ - @Excel(name = "岗位序号") - private Long postId; - - /** 岗位编码 */ - @Excel(name = "岗位编码") - private String postCode; - - /** 岗位名称 */ - @Excel(name = "岗位名称") - private String postName; - - /** 岗位排序 */ - @Excel(name = "岗位排序") - private String postSort; - - /** 状态(0正常 1停用) */ - @Excel(name = "状态", readConverterExp = "0=正常,1=停用") - private String status; - - /** 用户是否存在此岗位标识 默认不存在 */ - private boolean flag = false; - - public Long getPostId() - { - return postId; - } - - public void setPostId(Long postId) - { - this.postId = postId; - } - - @NotBlank(message = "岗位编码不能为空") - @Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符") - public String getPostCode() - { - return postCode; - } - - public void setPostCode(String postCode) - { - this.postCode = postCode; - } - - @NotBlank(message = "岗位名称不能为空") - @Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符") - public String getPostName() - { - return postName; - } - - public void setPostName(String postName) - { - this.postName = postName; - } - - @NotBlank(message = "显示顺序不能为空") - public String getPostSort() - { - return postSort; - } - - public void setPostSort(String postSort) - { - this.postSort = postSort; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public boolean isFlag() - { - return flag; - } - - public void setFlag(boolean flag) - { - this.flag = flag; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("postId", getPostId()) - .append("postCode", getPostCode()) - .append("postName", getPostName()) - .append("postSort", getPostSort()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 岗位表 sys_post + * + * @author ruoyi + */ +public class SysPost extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 岗位序号 */ + @Excel(name = "岗位序号") + private Long postId; + + /** 岗位编码 */ + @Excel(name = "岗位编码") + private String postCode; + + /** 岗位名称 */ + @Excel(name = "岗位名称") + private String postName; + + /** 岗位排序 */ + @Excel(name = "岗位排序") + private String postSort; + + /** 状态(0正常 1停用) */ + @Excel(name = "状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** 用户是否存在此岗位标识 默认不存在 */ + private boolean flag = false; + + public Long getPostId() + { + return postId; + } + + public void setPostId(Long postId) + { + this.postId = postId; + } + + @NotBlank(message = "岗位编码不能为空") + @Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符") + public String getPostCode() + { + return postCode; + } + + public void setPostCode(String postCode) + { + this.postCode = postCode; + } + + @NotBlank(message = "岗位名称不能为空") + @Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符") + public String getPostName() + { + return postName; + } + + public void setPostName(String postName) + { + this.postName = postName; + } + + @NotBlank(message = "显示顺序不能为空") + public String getPostSort() + { + return postSort; + } + + public void setPostSort(String postSort) + { + this.postSort = postSort; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public boolean isFlag() + { + return flag; + } + + public void setFlag(boolean flag) + { + this.flag = flag; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("postId", getPostId()) + .append("postCode", getPostCode()) + .append("postName", getPostName()) + .append("postSort", getPostSort()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysRole.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysRole.java index c7778f764..7102c845f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysRole.java @@ -1,176 +1,176 @@ -package com.ruoyi.system.domain; - -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 角色表 sys_role - * - * @author ruoyi - */ -public class SysRole extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 角色ID */ - @Excel(name = "角色序号") - private Long roleId; - - /** 角色名称 */ - @Excel(name = "角色名称") - private String roleName; - - /** 角色权限 */ - @Excel(name = "角色权限") - private String roleKey; - - /** 角色排序 */ - @Excel(name = "角色排序") - private String roleSort; - - /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限) */ - @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限") - private String dataScope; - - /** 角色状态(0正常 1停用) */ - @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") - private String status; - - /** 删除标志(0代表存在 2代表删除) */ - private String delFlag; - - /** 用户是否存在此角色标识 默认不存在 */ - private boolean flag = false; - - /** 菜单组 */ - private Long[] menuIds; - - /** 部门组(数据权限) */ - private Long[] deptIds; - - public Long getRoleId() - { - return roleId; - } - - public void setRoleId(Long roleId) - { - this.roleId = roleId; - } - - public String getDataScope() - { - return dataScope; - } - - public void setDataScope(String dataScope) - { - this.dataScope = dataScope; - } - - @NotBlank(message = "角色名称不能为空") - @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") - public String getRoleName() - { - return roleName; - } - - public void setRoleName(String roleName) - { - this.roleName = roleName; - } - - @NotBlank(message = "权限字符不能为空") - @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") - public String getRoleKey() - { - return roleKey; - } - - public void setRoleKey(String roleKey) - { - this.roleKey = roleKey; - } - - @NotBlank(message = "显示顺序不能为空") - public String getRoleSort() - { - return roleSort; - } - - public void setRoleSort(String roleSort) - { - this.roleSort = roleSort; - } - - public String getStatus() - { - return status; - } - - public String getDelFlag() - { - return delFlag; - } - - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public void setStatus(String status) - { - this.status = status; - } - - public boolean isFlag() - { - return flag; - } - - public void setFlag(boolean flag) - { - this.flag = flag; - } - - public Long[] getMenuIds() - { - return menuIds; - } - - public void setMenuIds(Long[] menuIds) - { - this.menuIds = menuIds; - } - - public Long[] getDeptIds() - { - return deptIds; - } - - public void setDeptIds(Long[] deptIds) - { - this.deptIds = deptIds; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("roleId", getRoleId()) - .append("roleName", getRoleName()) - .append("roleKey", getRoleKey()) - .append("roleSort", getRoleSort()) - .append("dataScope", getDataScope()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 角色表 sys_role + * + * @author ruoyi + */ +public class SysRole extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 角色ID */ + @Excel(name = "角色序号") + private Long roleId; + + /** 角色名称 */ + @Excel(name = "角色名称") + private String roleName; + + /** 角色权限 */ + @Excel(name = "角色权限") + private String roleKey; + + /** 角色排序 */ + @Excel(name = "角色排序") + private String roleSort; + + /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限) */ + @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限") + private String dataScope; + + /** 角色状态(0正常 1停用) */ + @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + /** 用户是否存在此角色标识 默认不存在 */ + private boolean flag = false; + + /** 菜单组 */ + private Long[] menuIds; + + /** 部门组(数据权限) */ + private Long[] deptIds; + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + public String getDataScope() + { + return dataScope; + } + + public void setDataScope(String dataScope) + { + this.dataScope = dataScope; + } + + @NotBlank(message = "角色名称不能为空") + @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") + public String getRoleName() + { + return roleName; + } + + public void setRoleName(String roleName) + { + this.roleName = roleName; + } + + @NotBlank(message = "权限字符不能为空") + @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") + public String getRoleKey() + { + return roleKey; + } + + public void setRoleKey(String roleKey) + { + this.roleKey = roleKey; + } + + @NotBlank(message = "显示顺序不能为空") + public String getRoleSort() + { + return roleSort; + } + + public void setRoleSort(String roleSort) + { + this.roleSort = roleSort; + } + + public String getStatus() + { + return status; + } + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public void setStatus(String status) + { + this.status = status; + } + + public boolean isFlag() + { + return flag; + } + + public void setFlag(boolean flag) + { + this.flag = flag; + } + + public Long[] getMenuIds() + { + return menuIds; + } + + public void setMenuIds(Long[] menuIds) + { + this.menuIds = menuIds; + } + + public Long[] getDeptIds() + { + return deptIds; + } + + public void setDeptIds(Long[] deptIds) + { + this.deptIds = deptIds; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("roleName", getRoleName()) + .append("roleKey", getRoleKey()) + .append("roleSort", getRoleSort()) + .append("dataScope", getDataScope()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java similarity index 94% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java index 8ed8e473e..47b21bf79 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java @@ -1,46 +1,46 @@ -package com.ruoyi.system.domain; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -/** - * 角色和部门关联 sys_role_dept - * - * @author ruoyi - */ -public class SysRoleDept -{ - /** 角色ID */ - private Long roleId; - - /** 部门ID */ - private Long deptId; - - public Long getRoleId() - { - return roleId; - } - - public void setRoleId(Long roleId) - { - this.roleId = roleId; - } - - public Long getDeptId() - { - return deptId; - } - - public void setDeptId(Long deptId) - { - this.deptId = deptId; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("roleId", getRoleId()) - .append("deptId", getDeptId()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 角色和部门关联 sys_role_dept + * + * @author ruoyi + */ +public class SysRoleDept +{ + /** 角色ID */ + private Long roleId; + + /** 部门ID */ + private Long deptId; + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + public Long getDeptId() + { + return deptId; + } + + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("deptId", getDeptId()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java similarity index 94% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java index 59d286999..de10a7470 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java @@ -1,46 +1,46 @@ -package com.ruoyi.system.domain; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -/** - * 角色和菜单关联 sys_role_menu - * - * @author ruoyi - */ -public class SysRoleMenu -{ - /** 角色ID */ - private Long roleId; - - /** 菜单ID */ - private Long menuId; - - public Long getRoleId() - { - return roleId; - } - - public void setRoleId(Long roleId) - { - this.roleId = roleId; - } - - public Long getMenuId() - { - return menuId; - } - - public void setMenuId(Long menuId) - { - this.menuId = menuId; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("roleId", getRoleId()) - .append("menuId", getMenuId()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 角色和菜单关联 sys_role_menu + * + * @author ruoyi + */ +public class SysRoleMenu +{ + /** 角色ID */ + private Long roleId; + + /** 菜单ID */ + private Long menuId; + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + public Long getMenuId() + { + return menuId; + } + + public void setMenuId(Long menuId) + { + this.menuId = menuId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("menuId", getMenuId()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysUser.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysUser.java index 3a3158eee..6ced3dc8c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysUser.java @@ -1,340 +1,340 @@ -package com.ruoyi.system.domain; - -import java.util.Date; -import java.util.List; -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.annotation.Excel.Type; -import com.ruoyi.common.annotation.Excels; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 用户对象 sys_user - * - * @author ruoyi - */ -public class SysUser extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 用户ID */ - @Excel(name = "用户序号", prompt = "用户编号") - private Long userId; - - /** 部门ID */ - @Excel(name = "部门编号", type = Type.IMPORT) - private Long deptId; - - /** 部门父ID */ - private Long parentId; - - /** 角色ID */ - private Long roleId; - - /** 登录名称 */ - @Excel(name = "登录名称") - private String loginName; - - /** 用户名称 */ - @Excel(name = "用户名称") - private String userName; - - /** 用户邮箱 */ - @Excel(name = "用户邮箱") - private String email; - - /** 手机号码 */ - @Excel(name = "手机号码") - private String phonenumber; - - /** 用户性别 */ - @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") - private String sex; - - /** 用户头像 */ - private String avatar; - - /** 密码 */ - private String password; - - /** 盐加密 */ - private String salt; - - /** 帐号状态(0正常 1停用) */ - @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") - private String status; - - /** 删除标志(0代表存在 2代表删除) */ - private String delFlag; - - /** 最后登陆IP */ - @Excel(name = "最后登陆IP", type = Type.EXPORT) - private String loginIp; - - /** 最后登陆时间 */ - @Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) - private Date loginDate; - - /** 部门对象 */ - @Excels({ - @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), - @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) - }) - private SysDept dept; - - private List roles; - - /** 角色组 */ - private Long[] roleIds; - - /** 岗位组 */ - private Long[] postIds; - - public Long getUserId() - { - return userId; - } - - public void setUserId(Long userId) - { - this.userId = userId; - } - - public boolean isAdmin() - { - return isAdmin(this.userId); - } - - public static boolean isAdmin(Long userId) - { - return userId != null && 1L == userId; - } - - public Long getDeptId() - { - return deptId; - } - - public void setDeptId(Long deptId) - { - this.deptId = deptId; - } - - public Long getParentId() - { - return parentId; - } - - public void setParentId(Long parentId) - { - this.parentId = parentId; - } - - public Long getRoleId() - { - return roleId; - } - - public void setRoleId(Long roleId) - { - this.roleId = roleId; - } - - @NotBlank(message = "登录账号不能为空") - @Size(min = 0, max = 30, message = "登录账号长度不能超过30个字符") - public String getLoginName() - { - return loginName; - } - - public void setLoginName(String loginName) - { - this.loginName = loginName; - } - - @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") - public String getUserName() - { - return userName; - } - - public void setUserName(String userName) - { - this.userName = userName; - } - - @Email(message = "邮箱格式不正确") - @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") - public String getEmail() - { - return email; - } - - public void setEmail(String email) - { - this.email = email; - } - - @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") - public String getPhonenumber() - { - return phonenumber; - } - - public void setPhonenumber(String phonenumber) - { - this.phonenumber = phonenumber; - } - - public String getSex() - { - return sex; - } - - public void setSex(String sex) - { - this.sex = sex; - } - - public String getAvatar() - { - return avatar; - } - - public void setAvatar(String avatar) - { - this.avatar = avatar; - } - - public String getPassword() - { - return password; - } - - public void setPassword(String password) - { - this.password = password; - } - - public String getSalt() - { - return salt; - } - - public void setSalt(String salt) - { - this.salt = salt; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getDelFlag() - { - return delFlag; - } - - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public String getLoginIp() - { - return loginIp; - } - - public void setLoginIp(String loginIp) - { - this.loginIp = loginIp; - } - - public Date getLoginDate() - { - return loginDate; - } - - public void setLoginDate(Date loginDate) - { - this.loginDate = loginDate; - } - - public SysDept getDept() - { - if (dept == null) - { - dept = new SysDept(); - } - return dept; - } - - public void setDept(SysDept dept) - { - this.dept = dept; - } - - public List getRoles() - { - return roles; - } - - public void setRoles(List roles) - { - this.roles = roles; - } - - public Long[] getRoleIds() - { - return roleIds; - } - - public void setRoleIds(Long[] roleIds) - { - this.roleIds = roleIds; - } - - public Long[] getPostIds() - { - return postIds; - } - - public void setPostIds(Long[] postIds) - { - this.postIds = postIds; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("deptId", getDeptId()) - .append("loginName", getLoginName()) - .append("userName", getUserName()) - .append("email", getEmail()) - .append("phonenumber", getPhonenumber()) - .append("sex", getSex()) - .append("avatar", getAvatar()) - .append("password", getPassword()) - .append("salt", getSalt()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("loginIp", getLoginIp()) - .append("loginDate", getLoginDate()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .append("dept", getDept()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import java.util.Date; +import java.util.List; +import javax.validation.constraints.*; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.Type; +import com.ruoyi.common.annotation.Excels; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 用户对象 sys_user + * + * @author ruoyi + */ +public class SysUser extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 用户ID */ + @Excel(name = "用户序号", prompt = "用户编号") + private Long userId; + + /** 部门ID */ + @Excel(name = "部门编号", type = Type.IMPORT) + private Long deptId; + + /** 部门父ID */ + private Long parentId; + + /** 角色ID */ + private Long roleId; + + /** 登录名称 */ + @Excel(name = "登录名称") + private String loginName; + + /** 用户名称 */ + @Excel(name = "用户名称") + private String userName; + + /** 用户邮箱 */ + @Excel(name = "用户邮箱") + private String email; + + /** 手机号码 */ + @Excel(name = "手机号码") + private String phonenumber; + + /** 用户性别 */ + @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") + private String sex; + + /** 用户头像 */ + private String avatar; + + /** 密码 */ + private String password; + + /** 盐加密 */ + private String salt; + + /** 帐号状态(0正常 1停用) */ + @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + /** 最后登陆IP */ + @Excel(name = "最后登陆IP", type = Type.EXPORT) + private String loginIp; + + /** 最后登陆时间 */ + @Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) + private Date loginDate; + + /** 部门对象 */ + @Excels({ + @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), + @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) + }) + private SysDept dept; + + private List roles; + + /** 角色组 */ + private Long[] roleIds; + + /** 岗位组 */ + private Long[] postIds; + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public boolean isAdmin() + { + return isAdmin(this.userId); + } + + public static boolean isAdmin(Long userId) + { + return userId != null && 1L == userId; + } + + public Long getDeptId() + { + return deptId; + } + + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + public Long getParentId() + { + return parentId; + } + + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + @NotBlank(message = "登录账号不能为空") + @Size(min = 0, max = 30, message = "登录账号长度不能超过30个字符") + public String getLoginName() + { + return loginName; + } + + public void setLoginName(String loginName) + { + this.loginName = loginName; + } + + @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") + public String getUserName() + { + return userName; + } + + public void setUserName(String userName) + { + this.userName = userName; + } + + @Email(message = "邮箱格式不正确") + @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") + public String getPhonenumber() + { + return phonenumber; + } + + public void setPhonenumber(String phonenumber) + { + this.phonenumber = phonenumber; + } + + public String getSex() + { + return sex; + } + + public void setSex(String sex) + { + this.sex = sex; + } + + public String getAvatar() + { + return avatar; + } + + public void setAvatar(String avatar) + { + this.avatar = avatar; + } + + public String getPassword() + { + return password; + } + + public void setPassword(String password) + { + this.password = password; + } + + public String getSalt() + { + return salt; + } + + public void setSalt(String salt) + { + this.salt = salt; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getLoginIp() + { + return loginIp; + } + + public void setLoginIp(String loginIp) + { + this.loginIp = loginIp; + } + + public Date getLoginDate() + { + return loginDate; + } + + public void setLoginDate(Date loginDate) + { + this.loginDate = loginDate; + } + + public SysDept getDept() + { + if (dept == null) + { + dept = new SysDept(); + } + return dept; + } + + public void setDept(SysDept dept) + { + this.dept = dept; + } + + public List getRoles() + { + return roles; + } + + public void setRoles(List roles) + { + this.roles = roles; + } + + public Long[] getRoleIds() + { + return roleIds; + } + + public void setRoleIds(Long[] roleIds) + { + this.roleIds = roleIds; + } + + public Long[] getPostIds() + { + return postIds; + } + + public void setPostIds(Long[] postIds) + { + this.postIds = postIds; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("deptId", getDeptId()) + .append("loginName", getLoginName()) + .append("userName", getUserName()) + .append("email", getEmail()) + .append("phonenumber", getPhonenumber()) + .append("sex", getSex()) + .append("avatar", getAvatar()) + .append("password", getPassword()) + .append("salt", getSalt()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("loginIp", getLoginIp()) + .append("loginDate", getLoginDate()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("dept", getDept()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java index c5467bb66..e13506e4f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java @@ -1,177 +1,177 @@ -package com.ruoyi.system.domain; - -import java.util.Date; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.core.domain.BaseEntity; -import com.ruoyi.common.enums.OnlineStatus; - -/** - * 当前在线会话 sys_user_online - * - * @author ruoyi - */ -public class SysUserOnline extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 用户会话id */ - private String sessionId; - - /** 部门名称 */ - private String deptName; - - /** 登录名称 */ - private String loginName; - - /** 登录IP地址 */ - private String ipaddr; - - /** 登录地址 */ - private String loginLocation; - - /** 浏览器类型 */ - private String browser; - - /** 操作系统 */ - private String os; - - /** session创建时间 */ - private Date startTimestamp; - - /** session最后访问时间 */ - private Date lastAccessTime; - - /** 超时时间,单位为分钟 */ - private Long expireTime; - - /** 在线状态 */ - private OnlineStatus status = OnlineStatus.on_line; - - public String getSessionId() - { - return sessionId; - } - - public void setSessionId(String sessionId) - { - this.sessionId = sessionId; - } - - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - public String getLoginName() - { - return loginName; - } - - public void setLoginName(String loginName) - { - this.loginName = loginName; - } - - public String getIpaddr() - { - return ipaddr; - } - - public void setIpaddr(String ipaddr) - { - this.ipaddr = ipaddr; - } - - public String getLoginLocation() - { - return loginLocation; - } - - public void setLoginLocation(String loginLocation) - { - this.loginLocation = loginLocation; - } - - public String getBrowser() - { - return browser; - } - - public void setBrowser(String browser) - { - this.browser = browser; - } - - public String getOs() - { - return os; - } - - public void setOs(String os) - { - this.os = os; - } - - public Date getStartTimestamp() - { - return startTimestamp; - } - - public void setStartTimestamp(Date startTimestamp) - { - this.startTimestamp = startTimestamp; - } - - public Date getLastAccessTime() - { - return lastAccessTime; - } - - public void setLastAccessTime(Date lastAccessTime) - { - this.lastAccessTime = lastAccessTime; - } - - public Long getExpireTime() - { - return expireTime; - } - - public void setExpireTime(Long expireTime) - { - this.expireTime = expireTime; - } - - public OnlineStatus getStatus() - { - return status; - } - - public void setStatus(OnlineStatus status) - { - this.status = status; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("sessionId", getSessionId()) - .append("loginName", getLoginName()) - .append("deptName", getDeptName()) - .append("ipaddr", getIpaddr()) - .append("loginLocation", getLoginLocation()) - .append("browser", getBrowser()) - .append("os", getOs()) - .append("status", getStatus()) - .append("startTimestamp", getStartTimestamp()) - .append("lastAccessTime", getLastAccessTime()) - .append("expireTime", getExpireTime()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import java.util.Date; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.enums.OnlineStatus; + +/** + * 当前在线会话 sys_user_online + * + * @author ruoyi + */ +public class SysUserOnline extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 用户会话id */ + private String sessionId; + + /** 部门名称 */ + private String deptName; + + /** 登录名称 */ + private String loginName; + + /** 登录IP地址 */ + private String ipaddr; + + /** 登录地址 */ + private String loginLocation; + + /** 浏览器类型 */ + private String browser; + + /** 操作系统 */ + private String os; + + /** session创建时间 */ + private Date startTimestamp; + + /** session最后访问时间 */ + private Date lastAccessTime; + + /** 超时时间,单位为分钟 */ + private Long expireTime; + + /** 在线状态 */ + private OnlineStatus status = OnlineStatus.on_line; + + public String getSessionId() + { + return sessionId; + } + + public void setSessionId(String sessionId) + { + this.sessionId = sessionId; + } + + public String getDeptName() + { + return deptName; + } + + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + public String getLoginName() + { + return loginName; + } + + public void setLoginName(String loginName) + { + this.loginName = loginName; + } + + public String getIpaddr() + { + return ipaddr; + } + + public void setIpaddr(String ipaddr) + { + this.ipaddr = ipaddr; + } + + public String getLoginLocation() + { + return loginLocation; + } + + public void setLoginLocation(String loginLocation) + { + this.loginLocation = loginLocation; + } + + public String getBrowser() + { + return browser; + } + + public void setBrowser(String browser) + { + this.browser = browser; + } + + public String getOs() + { + return os; + } + + public void setOs(String os) + { + this.os = os; + } + + public Date getStartTimestamp() + { + return startTimestamp; + } + + public void setStartTimestamp(Date startTimestamp) + { + this.startTimestamp = startTimestamp; + } + + public Date getLastAccessTime() + { + return lastAccessTime; + } + + public void setLastAccessTime(Date lastAccessTime) + { + this.lastAccessTime = lastAccessTime; + } + + public Long getExpireTime() + { + return expireTime; + } + + public void setExpireTime(Long expireTime) + { + this.expireTime = expireTime; + } + + public OnlineStatus getStatus() + { + return status; + } + + public void setStatus(OnlineStatus status) + { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("sessionId", getSessionId()) + .append("loginName", getLoginName()) + .append("deptName", getDeptName()) + .append("ipaddr", getIpaddr()) + .append("loginLocation", getLoginLocation()) + .append("browser", getBrowser()) + .append("os", getOs()) + .append("status", getStatus()) + .append("startTimestamp", getStartTimestamp()) + .append("lastAccessTime", getLastAccessTime()) + .append("expireTime", getExpireTime()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java similarity index 94% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java index 07ceb85cc..6e8c416f2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java @@ -1,46 +1,46 @@ -package com.ruoyi.system.domain; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -/** - * 用户和岗位关联 sys_user_post - * - * @author ruoyi - */ -public class SysUserPost -{ - /** 用户ID */ - private Long userId; - - /** 岗位ID */ - private Long postId; - - public Long getUserId() - { - return userId; - } - - public void setUserId(Long userId) - { - this.userId = userId; - } - - public Long getPostId() - { - return postId; - } - - public void setPostId(Long postId) - { - this.postId = postId; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("postId", getPostId()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 用户和岗位关联 sys_user_post + * + * @author ruoyi + */ +public class SysUserPost +{ + /** 用户ID */ + private Long userId; + + /** 岗位ID */ + private Long postId; + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getPostId() + { + return postId; + } + + public void setPostId(Long postId) + { + this.postId = postId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("postId", getPostId()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java b/bmw-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java similarity index 94% rename from ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java rename to bmw-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java index ce2af2bda..4d1581014 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java +++ b/bmw-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java @@ -1,46 +1,46 @@ -package com.ruoyi.system.domain; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -/** - * 用户和角色关联 sys_user_role - * - * @author ruoyi - */ -public class SysUserRole -{ - /** 用户ID */ - private Long userId; - - /** 角色ID */ - private Long roleId; - - public Long getUserId() - { - return userId; - } - - public void setUserId(Long userId) - { - this.userId = userId; - } - - public Long getRoleId() - { - return roleId; - } - - public void setRoleId(Long roleId) - { - this.roleId = roleId; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("userId", getUserId()) - .append("roleId", getRoleId()) - .toString(); - } -} +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 用户和角色关联 sys_user_role + * + * @author ruoyi + */ +public class SysUserRole +{ + /** 用户ID */ + private Long userId; + + /** 角色ID */ + private Long roleId; + + public Long getUserId() + { + return userId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getRoleId() + { + return roleId; + } + + public void setRoleId(Long roleId) + { + this.roleId = roleId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("userId", getUserId()) + .append("roleId", getRoleId()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java index 9bc8482cc..36cab8fd0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java @@ -1,60 +1,60 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysConfig; - -/** - * 参数配置 数据层 - * - * @author ruoyi - */ -public interface SysConfigMapper -{ - /** - * 查询参数配置信息 - * - * @param config 参数配置信息 - * @return 参数配置信息 - */ - public SysConfig selectConfig(SysConfig config); - - /** - * 查询参数配置列表 - * - * @param config 参数配置信息 - * @return 参数配置集合 - */ - public List selectConfigList(SysConfig config); - - /** - * 根据键名查询参数配置信息 - * - * @param configKey 参数键名 - * @return 参数配置信息 - */ - public SysConfig checkConfigKeyUnique(String configKey); - - /** - * 新增参数配置 - * - * @param config 参数配置信息 - * @return 结果 - */ - public int insertConfig(SysConfig config); - - /** - * 修改参数配置 - * - * @param config 参数配置信息 - * @return 结果 - */ - public int updateConfig(SysConfig config); - - /** - * 批量删除参数配置 - * - * @param configIds 需要删除的数据ID - * @return 结果 - */ - public int deleteConfigByIds(String[] configIds); +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysConfig; + +/** + * 参数配置 数据层 + * + * @author ruoyi + */ +public interface SysConfigMapper +{ + /** + * 查询参数配置信息 + * + * @param config 参数配置信息 + * @return 参数配置信息 + */ + public SysConfig selectConfig(SysConfig config); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(SysConfig config); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数配置信息 + */ + public SysConfig checkConfigKeyUnique(String configKey); + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int insertConfig(SysConfig config); + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int updateConfig(SysConfig config); + + /** + * 批量删除参数配置 + * + * @param configIds 需要删除的数据ID + * @return 结果 + */ + public int deleteConfigByIds(String[] configIds); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 3dcc9713d..593ef75f3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -1,108 +1,108 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import org.apache.ibatis.annotations.Param; -import com.ruoyi.system.domain.SysDept; - -/** - * 部门管理 数据层 - * - * @author ruoyi - */ -public interface SysDeptMapper -{ - /** - * 查询部门人数 - * - * @param dept 部门信息 - * @return 结果 - */ - public int selectDeptCount(SysDept dept); - - /** - * 查询部门是否存在用户 - * - * @param deptId 部门ID - * @return 结果 - */ - public int checkDeptExistUser(Long deptId); - - /** - * 查询部门管理数据 - * - * @param dept 部门信息 - * @return 部门信息集合 - */ - public List selectDeptList(SysDept dept); - - /** - * 删除部门管理信息 - * - * @param deptId 部门ID - * @return 结果 - */ - public int deleteDeptById(Long deptId); - - /** - * 新增部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - public int insertDept(SysDept dept); - - /** - * 修改部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - public int updateDept(SysDept dept); - - /** - * 修改子元素关系 - * - * @param depts 子元素 - * @return 结果 - */ - public int updateDeptChildren(@Param("depts") List depts); - - /** - * 根据部门ID查询信息 - * - * @param deptId 部门ID - * @return 部门信息 - */ - public SysDept selectDeptById(Long deptId); - - /** - * 校验部门名称是否唯一 - * - * @param deptName 部门名称 - * @param parentId 父部门ID - * @return 结果 - */ - public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); - - /** - * 根据角色ID查询部门 - * - * @param roleId 角色ID - * @return 部门列表 - */ - public List selectRoleDeptTree(Long roleId); - - /** - * 修改所在部门的父级部门状态 - * - * @param dept 部门 - */ - public void updateDeptStatus(SysDept dept); - - /** - * 根据ID查询所有子部门 - * @param deptId 部门ID - * @return 部门列表 - */ - public List selectChildrenDeptById(Long deptId); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import org.apache.ibatis.annotations.Param; +import com.ruoyi.system.domain.SysDept; + +/** + * 部门管理 数据层 + * + * @author ruoyi + */ +public interface SysDeptMapper +{ + /** + * 查询部门人数 + * + * @param dept 部门信息 + * @return 结果 + */ + public int selectDeptCount(SysDept dept); + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 + */ + public int checkDeptExistUser(Long deptId); + + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectDeptList(SysDept dept); + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + public int deleteDeptById(Long deptId); + + /** + * 新增部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int insertDept(SysDept dept); + + /** + * 修改部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int updateDept(SysDept dept); + + /** + * 修改子元素关系 + * + * @param depts 子元素 + * @return 结果 + */ + public int updateDeptChildren(@Param("depts") List depts); + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + public SysDept selectDeptById(Long deptId); + + /** + * 校验部门名称是否唯一 + * + * @param deptName 部门名称 + * @param parentId 父部门ID + * @return 结果 + */ + public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); + + /** + * 根据角色ID查询部门 + * + * @param roleId 角色ID + * @return 部门列表 + */ + public List selectRoleDeptTree(Long roleId); + + /** + * 修改所在部门的父级部门状态 + * + * @param dept 部门 + */ + public void updateDeptStatus(SysDept dept); + + /** + * 根据ID查询所有子部门 + * @param deptId 部门ID + * @return 部门列表 + */ + public List selectChildrenDeptById(Long deptId); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java index ad251fdea..4c3691f41 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java @@ -1,95 +1,95 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import org.apache.ibatis.annotations.Param; -import com.ruoyi.system.domain.SysDictData; - -/** - * 字典表 数据层 - * - * @author ruoyi - */ -public interface SysDictDataMapper -{ - /** - * 根据条件分页查询字典数据 - * - * @param dictData 字典数据信息 - * @return 字典数据集合信息 - */ - public List selectDictDataList(SysDictData dictData); - - /** - * 根据字典类型查询字典数据 - * - * @param dictType 字典类型 - * @return 字典数据集合信息 - */ - public List selectDictDataByType(String dictType); - - /** - * 根据字典类型和字典键值查询字典数据信息 - * - * @param dictType 字典类型 - * @param dictValue 字典键值 - * @return 字典标签 - */ - public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue); - - /** - * 根据字典数据ID查询信息 - * - * @param dictCode 字典数据ID - * @return 字典数据 - */ - public SysDictData selectDictDataById(Long dictCode); - - /** - * 查询字典数据 - * - * @param dictType 字典类型 - * @return 字典数据 - */ - public int countDictDataByType(String dictType); - - /** - * 通过字典ID删除字典数据信息 - * - * @param dictCode 字典数据ID - * @return 结果 - */ - public int deleteDictDataById(Long dictCode); - - /** - * 批量删除字典数据 - * - * @param ids 需要删除的数据 - * @return 结果 - */ - public int deleteDictDataByIds(String[] ids); - - /** - * 新增字典数据信息 - * - * @param dictData 字典数据信息 - * @return 结果 - */ - public int insertDictData(SysDictData dictData); - - /** - * 修改字典数据信息 - * - * @param dictData 字典数据信息 - * @return 结果 - */ - public int updateDictData(SysDictData dictData); - - /** - * 同步修改字典类型 - * - * @param oldDictType 旧字典类型 - * @param newDictType 新旧字典类型 - * @return 结果 - */ - public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import org.apache.ibatis.annotations.Param; +import com.ruoyi.system.domain.SysDictData; + +/** + * 字典表 数据层 + * + * @author ruoyi + */ +public interface SysDictDataMapper +{ + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + public List selectDictDataList(SysDictData dictData); + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue); + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + public SysDictData selectDictDataById(Long dictCode); + + /** + * 查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据 + */ + public int countDictDataByType(String dictType); + + /** + * 通过字典ID删除字典数据信息 + * + * @param dictCode 字典数据ID + * @return 结果 + */ + public int deleteDictDataById(Long dictCode); + + /** + * 批量删除字典数据 + * + * @param ids 需要删除的数据 + * @return 结果 + */ + public int deleteDictDataByIds(String[] ids); + + /** + * 新增字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int insertDictData(SysDictData dictData); + + /** + * 修改字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int updateDictData(SysDictData dictData); + + /** + * 同步修改字典类型 + * + * @param oldDictType 旧字典类型 + * @param newDictType 新旧字典类型 + * @return 结果 + */ + public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java index b2beb2122..51f068466 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java @@ -1,77 +1,77 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import org.apache.ibatis.annotations.Mapper; -import com.ruoyi.system.domain.SysDictType; - -/** - * 字典表 数据层 - * - * @author ruoyi - */ -@Mapper -public interface SysDictTypeMapper -{ - /** - * 根据条件分页查询字典类型 - * - * @param dictType 字典类型信息 - * @return 字典类型集合信息 - */ - public List selectDictTypeList(SysDictType dictType); - - /** - * 根据所有字典类型 - * - * @return 字典类型集合信息 - */ - public List selectDictTypeAll(); - - /** - * 根据字典类型ID查询信息 - * - * @param dictId 字典类型ID - * @return 字典类型 - */ - public SysDictType selectDictTypeById(Long dictId); - - /** - * 通过字典ID删除字典信息 - * - * @param dictId 字典ID - * @return 结果 - */ - public int deleteDictTypeById(Long dictId); - - /** - * 批量删除字典类型 - * - * @param ids 需要删除的数据 - * @return 结果 - */ - public int deleteDictTypeByIds(Long[] ids); - - /** - * 新增字典类型信息 - * - * @param dictType 字典类型信息 - * @return 结果 - */ - public int insertDictType(SysDictType dictType); - - /** - * 修改字典类型信息 - * - * @param dictType 字典类型信息 - * @return 结果 - */ - public int updateDictType(SysDictType dictType); - - /** - * 校验字典类型称是否唯一 - * - * @param dictType 字典类型 - * @return 结果 - */ - public SysDictType checkDictTypeUnique(String dictType); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import org.apache.ibatis.annotations.Mapper; +import com.ruoyi.system.domain.SysDictType; + +/** + * 字典表 数据层 + * + * @author ruoyi + */ +@Mapper +public interface SysDictTypeMapper +{ + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + public List selectDictTypeList(SysDictType dictType); + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + public List selectDictTypeAll(); + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + public SysDictType selectDictTypeById(Long dictId); + + /** + * 通过字典ID删除字典信息 + * + * @param dictId 字典ID + * @return 结果 + */ + public int deleteDictTypeById(Long dictId); + + /** + * 批量删除字典类型 + * + * @param ids 需要删除的数据 + * @return 结果 + */ + public int deleteDictTypeByIds(Long[] ids); + + /** + * 新增字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int insertDictType(SysDictType dictType); + + /** + * 修改字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int updateDictType(SysDictType dictType); + + /** + * 校验字典类型称是否唯一 + * + * @param dictType 字典类型 + * @return 结果 + */ + public SysDictType checkDictTypeUnique(String dictType); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java index 0efe3d7e8..7ee47dc23 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java @@ -1,42 +1,42 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysLogininfor; - -/** - * 系统访问日志情况信息 数据层 - * - * @author ruoyi - */ -public interface SysLogininforMapper -{ - /** - * 新增系统登录日志 - * - * @param logininfor 访问日志对象 - */ - public void insertLogininfor(SysLogininfor logininfor); - - /** - * 查询系统登录日志集合 - * - * @param logininfor 访问日志对象 - * @return 登录记录集合 - */ - public List selectLogininforList(SysLogininfor logininfor); - - /** - * 批量删除系统登录日志 - * - * @param ids 需要删除的数据 - * @return 结果 - */ - public int deleteLogininforByIds(String[] ids); - - /** - * 清空系统登录日志 - * - * @return 结果 - */ - public int cleanLogininfor(); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysLogininfor; + +/** + * 系统访问日志情况信息 数据层 + * + * @author ruoyi + */ +public interface SysLogininforMapper +{ + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + public void insertLogininfor(SysLogininfor logininfor); + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + public List selectLogininforList(SysLogininfor logininfor); + + /** + * 批量删除系统登录日志 + * + * @param ids 需要删除的数据 + * @return 结果 + */ + public int deleteLogininforByIds(String[] ids); + + /** + * 清空系统登录日志 + * + * @return 结果 + */ + public int cleanLogininfor(); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java index 4b09dda5f..a5f69ed2e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java @@ -1,124 +1,124 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import org.apache.ibatis.annotations.Param; -import com.ruoyi.system.domain.SysMenu; - -/** - * 菜单表 数据层 - * - * @author ruoyi - */ -public interface SysMenuMapper -{ - /** - * 查询系统所有菜单(含按钮) - * - * @return 菜单列表 - */ - public List selectMenuAll(); - - /** - * 根据用户ID查询菜单 - * - * @param userId 用户ID - * @return 菜单列表 - */ - public List selectMenuAllByUserId(Long userId); - - /** - * 查询系统正常显示菜单(不含按钮) - * - * @return 菜单列表 - */ - public List selectMenuNormalAll(); - - /** - * 根据用户ID查询菜单 - * - * @param userId 用户ID - * @return 菜单列表 - */ - public List selectMenusByUserId(Long userId); - - /** - * 根据用户ID查询权限 - * - * @param userId 用户ID - * @return 权限列表 - */ - public List selectPermsByUserId(Long userId); - - /** - * 根据角色ID查询菜单 - * - * @param roleId 角色ID - * @return 菜单列表 - */ - public List selectMenuTree(Long roleId); - - /** - * 查询系统菜单列表 - * - * @param menu 菜单信息 - * @return 菜单列表 - */ - public List selectMenuList(SysMenu menu); - - /** - * 查询系统菜单列表 - * - * @param menu 菜单信息 - * @return 菜单列表 - */ - public List selectMenuListByUserId(SysMenu menu); - - /** - * 删除菜单管理信息 - * - * @param menuId 菜单ID - * @return 结果 - */ - public int deleteMenuById(Long menuId); - - /** - * 根据菜单ID查询信息 - * - * @param menuId 菜单ID - * @return 菜单信息 - */ - public SysMenu selectMenuById(Long menuId); - - /** - * 查询菜单数量 - * - * @param parentId 菜单父ID - * @return 结果 - */ - public int selectCountMenuByParentId(Long parentId); - - /** - * 新增菜单信息 - * - * @param menu 菜单信息 - * @return 结果 - */ - public int insertMenu(SysMenu menu); - - /** - * 修改菜单信息 - * - * @param menu 菜单信息 - * @return 结果 - */ - public int updateMenu(SysMenu menu); - - /** - * 校验菜单名称是否唯一 - * - * @param menuName 菜单名称 - * @param parentId 父菜单ID - * @return 结果 - */ - public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import org.apache.ibatis.annotations.Param; +import com.ruoyi.system.domain.SysMenu; + +/** + * 菜单表 数据层 + * + * @author ruoyi + */ +public interface SysMenuMapper +{ + /** + * 查询系统所有菜单(含按钮) + * + * @return 菜单列表 + */ + public List selectMenuAll(); + + /** + * 根据用户ID查询菜单 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuAllByUserId(Long userId); + + /** + * 查询系统正常显示菜单(不含按钮) + * + * @return 菜单列表 + */ + public List selectMenuNormalAll(); + + /** + * 根据用户ID查询菜单 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenusByUserId(Long userId); + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public List selectPermsByUserId(Long userId); + + /** + * 根据角色ID查询菜单 + * + * @param roleId 角色ID + * @return 菜单列表 + */ + public List selectMenuTree(Long roleId); + + /** + * 查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + public List selectMenuList(SysMenu menu); + + /** + * 查询系统菜单列表 + * + * @param menu 菜单信息 + * @return 菜单列表 + */ + public List selectMenuListByUserId(SysMenu menu); + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int deleteMenuById(Long menuId); + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + public SysMenu selectMenuById(Long menuId); + + /** + * 查询菜单数量 + * + * @param parentId 菜单父ID + * @return 结果 + */ + public int selectCountMenuByParentId(Long parentId); + + /** + * 新增菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int insertMenu(SysMenu menu); + + /** + * 修改菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int updateMenu(SysMenu menu); + + /** + * 校验菜单名称是否唯一 + * + * @param menuName 菜单名称 + * @param parentId 父菜单ID + * @return 结果 + */ + public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java index 1ce1d8cde..dd402e2c5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java @@ -1,52 +1,52 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysNotice; - -/** - * 公告 数据层 - * - * @author ruoyi - */ -public interface SysNoticeMapper -{ - /** - * 查询公告信息 - * - * @param noticeId 公告ID - * @return 公告信息 - */ - public SysNotice selectNoticeById(Long noticeId); - - /** - * 查询公告列表 - * - * @param notice 公告信息 - * @return 公告集合 - */ - public List selectNoticeList(SysNotice notice); - - /** - * 新增公告 - * - * @param notice 公告信息 - * @return 结果 - */ - public int insertNotice(SysNotice notice); - - /** - * 修改公告 - * - * @param notice 公告信息 - * @return 结果 - */ - public int updateNotice(SysNotice notice); - - /** - * 批量删除公告 - * - * @param noticeIds 需要删除的数据ID - * @return 结果 - */ - public int deleteNoticeByIds(String[] noticeIds); +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysNotice; + +/** + * 公告 数据层 + * + * @author ruoyi + */ +public interface SysNoticeMapper +{ + /** + * 查询公告信息 + * + * @param noticeId 公告ID + * @return 公告信息 + */ + public SysNotice selectNoticeById(Long noticeId); + + /** + * 查询公告列表 + * + * @param notice 公告信息 + * @return 公告集合 + */ + public List selectNoticeList(SysNotice notice); + + /** + * 新增公告 + * + * @param notice 公告信息 + * @return 结果 + */ + public int insertNotice(SysNotice notice); + + /** + * 修改公告 + * + * @param notice 公告信息 + * @return 结果 + */ + public int updateNotice(SysNotice notice); + + /** + * 批量删除公告 + * + * @param noticeIds 需要删除的数据ID + * @return 结果 + */ + public int deleteNoticeByIds(String[] noticeIds); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java index 98ca5d130..b40bd29c4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java @@ -1,48 +1,48 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysOperLog; - -/** - * 操作日志 数据层 - * - * @author ruoyi - */ -public interface SysOperLogMapper -{ - /** - * 新增操作日志 - * - * @param operLog 操作日志对象 - */ - public void insertOperlog(SysOperLog operLog); - - /** - * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 - * @return 操作日志集合 - */ - public List selectOperLogList(SysOperLog operLog); - - /** - * 批量删除系统操作日志 - * - * @param ids 需要删除的数据 - * @return 结果 - */ - public int deleteOperLogByIds(String[] ids); - - /** - * 查询操作日志详细 - * - * @param operId 操作ID - * @return 操作日志对象 - */ - public SysOperLog selectOperLogById(Long operId); - - /** - * 清空操作日志 - */ - public void cleanOperLog(); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysOperLog; + +/** + * 操作日志 数据层 + * + * @author ruoyi + */ +public interface SysOperLogMapper +{ + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + */ + public void insertOperlog(SysOperLog operLog); + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + public List selectOperLogList(SysOperLog operLog); + + /** + * 批量删除系统操作日志 + * + * @param ids 需要删除的数据 + * @return 结果 + */ + public int deleteOperLogByIds(String[] ids); + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + public SysOperLog selectOperLogById(Long operId); + + /** + * 清空操作日志 + */ + public void cleanOperLog(); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java index a4aab595b..188f3355f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java @@ -1,83 +1,83 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysPost; - -/** - * 岗位信息 数据层 - * - * @author ruoyi - */ -public interface SysPostMapper -{ - /** - * 查询岗位数据集合 - * - * @param post 岗位信息 - * @return 岗位数据集合 - */ - public List selectPostList(SysPost post); - - /** - * 查询所有岗位 - * - * @return 岗位列表 - */ - public List selectPostAll(); - - /** - * 根据用户ID查询岗位 - * - * @param userId 用户ID - * @return 岗位列表 - */ - public List selectPostsByUserId(Long userId); - - /** - * 通过岗位ID查询岗位信息 - * - * @param postId 岗位ID - * @return 角色对象信息 - */ - public SysPost selectPostById(Long postId); - - /** - * 批量删除岗位信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deletePostByIds(Long[] ids); - - /** - * 修改岗位信息 - * - * @param post 岗位信息 - * @return 结果 - */ - public int updatePost(SysPost post); - - /** - * 新增岗位信息 - * - * @param post 岗位信息 - * @return 结果 - */ - public int insertPost(SysPost post); - - /** - * 校验岗位名称 - * - * @param postName 岗位名称 - * @return 结果 - */ - public SysPost checkPostNameUnique(String postName); - - /** - * 校验岗位编码 - * - * @param postCode 岗位编码 - * @return 结果 - */ - public SysPost checkPostCodeUnique(String postCode); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysPost; + +/** + * 岗位信息 数据层 + * + * @author ruoyi + */ +public interface SysPostMapper +{ + /** + * 查询岗位数据集合 + * + * @param post 岗位信息 + * @return 岗位数据集合 + */ + public List selectPostList(SysPost post); + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + public List selectPostAll(); + + /** + * 根据用户ID查询岗位 + * + * @param userId 用户ID + * @return 岗位列表 + */ + public List selectPostsByUserId(Long userId); + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + public SysPost selectPostById(Long postId); + + /** + * 批量删除岗位信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deletePostByIds(Long[] ids); + + /** + * 修改岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int updatePost(SysPost post); + + /** + * 新增岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int insertPost(SysPost post); + + /** + * 校验岗位名称 + * + * @param postName 岗位名称 + * @return 结果 + */ + public SysPost checkPostNameUnique(String postName); + + /** + * 校验岗位编码 + * + * @param postCode 岗位编码 + * @return 结果 + */ + public SysPost checkPostCodeUnique(String postCode); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java index a4ad4de24..f9d3a2f39 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java @@ -1,44 +1,44 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysRoleDept; - -/** - * 角色与部门关联表 数据层 - * - * @author ruoyi - */ -public interface SysRoleDeptMapper -{ - /** - * 通过角色ID删除角色和部门关联 - * - * @param roleId 角色ID - * @return 结果 - */ - public int deleteRoleDeptByRoleId(Long roleId); - - /** - * 批量删除角色部门关联信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteRoleDept(Long[] ids); - - /** - * 查询部门使用数量 - * - * @param deptId 部门ID - * @return 结果 - */ - public int selectCountRoleDeptByDeptId(Long deptId); - - /** - * 批量新增角色部门信息 - * - * @param roleDeptList 角色部门列表 - * @return 结果 - */ - public int batchRoleDept(List roleDeptList); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysRoleDept; + +/** + * 角色与部门关联表 数据层 + * + * @author ruoyi + */ +public interface SysRoleDeptMapper +{ + /** + * 通过角色ID删除角色和部门关联 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleDeptByRoleId(Long roleId); + + /** + * 批量删除角色部门关联信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteRoleDept(Long[] ids); + + /** + * 查询部门使用数量 + * + * @param deptId 部门ID + * @return 结果 + */ + public int selectCountRoleDeptByDeptId(Long deptId); + + /** + * 批量新增角色部门信息 + * + * @param roleDeptList 角色部门列表 + * @return 结果 + */ + public int batchRoleDept(List roleDeptList); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java index 8c2ea6501..eca02da99 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java @@ -1,84 +1,84 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysRole; - -/** - * 角色表 数据层 - * - * @author ruoyi - */ -public interface SysRoleMapper -{ - /** - * 根据条件分页查询角色数据 - * - * @param role 角色信息 - * @return 角色数据集合信息 - */ - public List selectRoleList(SysRole role); - - /** - * 根据用户ID查询角色 - * - * @param userId 用户ID - * @return 角色列表 - */ - public List selectRolesByUserId(Long userId); - - /** - * 通过角色ID查询角色 - * - * @param roleId 角色ID - * @return 角色对象信息 - */ - public SysRole selectRoleById(Long roleId); - - /** - * 通过角色ID删除角色 - * - * @param roleId 角色ID - * @return 结果 - */ - public int deleteRoleById(Long roleId); - - /** - * 批量角色用户信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteRoleByIds(Long[] ids); - - /** - * 修改角色信息 - * - * @param role 角色信息 - * @return 结果 - */ - public int updateRole(SysRole role); - - /** - * 新增角色信息 - * - * @param role 角色信息 - * @return 结果 - */ - public int insertRole(SysRole role); - - /** - * 校验角色名称是否唯一 - * - * @param roleName 角色名称 - * @return 角色信息 - */ - public SysRole checkRoleNameUnique(String roleName); - - /** - * 校验角色权限是否唯一 - * - * @param roleKey 角色权限 - * @return 角色信息 - */ - public SysRole checkRoleKeyUnique(String roleKey); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysRole; + +/** + * 角色表 数据层 + * + * @author ruoyi + */ +public interface SysRoleMapper +{ + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + public List selectRoleList(SysRole role); + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolesByUserId(Long userId); + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + public SysRole selectRoleById(Long roleId); + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleById(Long roleId); + + /** + * 批量角色用户信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteRoleByIds(Long[] ids); + + /** + * 修改角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int updateRole(SysRole role); + + /** + * 新增角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int insertRole(SysRole role); + + /** + * 校验角色名称是否唯一 + * + * @param roleName 角色名称 + * @return 角色信息 + */ + public SysRole checkRoleNameUnique(String roleName); + + /** + * 校验角色权限是否唯一 + * + * @param roleKey 角色权限 + * @return 角色信息 + */ + public SysRole checkRoleKeyUnique(String roleKey); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java index 5ed98f294..9b8879663 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java @@ -1,44 +1,44 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysRoleMenu; - -/** - * 角色与菜单关联表 数据层 - * - * @author ruoyi - */ -public interface SysRoleMenuMapper -{ - /** - * 通过角色ID删除角色和菜单关联 - * - * @param roleId 角色ID - * @return 结果 - */ - public int deleteRoleMenuByRoleId(Long roleId); - - /** - * 批量删除角色菜单关联信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteRoleMenu(Long[] ids); - - /** - * 查询菜单使用数量 - * - * @param menuId 菜单ID - * @return 结果 - */ - public int selectCountRoleMenuByMenuId(Long menuId); - - /** - * 批量新增角色菜单信息 - * - * @param roleMenuList 角色菜单列表 - * @return 结果 - */ - public int batchRoleMenu(List roleMenuList); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysRoleMenu; + +/** + * 角色与菜单关联表 数据层 + * + * @author ruoyi + */ +public interface SysRoleMenuMapper +{ + /** + * 通过角色ID删除角色和菜单关联 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteRoleMenuByRoleId(Long roleId); + + /** + * 批量删除角色菜单关联信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteRoleMenu(Long[] ids); + + /** + * 查询菜单使用数量 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int selectCountRoleMenuByMenuId(Long menuId); + + /** + * 批量新增角色菜单信息 + * + * @param roleMenuList 角色菜单列表 + * @return 结果 + */ + public int batchRoleMenu(List roleMenuList); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index ab4a15fe6..c7ebaf039 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -1,124 +1,124 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysUser; - -/** - * 用户表 数据层 - * - * @author ruoyi - */ -public interface SysUserMapper -{ - /** - * 根据条件分页查询用户列表 - * - * @param sysUser 用户信息 - * @return 用户信息集合信息 - */ - public List selectUserList(SysUser sysUser); - - /** - * 根据条件分页查询未已配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - public List selectAllocatedList(SysUser user); - - /** - * 根据条件分页查询未分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - public List selectUnallocatedList(SysUser user); - - /** - * 通过用户名查询用户 - * - * @param userName 用户名 - * @return 用户对象信息 - */ - public SysUser selectUserByLoginName(String userName); - - /** - * 通过手机号码查询用户 - * - * @param phoneNumber 手机号码 - * @return 用户对象信息 - */ - public SysUser selectUserByPhoneNumber(String phoneNumber); - - /** - * 通过邮箱查询用户 - * - * @param email 邮箱 - * @return 用户对象信息 - */ - public SysUser selectUserByEmail(String email); - - /** - * 通过用户ID查询用户 - * - * @param userId 用户ID - * @return 用户对象信息 - */ - public SysUser selectUserById(Long userId); - - /** - * 通过用户ID删除用户 - * - * @param userId 用户ID - * @return 结果 - */ - public int deleteUserById(Long userId); - - /** - * 批量删除用户信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteUserByIds(Long[] ids); - - /** - * 修改用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - public int updateUser(SysUser user); - - /** - * 新增用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - public int insertUser(SysUser user); - - /** - * 校验用户名称是否唯一 - * - * @param loginName 登录名称 - * @return 结果 - */ - public int checkLoginNameUnique(String loginName); - - /** - * 校验手机号码是否唯一 - * - * @param phonenumber 手机号码 - * @return 结果 - */ - public SysUser checkPhoneUnique(String phonenumber); - - /** - * 校验email是否唯一 - * - * @param email 用户邮箱 - * @return 结果 - */ - public SysUser checkEmailUnique(String email); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysUser; + +/** + * 用户表 数据层 + * + * @author ruoyi + */ +public interface SysUserMapper +{ + /** + * 根据条件分页查询用户列表 + * + * @param sysUser 用户信息 + * @return 用户信息集合信息 + */ + public List selectUserList(SysUser sysUser); + + /** + * 根据条件分页查询未已配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectAllocatedList(SysUser user); + + /** + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectUnallocatedList(SysUser user); + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + public SysUser selectUserByLoginName(String userName); + + /** + * 通过手机号码查询用户 + * + * @param phoneNumber 手机号码 + * @return 用户对象信息 + */ + public SysUser selectUserByPhoneNumber(String phoneNumber); + + /** + * 通过邮箱查询用户 + * + * @param email 邮箱 + * @return 用户对象信息 + */ + public SysUser selectUserByEmail(String email); + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + public SysUser selectUserById(Long userId); + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserById(Long userId); + + /** + * 批量删除用户信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteUserByIds(Long[] ids); + + /** + * 修改用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUser(SysUser user); + + /** + * 新增用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int insertUser(SysUser user); + + /** + * 校验用户名称是否唯一 + * + * @param loginName 登录名称 + * @return 结果 + */ + public int checkLoginNameUnique(String loginName); + + /** + * 校验手机号码是否唯一 + * + * @param phonenumber 手机号码 + * @return 结果 + */ + public SysUser checkPhoneUnique(String phonenumber); + + /** + * 校验email是否唯一 + * + * @param email 用户邮箱 + * @return 结果 + */ + public SysUser checkEmailUnique(String email); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java index c6bf94cd2..5bd68edff 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java @@ -1,52 +1,52 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysUserOnline; - -/** - * 在线用户 数据层 - * - * @author ruoyi - */ -public interface SysUserOnlineMapper -{ - /** - * 通过会话序号查询信息 - * - * @param sessionId 会话ID - * @return 在线用户信息 - */ - public SysUserOnline selectOnlineById(String sessionId); - - /** - * 通过会话序号删除信息 - * - * @param sessionId 会话ID - * @return 在线用户信息 - */ - public int deleteOnlineById(String sessionId); - - /** - * 保存会话信息 - * - * @param online 会话信息 - * @return 结果 - */ - public int saveOnline(SysUserOnline online); - - /** - * 查询会话集合 - * - * @param userOnline 会话参数 - * @return 会话集合 - */ - public List selectUserOnlineList(SysUserOnline userOnline); - - /** - * 查询过期会话集合 - * - * @param lastAccessTime 过期时间 - * @return 会话集合 - */ - public List selectOnlineByExpired(String lastAccessTime); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysUserOnline; + +/** + * 在线用户 数据层 + * + * @author ruoyi + */ +public interface SysUserOnlineMapper +{ + /** + * 通过会话序号查询信息 + * + * @param sessionId 会话ID + * @return 在线用户信息 + */ + public SysUserOnline selectOnlineById(String sessionId); + + /** + * 通过会话序号删除信息 + * + * @param sessionId 会话ID + * @return 在线用户信息 + */ + public int deleteOnlineById(String sessionId); + + /** + * 保存会话信息 + * + * @param online 会话信息 + * @return 结果 + */ + public int saveOnline(SysUserOnline online); + + /** + * 查询会话集合 + * + * @param userOnline 会话参数 + * @return 会话集合 + */ + public List selectUserOnlineList(SysUserOnline userOnline); + + /** + * 查询过期会话集合 + * + * @param lastAccessTime 过期时间 + * @return 会话集合 + */ + public List selectOnlineByExpired(String lastAccessTime); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java index d2e8e7e5e..348c44f20 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java @@ -1,44 +1,44 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import com.ruoyi.system.domain.SysUserPost; - -/** - * 用户与岗位 表 数据层 - * - * @author ruoyi - */ -public interface SysUserPostMapper -{ - /** - * 通过用户ID删除用户和岗位关联 - * - * @param userId 用户ID - * @return 结果 - */ - public int deleteUserPostByUserId(Long userId); - - /** - * 通过岗位ID查询岗位使用数量 - * - * @param postId 岗位ID - * @return 结果 - */ - public int countUserPostById(Long postId); - - /** - * 批量删除用户和岗位关联 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteUserPost(Long[] ids); - - /** - * 批量新增用户岗位信息 - * - * @param userPostList 用户角色列表 - * @return 结果 - */ - public int batchUserPost(List userPostList); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.SysUserPost; + +/** + * 用户与岗位 表 数据层 + * + * @author ruoyi + */ +public interface SysUserPostMapper +{ + /** + * 通过用户ID删除用户和岗位关联 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserPostByUserId(Long userId); + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + public int countUserPostById(Long postId); + + /** + * 批量删除用户和岗位关联 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteUserPost(Long[] ids); + + /** + * 批量新增用户岗位信息 + * + * @param userPostList 用户角色列表 + * @return 结果 + */ + public int batchUserPost(List userPostList); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java rename to bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java index fa099c17d..e2b1c0ca5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java +++ b/bmw-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java @@ -1,62 +1,62 @@ -package com.ruoyi.system.mapper; - -import java.util.List; -import org.apache.ibatis.annotations.Param; -import com.ruoyi.system.domain.SysUserRole; - -/** - * 用户表 数据层 - * - * @author ruoyi - */ -public interface SysUserRoleMapper -{ - /** - * 通过用户ID删除用户和角色关联 - * - * @param userId 用户ID - * @return 结果 - */ - public int deleteUserRoleByUserId(Long userId); - - /** - * 批量删除用户和角色关联 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteUserRole(Long[] ids); - - /** - * 通过角色ID查询角色使用数量 - * - * @param roleId 角色ID - * @return 结果 - */ - public int countUserRoleByRoleId(Long roleId); - - /** - * 批量新增用户角色信息 - * - * @param userRoleList 用户角色列表 - * @return 结果 - */ - public int batchUserRole(List userRoleList); - - /** - * 删除用户和角色关联信息 - * - * @param userRole 用户和角色关联信息 - * @return 结果 - */ - public int deleteUserRoleInfo(SysUserRole userRole); - - /** - * 批量取消授权用户角色 - * - * @param roleId 角色ID - * @param userIds 需要删除的用户数据ID - * @return 结果 - */ - public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds); -} +package com.ruoyi.system.mapper; + +import java.util.List; +import org.apache.ibatis.annotations.Param; +import com.ruoyi.system.domain.SysUserRole; + +/** + * 用户表 数据层 + * + * @author ruoyi + */ +public interface SysUserRoleMapper +{ + /** + * 通过用户ID删除用户和角色关联 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserRoleByUserId(Long userId); + + /** + * 批量删除用户和角色关联 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteUserRole(Long[] ids); + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + public int countUserRoleByRoleId(Long roleId); + + /** + * 批量新增用户角色信息 + * + * @param userRoleList 用户角色列表 + * @return 结果 + */ + public int batchUserRole(List userRoleList); + + /** + * 删除用户和角色关联信息 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + public int deleteUserRoleInfo(SysUserRole userRole); + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java index 949bf44c9..a1e269b89 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java @@ -1,68 +1,68 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysConfig; - -/** - * 参数配置 服务层 - * - * @author ruoyi - */ -public interface ISysConfigService -{ - /** - * 查询参数配置信息 - * - * @param configId 参数配置ID - * @return 参数配置信息 - */ - public SysConfig selectConfigById(Long configId); - - /** - * 根据键名查询参数配置信息 - * - * @param configKey 参数键名 - * @return 参数键值 - */ - public String selectConfigByKey(String configKey); - - /** - * 查询参数配置列表 - * - * @param config 参数配置信息 - * @return 参数配置集合 - */ - public List selectConfigList(SysConfig config); - - /** - * 新增参数配置 - * - * @param config 参数配置信息 - * @return 结果 - */ - public int insertConfig(SysConfig config); - - /** - * 修改参数配置 - * - * @param config 参数配置信息 - * @return 结果 - */ - public int updateConfig(SysConfig config); - - /** - * 批量删除参数配置信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteConfigByIds(String ids); - - /** - * 校验参数键名是否唯一 - * - * @param config 参数信息 - * @return 结果 - */ - public String checkConfigKeyUnique(SysConfig config); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysConfig; + +/** + * 参数配置 服务层 + * + * @author ruoyi + */ +public interface ISysConfigService +{ + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + public SysConfig selectConfigById(Long configId); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数键值 + */ + public String selectConfigByKey(String configKey); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(SysConfig config); + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int insertConfig(SysConfig config); + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int updateConfig(SysConfig config); + + /** + * 批量删除参数配置信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteConfigByIds(String ids); + + /** + * 校验参数键名是否唯一 + * + * @param config 参数信息 + * @return 结果 + */ + public String checkConfigKeyUnique(SysConfig config); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index 6e75df247..f73a0b7d8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -1,94 +1,94 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.common.core.domain.Ztree; -import com.ruoyi.system.domain.SysDept; -import com.ruoyi.system.domain.SysRole; - -/** - * 部门管理 服务层 - * - * @author ruoyi - */ -public interface ISysDeptService -{ - /** - * 查询部门管理数据 - * - * @param dept 部门信息 - * @return 部门信息集合 - */ - public List selectDeptList(SysDept dept); - - /** - * 查询部门管理树 - * - * @param dept 部门信息 - * @return 所有部门信息 - */ - public List selectDeptTree(SysDept dept); - - /** - * 根据角色ID查询菜单 - * - * @param role 角色对象 - * @return 菜单列表 - */ - public List roleDeptTreeData(SysRole role); - - /** - * 查询部门人数 - * - * @param parentId 父部门ID - * @return 结果 - */ - public int selectDeptCount(Long parentId); - - /** - * 查询部门是否存在用户 - * - * @param deptId 部门ID - * @return 结果 true 存在 false 不存在 - */ - public boolean checkDeptExistUser(Long deptId); - - /** - * 删除部门管理信息 - * - * @param deptId 部门ID - * @return 结果 - */ - public int deleteDeptById(Long deptId); - - /** - * 新增保存部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - public int insertDept(SysDept dept); - - /** - * 修改保存部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - public int updateDept(SysDept dept); - - /** - * 根据部门ID查询信息 - * - * @param deptId 部门ID - * @return 部门信息 - */ - public SysDept selectDeptById(Long deptId); - - /** - * 校验部门名称是否唯一 - * - * @param dept 部门信息 - * @return 结果 - */ - public String checkDeptNameUnique(SysDept dept); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.system.domain.SysDept; +import com.ruoyi.system.domain.SysRole; + +/** + * 部门管理 服务层 + * + * @author ruoyi + */ +public interface ISysDeptService +{ + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectDeptList(SysDept dept); + + /** + * 查询部门管理树 + * + * @param dept 部门信息 + * @return 所有部门信息 + */ + public List selectDeptTree(SysDept dept); + + /** + * 根据角色ID查询菜单 + * + * @param role 角色对象 + * @return 菜单列表 + */ + public List roleDeptTreeData(SysRole role); + + /** + * 查询部门人数 + * + * @param parentId 父部门ID + * @return 结果 + */ + public int selectDeptCount(Long parentId); + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 true 存在 false 不存在 + */ + public boolean checkDeptExistUser(Long deptId); + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + public int deleteDeptById(Long deptId); + + /** + * 新增保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int insertDept(SysDept dept); + + /** + * 修改保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + public int updateDept(SysDept dept); + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + public SysDept selectDeptById(Long deptId); + + /** + * 校验部门名称是否唯一 + * + * @param dept 部门信息 + * @return 结果 + */ + public String checkDeptNameUnique(SysDept dept); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java index 68d68d812..5403a0f9b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java @@ -1,77 +1,77 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysDictData; - -/** - * 字典 业务层 - * - * @author ruoyi - */ -public interface ISysDictDataService -{ - /** - * 根据条件分页查询字典数据 - * - * @param dictData 字典数据信息 - * @return 字典数据集合信息 - */ - public List selectDictDataList(SysDictData dictData); - - /** - * 根据字典类型查询字典数据 - * - * @param dictType 字典类型 - * @return 字典数据集合信息 - */ - public List selectDictDataByType(String dictType); - - /** - * 根据字典类型和字典键值查询字典数据信息 - * - * @param dictType 字典类型 - * @param dictValue 字典键值 - * @return 字典标签 - */ - public String selectDictLabel(String dictType, String dictValue); - - /** - * 根据字典数据ID查询信息 - * - * @param dictCode 字典数据ID - * @return 字典数据 - */ - public SysDictData selectDictDataById(Long dictCode); - - /** - * 通过字典ID删除字典数据信息 - * - * @param dictCode 字典数据ID - * @return 结果 - */ - public int deleteDictDataById(Long dictCode); - - /** - * 批量删除字典数据 - * - * @param ids 需要删除的数据 - * @return 结果 - */ - public int deleteDictDataByIds(String ids); - - /** - * 新增保存字典数据信息 - * - * @param dictData 字典数据信息 - * @return 结果 - */ - public int insertDictData(SysDictData dictData); - - /** - * 修改保存字典数据信息 - * - * @param dictData 字典数据信息 - * @return 结果 - */ - public int updateDictData(SysDictData dictData); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysDictData; + +/** + * 字典 业务层 + * + * @author ruoyi + */ +public interface ISysDictDataService +{ + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + public List selectDictDataList(SysDictData dictData); + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + public String selectDictLabel(String dictType, String dictValue); + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + public SysDictData selectDictDataById(Long dictCode); + + /** + * 通过字典ID删除字典数据信息 + * + * @param dictCode 字典数据ID + * @return 结果 + */ + public int deleteDictDataById(Long dictCode); + + /** + * 批量删除字典数据 + * + * @param ids 需要删除的数据 + * @return 结果 + */ + public int deleteDictDataByIds(String ids); + + /** + * 新增保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int insertDictData(SysDictData dictData); + + /** + * 修改保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + public int updateDictData(SysDictData dictData); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java index 0039de632..3b15d3462 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java @@ -1,76 +1,76 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysDictType; - -/** - * 字典 业务层 - * - * @author ruoyi - */ -public interface ISysDictTypeService -{ - /** - * 根据条件分页查询字典类型 - * - * @param dictType 字典类型信息 - * @return 字典类型集合信息 - */ - public List selectDictTypeList(SysDictType dictType); - - /** - * 根据所有字典类型 - * - * @return 字典类型集合信息 - */ - public List selectDictTypeAll(); - - /** - * 根据字典类型ID查询信息 - * - * @param dictId 字典类型ID - * @return 字典类型 - */ - public SysDictType selectDictTypeById(Long dictId); - - /** - * 通过字典ID删除字典信息 - * - * @param dictId 字典ID - * @return 结果 - */ - public int deleteDictTypeById(Long dictId); - - /** - * 批量删除字典类型 - * - * @param ids 需要删除的数据 - * @return 结果 - * @throws Exception 异常 - */ - public int deleteDictTypeByIds(String ids) throws Exception; - - /** - * 新增保存字典类型信息 - * - * @param dictType 字典类型信息 - * @return 结果 - */ - public int insertDictType(SysDictType dictType); - - /** - * 修改保存字典类型信息 - * - * @param dictType 字典类型信息 - * @return 结果 - */ - public int updateDictType(SysDictType dictType); - - /** - * 校验字典类型称是否唯一 - * - * @param dictType 字典类型 - * @return 结果 - */ - public String checkDictTypeUnique(SysDictType dictType); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysDictType; + +/** + * 字典 业务层 + * + * @author ruoyi + */ +public interface ISysDictTypeService +{ + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + public List selectDictTypeList(SysDictType dictType); + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + public List selectDictTypeAll(); + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + public SysDictType selectDictTypeById(Long dictId); + + /** + * 通过字典ID删除字典信息 + * + * @param dictId 字典ID + * @return 结果 + */ + public int deleteDictTypeById(Long dictId); + + /** + * 批量删除字典类型 + * + * @param ids 需要删除的数据 + * @return 结果 + * @throws Exception 异常 + */ + public int deleteDictTypeByIds(String ids) throws Exception; + + /** + * 新增保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int insertDictType(SysDictType dictType); + + /** + * 修改保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + public int updateDictType(SysDictType dictType); + + /** + * 校验字典类型称是否唯一 + * + * @param dictType 字典类型 + * @return 结果 + */ + public String checkDictTypeUnique(SysDictType dictType); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java index 8e292c25b..159bb458b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java @@ -1,40 +1,40 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysLogininfor; - -/** - * 系统访问日志情况信息 服务层 - * - * @author ruoyi - */ -public interface ISysLogininforService -{ - /** - * 新增系统登录日志 - * - * @param logininfor 访问日志对象 - */ - public void insertLogininfor(SysLogininfor logininfor); - - /** - * 查询系统登录日志集合 - * - * @param logininfor 访问日志对象 - * @return 登录记录集合 - */ - public List selectLogininforList(SysLogininfor logininfor); - - /** - * 批量删除系统登录日志 - * - * @param ids 需要删除的数据 - * @return - */ - public int deleteLogininforByIds(String ids); - - /** - * 清空系统登录日志 - */ - public void cleanLogininfor(); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysLogininfor; + +/** + * 系统访问日志情况信息 服务层 + * + * @author ruoyi + */ +public interface ISysLogininforService +{ + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + public void insertLogininfor(SysLogininfor logininfor); + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + public List selectLogininforList(SysLogininfor logininfor); + + /** + * 批量删除系统登录日志 + * + * @param ids 需要删除的数据 + * @return + */ + public int deleteLogininforByIds(String ids); + + /** + * 清空系统登录日志 + */ + public void cleanLogininfor(); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java index 04cb8e091..b63def943 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java @@ -1,131 +1,131 @@ -package com.ruoyi.system.service; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import com.ruoyi.common.core.domain.Ztree; -import com.ruoyi.system.domain.SysMenu; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.domain.SysUser; - -/** - * 菜单 业务层 - * - * @author ruoyi - */ -public interface ISysMenuService -{ - /** - * 根据用户ID查询菜单 - * - * @param user 用户信息 - * @return 菜单列表 - */ - public List selectMenusByUser(SysUser user); - - /** - * 查询系统菜单列表 - * - * @param menu 菜单信息 - * @param userId 用户ID - * @return 菜单列表 - */ - public List selectMenuList(SysMenu menu, Long userId); - - /** - * 查询菜单集合 - * - * @param userId 用户ID - * @return 所有菜单信息 - */ - public List selectMenuAll(Long userId); - - /** - * 根据用户ID查询权限 - * - * @param userId 用户ID - * @return 权限列表 - */ - public Set selectPermsByUserId(Long userId); - - /** - * 根据角色ID查询菜单 - * - * @param role 角色对象 - * @param userId 用户ID - * @return 菜单列表 - */ - public List roleMenuTreeData(SysRole role, Long userId); - - /** - * 查询所有菜单信息 - * - * @param userId 用户ID - * @return 菜单列表 - */ - public List menuTreeData(Long userId); - - /** - * 查询系统所有权限 - * - * @param userId 用户ID - * @return 权限列表 - */ - public Map selectPermsAll(Long userId); - - /** - * 删除菜单管理信息 - * - * @param menuId 菜单ID - * @return 结果 - */ - public int deleteMenuById(Long menuId); - - /** - * 根据菜单ID查询信息 - * - * @param menuId 菜单ID - * @return 菜单信息 - */ - public SysMenu selectMenuById(Long menuId); - - /** - * 查询菜单数量 - * - * @param parentId 菜单父ID - * @return 结果 - */ - public int selectCountMenuByParentId(Long parentId); - - /** - * 查询菜单使用数量 - * - * @param menuId 菜单ID - * @return 结果 - */ - public int selectCountRoleMenuByMenuId(Long menuId); - - /** - * 新增保存菜单信息 - * - * @param menu 菜单信息 - * @return 结果 - */ - public int insertMenu(SysMenu menu); - - /** - * 修改保存菜单信息 - * - * @param menu 菜单信息 - * @return 结果 - */ - public int updateMenu(SysMenu menu); - - /** - * 校验菜单名称是否唯一 - * - * @param menu 菜单信息 - * @return 结果 - */ - public String checkMenuNameUnique(SysMenu menu); -} +package com.ruoyi.system.service; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.system.domain.SysMenu; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.domain.SysUser; + +/** + * 菜单 业务层 + * + * @author ruoyi + */ +public interface ISysMenuService +{ + /** + * 根据用户ID查询菜单 + * + * @param user 用户信息 + * @return 菜单列表 + */ + public List selectMenusByUser(SysUser user); + + /** + * 查询系统菜单列表 + * + * @param menu 菜单信息 + * @param userId 用户ID + * @return 菜单列表 + */ + public List selectMenuList(SysMenu menu, Long userId); + + /** + * 查询菜单集合 + * + * @param userId 用户ID + * @return 所有菜单信息 + */ + public List selectMenuAll(Long userId); + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public Set selectPermsByUserId(Long userId); + + /** + * 根据角色ID查询菜单 + * + * @param role 角色对象 + * @param userId 用户ID + * @return 菜单列表 + */ + public List roleMenuTreeData(SysRole role, Long userId); + + /** + * 查询所有菜单信息 + * + * @param userId 用户ID + * @return 菜单列表 + */ + public List menuTreeData(Long userId); + + /** + * 查询系统所有权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + public Map selectPermsAll(Long userId); + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int deleteMenuById(Long menuId); + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + public SysMenu selectMenuById(Long menuId); + + /** + * 查询菜单数量 + * + * @param parentId 菜单父ID + * @return 结果 + */ + public int selectCountMenuByParentId(Long parentId); + + /** + * 查询菜单使用数量 + * + * @param menuId 菜单ID + * @return 结果 + */ + public int selectCountRoleMenuByMenuId(Long menuId); + + /** + * 新增保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int insertMenu(SysMenu menu); + + /** + * 修改保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + public int updateMenu(SysMenu menu); + + /** + * 校验菜单名称是否唯一 + * + * @param menu 菜单信息 + * @return 结果 + */ + public String checkMenuNameUnique(SysMenu menu); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java similarity index 94% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java index abd6d7afc..6398b5a81 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java @@ -1,52 +1,52 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysNotice; - -/** - * 公告 服务层 - * - * @author ruoyi - */ -public interface ISysNoticeService -{ - /** - * 查询公告信息 - * - * @param noticeId 公告ID - * @return 公告信息 - */ - public SysNotice selectNoticeById(Long noticeId); - - /** - * 查询公告列表 - * - * @param notice 公告信息 - * @return 公告集合 - */ - public List selectNoticeList(SysNotice notice); - - /** - * 新增公告 - * - * @param notice 公告信息 - * @return 结果 - */ - public int insertNotice(SysNotice notice); - - /** - * 修改公告 - * - * @param notice 公告信息 - * @return 结果 - */ - public int updateNotice(SysNotice notice); - - /** - * 删除公告信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteNoticeByIds(String ids); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysNotice; + +/** + * 公告 服务层 + * + * @author ruoyi + */ +public interface ISysNoticeService +{ + /** + * 查询公告信息 + * + * @param noticeId 公告ID + * @return 公告信息 + */ + public SysNotice selectNoticeById(Long noticeId); + + /** + * 查询公告列表 + * + * @param notice 公告信息 + * @return 公告集合 + */ + public List selectNoticeList(SysNotice notice); + + /** + * 新增公告 + * + * @param notice 公告信息 + * @return 结果 + */ + public int insertNotice(SysNotice notice); + + /** + * 修改公告 + * + * @param notice 公告信息 + * @return 结果 + */ + public int updateNotice(SysNotice notice); + + /** + * 删除公告信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteNoticeByIds(String ids); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java index 61efe6020..3cdc5d269 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java @@ -1,48 +1,48 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysOperLog; - -/** - * 操作日志 服务层 - * - * @author ruoyi - */ -public interface ISysOperLogService -{ - /** - * 新增操作日志 - * - * @param operLog 操作日志对象 - */ - public void insertOperlog(SysOperLog operLog); - - /** - * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 - * @return 操作日志集合 - */ - public List selectOperLogList(SysOperLog operLog); - - /** - * 批量删除系统操作日志 - * - * @param ids 需要删除的数据 - * @return 结果 - */ - public int deleteOperLogByIds(String ids); - - /** - * 查询操作日志详细 - * - * @param operId 操作ID - * @return 操作日志对象 - */ - public SysOperLog selectOperLogById(Long operId); - - /** - * 清空操作日志 - */ - public void cleanOperLog(); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysOperLog; + +/** + * 操作日志 服务层 + * + * @author ruoyi + */ +public interface ISysOperLogService +{ + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + */ + public void insertOperlog(SysOperLog operLog); + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + public List selectOperLogList(SysOperLog operLog); + + /** + * 批量删除系统操作日志 + * + * @param ids 需要删除的数据 + * @return 结果 + */ + public int deleteOperLogByIds(String ids); + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + public SysOperLog selectOperLogById(Long operId); + + /** + * 清空操作日志 + */ + public void cleanOperLog(); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysPostService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysPostService.java index bbf7b784f..53013cb4a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysPostService.java @@ -1,92 +1,92 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysPost; - -/** - * 岗位信息 服务层 - * - * @author ruoyi - */ -public interface ISysPostService -{ - /** - * 查询岗位信息集合 - * - * @param post 岗位信息 - * @return 岗位信息集合 - */ - public List selectPostList(SysPost post); - - /** - * 查询所有岗位 - * - * @return 岗位列表 - */ - public List selectPostAll(); - - /** - * 根据用户ID查询岗位 - * - * @param userId 用户ID - * @return 岗位列表 - */ - public List selectPostsByUserId(Long userId); - - /** - * 通过岗位ID查询岗位信息 - * - * @param postId 岗位ID - * @return 角色对象信息 - */ - public SysPost selectPostById(Long postId); - - /** - * 批量删除岗位信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - * @throws Exception 异常 - */ - public int deletePostByIds(String ids) throws Exception; - - /** - * 新增保存岗位信息 - * - * @param post 岗位信息 - * @return 结果 - */ - public int insertPost(SysPost post); - - /** - * 修改保存岗位信息 - * - * @param post 岗位信息 - * @return 结果 - */ - public int updatePost(SysPost post); - - /** - * 通过岗位ID查询岗位使用数量 - * - * @param postId 岗位ID - * @return 结果 - */ - public int countUserPostById(Long postId); - - /** - * 校验岗位名称 - * - * @param post 岗位信息 - * @return 结果 - */ - public String checkPostNameUnique(SysPost post); - - /** - * 校验岗位编码 - * - * @param post 岗位信息 - * @return 结果 - */ - public String checkPostCodeUnique(SysPost post); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysPost; + +/** + * 岗位信息 服务层 + * + * @author ruoyi + */ +public interface ISysPostService +{ + /** + * 查询岗位信息集合 + * + * @param post 岗位信息 + * @return 岗位信息集合 + */ + public List selectPostList(SysPost post); + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + public List selectPostAll(); + + /** + * 根据用户ID查询岗位 + * + * @param userId 用户ID + * @return 岗位列表 + */ + public List selectPostsByUserId(Long userId); + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + public SysPost selectPostById(Long postId); + + /** + * 批量删除岗位信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + * @throws Exception 异常 + */ + public int deletePostByIds(String ids) throws Exception; + + /** + * 新增保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int insertPost(SysPost post); + + /** + * 修改保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + public int updatePost(SysPost post); + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + public int countUserPostById(Long postId); + + /** + * 校验岗位名称 + * + * @param post 岗位信息 + * @return 结果 + */ + public String checkPostNameUnique(SysPost post); + + /** + * 校验岗位编码 + * + * @param post 岗位信息 + * @return 结果 + */ + public String checkPostCodeUnique(SysPost post); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java index 0c8d30eee..c16f5ccf5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java @@ -1,151 +1,151 @@ -package com.ruoyi.system.service; - -import java.util.List; -import java.util.Set; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.domain.SysUserRole; - -/** - * 角色业务层 - * - * @author ruoyi - */ -public interface ISysRoleService -{ - /** - * 根据条件分页查询角色数据 - * - * @param role 角色信息 - * @return 角色数据集合信息 - */ - public List selectRoleList(SysRole role); - - /** - * 根据用户ID查询角色 - * - * @param userId 用户ID - * @return 权限列表 - */ - public Set selectRoleKeys(Long userId); - - /** - * 根据用户ID查询角色 - * - * @param userId 用户ID - * @return 角色列表 - */ - public List selectRolesByUserId(Long userId); - - /** - * 查询所有角色 - * - * @return 角色列表 - */ - public List selectRoleAll(); - - /** - * 通过角色ID查询角色 - * - * @param roleId 角色ID - * @return 角色对象信息 - */ - public SysRole selectRoleById(Long roleId); - - /** - * 通过角色ID删除角色 - * - * @param roleId 角色ID - * @return 结果 - */ - public boolean deleteRoleById(Long roleId); - - /** - * 批量删除角色用户信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - * @throws Exception 异常 - */ - public int deleteRoleByIds(String ids) throws Exception; - - /** - * 新增保存角色信息 - * - * @param role 角色信息 - * @return 结果 - */ - public int insertRole(SysRole role); - - /** - * 修改保存角色信息 - * - * @param role 角色信息 - * @return 结果 - */ - public int updateRole(SysRole role); - - /** - * 修改数据权限信息 - * - * @param role 角色信息 - * @return 结果 - */ - public int authDataScope(SysRole role); - - /** - * 校验角色名称是否唯一 - * - * @param role 角色信息 - * @return 结果 - */ - public String checkRoleNameUnique(SysRole role); - - /** - * 校验角色权限是否唯一 - * - * @param role 角色信息 - * @return 结果 - */ - public String checkRoleKeyUnique(SysRole role); - - /** - * 通过角色ID查询角色使用数量 - * - * @param roleId 角色ID - * @return 结果 - */ - public int countUserRoleByRoleId(Long roleId); - - /** - * 角色状态修改 - * - * @param role 角色信息 - * @return 结果 - */ - public int changeStatus(SysRole role); - /** - * 取消授权用户角色 - * - * @param userRole 用户和角色关联信息 - * @return 结果 - */ - public int deleteAuthUser(SysUserRole userRole); - - /** - * 批量取消授权用户角色 - * - * @param roleId 角色ID - * @param userIds 需要删除的用户数据ID - * @return 结果 - */ - public int deleteAuthUsers(Long roleId, String userIds); - - /** - * 批量选择授权用户角色 - * - * @param roleId 角色ID - * @param userIds 需要删除的用户数据ID - * @return 结果 - */ - public int insertAuthUsers(Long roleId, String userIds); -} +package com.ruoyi.system.service; + +import java.util.List; +import java.util.Set; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.domain.SysUserRole; + +/** + * 角色业务层 + * + * @author ruoyi + */ +public interface ISysRoleService +{ + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + public List selectRoleList(SysRole role); + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 权限列表 + */ + public Set selectRoleKeys(Long userId); + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + public List selectRolesByUserId(Long userId); + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + public List selectRoleAll(); + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + public SysRole selectRoleById(Long roleId); + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + public boolean deleteRoleById(Long roleId); + + /** + * 批量删除角色用户信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + * @throws Exception 异常 + */ + public int deleteRoleByIds(String ids) throws Exception; + + /** + * 新增保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int insertRole(SysRole role); + + /** + * 修改保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int updateRole(SysRole role); + + /** + * 修改数据权限信息 + * + * @param role 角色信息 + * @return 结果 + */ + public int authDataScope(SysRole role); + + /** + * 校验角色名称是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + public String checkRoleNameUnique(SysRole role); + + /** + * 校验角色权限是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + public String checkRoleKeyUnique(SysRole role); + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + public int countUserRoleByRoleId(Long roleId); + + /** + * 角色状态修改 + * + * @param role 角色信息 + * @return 结果 + */ + public int changeStatus(SysRole role); + /** + * 取消授权用户角色 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + public int deleteAuthUser(SysUserRole userRole); + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int deleteAuthUsers(Long roleId, String userIds); + + /** + * 批量选择授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int insertAuthUsers(Long roleId, String userIds); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java index 1ed908064..2b3545c1c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java @@ -1,67 +1,67 @@ -package com.ruoyi.system.service; - -import java.util.Date; -import java.util.List; -import com.ruoyi.system.domain.SysUserOnline; - -/** - * 在线用户 服务层 - * - * @author ruoyi - */ -public interface ISysUserOnlineService -{ - /** - * 通过会话序号查询信息 - * - * @param sessionId 会话ID - * @return 在线用户信息 - */ - public SysUserOnline selectOnlineById(String sessionId); - - /** - * 通过会话序号删除信息 - * - * @param sessionId 会话ID - * @return 在线用户信息 - */ - public void deleteOnlineById(String sessionId); - - /** - * 通过会话序号删除信息 - * - * @param sessions 会话ID集合 - * @return 在线用户信息 - */ - public void batchDeleteOnline(List sessions); - - /** - * 保存会话信息 - * - * @param online 会话信息 - */ - public void saveOnline(SysUserOnline online); - - /** - * 查询会话集合 - * - * @param userOnline 分页参数 - * @return 会话集合 - */ - public List selectUserOnlineList(SysUserOnline userOnline); - - /** - * 强退用户 - * - * @param sessionId 会话ID - */ - public void forceLogout(String sessionId); - - /** - * 查询会话集合 - * - * @param expiredDate 有效期 - * @return 会话集合 - */ - public List selectOnlineByExpired(Date expiredDate); -} +package com.ruoyi.system.service; + +import java.util.Date; +import java.util.List; +import com.ruoyi.system.domain.SysUserOnline; + +/** + * 在线用户 服务层 + * + * @author ruoyi + */ +public interface ISysUserOnlineService +{ + /** + * 通过会话序号查询信息 + * + * @param sessionId 会话ID + * @return 在线用户信息 + */ + public SysUserOnline selectOnlineById(String sessionId); + + /** + * 通过会话序号删除信息 + * + * @param sessionId 会话ID + * @return 在线用户信息 + */ + public void deleteOnlineById(String sessionId); + + /** + * 通过会话序号删除信息 + * + * @param sessions 会话ID集合 + * @return 在线用户信息 + */ + public void batchDeleteOnline(List sessions); + + /** + * 保存会话信息 + * + * @param online 会话信息 + */ + public void saveOnline(SysUserOnline online); + + /** + * 查询会话集合 + * + * @param userOnline 分页参数 + * @return 会话集合 + */ + public List selectUserOnlineList(SysUserOnline userOnline); + + /** + * 强退用户 + * + * @param sessionId 会话ID + */ + public void forceLogout(String sessionId); + + /** + * 查询会话集合 + * + * @param expiredDate 有效期 + * @return 会话集合 + */ + public List selectOnlineByExpired(Date expiredDate); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/bmw-system/src/main/java/com/ruoyi/system/service/ISysUserService.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java rename to bmw-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index db9ee61c6..3b34be679 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -1,175 +1,175 @@ -package com.ruoyi.system.service; - -import java.util.List; -import com.ruoyi.system.domain.SysUser; - -/** - * 用户 业务层 - * - * @author ruoyi - */ -public interface ISysUserService -{ - /** - * 根据条件分页查询用户列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - public List selectUserList(SysUser user); - - /** - * 根据条件分页查询已分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - public List selectAllocatedList(SysUser user); - - /** - * 根据条件分页查询未分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - public List selectUnallocatedList(SysUser user); - - /** - * 通过用户名查询用户 - * - * @param userName 用户名 - * @return 用户对象信息 - */ - public SysUser selectUserByLoginName(String userName); - - /** - * 通过手机号码查询用户 - * - * @param phoneNumber 手机号码 - * @return 用户对象信息 - */ - public SysUser selectUserByPhoneNumber(String phoneNumber); - - /** - * 通过邮箱查询用户 - * - * @param email 邮箱 - * @return 用户对象信息 - */ - public SysUser selectUserByEmail(String email); - - /** - * 通过用户ID查询用户 - * - * @param userId 用户ID - * @return 用户对象信息 - */ - public SysUser selectUserById(Long userId); - - /** - * 通过用户ID删除用户 - * - * @param userId 用户ID - * @return 结果 - */ - public int deleteUserById(Long userId); - - /** - * 批量删除用户信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - * @throws Exception 异常 - */ - public int deleteUserByIds(String ids) throws Exception; - - /** - * 保存用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - public int insertUser(SysUser user); - - /** - * 保存用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - public int updateUser(SysUser user); - - /** - * 修改用户详细信息 - * - * @param user 用户信息 - * @return 结果 - */ - public int updateUserInfo(SysUser user); - - /** - * 修改用户密码信息 - * - * @param user 用户信息 - * @return 结果 - */ - public int resetUserPwd(SysUser user); - - /** - * 校验用户名称是否唯一 - * - * @param loginName 登录名称 - * @return 结果 - */ - public String checkLoginNameUnique(String loginName); - - /** - * 校验手机号码是否唯一 - * - * @param user 用户信息 - * @return 结果 - */ - public String checkPhoneUnique(SysUser user); - - /** - * 校验email是否唯一 - * - * @param user 用户信息 - * @return 结果 - */ - public String checkEmailUnique(SysUser user); - - /** - * 根据用户ID查询用户所属角色组 - * - * @param userId 用户ID - * @return 结果 - */ - public String selectUserRoleGroup(Long userId); - - /** - * 根据用户ID查询用户所属岗位组 - * - * @param userId 用户ID - * @return 结果 - */ - public String selectUserPostGroup(Long userId); - - /** - * 导入用户数据 - * - * @param userList 用户数据列表 - * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 - * @param operName 操作用户 - * @return 结果 - */ - public String importUser(List userList, Boolean isUpdateSupport, String operName); - - /** - * 用户状态修改 - * - * @param user 用户信息 - * @return 结果 - */ - public int changeStatus(SysUser user); -} +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.SysUser; + +/** + * 用户 业务层 + * + * @author ruoyi + */ +public interface ISysUserService +{ + /** + * 根据条件分页查询用户列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectUserList(SysUser user); + + /** + * 根据条件分页查询已分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectAllocatedList(SysUser user); + + /** + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + public List selectUnallocatedList(SysUser user); + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + public SysUser selectUserByLoginName(String userName); + + /** + * 通过手机号码查询用户 + * + * @param phoneNumber 手机号码 + * @return 用户对象信息 + */ + public SysUser selectUserByPhoneNumber(String phoneNumber); + + /** + * 通过邮箱查询用户 + * + * @param email 邮箱 + * @return 用户对象信息 + */ + public SysUser selectUserByEmail(String email); + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + public SysUser selectUserById(Long userId); + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + public int deleteUserById(Long userId); + + /** + * 批量删除用户信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + * @throws Exception 异常 + */ + public int deleteUserByIds(String ids) throws Exception; + + /** + * 保存用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int insertUser(SysUser user); + + /** + * 保存用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUser(SysUser user); + + /** + * 修改用户详细信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int updateUserInfo(SysUser user); + + /** + * 修改用户密码信息 + * + * @param user 用户信息 + * @return 结果 + */ + public int resetUserPwd(SysUser user); + + /** + * 校验用户名称是否唯一 + * + * @param loginName 登录名称 + * @return 结果 + */ + public String checkLoginNameUnique(String loginName); + + /** + * 校验手机号码是否唯一 + * + * @param user 用户信息 + * @return 结果 + */ + public String checkPhoneUnique(SysUser user); + + /** + * 校验email是否唯一 + * + * @param user 用户信息 + * @return 结果 + */ + public String checkEmailUnique(SysUser user); + + /** + * 根据用户ID查询用户所属角色组 + * + * @param userId 用户ID + * @return 结果 + */ + public String selectUserRoleGroup(Long userId); + + /** + * 根据用户ID查询用户所属岗位组 + * + * @param userId 用户ID + * @return 结果 + */ + public String selectUserPostGroup(Long userId); + + /** + * 导入用户数据 + * + * @param userList 用户数据列表 + * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @param operName 操作用户 + * @return 结果 + */ + public String importUser(List userList, Boolean isUpdateSupport, String operName); + + /** + * 用户状态修改 + * + * @param user 用户信息 + * @return 结果 + */ + public int changeStatus(SysUser user); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index 8b2a02d0a..bd3fd164a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -1,118 +1,118 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.system.domain.SysConfig; -import com.ruoyi.system.mapper.SysConfigMapper; -import com.ruoyi.system.service.ISysConfigService; - -/** - * 参数配置 服务层实现 - * - * @author ruoyi - */ -@Service -public class SysConfigServiceImpl implements ISysConfigService -{ - @Autowired - private SysConfigMapper configMapper; - - /** - * 查询参数配置信息 - * - * @param configId 参数配置ID - * @return 参数配置信息 - */ - @Override - public SysConfig selectConfigById(Long configId) - { - SysConfig config = new SysConfig(); - config.setConfigId(configId); - return configMapper.selectConfig(config); - } - - /** - * 根据键名查询参数配置信息 - * - * @param configKey 参数key - * @return 参数键值 - */ - @Override - public String selectConfigByKey(String configKey) - { - SysConfig config = new SysConfig(); - config.setConfigKey(configKey); - SysConfig retConfig = configMapper.selectConfig(config); - return StringUtils.isNotNull(retConfig) ? retConfig.getConfigValue() : ""; - } - - /** - * 查询参数配置列表 - * - * @param config 参数配置信息 - * @return 参数配置集合 - */ - @Override - public List selectConfigList(SysConfig config) - { - return configMapper.selectConfigList(config); - } - - /** - * 新增参数配置 - * - * @param config 参数配置信息 - * @return 结果 - */ - @Override - public int insertConfig(SysConfig config) - { - return configMapper.insertConfig(config); - } - - /** - * 修改参数配置 - * - * @param config 参数配置信息 - * @return 结果 - */ - @Override - public int updateConfig(SysConfig config) - { - return configMapper.updateConfig(config); - } - - /** - * 批量删除参数配置对象 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - @Override - public int deleteConfigByIds(String ids) - { - return configMapper.deleteConfigByIds(Convert.toStrArray(ids)); - } - - /** - * 校验参数键名是否唯一 - * - * @param config 参数配置信息 - * @return 结果 - */ - @Override - public String checkConfigKeyUnique(SysConfig config) - { - Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); - SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey()); - if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) - { - return UserConstants.CONFIG_KEY_NOT_UNIQUE; - } - return UserConstants.CONFIG_KEY_UNIQUE; - } -} +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysConfig; +import com.ruoyi.system.mapper.SysConfigMapper; +import com.ruoyi.system.service.ISysConfigService; + +/** + * 参数配置 服务层实现 + * + * @author ruoyi + */ +@Service +public class SysConfigServiceImpl implements ISysConfigService +{ + @Autowired + private SysConfigMapper configMapper; + + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + @Override + public SysConfig selectConfigById(Long configId) + { + SysConfig config = new SysConfig(); + config.setConfigId(configId); + return configMapper.selectConfig(config); + } + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数key + * @return 参数键值 + */ + @Override + public String selectConfigByKey(String configKey) + { + SysConfig config = new SysConfig(); + config.setConfigKey(configKey); + SysConfig retConfig = configMapper.selectConfig(config); + return StringUtils.isNotNull(retConfig) ? retConfig.getConfigValue() : ""; + } + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + @Override + public List selectConfigList(SysConfig config) + { + return configMapper.selectConfigList(config); + } + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public int insertConfig(SysConfig config) + { + return configMapper.insertConfig(config); + } + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public int updateConfig(SysConfig config) + { + return configMapper.updateConfig(config); + } + + /** + * 批量删除参数配置对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteConfigByIds(String ids) + { + return configMapper.deleteConfigByIds(Convert.toStrArray(ids)); + } + + /** + * 校验参数键名是否唯一 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public String checkConfigKeyUnique(SysConfig config) + { + Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); + SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey()); + if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) + { + return UserConstants.CONFIG_KEY_NOT_UNIQUE; + } + return UserConstants.CONFIG_KEY_UNIQUE; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 422b33643..768eb26a8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -1,271 +1,271 @@ -package com.ruoyi.system.service.impl; - -import java.util.ArrayList; -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.common.annotation.DataScope; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.domain.Ztree; -import com.ruoyi.common.exception.BusinessException; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.system.domain.SysDept; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.mapper.SysDeptMapper; -import com.ruoyi.system.service.ISysDeptService; - -/** - * 部门管理 服务实现 - * - * @author ruoyi - */ -@Service -public class SysDeptServiceImpl implements ISysDeptService -{ - @Autowired - private SysDeptMapper deptMapper; - - /** - * 查询部门管理数据 - * - * @param dept 部门信息 - * @return 部门信息集合 - */ - @Override - @DataScope(deptAlias = "d") - public List selectDeptList(SysDept dept) - { - return deptMapper.selectDeptList(dept); - } - - /** - * 查询部门管理树 - * - * @param dept 部门信息 - * @return 所有部门信息 - */ - @Override - @DataScope(deptAlias = "d") - public List selectDeptTree(SysDept dept) - { - List deptList = deptMapper.selectDeptList(dept); - List ztrees = initZtree(deptList); - return ztrees; - } - - /** - * 根据角色ID查询部门(数据权限) - * - * @param role 角色对象 - * @return 部门列表(数据权限) - */ - @Override - public List roleDeptTreeData(SysRole role) - { - Long roleId = role.getRoleId(); - List ztrees = new ArrayList(); - List deptList = selectDeptList(new SysDept()); - if (StringUtils.isNotNull(roleId)) - { - List roleDeptList = deptMapper.selectRoleDeptTree(roleId); - ztrees = initZtree(deptList, roleDeptList); - } - else - { - ztrees = initZtree(deptList); - } - return ztrees; - } - - /** - * 对象转部门树 - * - * @param deptList 部门列表 - * @return 树结构列表 - */ - public List initZtree(List deptList) - { - return initZtree(deptList, null); - } - - /** - * 对象转部门树 - * - * @param deptList 部门列表 - * @param roleDeptList 角色已存在菜单列表 - * @return 树结构列表 - */ - public List initZtree(List deptList, List roleDeptList) - { - - List ztrees = new ArrayList(); - boolean isCheck = StringUtils.isNotNull(roleDeptList); - for (SysDept dept : deptList) - { - if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) - { - Ztree ztree = new Ztree(); - ztree.setId(dept.getDeptId()); - ztree.setpId(dept.getParentId()); - ztree.setName(dept.getDeptName()); - ztree.setTitle(dept.getDeptName()); - if (isCheck) - { - ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); - } - ztrees.add(ztree); - } - } - return ztrees; - } - - /** - * 查询部门人数 - * - * @param parentId 部门ID - * @return 结果 - */ - @Override - public int selectDeptCount(Long parentId) - { - SysDept dept = new SysDept(); - dept.setParentId(parentId); - return deptMapper.selectDeptCount(dept); - } - - /** - * 查询部门是否存在用户 - * - * @param deptId 部门ID - * @return 结果 true 存在 false 不存在 - */ - @Override - public boolean checkDeptExistUser(Long deptId) - { - int result = deptMapper.checkDeptExistUser(deptId); - return result > 0 ? true : false; - } - - /** - * 删除部门管理信息 - * - * @param deptId 部门ID - * @return 结果 - */ - @Override - public int deleteDeptById(Long deptId) - { - return deptMapper.deleteDeptById(deptId); - } - - /** - * 新增保存部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - @Override - public int insertDept(SysDept dept) - { - SysDept info = deptMapper.selectDeptById(dept.getParentId()); - // 如果父节点不为"正常"状态,则不允许新增子节点 - if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) - { - throw new BusinessException("部门停用,不允许新增"); - } - dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); - return deptMapper.insertDept(dept); - } - - /** - * 修改保存部门信息 - * - * @param dept 部门信息 - * @return 结果 - */ - @Override - @Transactional - public int updateDept(SysDept dept) - { - SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); - SysDept oldDept = selectDeptById(dept.getDeptId()); - if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) - { - String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); - String oldAncestors = oldDept.getAncestors(); - dept.setAncestors(newAncestors); - updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); - } - int result = deptMapper.updateDept(dept); - if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) - { - // 如果该部门是启用状态,则启用该部门的所有上级部门 - updateParentDeptStatus(dept); - } - return result; - } - - /** - * 修改该部门的父级部门状态 - * - * @param dept 当前部门 - */ - private void updateParentDeptStatus(SysDept dept) - { - String updateBy = dept.getUpdateBy(); - dept = deptMapper.selectDeptById(dept.getDeptId()); - dept.setUpdateBy(updateBy); - deptMapper.updateDeptStatus(dept); - } - - /** - * 修改子元素关系 - * - * @param deptId 被修改的部门ID - * @param newAncestors 新的父ID集合 - * @param oldAncestors 旧的父ID集合 - */ - public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) - { - List children = deptMapper.selectChildrenDeptById(deptId); - for (SysDept child : children) - { - child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors)); - } - if (children.size() > 0) - { - deptMapper.updateDeptChildren(children); - } - } - - /** - * 根据部门ID查询信息 - * - * @param deptId 部门ID - * @return 部门信息 - */ - @Override - public SysDept selectDeptById(Long deptId) - { - return deptMapper.selectDeptById(deptId); - } - - /** - * 校验部门名称是否唯一 - * - * @param dept 部门信息 - * @return 结果 - */ - @Override - public String checkDeptNameUnique(SysDept dept) - { - Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); - SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); - if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) - { - return UserConstants.DEPT_NAME_NOT_UNIQUE; - } - return UserConstants.DEPT_NAME_UNIQUE; - } -} +package com.ruoyi.system.service.impl; + +import java.util.ArrayList; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysDept; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.system.service.ISysDeptService; + +/** + * 部门管理 服务实现 + * + * @author ruoyi + */ +@Service +public class SysDeptServiceImpl implements ISysDeptService +{ + @Autowired + private SysDeptMapper deptMapper; + + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + @Override + @DataScope(deptAlias = "d") + public List selectDeptList(SysDept dept) + { + return deptMapper.selectDeptList(dept); + } + + /** + * 查询部门管理树 + * + * @param dept 部门信息 + * @return 所有部门信息 + */ + @Override + @DataScope(deptAlias = "d") + public List selectDeptTree(SysDept dept) + { + List deptList = deptMapper.selectDeptList(dept); + List ztrees = initZtree(deptList); + return ztrees; + } + + /** + * 根据角色ID查询部门(数据权限) + * + * @param role 角色对象 + * @return 部门列表(数据权限) + */ + @Override + public List roleDeptTreeData(SysRole role) + { + Long roleId = role.getRoleId(); + List ztrees = new ArrayList(); + List deptList = selectDeptList(new SysDept()); + if (StringUtils.isNotNull(roleId)) + { + List roleDeptList = deptMapper.selectRoleDeptTree(roleId); + ztrees = initZtree(deptList, roleDeptList); + } + else + { + ztrees = initZtree(deptList); + } + return ztrees; + } + + /** + * 对象转部门树 + * + * @param deptList 部门列表 + * @return 树结构列表 + */ + public List initZtree(List deptList) + { + return initZtree(deptList, null); + } + + /** + * 对象转部门树 + * + * @param deptList 部门列表 + * @param roleDeptList 角色已存在菜单列表 + * @return 树结构列表 + */ + public List initZtree(List deptList, List roleDeptList) + { + + List ztrees = new ArrayList(); + boolean isCheck = StringUtils.isNotNull(roleDeptList); + for (SysDept dept : deptList) + { + if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) + { + Ztree ztree = new Ztree(); + ztree.setId(dept.getDeptId()); + ztree.setpId(dept.getParentId()); + ztree.setName(dept.getDeptName()); + ztree.setTitle(dept.getDeptName()); + if (isCheck) + { + ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); + } + ztrees.add(ztree); + } + } + return ztrees; + } + + /** + * 查询部门人数 + * + * @param parentId 部门ID + * @return 结果 + */ + @Override + public int selectDeptCount(Long parentId) + { + SysDept dept = new SysDept(); + dept.setParentId(parentId); + return deptMapper.selectDeptCount(dept); + } + + /** + * 查询部门是否存在用户 + * + * @param deptId 部门ID + * @return 结果 true 存在 false 不存在 + */ + @Override + public boolean checkDeptExistUser(Long deptId) + { + int result = deptMapper.checkDeptExistUser(deptId); + return result > 0 ? true : false; + } + + /** + * 删除部门管理信息 + * + * @param deptId 部门ID + * @return 结果 + */ + @Override + public int deleteDeptById(Long deptId) + { + return deptMapper.deleteDeptById(deptId); + } + + /** + * 新增保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + public int insertDept(SysDept dept) + { + SysDept info = deptMapper.selectDeptById(dept.getParentId()); + // 如果父节点不为"正常"状态,则不允许新增子节点 + if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) + { + throw new BusinessException("部门停用,不允许新增"); + } + dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); + return deptMapper.insertDept(dept); + } + + /** + * 修改保存部门信息 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + @Transactional + public int updateDept(SysDept dept) + { + SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); + SysDept oldDept = selectDeptById(dept.getDeptId()); + if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) + { + String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); + String oldAncestors = oldDept.getAncestors(); + dept.setAncestors(newAncestors); + updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); + } + int result = deptMapper.updateDept(dept); + if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) + { + // 如果该部门是启用状态,则启用该部门的所有上级部门 + updateParentDeptStatus(dept); + } + return result; + } + + /** + * 修改该部门的父级部门状态 + * + * @param dept 当前部门 + */ + private void updateParentDeptStatus(SysDept dept) + { + String updateBy = dept.getUpdateBy(); + dept = deptMapper.selectDeptById(dept.getDeptId()); + dept.setUpdateBy(updateBy); + deptMapper.updateDeptStatus(dept); + } + + /** + * 修改子元素关系 + * + * @param deptId 被修改的部门ID + * @param newAncestors 新的父ID集合 + * @param oldAncestors 旧的父ID集合 + */ + public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) + { + List children = deptMapper.selectChildrenDeptById(deptId); + for (SysDept child : children) + { + child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors)); + } + if (children.size() > 0) + { + deptMapper.updateDeptChildren(children); + } + } + + /** + * 根据部门ID查询信息 + * + * @param deptId 部门ID + * @return 部门信息 + */ + @Override + public SysDept selectDeptById(Long deptId) + { + return deptMapper.selectDeptById(deptId); + } + + /** + * 校验部门名称是否唯一 + * + * @param dept 部门信息 + * @return 结果 + */ + @Override + public String checkDeptNameUnique(SysDept dept) + { + Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); + SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); + if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) + { + return UserConstants.DEPT_NAME_NOT_UNIQUE; + } + return UserConstants.DEPT_NAME_UNIQUE; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java index 502e03f43..2bc1691c3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java @@ -1,118 +1,118 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.system.domain.SysDictData; -import com.ruoyi.system.mapper.SysDictDataMapper; -import com.ruoyi.system.service.ISysDictDataService; - -/** - * 字典 业务层处理 - * - * @author ruoyi - */ -@Service -public class SysDictDataServiceImpl implements ISysDictDataService -{ - @Autowired - private SysDictDataMapper dictDataMapper; - - /** - * 根据条件分页查询字典数据 - * - * @param dictData 字典数据信息 - * @return 字典数据集合信息 - */ - @Override - public List selectDictDataList(SysDictData dictData) - { - return dictDataMapper.selectDictDataList(dictData); - } - - /** - * 根据字典类型查询字典数据 - * - * @param dictType 字典类型 - * @return 字典数据集合信息 - */ - @Override - public List selectDictDataByType(String dictType) - { - return dictDataMapper.selectDictDataByType(dictType); - } - - /** - * 根据字典类型和字典键值查询字典数据信息 - * - * @param dictType 字典类型 - * @param dictValue 字典键值 - * @return 字典标签 - */ - @Override - public String selectDictLabel(String dictType, String dictValue) - { - return dictDataMapper.selectDictLabel(dictType, dictValue); - } - - /** - * 根据字典数据ID查询信息 - * - * @param dictCode 字典数据ID - * @return 字典数据 - */ - @Override - public SysDictData selectDictDataById(Long dictCode) - { - return dictDataMapper.selectDictDataById(dictCode); - } - - /** - * 通过字典ID删除字典数据信息 - * - * @param dictCode 字典数据ID - * @return 结果 - */ - @Override - public int deleteDictDataById(Long dictCode) - { - return dictDataMapper.deleteDictDataById(dictCode); - } - - /** - * 批量删除字典数据 - * - * @param ids 需要删除的数据 - * @return 结果 - */ - @Override - public int deleteDictDataByIds(String ids) - { - return dictDataMapper.deleteDictDataByIds(Convert.toStrArray(ids)); - } - - /** - * 新增保存字典数据信息 - * - * @param dictData 字典数据信息 - * @return 结果 - */ - @Override - public int insertDictData(SysDictData dictData) - { - return dictDataMapper.insertDictData(dictData); - } - - /** - * 修改保存字典数据信息 - * - * @param dictData 字典数据信息 - * @return 结果 - */ - @Override - public int updateDictData(SysDictData dictData) - { - return dictDataMapper.updateDictData(dictData); - } -} +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.system.domain.SysDictData; +import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.system.service.ISysDictDataService; + +/** + * 字典 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysDictDataServiceImpl implements ISysDictDataService +{ + @Autowired + private SysDictDataMapper dictDataMapper; + + /** + * 根据条件分页查询字典数据 + * + * @param dictData 字典数据信息 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataList(SysDictData dictData) + { + return dictDataMapper.selectDictDataList(dictData); + } + + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataByType(String dictType) + { + return dictDataMapper.selectDictDataByType(dictType); + } + + /** + * 根据字典类型和字典键值查询字典数据信息 + * + * @param dictType 字典类型 + * @param dictValue 字典键值 + * @return 字典标签 + */ + @Override + public String selectDictLabel(String dictType, String dictValue) + { + return dictDataMapper.selectDictLabel(dictType, dictValue); + } + + /** + * 根据字典数据ID查询信息 + * + * @param dictCode 字典数据ID + * @return 字典数据 + */ + @Override + public SysDictData selectDictDataById(Long dictCode) + { + return dictDataMapper.selectDictDataById(dictCode); + } + + /** + * 通过字典ID删除字典数据信息 + * + * @param dictCode 字典数据ID + * @return 结果 + */ + @Override + public int deleteDictDataById(Long dictCode) + { + return dictDataMapper.deleteDictDataById(dictCode); + } + + /** + * 批量删除字典数据 + * + * @param ids 需要删除的数据 + * @return 结果 + */ + @Override + public int deleteDictDataByIds(String ids) + { + return dictDataMapper.deleteDictDataByIds(Convert.toStrArray(ids)); + } + + /** + * 新增保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + @Override + public int insertDictData(SysDictData dictData) + { + return dictDataMapper.insertDictData(dictData); + } + + /** + * 修改保存字典数据信息 + * + * @param dictData 字典数据信息 + * @return 结果 + */ + @Override + public int updateDictData(SysDictData dictData) + { + return dictDataMapper.updateDictData(dictData); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java index 7d205fc16..a1063f87f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java @@ -1,143 +1,143 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.system.domain.SysDictType; -import com.ruoyi.system.mapper.SysDictDataMapper; -import com.ruoyi.system.mapper.SysDictTypeMapper; -import com.ruoyi.system.service.ISysDictTypeService; - -/** - * 字典 业务层处理 - * - * @author ruoyi - */ -@Service -public class SysDictTypeServiceImpl implements ISysDictTypeService -{ - @Autowired - private SysDictTypeMapper dictTypeMapper; - - @Autowired - private SysDictDataMapper dictDataMapper; - - /** - * 根据条件分页查询字典类型 - * - * @param dictType 字典类型信息 - * @return 字典类型集合信息 - */ - @Override - public List selectDictTypeList(SysDictType dictType) - { - return dictTypeMapper.selectDictTypeList(dictType); - } - - /** - * 根据所有字典类型 - * - * @return 字典类型集合信息 - */ - @Override - public List selectDictTypeAll() - { - return dictTypeMapper.selectDictTypeAll(); - } - - /** - * 根据字典类型ID查询信息 - * - * @param dictId 字典类型ID - * @return 字典类型 - */ - @Override - public SysDictType selectDictTypeById(Long dictId) - { - return dictTypeMapper.selectDictTypeById(dictId); - } - - /** - * 通过字典ID删除字典信息 - * - * @param dictId 字典ID - * @return 结果 - */ - @Override - public int deleteDictTypeById(Long dictId) - { - return dictTypeMapper.deleteDictTypeById(dictId); - } - - /** - * 批量删除字典类型 - * - * @param ids 需要删除的数据 - * @return 结果 - */ - @Override - public int deleteDictTypeByIds(String ids) throws BusinessException - { - Long[] dictIds = Convert.toLongArray(ids); - for (Long dictId : dictIds) - { - SysDictType dictType = selectDictTypeById(dictId); - if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) - { - throw new BusinessException(String.format("%1$s已分配,不能删除", dictType.getDictName())); - } - } - - return dictTypeMapper.deleteDictTypeByIds(dictIds); - } - - /** - * 新增保存字典类型信息 - * - * @param dictType 字典类型信息 - * @return 结果 - */ - @Override - public int insertDictType(SysDictType dictType) - { - return dictTypeMapper.insertDictType(dictType); - } - - /** - * 修改保存字典类型信息 - * - * @param dictType 字典类型信息 - * @return 结果 - */ - @Override - @Transactional - public int updateDictType(SysDictType dictType) - { - SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId()); - dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); - return dictTypeMapper.updateDictType(dictType); - } - - /** - * 校验字典类型称是否唯一 - * - * @param dict 字典类型 - * @return 结果 - */ - @Override - public String checkDictTypeUnique(SysDictType dict) - { - Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); - SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); - if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) - { - return UserConstants.DICT_TYPE_NOT_UNIQUE; - } - return UserConstants.DICT_TYPE_UNIQUE; - } -} +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysDictType; +import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.system.mapper.SysDictTypeMapper; +import com.ruoyi.system.service.ISysDictTypeService; + +/** + * 字典 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysDictTypeServiceImpl implements ISysDictTypeService +{ + @Autowired + private SysDictTypeMapper dictTypeMapper; + + @Autowired + private SysDictDataMapper dictDataMapper; + + /** + * 根据条件分页查询字典类型 + * + * @param dictType 字典类型信息 + * @return 字典类型集合信息 + */ + @Override + public List selectDictTypeList(SysDictType dictType) + { + return dictTypeMapper.selectDictTypeList(dictType); + } + + /** + * 根据所有字典类型 + * + * @return 字典类型集合信息 + */ + @Override + public List selectDictTypeAll() + { + return dictTypeMapper.selectDictTypeAll(); + } + + /** + * 根据字典类型ID查询信息 + * + * @param dictId 字典类型ID + * @return 字典类型 + */ + @Override + public SysDictType selectDictTypeById(Long dictId) + { + return dictTypeMapper.selectDictTypeById(dictId); + } + + /** + * 通过字典ID删除字典信息 + * + * @param dictId 字典ID + * @return 结果 + */ + @Override + public int deleteDictTypeById(Long dictId) + { + return dictTypeMapper.deleteDictTypeById(dictId); + } + + /** + * 批量删除字典类型 + * + * @param ids 需要删除的数据 + * @return 结果 + */ + @Override + public int deleteDictTypeByIds(String ids) throws BusinessException + { + Long[] dictIds = Convert.toLongArray(ids); + for (Long dictId : dictIds) + { + SysDictType dictType = selectDictTypeById(dictId); + if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) + { + throw new BusinessException(String.format("%1$s已分配,不能删除", dictType.getDictName())); + } + } + + return dictTypeMapper.deleteDictTypeByIds(dictIds); + } + + /** + * 新增保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + @Override + public int insertDictType(SysDictType dictType) + { + return dictTypeMapper.insertDictType(dictType); + } + + /** + * 修改保存字典类型信息 + * + * @param dictType 字典类型信息 + * @return 结果 + */ + @Override + @Transactional + public int updateDictType(SysDictType dictType) + { + SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId()); + dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); + return dictTypeMapper.updateDictType(dictType); + } + + /** + * 校验字典类型称是否唯一 + * + * @param dict 字典类型 + * @return 结果 + */ + @Override + public String checkDictTypeUnique(SysDictType dict) + { + Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); + SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); + if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) + { + return UserConstants.DICT_TYPE_NOT_UNIQUE; + } + return UserConstants.DICT_TYPE_UNIQUE; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java index 3f183d62c..f225fe98d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java @@ -1,66 +1,66 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.system.domain.SysLogininfor; -import com.ruoyi.system.mapper.SysLogininforMapper; -import com.ruoyi.system.service.ISysLogininforService; - -/** - * 系统访问日志情况信息 服务层处理 - * - * @author ruoyi - */ -@Service -public class SysLogininforServiceImpl implements ISysLogininforService -{ - - @Autowired - private SysLogininforMapper logininforMapper; - - /** - * 新增系统登录日志 - * - * @param logininfor 访问日志对象 - */ - @Override - public void insertLogininfor(SysLogininfor logininfor) - { - logininforMapper.insertLogininfor(logininfor); - } - - /** - * 查询系统登录日志集合 - * - * @param logininfor 访问日志对象 - * @return 登录记录集合 - */ - @Override - public List selectLogininforList(SysLogininfor logininfor) - { - return logininforMapper.selectLogininforList(logininfor); - } - - /** - * 批量删除系统登录日志 - * - * @param ids 需要删除的数据 - * @return - */ - @Override - public int deleteLogininforByIds(String ids) - { - return logininforMapper.deleteLogininforByIds(Convert.toStrArray(ids)); - } - - /** - * 清空系统登录日志 - */ - @Override - public void cleanLogininfor() - { - logininforMapper.cleanLogininfor(); - } -} +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.mapper.SysLogininforMapper; +import com.ruoyi.system.service.ISysLogininforService; + +/** + * 系统访问日志情况信息 服务层处理 + * + * @author ruoyi + */ +@Service +public class SysLogininforServiceImpl implements ISysLogininforService +{ + + @Autowired + private SysLogininforMapper logininforMapper; + + /** + * 新增系统登录日志 + * + * @param logininfor 访问日志对象 + */ + @Override + public void insertLogininfor(SysLogininfor logininfor) + { + logininforMapper.insertLogininfor(logininfor); + } + + /** + * 查询系统登录日志集合 + * + * @param logininfor 访问日志对象 + * @return 登录记录集合 + */ + @Override + public List selectLogininforList(SysLogininfor logininfor) + { + return logininforMapper.selectLogininforList(logininfor); + } + + /** + * 批量删除系统登录日志 + * + * @param ids 需要删除的数据 + * @return + */ + @Override + public int deleteLogininforByIds(String ids) + { + return logininforMapper.deleteLogininforByIds(Convert.toStrArray(ids)); + } + + /** + * 清空系统登录日志 + */ + @Override + public void cleanLogininfor() + { + logininforMapper.cleanLogininfor(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java index 5dee886be..c1d537791 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -1,395 +1,395 @@ -package com.ruoyi.system.service.impl; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.domain.Ztree; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.system.domain.SysMenu; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.domain.SysUser; -import com.ruoyi.system.mapper.SysMenuMapper; -import com.ruoyi.system.mapper.SysRoleMenuMapper; -import com.ruoyi.system.service.ISysMenuService; - -/** - * 菜单 业务层处理 - * - * @author ruoyi - */ -@Service -public class SysMenuServiceImpl implements ISysMenuService -{ - public static final String PREMISSION_STRING = "perms[\"{0}\"]"; - - @Autowired - private SysMenuMapper menuMapper; - - @Autowired - private SysRoleMenuMapper roleMenuMapper; - - /** - * 根据用户查询菜单 - * - * @param user 用户信息 - * @return 菜单列表 - */ - @Override - public List selectMenusByUser(SysUser user) - { - List menus = new LinkedList(); - // 管理员显示所有菜单信息 - if (user.isAdmin()) - { - menus = menuMapper.selectMenuNormalAll(); - } - else - { - menus = menuMapper.selectMenusByUserId(user.getUserId()); - } - return getChildPerms(menus, 0); - } - - /** - * 查询菜单集合 - * - * @return 所有菜单信息 - */ - @Override - public List selectMenuList(SysMenu menu, Long userId) - { - List menuList = null; - if (SysUser.isAdmin(userId)) - { - menuList = menuMapper.selectMenuList(menu); - } - else - { - menu.getParams().put("userId", userId); - menuList = menuMapper.selectMenuListByUserId(menu); - } - return menuList; - } - - /** - * 查询菜单集合 - * - * @return 所有菜单信息 - */ - @Override - public List selectMenuAll(Long userId) - { - List menuList = null; - if (SysUser.isAdmin(userId)) - { - menuList = menuMapper.selectMenuAll(); - } - else - { - menuList = menuMapper.selectMenuAllByUserId(userId); - } - return menuList; - } - - /** - * 根据用户ID查询权限 - * - * @param userId 用户ID - * @return 权限列表 - */ - @Override - public Set selectPermsByUserId(Long userId) - { - List perms = menuMapper.selectPermsByUserId(userId); - Set permsSet = new HashSet<>(); - for (String perm : perms) - { - if (StringUtils.isNotEmpty(perm)) - { - permsSet.addAll(Arrays.asList(perm.trim().split(","))); - } - } - return permsSet; - } - - /** - * 根据角色ID查询菜单 - * - * @param role 角色对象 - * @return 菜单列表 - */ - @Override - public List roleMenuTreeData(SysRole role, Long userId) - { - Long roleId = role.getRoleId(); - List ztrees = new ArrayList(); - List menuList = selectMenuAll(userId); - if (StringUtils.isNotNull(roleId)) - { - List roleMenuList = menuMapper.selectMenuTree(roleId); - ztrees = initZtree(menuList, roleMenuList, true); - } - else - { - ztrees = initZtree(menuList, null, true); - } - return ztrees; - } - - /** - * 查询所有菜单 - * - * @return 菜单列表 - */ - @Override - public List menuTreeData(Long userId) - { - List menuList = selectMenuAll(userId); - List ztrees = initZtree(menuList); - return ztrees; - } - - /** - * 查询系统所有权限 - * - * @return 权限列表 - */ - @Override - public LinkedHashMap selectPermsAll(Long userId) - { - LinkedHashMap section = new LinkedHashMap<>(); - List permissions = selectMenuAll(userId); - if (StringUtils.isNotEmpty(permissions)) - { - for (SysMenu menu : permissions) - { - section.put(menu.getUrl(), MessageFormat.format(PREMISSION_STRING, menu.getPerms())); - } - } - return section; - } - - /** - * 对象转菜单树 - * - * @param menuList 菜单列表 - * @return 树结构列表 - */ - public List initZtree(List menuList) - { - return initZtree(menuList, null, false); - } - - /** - * 对象转菜单树 - * - * @param menuList 菜单列表 - * @param roleMenuList 角色已存在菜单列表 - * @param permsFlag 是否需要显示权限标识 - * @return 树结构列表 - */ - public List initZtree(List menuList, List roleMenuList, boolean permsFlag) - { - List ztrees = new ArrayList(); - boolean isCheck = StringUtils.isNotNull(roleMenuList); - for (SysMenu menu : menuList) - { - Ztree ztree = new Ztree(); - ztree.setId(menu.getMenuId()); - ztree.setpId(menu.getParentId()); - ztree.setName(transMenuName(menu, roleMenuList, permsFlag)); - ztree.setTitle(menu.getMenuName()); - if (isCheck) - { - ztree.setChecked(roleMenuList.contains(menu.getMenuId() + menu.getPerms())); - } - ztrees.add(ztree); - } - return ztrees; - } - - public String transMenuName(SysMenu menu, List roleMenuList, boolean permsFlag) - { - StringBuffer sb = new StringBuffer(); - sb.append(menu.getMenuName()); - if (permsFlag) - { - sb.append("   " + menu.getPerms() + ""); - } - return sb.toString(); - } - - /** - * 删除菜单管理信息 - * - * @param menuId 菜单ID - * @return 结果 - */ - @Override - public int deleteMenuById(Long menuId) - { - return menuMapper.deleteMenuById(menuId); - } - - /** - * 根据菜单ID查询信息 - * - * @param menuId 菜单ID - * @return 菜单信息 - */ - @Override - public SysMenu selectMenuById(Long menuId) - { - return menuMapper.selectMenuById(menuId); - } - - /** - * 查询子菜单数量 - * - * @param parentId 父级菜单ID - * @return 结果 - */ - @Override - public int selectCountMenuByParentId(Long parentId) - { - return menuMapper.selectCountMenuByParentId(parentId); - } - - /** - * 查询菜单使用数量 - * - * @param menuId 菜单ID - * @return 结果 - */ - @Override - public int selectCountRoleMenuByMenuId(Long menuId) - { - return roleMenuMapper.selectCountRoleMenuByMenuId(menuId); - } - - /** - * 新增保存菜单信息 - * - * @param menu 菜单信息 - * @return 结果 - */ - @Override - public int insertMenu(SysMenu menu) - { - return menuMapper.insertMenu(menu); - } - - /** - * 修改保存菜单信息 - * - * @param menu 菜单信息 - * @return 结果 - */ - @Override - public int updateMenu(SysMenu menu) - { - return menuMapper.updateMenu(menu); - } - - /** - * 校验菜单名称是否唯一 - * - * @param menu 菜单信息 - * @return 结果 - */ - @Override - public String checkMenuNameUnique(SysMenu menu) - { - Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); - SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); - if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) - { - return UserConstants.MENU_NAME_NOT_UNIQUE; - } - return UserConstants.MENU_NAME_UNIQUE; - } - - /** - * 根据父节点的ID获取所有子节点 - * - * @param list 分类表 - * @param parentId 传入的父节点ID - * @return String - */ - public List getChildPerms(List list, int parentId) - { - List returnList = new ArrayList(); - for (Iterator iterator = list.iterator(); iterator.hasNext();) - { - SysMenu t = (SysMenu) iterator.next(); - // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 - if (t.getParentId() == parentId) - { - recursionFn(list, t); - returnList.add(t); - } - } - return returnList; - } - - /** - * 递归列表 - * - * @param list - * @param t - */ - private void recursionFn(List list, SysMenu t) - { - // 得到子节点列表 - List childList = getChildList(list, t); - t.setChildren(childList); - for (SysMenu tChild : childList) - { - if (hasChild(list, tChild)) - { - // 判断是否有子节点 - Iterator it = childList.iterator(); - while (it.hasNext()) - { - SysMenu n = (SysMenu) it.next(); - recursionFn(list, n); - } - } - } - } - - /** - * 得到子节点列表 - */ - private List getChildList(List list, SysMenu t) - { - List tlist = new ArrayList(); - Iterator it = list.iterator(); - while (it.hasNext()) - { - SysMenu n = (SysMenu) it.next(); - if (n.getParentId().longValue() == t.getMenuId().longValue()) - { - tlist.add(n); - } - } - return tlist; - } - - /** - * 判断是否有子节点 - */ - private boolean hasChild(List list, SysMenu t) - { - return getChildList(list, t).size() > 0 ? true : false; - } -} +package com.ruoyi.system.service.impl; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysMenu; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.mapper.SysMenuMapper; +import com.ruoyi.system.mapper.SysRoleMenuMapper; +import com.ruoyi.system.service.ISysMenuService; + +/** + * 菜单 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysMenuServiceImpl implements ISysMenuService +{ + public static final String PREMISSION_STRING = "perms[\"{0}\"]"; + + @Autowired + private SysMenuMapper menuMapper; + + @Autowired + private SysRoleMenuMapper roleMenuMapper; + + /** + * 根据用户查询菜单 + * + * @param user 用户信息 + * @return 菜单列表 + */ + @Override + public List selectMenusByUser(SysUser user) + { + List menus = new LinkedList(); + // 管理员显示所有菜单信息 + if (user.isAdmin()) + { + menus = menuMapper.selectMenuNormalAll(); + } + else + { + menus = menuMapper.selectMenusByUserId(user.getUserId()); + } + return getChildPerms(menus, 0); + } + + /** + * 查询菜单集合 + * + * @return 所有菜单信息 + */ + @Override + public List selectMenuList(SysMenu menu, Long userId) + { + List menuList = null; + if (SysUser.isAdmin(userId)) + { + menuList = menuMapper.selectMenuList(menu); + } + else + { + menu.getParams().put("userId", userId); + menuList = menuMapper.selectMenuListByUserId(menu); + } + return menuList; + } + + /** + * 查询菜单集合 + * + * @return 所有菜单信息 + */ + @Override + public List selectMenuAll(Long userId) + { + List menuList = null; + if (SysUser.isAdmin(userId)) + { + menuList = menuMapper.selectMenuAll(); + } + else + { + menuList = menuMapper.selectMenuAllByUserId(userId); + } + return menuList; + } + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + @Override + public Set selectPermsByUserId(Long userId) + { + List perms = menuMapper.selectPermsByUserId(userId); + Set permsSet = new HashSet<>(); + for (String perm : perms) + { + if (StringUtils.isNotEmpty(perm)) + { + permsSet.addAll(Arrays.asList(perm.trim().split(","))); + } + } + return permsSet; + } + + /** + * 根据角色ID查询菜单 + * + * @param role 角色对象 + * @return 菜单列表 + */ + @Override + public List roleMenuTreeData(SysRole role, Long userId) + { + Long roleId = role.getRoleId(); + List ztrees = new ArrayList(); + List menuList = selectMenuAll(userId); + if (StringUtils.isNotNull(roleId)) + { + List roleMenuList = menuMapper.selectMenuTree(roleId); + ztrees = initZtree(menuList, roleMenuList, true); + } + else + { + ztrees = initZtree(menuList, null, true); + } + return ztrees; + } + + /** + * 查询所有菜单 + * + * @return 菜单列表 + */ + @Override + public List menuTreeData(Long userId) + { + List menuList = selectMenuAll(userId); + List ztrees = initZtree(menuList); + return ztrees; + } + + /** + * 查询系统所有权限 + * + * @return 权限列表 + */ + @Override + public LinkedHashMap selectPermsAll(Long userId) + { + LinkedHashMap section = new LinkedHashMap<>(); + List permissions = selectMenuAll(userId); + if (StringUtils.isNotEmpty(permissions)) + { + for (SysMenu menu : permissions) + { + section.put(menu.getUrl(), MessageFormat.format(PREMISSION_STRING, menu.getPerms())); + } + } + return section; + } + + /** + * 对象转菜单树 + * + * @param menuList 菜单列表 + * @return 树结构列表 + */ + public List initZtree(List menuList) + { + return initZtree(menuList, null, false); + } + + /** + * 对象转菜单树 + * + * @param menuList 菜单列表 + * @param roleMenuList 角色已存在菜单列表 + * @param permsFlag 是否需要显示权限标识 + * @return 树结构列表 + */ + public List initZtree(List menuList, List roleMenuList, boolean permsFlag) + { + List ztrees = new ArrayList(); + boolean isCheck = StringUtils.isNotNull(roleMenuList); + for (SysMenu menu : menuList) + { + Ztree ztree = new Ztree(); + ztree.setId(menu.getMenuId()); + ztree.setpId(menu.getParentId()); + ztree.setName(transMenuName(menu, roleMenuList, permsFlag)); + ztree.setTitle(menu.getMenuName()); + if (isCheck) + { + ztree.setChecked(roleMenuList.contains(menu.getMenuId() + menu.getPerms())); + } + ztrees.add(ztree); + } + return ztrees; + } + + public String transMenuName(SysMenu menu, List roleMenuList, boolean permsFlag) + { + StringBuffer sb = new StringBuffer(); + sb.append(menu.getMenuName()); + if (permsFlag) + { + sb.append("   " + menu.getPerms() + ""); + } + return sb.toString(); + } + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public int deleteMenuById(Long menuId) + { + return menuMapper.deleteMenuById(menuId); + } + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + @Override + public SysMenu selectMenuById(Long menuId) + { + return menuMapper.selectMenuById(menuId); + } + + /** + * 查询子菜单数量 + * + * @param parentId 父级菜单ID + * @return 结果 + */ + @Override + public int selectCountMenuByParentId(Long parentId) + { + return menuMapper.selectCountMenuByParentId(parentId); + } + + /** + * 查询菜单使用数量 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public int selectCountRoleMenuByMenuId(Long menuId) + { + return roleMenuMapper.selectCountRoleMenuByMenuId(menuId); + } + + /** + * 新增保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public int insertMenu(SysMenu menu) + { + return menuMapper.insertMenu(menu); + } + + /** + * 修改保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public int updateMenu(SysMenu menu) + { + return menuMapper.updateMenu(menu); + } + + /** + * 校验菜单名称是否唯一 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public String checkMenuNameUnique(SysMenu menu) + { + Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); + SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); + if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) + { + return UserConstants.MENU_NAME_NOT_UNIQUE; + } + return UserConstants.MENU_NAME_UNIQUE; + } + + /** + * 根据父节点的ID获取所有子节点 + * + * @param list 分类表 + * @param parentId 传入的父节点ID + * @return String + */ + public List getChildPerms(List list, int parentId) + { + List returnList = new ArrayList(); + for (Iterator iterator = list.iterator(); iterator.hasNext();) + { + SysMenu t = (SysMenu) iterator.next(); + // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 + if (t.getParentId() == parentId) + { + recursionFn(list, t); + returnList.add(t); + } + } + return returnList; + } + + /** + * 递归列表 + * + * @param list + * @param t + */ + private void recursionFn(List list, SysMenu t) + { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (SysMenu tChild : childList) + { + if (hasChild(list, tChild)) + { + // 判断是否有子节点 + Iterator it = childList.iterator(); + while (it.hasNext()) + { + SysMenu n = (SysMenu) it.next(); + recursionFn(list, n); + } + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, SysMenu t) + { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) + { + SysMenu n = (SysMenu) it.next(); + if (n.getParentId().longValue() == t.getMenuId().longValue()) + { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, SysMenu t) + { + return getChildList(list, t).size() > 0 ? true : false; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java index 0f4814d0a..7968b9a70 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java @@ -1,82 +1,82 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.system.domain.SysNotice; -import com.ruoyi.system.mapper.SysNoticeMapper; -import com.ruoyi.system.service.ISysNoticeService; - -/** - * 公告 服务层实现 - * - * @author ruoyi - * @date 2018-06-25 - */ -@Service -public class SysNoticeServiceImpl implements ISysNoticeService -{ - @Autowired - private SysNoticeMapper noticeMapper; - - /** - * 查询公告信息 - * - * @param noticeId 公告ID - * @return 公告信息 - */ - @Override - public SysNotice selectNoticeById(Long noticeId) - { - return noticeMapper.selectNoticeById(noticeId); - } - - /** - * 查询公告列表 - * - * @param notice 公告信息 - * @return 公告集合 - */ - @Override - public List selectNoticeList(SysNotice notice) - { - return noticeMapper.selectNoticeList(notice); - } - - /** - * 新增公告 - * - * @param notice 公告信息 - * @return 结果 - */ - @Override - public int insertNotice(SysNotice notice) - { - return noticeMapper.insertNotice(notice); - } - - /** - * 修改公告 - * - * @param notice 公告信息 - * @return 结果 - */ - @Override - public int updateNotice(SysNotice notice) - { - return noticeMapper.updateNotice(notice); - } - - /** - * 删除公告对象 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - @Override - public int deleteNoticeByIds(String ids) - { - return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids)); - } -} +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.mapper.SysNoticeMapper; +import com.ruoyi.system.service.ISysNoticeService; + +/** + * 公告 服务层实现 + * + * @author ruoyi + * @date 2018-06-25 + */ +@Service +public class SysNoticeServiceImpl implements ISysNoticeService +{ + @Autowired + private SysNoticeMapper noticeMapper; + + /** + * 查询公告信息 + * + * @param noticeId 公告ID + * @return 公告信息 + */ + @Override + public SysNotice selectNoticeById(Long noticeId) + { + return noticeMapper.selectNoticeById(noticeId); + } + + /** + * 查询公告列表 + * + * @param notice 公告信息 + * @return 公告集合 + */ + @Override + public List selectNoticeList(SysNotice notice) + { + return noticeMapper.selectNoticeList(notice); + } + + /** + * 新增公告 + * + * @param notice 公告信息 + * @return 结果 + */ + @Override + public int insertNotice(SysNotice notice) + { + return noticeMapper.insertNotice(notice); + } + + /** + * 修改公告 + * + * @param notice 公告信息 + * @return 结果 + */ + @Override + public int updateNotice(SysNotice notice) + { + return noticeMapper.updateNotice(notice); + } + + /** + * 删除公告对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteNoticeByIds(String ids) + { + return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids)); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java similarity index 95% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java index c79668b2e..78ae353a5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java @@ -1,77 +1,77 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.system.domain.SysOperLog; -import com.ruoyi.system.mapper.SysOperLogMapper; -import com.ruoyi.system.service.ISysOperLogService; - -/** - * 操作日志 服务层处理 - * - * @author ruoyi - */ -@Service -public class SysOperLogServiceImpl implements ISysOperLogService -{ - @Autowired - private SysOperLogMapper operLogMapper; - - /** - * 新增操作日志 - * - * @param operLog 操作日志对象 - */ - @Override - public void insertOperlog(SysOperLog operLog) - { - operLogMapper.insertOperlog(operLog); - } - - /** - * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 - * @return 操作日志集合 - */ - @Override - public List selectOperLogList(SysOperLog operLog) - { - return operLogMapper.selectOperLogList(operLog); - } - - /** - * 批量删除系统操作日志 - * - * @param ids 需要删除的数据 - * @return - */ - @Override - public int deleteOperLogByIds(String ids) - { - return operLogMapper.deleteOperLogByIds(Convert.toStrArray(ids)); - } - - /** - * 查询操作日志详细 - * - * @param operId 操作ID - * @return 操作日志对象 - */ - @Override - public SysOperLog selectOperLogById(Long operId) - { - return operLogMapper.selectOperLogById(operId); - } - - /** - * 清空操作日志 - */ - @Override - public void cleanOperLog() - { - operLogMapper.cleanOperLog(); - } -} +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.mapper.SysOperLogMapper; +import com.ruoyi.system.service.ISysOperLogService; + +/** + * 操作日志 服务层处理 + * + * @author ruoyi + */ +@Service +public class SysOperLogServiceImpl implements ISysOperLogService +{ + @Autowired + private SysOperLogMapper operLogMapper; + + /** + * 新增操作日志 + * + * @param operLog 操作日志对象 + */ + @Override + public void insertOperlog(SysOperLog operLog) + { + operLogMapper.insertOperlog(operLog); + } + + /** + * 查询系统操作日志集合 + * + * @param operLog 操作日志对象 + * @return 操作日志集合 + */ + @Override + public List selectOperLogList(SysOperLog operLog) + { + return operLogMapper.selectOperLogList(operLog); + } + + /** + * 批量删除系统操作日志 + * + * @param ids 需要删除的数据 + * @return + */ + @Override + public int deleteOperLogByIds(String ids) + { + return operLogMapper.deleteOperLogByIds(Convert.toStrArray(ids)); + } + + /** + * 查询操作日志详细 + * + * @param operId 操作ID + * @return 操作日志对象 + */ + @Override + public SysOperLog selectOperLogById(Long operId) + { + return operLogMapper.selectOperLogById(operId); + } + + /** + * 清空操作日志 + */ + @Override + public void cleanOperLog() + { + operLogMapper.cleanOperLog(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index 885b89240..8cbfc89f2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -1,181 +1,181 @@ -package com.ruoyi.system.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.system.domain.SysPost; -import com.ruoyi.system.mapper.SysPostMapper; -import com.ruoyi.system.mapper.SysUserPostMapper; -import com.ruoyi.system.service.ISysPostService; - -/** - * 岗位信息 服务层处理 - * - * @author ruoyi - */ -@Service -public class SysPostServiceImpl implements ISysPostService -{ - @Autowired - private SysPostMapper postMapper; - - @Autowired - private SysUserPostMapper userPostMapper; - - /** - * 查询岗位信息集合 - * - * @param post 岗位信息 - * @return 岗位信息集合 - */ - @Override - public List selectPostList(SysPost post) - { - return postMapper.selectPostList(post); - } - - /** - * 查询所有岗位 - * - * @return 岗位列表 - */ - @Override - public List selectPostAll() - { - return postMapper.selectPostAll(); - } - - /** - * 根据用户ID查询岗位 - * - * @param userId 用户ID - * @return 岗位列表 - */ - @Override - public List selectPostsByUserId(Long userId) - { - List userPosts = postMapper.selectPostsByUserId(userId); - List posts = postMapper.selectPostAll(); - for (SysPost post : posts) - { - for (SysPost userRole : userPosts) - { - if (post.getPostId().longValue() == userRole.getPostId().longValue()) - { - post.setFlag(true); - break; - } - } - } - return posts; - } - - /** - * 通过岗位ID查询岗位信息 - * - * @param postId 岗位ID - * @return 角色对象信息 - */ - @Override - public SysPost selectPostById(Long postId) - { - return postMapper.selectPostById(postId); - } - - /** - * 批量删除岗位信息 - * - * @param ids 需要删除的数据ID - * @throws Exception - */ - @Override - public int deletePostByIds(String ids) throws BusinessException - { - Long[] postIds = Convert.toLongArray(ids); - for (Long postId : postIds) - { - SysPost post = selectPostById(postId); - if (countUserPostById(postId) > 0) - { - throw new BusinessException(String.format("%1$s已分配,不能删除", post.getPostName())); - } - } - return postMapper.deletePostByIds(postIds); - } - - /** - * 新增保存岗位信息 - * - * @param post 岗位信息 - * @return 结果 - */ - @Override - public int insertPost(SysPost post) - { - return postMapper.insertPost(post); - } - - /** - * 修改保存岗位信息 - * - * @param post 岗位信息 - * @return 结果 - */ - @Override - public int updatePost(SysPost post) - { - return postMapper.updatePost(post); - } - - /** - * 通过岗位ID查询岗位使用数量 - * - * @param postId 岗位ID - * @return 结果 - */ - @Override - public int countUserPostById(Long postId) - { - return userPostMapper.countUserPostById(postId); - } - - /** - * 校验岗位名称是否唯一 - * - * @param post 岗位信息 - * @return 结果 - */ - @Override - public String checkPostNameUnique(SysPost post) - { - Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); - SysPost info = postMapper.checkPostNameUnique(post.getPostName()); - if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) - { - return UserConstants.POST_NAME_NOT_UNIQUE; - } - return UserConstants.POST_NAME_UNIQUE; - } - - /** - * 校验岗位编码是否唯一 - * - * @param post 岗位信息 - * @return 结果 - */ - @Override - public String checkPostCodeUnique(SysPost post) - { - Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); - SysPost info = postMapper.checkPostCodeUnique(post.getPostCode()); - if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) - { - return UserConstants.POST_CODE_NOT_UNIQUE; - } - return UserConstants.POST_CODE_UNIQUE; - } -} +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.mapper.SysPostMapper; +import com.ruoyi.system.mapper.SysUserPostMapper; +import com.ruoyi.system.service.ISysPostService; + +/** + * 岗位信息 服务层处理 + * + * @author ruoyi + */ +@Service +public class SysPostServiceImpl implements ISysPostService +{ + @Autowired + private SysPostMapper postMapper; + + @Autowired + private SysUserPostMapper userPostMapper; + + /** + * 查询岗位信息集合 + * + * @param post 岗位信息 + * @return 岗位信息集合 + */ + @Override + public List selectPostList(SysPost post) + { + return postMapper.selectPostList(post); + } + + /** + * 查询所有岗位 + * + * @return 岗位列表 + */ + @Override + public List selectPostAll() + { + return postMapper.selectPostAll(); + } + + /** + * 根据用户ID查询岗位 + * + * @param userId 用户ID + * @return 岗位列表 + */ + @Override + public List selectPostsByUserId(Long userId) + { + List userPosts = postMapper.selectPostsByUserId(userId); + List posts = postMapper.selectPostAll(); + for (SysPost post : posts) + { + for (SysPost userRole : userPosts) + { + if (post.getPostId().longValue() == userRole.getPostId().longValue()) + { + post.setFlag(true); + break; + } + } + } + return posts; + } + + /** + * 通过岗位ID查询岗位信息 + * + * @param postId 岗位ID + * @return 角色对象信息 + */ + @Override + public SysPost selectPostById(Long postId) + { + return postMapper.selectPostById(postId); + } + + /** + * 批量删除岗位信息 + * + * @param ids 需要删除的数据ID + * @throws Exception + */ + @Override + public int deletePostByIds(String ids) throws BusinessException + { + Long[] postIds = Convert.toLongArray(ids); + for (Long postId : postIds) + { + SysPost post = selectPostById(postId); + if (countUserPostById(postId) > 0) + { + throw new BusinessException(String.format("%1$s已分配,不能删除", post.getPostName())); + } + } + return postMapper.deletePostByIds(postIds); + } + + /** + * 新增保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public int insertPost(SysPost post) + { + return postMapper.insertPost(post); + } + + /** + * 修改保存岗位信息 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public int updatePost(SysPost post) + { + return postMapper.updatePost(post); + } + + /** + * 通过岗位ID查询岗位使用数量 + * + * @param postId 岗位ID + * @return 结果 + */ + @Override + public int countUserPostById(Long postId) + { + return userPostMapper.countUserPostById(postId); + } + + /** + * 校验岗位名称是否唯一 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public String checkPostNameUnique(SysPost post) + { + Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); + SysPost info = postMapper.checkPostNameUnique(post.getPostName()); + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) + { + return UserConstants.POST_NAME_NOT_UNIQUE; + } + return UserConstants.POST_NAME_UNIQUE; + } + + /** + * 校验岗位编码是否唯一 + * + * @param post 岗位信息 + * @return 结果 + */ + @Override + public String checkPostCodeUnique(SysPost post) + { + Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); + SysPost info = postMapper.checkPostCodeUnique(post.getPostCode()); + if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) + { + return UserConstants.POST_CODE_NOT_UNIQUE; + } + return UserConstants.POST_CODE_UNIQUE; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index caa9f5702..4b3ed745f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -1,365 +1,365 @@ -package com.ruoyi.system.service.impl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.common.annotation.DataScope; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.domain.SysRoleDept; -import com.ruoyi.system.domain.SysRoleMenu; -import com.ruoyi.system.domain.SysUserRole; -import com.ruoyi.system.mapper.SysRoleDeptMapper; -import com.ruoyi.system.mapper.SysRoleMapper; -import com.ruoyi.system.mapper.SysRoleMenuMapper; -import com.ruoyi.system.mapper.SysUserRoleMapper; -import com.ruoyi.system.service.ISysRoleService; - -/** - * 角色 业务层处理 - * - * @author ruoyi - */ -@Service -public class SysRoleServiceImpl implements ISysRoleService -{ - @Autowired - private SysRoleMapper roleMapper; - - @Autowired - private SysRoleMenuMapper roleMenuMapper; - - @Autowired - private SysUserRoleMapper userRoleMapper; - - @Autowired - private SysRoleDeptMapper roleDeptMapper; - - /** - * 根据条件分页查询角色数据 - * - * @param role 角色信息 - * @return 角色数据集合信息 - */ - @Override - @DataScope(deptAlias = "d") - public List selectRoleList(SysRole role) - { - return roleMapper.selectRoleList(role); - } - - /** - * 根据用户ID查询权限 - * - * @param userId 用户ID - * @return 权限列表 - */ - @Override - public Set selectRoleKeys(Long userId) - { - List perms = roleMapper.selectRolesByUserId(userId); - Set permsSet = new HashSet<>(); - for (SysRole perm : perms) - { - if (StringUtils.isNotNull(perm)) - { - permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); - } - } - return permsSet; - } - - /** - * 根据用户ID查询角色 - * - * @param userId 用户ID - * @return 角色列表 - */ - @Override - public List selectRolesByUserId(Long userId) - { - List userRoles = roleMapper.selectRolesByUserId(userId); - List roles = selectRoleAll(); - for (SysRole role : roles) - { - for (SysRole userRole : userRoles) - { - if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) - { - role.setFlag(true); - break; - } - } - } - return roles; - } - - /** - * 查询所有角色 - * - * @return 角色列表 - */ - @Override - public List selectRoleAll() - { - return SpringUtils.getAopProxy(this).selectRoleList(new SysRole()); - } - - /** - * 通过角色ID查询角色 - * - * @param roleId 角色ID - * @return 角色对象信息 - */ - @Override - public SysRole selectRoleById(Long roleId) - { - return roleMapper.selectRoleById(roleId); - } - - /** - * 通过角色ID删除角色 - * - * @param roleId 角色ID - * @return 结果 - */ - @Override - public boolean deleteRoleById(Long roleId) - { - return roleMapper.deleteRoleById(roleId) > 0 ? true : false; - } - - /** - * 批量删除角色信息 - * - * @param ids 需要删除的数据ID - * @throws Exception - */ - @Override - public int deleteRoleByIds(String ids) throws BusinessException - { - Long[] roleIds = Convert.toLongArray(ids); - for (Long roleId : roleIds) - { - SysRole role = selectRoleById(roleId); - if (countUserRoleByRoleId(roleId) > 0) - { - throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName())); - } - } - return roleMapper.deleteRoleByIds(roleIds); - } - - /** - * 新增保存角色信息 - * - * @param role 角色信息 - * @return 结果 - */ - @Override - @Transactional - public int insertRole(SysRole role) - { - // 新增角色信息 - roleMapper.insertRole(role); - return insertRoleMenu(role); - } - - /** - * 修改保存角色信息 - * - * @param role 角色信息 - * @return 结果 - */ - @Override - @Transactional - public int updateRole(SysRole role) - { - // 修改角色信息 - roleMapper.updateRole(role); - // 删除角色与菜单关联 - roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId()); - return insertRoleMenu(role); - } - - /** - * 修改数据权限信息 - * - * @param role 角色信息 - * @return 结果 - */ - @Override - @Transactional - public int authDataScope(SysRole role) - { - // 修改角色信息 - roleMapper.updateRole(role); - // 删除角色与部门关联 - roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId()); - // 新增角色和部门信息(数据权限) - return insertRoleDept(role); - } - - /** - * 新增角色菜单信息 - * - * @param role 角色对象 - */ - public int insertRoleMenu(SysRole role) - { - int rows = 1; - // 新增用户与角色管理 - List list = new ArrayList(); - for (Long menuId : role.getMenuIds()) - { - SysRoleMenu rm = new SysRoleMenu(); - rm.setRoleId(role.getRoleId()); - rm.setMenuId(menuId); - list.add(rm); - } - if (list.size() > 0) - { - rows = roleMenuMapper.batchRoleMenu(list); - } - return rows; - } - - /** - * 新增角色部门信息(数据权限) - * - * @param role 角色对象 - */ - public int insertRoleDept(SysRole role) - { - int rows = 1; - // 新增角色与部门(数据权限)管理 - List list = new ArrayList(); - for (Long deptId : role.getDeptIds()) - { - SysRoleDept rd = new SysRoleDept(); - rd.setRoleId(role.getRoleId()); - rd.setDeptId(deptId); - list.add(rd); - } - if (list.size() > 0) - { - rows = roleDeptMapper.batchRoleDept(list); - } - return rows; - } - - /** - * 校验角色名称是否唯一 - * - * @param role 角色信息 - * @return 结果 - */ - @Override - public String checkRoleNameUnique(SysRole role) - { - Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); - SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { - return UserConstants.ROLE_NAME_NOT_UNIQUE; - } - return UserConstants.ROLE_NAME_UNIQUE; - } - - /** - * 校验角色权限是否唯一 - * - * @param role 角色信息 - * @return 结果 - */ - @Override - public String checkRoleKeyUnique(SysRole role) - { - Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); - SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { - return UserConstants.ROLE_KEY_NOT_UNIQUE; - } - return UserConstants.ROLE_KEY_UNIQUE; - } - - /** - * 通过角色ID查询角色使用数量 - * - * @param roleId 角色ID - * @return 结果 - */ - @Override - public int countUserRoleByRoleId(Long roleId) - { - return userRoleMapper.countUserRoleByRoleId(roleId); - } - - /** - * 角色状态修改 - * - * @param role 角色信息 - * @return 结果 - */ - @Override - public int changeStatus(SysRole role) - { - return roleMapper.updateRole(role); - } - - /** - * 取消授权用户角色 - * - * @param userRole 用户和角色关联信息 - * @return 结果 - */ - @Override - public int deleteAuthUser(SysUserRole userRole) - { - return userRoleMapper.deleteUserRoleInfo(userRole); - } - - /** - * 批量取消授权用户角色 - * - * @param roleId 角色ID - * @param userIds 需要删除的用户数据ID - * @return 结果 - */ - public int deleteAuthUsers(Long roleId, String userIds) - { - return userRoleMapper.deleteUserRoleInfos(roleId, Convert.toLongArray(userIds)); - } - - /** - * 批量选择授权用户角色 - * - * @param roleId 角色ID - * @param userIds 需要删除的用户数据ID - * @return 结果 - */ - public int insertAuthUsers(Long roleId, String userIds) - { - Long[] users = Convert.toLongArray(userIds); - // 新增用户与角色管理 - List list = new ArrayList(); - for (Long userId : users) - { - SysUserRole ur = new SysUserRole(); - ur.setUserId(userId); - ur.setRoleId(roleId); - list.add(ur); - } - return userRoleMapper.batchUserRole(list); - } -} +package com.ruoyi.system.service.impl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.domain.SysRoleDept; +import com.ruoyi.system.domain.SysRoleMenu; +import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.mapper.SysRoleDeptMapper; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysRoleMenuMapper; +import com.ruoyi.system.mapper.SysUserRoleMapper; +import com.ruoyi.system.service.ISysRoleService; + +/** + * 角色 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysRoleServiceImpl implements ISysRoleService +{ + @Autowired + private SysRoleMapper roleMapper; + + @Autowired + private SysRoleMenuMapper roleMenuMapper; + + @Autowired + private SysUserRoleMapper userRoleMapper; + + @Autowired + private SysRoleDeptMapper roleDeptMapper; + + /** + * 根据条件分页查询角色数据 + * + * @param role 角色信息 + * @return 角色数据集合信息 + */ + @Override + @DataScope(deptAlias = "d") + public List selectRoleList(SysRole role) + { + return roleMapper.selectRoleList(role); + } + + /** + * 根据用户ID查询权限 + * + * @param userId 用户ID + * @return 权限列表 + */ + @Override + public Set selectRoleKeys(Long userId) + { + List perms = roleMapper.selectRolesByUserId(userId); + Set permsSet = new HashSet<>(); + for (SysRole perm : perms) + { + if (StringUtils.isNotNull(perm)) + { + permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); + } + } + return permsSet; + } + + /** + * 根据用户ID查询角色 + * + * @param userId 用户ID + * @return 角色列表 + */ + @Override + public List selectRolesByUserId(Long userId) + { + List userRoles = roleMapper.selectRolesByUserId(userId); + List roles = selectRoleAll(); + for (SysRole role : roles) + { + for (SysRole userRole : userRoles) + { + if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) + { + role.setFlag(true); + break; + } + } + } + return roles; + } + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + @Override + public List selectRoleAll() + { + return SpringUtils.getAopProxy(this).selectRoleList(new SysRole()); + } + + /** + * 通过角色ID查询角色 + * + * @param roleId 角色ID + * @return 角色对象信息 + */ + @Override + public SysRole selectRoleById(Long roleId) + { + return roleMapper.selectRoleById(roleId); + } + + /** + * 通过角色ID删除角色 + * + * @param roleId 角色ID + * @return 结果 + */ + @Override + public boolean deleteRoleById(Long roleId) + { + return roleMapper.deleteRoleById(roleId) > 0 ? true : false; + } + + /** + * 批量删除角色信息 + * + * @param ids 需要删除的数据ID + * @throws Exception + */ + @Override + public int deleteRoleByIds(String ids) throws BusinessException + { + Long[] roleIds = Convert.toLongArray(ids); + for (Long roleId : roleIds) + { + SysRole role = selectRoleById(roleId); + if (countUserRoleByRoleId(roleId) > 0) + { + throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName())); + } + } + return roleMapper.deleteRoleByIds(roleIds); + } + + /** + * 新增保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional + public int insertRole(SysRole role) + { + // 新增角色信息 + roleMapper.insertRole(role); + return insertRoleMenu(role); + } + + /** + * 修改保存角色信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional + public int updateRole(SysRole role) + { + // 修改角色信息 + roleMapper.updateRole(role); + // 删除角色与菜单关联 + roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId()); + return insertRoleMenu(role); + } + + /** + * 修改数据权限信息 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + @Transactional + public int authDataScope(SysRole role) + { + // 修改角色信息 + roleMapper.updateRole(role); + // 删除角色与部门关联 + roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId()); + // 新增角色和部门信息(数据权限) + return insertRoleDept(role); + } + + /** + * 新增角色菜单信息 + * + * @param role 角色对象 + */ + public int insertRoleMenu(SysRole role) + { + int rows = 1; + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long menuId : role.getMenuIds()) + { + SysRoleMenu rm = new SysRoleMenu(); + rm.setRoleId(role.getRoleId()); + rm.setMenuId(menuId); + list.add(rm); + } + if (list.size() > 0) + { + rows = roleMenuMapper.batchRoleMenu(list); + } + return rows; + } + + /** + * 新增角色部门信息(数据权限) + * + * @param role 角色对象 + */ + public int insertRoleDept(SysRole role) + { + int rows = 1; + // 新增角色与部门(数据权限)管理 + List list = new ArrayList(); + for (Long deptId : role.getDeptIds()) + { + SysRoleDept rd = new SysRoleDept(); + rd.setRoleId(role.getRoleId()); + rd.setDeptId(deptId); + list.add(rd); + } + if (list.size() > 0) + { + rows = roleDeptMapper.batchRoleDept(list); + } + return rows; + } + + /** + * 校验角色名称是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public String checkRoleNameUnique(SysRole role) + { + Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); + SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) + { + return UserConstants.ROLE_NAME_NOT_UNIQUE; + } + return UserConstants.ROLE_NAME_UNIQUE; + } + + /** + * 校验角色权限是否唯一 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public String checkRoleKeyUnique(SysRole role) + { + Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); + SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) + { + return UserConstants.ROLE_KEY_NOT_UNIQUE; + } + return UserConstants.ROLE_KEY_UNIQUE; + } + + /** + * 通过角色ID查询角色使用数量 + * + * @param roleId 角色ID + * @return 结果 + */ + @Override + public int countUserRoleByRoleId(Long roleId) + { + return userRoleMapper.countUserRoleByRoleId(roleId); + } + + /** + * 角色状态修改 + * + * @param role 角色信息 + * @return 结果 + */ + @Override + public int changeStatus(SysRole role) + { + return roleMapper.updateRole(role); + } + + /** + * 取消授权用户角色 + * + * @param userRole 用户和角色关联信息 + * @return 结果 + */ + @Override + public int deleteAuthUser(SysUserRole userRole) + { + return userRoleMapper.deleteUserRoleInfo(userRole); + } + + /** + * 批量取消授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int deleteAuthUsers(Long roleId, String userIds) + { + return userRoleMapper.deleteUserRoleInfos(roleId, Convert.toLongArray(userIds)); + } + + /** + * 批量选择授权用户角色 + * + * @param roleId 角色ID + * @param userIds 需要删除的用户数据ID + * @return 结果 + */ + public int insertAuthUsers(Long roleId, String userIds) + { + Long[] users = Convert.toLongArray(userIds); + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long userId : users) + { + SysUserRole ur = new SysUserRole(); + ur.setUserId(userId); + ur.setRoleId(roleId); + list.add(ur); + } + return userRoleMapper.batchUserRole(list); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java index b9d6f1d24..3a0216cf0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java @@ -1,115 +1,115 @@ -package com.ruoyi.system.service.impl; - -import java.util.Date; -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.system.domain.SysUserOnline; -import com.ruoyi.system.mapper.SysUserOnlineMapper; -import com.ruoyi.system.service.ISysUserOnlineService; - -/** - * 在线用户 服务层处理 - * - * @author ruoyi - */ -@Service -public class SysUserOnlineServiceImpl implements ISysUserOnlineService -{ - @Autowired - private SysUserOnlineMapper userOnlineDao; - - /** - * 通过会话序号查询信息 - * - * @param sessionId 会话ID - * @return 在线用户信息 - */ - @Override - public SysUserOnline selectOnlineById(String sessionId) - { - return userOnlineDao.selectOnlineById(sessionId); - } - - /** - * 通过会话序号删除信息 - * - * @param sessionId 会话ID - * @return 在线用户信息 - */ - @Override - public void deleteOnlineById(String sessionId) - { - SysUserOnline userOnline = selectOnlineById(sessionId); - if (StringUtils.isNotNull(userOnline)) - { - userOnlineDao.deleteOnlineById(sessionId); - } - } - - /** - * 通过会话序号删除信息 - * - * @param sessions 会话ID集合 - * @return 在线用户信息 - */ - @Override - public void batchDeleteOnline(List sessions) - { - for (String sessionId : sessions) - { - SysUserOnline userOnline = selectOnlineById(sessionId); - if (StringUtils.isNotNull(userOnline)) - { - userOnlineDao.deleteOnlineById(sessionId); - } - } - } - - /** - * 保存会话信息 - * - * @param online 会话信息 - */ - @Override - public void saveOnline(SysUserOnline online) - { - userOnlineDao.saveOnline(online); - } - - /** - * 查询会话集合 - * - * @param userOnline 在线用户 - */ - @Override - public List selectUserOnlineList(SysUserOnline userOnline) - { - return userOnlineDao.selectUserOnlineList(userOnline); - } - - /** - * 强退用户 - * - * @param sessionId 会话ID - */ - @Override - public void forceLogout(String sessionId) - { - userOnlineDao.deleteOnlineById(sessionId); - } - - /** - * 查询会话集合 - * - * @param expiredDate 失效日期 - */ - @Override - public List selectOnlineByExpired(Date expiredDate) - { - String lastAccessTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, expiredDate); - return userOnlineDao.selectOnlineByExpired(lastAccessTime); - } -} +package com.ruoyi.system.service.impl; + +import java.util.Date; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.domain.SysUserOnline; +import com.ruoyi.system.mapper.SysUserOnlineMapper; +import com.ruoyi.system.service.ISysUserOnlineService; + +/** + * 在线用户 服务层处理 + * + * @author ruoyi + */ +@Service +public class SysUserOnlineServiceImpl implements ISysUserOnlineService +{ + @Autowired + private SysUserOnlineMapper userOnlineDao; + + /** + * 通过会话序号查询信息 + * + * @param sessionId 会话ID + * @return 在线用户信息 + */ + @Override + public SysUserOnline selectOnlineById(String sessionId) + { + return userOnlineDao.selectOnlineById(sessionId); + } + + /** + * 通过会话序号删除信息 + * + * @param sessionId 会话ID + * @return 在线用户信息 + */ + @Override + public void deleteOnlineById(String sessionId) + { + SysUserOnline userOnline = selectOnlineById(sessionId); + if (StringUtils.isNotNull(userOnline)) + { + userOnlineDao.deleteOnlineById(sessionId); + } + } + + /** + * 通过会话序号删除信息 + * + * @param sessions 会话ID集合 + * @return 在线用户信息 + */ + @Override + public void batchDeleteOnline(List sessions) + { + for (String sessionId : sessions) + { + SysUserOnline userOnline = selectOnlineById(sessionId); + if (StringUtils.isNotNull(userOnline)) + { + userOnlineDao.deleteOnlineById(sessionId); + } + } + } + + /** + * 保存会话信息 + * + * @param online 会话信息 + */ + @Override + public void saveOnline(SysUserOnline online) + { + userOnlineDao.saveOnline(online); + } + + /** + * 查询会话集合 + * + * @param userOnline 在线用户 + */ + @Override + public List selectUserOnlineList(SysUserOnline userOnline) + { + return userOnlineDao.selectUserOnlineList(userOnline); + } + + /** + * 强退用户 + * + * @param sessionId 会话ID + */ + @Override + public void forceLogout(String sessionId) + { + userOnlineDao.deleteOnlineById(sessionId); + } + + /** + * 查询会话集合 + * + * @param expiredDate 失效日期 + */ + @Override + public List selectOnlineByExpired(Date expiredDate) + { + String lastAccessTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, expiredDate); + return userOnlineDao.selectOnlineByExpired(lastAccessTime); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java similarity index 96% rename from ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java rename to bmw-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index dd62ddeac..35d0307a7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/bmw-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -1,474 +1,474 @@ -package com.ruoyi.system.service.impl; - -import java.util.ArrayList; -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.common.annotation.DataScope; -import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.BusinessException; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.security.Md5Utils; -import com.ruoyi.system.domain.SysPost; -import com.ruoyi.system.domain.SysRole; -import com.ruoyi.system.domain.SysUser; -import com.ruoyi.system.domain.SysUserPost; -import com.ruoyi.system.domain.SysUserRole; -import com.ruoyi.system.mapper.SysPostMapper; -import com.ruoyi.system.mapper.SysRoleMapper; -import com.ruoyi.system.mapper.SysUserMapper; -import com.ruoyi.system.mapper.SysUserPostMapper; -import com.ruoyi.system.mapper.SysUserRoleMapper; -import com.ruoyi.system.service.ISysConfigService; -import com.ruoyi.system.service.ISysUserService; - -/** - * 用户 业务层处理 - * - * @author ruoyi - */ -@Service -public class SysUserServiceImpl implements ISysUserService -{ - private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); - - @Autowired - private SysUserMapper userMapper; - - @Autowired - private SysRoleMapper roleMapper; - - @Autowired - private SysPostMapper postMapper; - - @Autowired - private SysUserPostMapper userPostMapper; - - @Autowired - private SysUserRoleMapper userRoleMapper; - - @Autowired - private ISysConfigService configService; - - /** - * 根据条件分页查询用户列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - @Override - @DataScope(deptAlias = "d", userAlias = "u") - public List selectUserList(SysUser user) - { - return userMapper.selectUserList(user); - } - - /** - * 根据条件分页查询已分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - @DataScope(deptAlias = "d", userAlias = "u") - public List selectAllocatedList(SysUser user) - { - return userMapper.selectAllocatedList(user); - } - - /** - * 根据条件分页查询未分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - @DataScope(deptAlias = "d", userAlias = "u") - public List selectUnallocatedList(SysUser user) - { - return userMapper.selectUnallocatedList(user); - } - - /** - * 通过用户名查询用户 - * - * @param userName 用户名 - * @return 用户对象信息 - */ - @Override - public SysUser selectUserByLoginName(String userName) - { - return userMapper.selectUserByLoginName(userName); - } - - /** - * 通过手机号码查询用户 - * - * @param phoneNumber 手机号码 - * @return 用户对象信息 - */ - @Override - public SysUser selectUserByPhoneNumber(String phoneNumber) - { - return userMapper.selectUserByPhoneNumber(phoneNumber); - } - - /** - * 通过邮箱查询用户 - * - * @param email 邮箱 - * @return 用户对象信息 - */ - @Override - public SysUser selectUserByEmail(String email) - { - return userMapper.selectUserByEmail(email); - } - - /** - * 通过用户ID查询用户 - * - * @param userId 用户ID - * @return 用户对象信息 - */ - @Override - public SysUser selectUserById(Long userId) - { - return userMapper.selectUserById(userId); - } - - /** - * 通过用户ID删除用户 - * - * @param userId 用户ID - * @return 结果 - */ - @Override - public int deleteUserById(Long userId) - { - // 删除用户与角色关联 - userRoleMapper.deleteUserRoleByUserId(userId); - // 删除用户与岗位表 - userPostMapper.deleteUserPostByUserId(userId); - return userMapper.deleteUserById(userId); - } - - /** - * 批量删除用户信息 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - @Override - public int deleteUserByIds(String ids) throws BusinessException - { - Long[] userIds = Convert.toLongArray(ids); - for (Long userId : userIds) - { - if (SysUser.isAdmin(userId)) - { - throw new BusinessException("不允许删除超级管理员用户"); - } - } - return userMapper.deleteUserByIds(userIds); - } - - /** - * 新增保存用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - @Transactional - public int insertUser(SysUser user) - { - // 新增用户信息 - int rows = userMapper.insertUser(user); - // 新增用户岗位关联 - insertUserPost(user); - // 新增用户与角色管理 - insertUserRole(user); - return rows; - } - - /** - * 修改保存用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - @Transactional - public int updateUser(SysUser user) - { - Long userId = user.getUserId(); - // 删除用户与角色关联 - userRoleMapper.deleteUserRoleByUserId(userId); - // 新增用户与角色管理 - insertUserRole(user); - // 删除用户与岗位关联 - userPostMapper.deleteUserPostByUserId(userId); - // 新增用户与岗位管理 - insertUserPost(user); - return userMapper.updateUser(user); - } - - /** - * 修改用户个人详细信息 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - public int updateUserInfo(SysUser user) - { - return userMapper.updateUser(user); - } - - /** - * 修改用户密码 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - public int resetUserPwd(SysUser user) - { - return updateUserInfo(user); - } - - /** - * 新增用户角色信息 - * - * @param user 用户对象 - */ - public void insertUserRole(SysUser user) - { - Long[] roles = user.getRoleIds(); - if (StringUtils.isNotNull(roles)) - { - // 新增用户与角色管理 - List list = new ArrayList(); - for (Long roleId : roles) - { - SysUserRole ur = new SysUserRole(); - ur.setUserId(user.getUserId()); - ur.setRoleId(roleId); - list.add(ur); - } - if (list.size() > 0) - { - userRoleMapper.batchUserRole(list); - } - } - } - - /** - * 新增用户岗位信息 - * - * @param user 用户对象 - */ - public void insertUserPost(SysUser user) - { - Long[] posts = user.getPostIds(); - if (StringUtils.isNotNull(posts)) - { - // 新增用户与岗位管理 - List list = new ArrayList(); - for (Long postId : posts) - { - SysUserPost up = new SysUserPost(); - up.setUserId(user.getUserId()); - up.setPostId(postId); - list.add(up); - } - if (list.size() > 0) - { - userPostMapper.batchUserPost(list); - } - } - } - - /** - * 校验登录名称是否唯一 - * - * @param loginName 用户名 - * @return - */ - @Override - public String checkLoginNameUnique(String loginName) - { - int count = userMapper.checkLoginNameUnique(loginName); - if (count > 0) - { - return UserConstants.USER_NAME_NOT_UNIQUE; - } - return UserConstants.USER_NAME_UNIQUE; - } - - /** - * 校验用户名称是否唯一 - * - * @param user 用户信息 - * @return - */ - @Override - public String checkPhoneUnique(SysUser user) - { - Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); - SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { - return UserConstants.USER_PHONE_NOT_UNIQUE; - } - return UserConstants.USER_PHONE_UNIQUE; - } - - /** - * 校验email是否唯一 - * - * @param user 用户信息 - * @return - */ - @Override - public String checkEmailUnique(SysUser user) - { - Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); - SysUser info = userMapper.checkEmailUnique(user.getEmail()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) - { - return UserConstants.USER_EMAIL_NOT_UNIQUE; - } - return UserConstants.USER_EMAIL_UNIQUE; - } - - /** - * 查询用户所属角色组 - * - * @param userId 用户ID - * @return 结果 - */ - @Override - public String selectUserRoleGroup(Long userId) - { - List list = roleMapper.selectRolesByUserId(userId); - StringBuffer idsStr = new StringBuffer(); - for (SysRole role : list) - { - idsStr.append(role.getRoleName()).append(","); - } - if (StringUtils.isNotEmpty(idsStr.toString())) - { - return idsStr.substring(0, idsStr.length() - 1); - } - return idsStr.toString(); - } - - /** - * 查询用户所属岗位组 - * - * @param userId 用户ID - * @return 结果 - */ - @Override - public String selectUserPostGroup(Long userId) - { - List list = postMapper.selectPostsByUserId(userId); - StringBuffer idsStr = new StringBuffer(); - for (SysPost post : list) - { - idsStr.append(post.getPostName()).append(","); - } - if (StringUtils.isNotEmpty(idsStr.toString())) - { - return idsStr.substring(0, idsStr.length() - 1); - } - return idsStr.toString(); - } - - /** - * 导入用户数据 - * - * @param userList 用户数据列表 - * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 - * @param operName 操作用户 - * @return 结果 - */ - @Override - public String importUser(List userList, Boolean isUpdateSupport, String operName) - { - if (StringUtils.isNull(userList) || userList.size() == 0) - { - throw new BusinessException("导入用户数据不能为空!"); - } - int successNum = 0; - int failureNum = 0; - StringBuilder successMsg = new StringBuilder(); - StringBuilder failureMsg = new StringBuilder(); - String password = configService.selectConfigByKey("sys.user.initPassword"); - for (SysUser user : userList) - { - try - { - // 验证是否存在这个用户 - SysUser u = userMapper.selectUserByLoginName(user.getLoginName()); - if (StringUtils.isNull(u)) - { - user.setPassword(Md5Utils.hash(user.getLoginName() + password)); - user.setCreateBy(operName); - this.insertUser(user); - successNum++; - successMsg.append("
                            " + successNum + "、账号 " + user.getLoginName() + " 导入成功"); - } - else if (isUpdateSupport) - { - user.setUpdateBy(operName); - this.updateUser(user); - successNum++; - successMsg.append("
                            " + successNum + "、账号 " + user.getLoginName() + " 更新成功"); - } - else - { - failureNum++; - failureMsg.append("
                            " + failureNum + "、账号 " + user.getLoginName() + " 已存在"); - } - } - catch (Exception e) - { - failureNum++; - String msg = "
                            " + failureNum + "、账号 " + user.getLoginName() + " 导入失败:"; - failureMsg.append(msg + e.getMessage()); - log.error(msg, e); - } - } - if (failureNum > 0) - { - failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); - throw new BusinessException(failureMsg.toString()); - } - else - { - successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); - } - return successMsg.toString(); - } - - /** - * 用户状态修改 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - public int changeStatus(SysUser user) - { - if (SysUser.isAdmin(user.getUserId())) - { - throw new BusinessException("不允许修改超级管理员用户"); - } - return userMapper.updateUser(user); - } -} +package com.ruoyi.system.service.impl; + +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.security.Md5Utils; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.domain.SysRole; +import com.ruoyi.system.domain.SysUser; +import com.ruoyi.system.domain.SysUserPost; +import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.mapper.SysPostMapper; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.mapper.SysUserPostMapper; +import com.ruoyi.system.mapper.SysUserRoleMapper; +import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysUserService; + +/** + * 用户 业务层处理 + * + * @author ruoyi + */ +@Service +public class SysUserServiceImpl implements ISysUserService +{ + private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); + + @Autowired + private SysUserMapper userMapper; + + @Autowired + private SysRoleMapper roleMapper; + + @Autowired + private SysPostMapper postMapper; + + @Autowired + private SysUserPostMapper userPostMapper; + + @Autowired + private SysUserRoleMapper userRoleMapper; + + @Autowired + private ISysConfigService configService; + + /** + * 根据条件分页查询用户列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @Override + @DataScope(deptAlias = "d", userAlias = "u") + public List selectUserList(SysUser user) + { + return userMapper.selectUserList(user); + } + + /** + * 根据条件分页查询已分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @DataScope(deptAlias = "d", userAlias = "u") + public List selectAllocatedList(SysUser user) + { + return userMapper.selectAllocatedList(user); + } + + /** + * 根据条件分页查询未分配用户角色列表 + * + * @param user 用户信息 + * @return 用户信息集合信息 + */ + @DataScope(deptAlias = "d", userAlias = "u") + public List selectUnallocatedList(SysUser user) + { + return userMapper.selectUnallocatedList(user); + } + + /** + * 通过用户名查询用户 + * + * @param userName 用户名 + * @return 用户对象信息 + */ + @Override + public SysUser selectUserByLoginName(String userName) + { + return userMapper.selectUserByLoginName(userName); + } + + /** + * 通过手机号码查询用户 + * + * @param phoneNumber 手机号码 + * @return 用户对象信息 + */ + @Override + public SysUser selectUserByPhoneNumber(String phoneNumber) + { + return userMapper.selectUserByPhoneNumber(phoneNumber); + } + + /** + * 通过邮箱查询用户 + * + * @param email 邮箱 + * @return 用户对象信息 + */ + @Override + public SysUser selectUserByEmail(String email) + { + return userMapper.selectUserByEmail(email); + } + + /** + * 通过用户ID查询用户 + * + * @param userId 用户ID + * @return 用户对象信息 + */ + @Override + public SysUser selectUserById(Long userId) + { + return userMapper.selectUserById(userId); + } + + /** + * 通过用户ID删除用户 + * + * @param userId 用户ID + * @return 结果 + */ + @Override + public int deleteUserById(Long userId) + { + // 删除用户与角色关联 + userRoleMapper.deleteUserRoleByUserId(userId); + // 删除用户与岗位表 + userPostMapper.deleteUserPostByUserId(userId); + return userMapper.deleteUserById(userId); + } + + /** + * 批量删除用户信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteUserByIds(String ids) throws BusinessException + { + Long[] userIds = Convert.toLongArray(ids); + for (Long userId : userIds) + { + if (SysUser.isAdmin(userId)) + { + throw new BusinessException("不允许删除超级管理员用户"); + } + } + return userMapper.deleteUserByIds(userIds); + } + + /** + * 新增保存用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + @Transactional + public int insertUser(SysUser user) + { + // 新增用户信息 + int rows = userMapper.insertUser(user); + // 新增用户岗位关联 + insertUserPost(user); + // 新增用户与角色管理 + insertUserRole(user); + return rows; + } + + /** + * 修改保存用户信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + @Transactional + public int updateUser(SysUser user) + { + Long userId = user.getUserId(); + // 删除用户与角色关联 + userRoleMapper.deleteUserRoleByUserId(userId); + // 新增用户与角色管理 + insertUserRole(user); + // 删除用户与岗位关联 + userPostMapper.deleteUserPostByUserId(userId); + // 新增用户与岗位管理 + insertUserPost(user); + return userMapper.updateUser(user); + } + + /** + * 修改用户个人详细信息 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int updateUserInfo(SysUser user) + { + return userMapper.updateUser(user); + } + + /** + * 修改用户密码 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int resetUserPwd(SysUser user) + { + return updateUserInfo(user); + } + + /** + * 新增用户角色信息 + * + * @param user 用户对象 + */ + public void insertUserRole(SysUser user) + { + Long[] roles = user.getRoleIds(); + if (StringUtils.isNotNull(roles)) + { + // 新增用户与角色管理 + List list = new ArrayList(); + for (Long roleId : roles) + { + SysUserRole ur = new SysUserRole(); + ur.setUserId(user.getUserId()); + ur.setRoleId(roleId); + list.add(ur); + } + if (list.size() > 0) + { + userRoleMapper.batchUserRole(list); + } + } + } + + /** + * 新增用户岗位信息 + * + * @param user 用户对象 + */ + public void insertUserPost(SysUser user) + { + Long[] posts = user.getPostIds(); + if (StringUtils.isNotNull(posts)) + { + // 新增用户与岗位管理 + List list = new ArrayList(); + for (Long postId : posts) + { + SysUserPost up = new SysUserPost(); + up.setUserId(user.getUserId()); + up.setPostId(postId); + list.add(up); + } + if (list.size() > 0) + { + userPostMapper.batchUserPost(list); + } + } + } + + /** + * 校验登录名称是否唯一 + * + * @param loginName 用户名 + * @return + */ + @Override + public String checkLoginNameUnique(String loginName) + { + int count = userMapper.checkLoginNameUnique(loginName); + if (count > 0) + { + return UserConstants.USER_NAME_NOT_UNIQUE; + } + return UserConstants.USER_NAME_UNIQUE; + } + + /** + * 校验用户名称是否唯一 + * + * @param user 用户信息 + * @return + */ + @Override + public String checkPhoneUnique(SysUser user) + { + Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); + SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) + { + return UserConstants.USER_PHONE_NOT_UNIQUE; + } + return UserConstants.USER_PHONE_UNIQUE; + } + + /** + * 校验email是否唯一 + * + * @param user 用户信息 + * @return + */ + @Override + public String checkEmailUnique(SysUser user) + { + Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); + SysUser info = userMapper.checkEmailUnique(user.getEmail()); + if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) + { + return UserConstants.USER_EMAIL_NOT_UNIQUE; + } + return UserConstants.USER_EMAIL_UNIQUE; + } + + /** + * 查询用户所属角色组 + * + * @param userId 用户ID + * @return 结果 + */ + @Override + public String selectUserRoleGroup(Long userId) + { + List list = roleMapper.selectRolesByUserId(userId); + StringBuffer idsStr = new StringBuffer(); + for (SysRole role : list) + { + idsStr.append(role.getRoleName()).append(","); + } + if (StringUtils.isNotEmpty(idsStr.toString())) + { + return idsStr.substring(0, idsStr.length() - 1); + } + return idsStr.toString(); + } + + /** + * 查询用户所属岗位组 + * + * @param userId 用户ID + * @return 结果 + */ + @Override + public String selectUserPostGroup(Long userId) + { + List list = postMapper.selectPostsByUserId(userId); + StringBuffer idsStr = new StringBuffer(); + for (SysPost post : list) + { + idsStr.append(post.getPostName()).append(","); + } + if (StringUtils.isNotEmpty(idsStr.toString())) + { + return idsStr.substring(0, idsStr.length() - 1); + } + return idsStr.toString(); + } + + /** + * 导入用户数据 + * + * @param userList 用户数据列表 + * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 + * @param operName 操作用户 + * @return 结果 + */ + @Override + public String importUser(List userList, Boolean isUpdateSupport, String operName) + { + if (StringUtils.isNull(userList) || userList.size() == 0) + { + throw new BusinessException("导入用户数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + String password = configService.selectConfigByKey("sys.user.initPassword"); + for (SysUser user : userList) + { + try + { + // 验证是否存在这个用户 + SysUser u = userMapper.selectUserByLoginName(user.getLoginName()); + if (StringUtils.isNull(u)) + { + user.setPassword(Md5Utils.hash(user.getLoginName() + password)); + user.setCreateBy(operName); + this.insertUser(user); + successNum++; + successMsg.append("
                            " + successNum + "、账号 " + user.getLoginName() + " 导入成功"); + } + else if (isUpdateSupport) + { + user.setUpdateBy(operName); + this.updateUser(user); + successNum++; + successMsg.append("
                            " + successNum + "、账号 " + user.getLoginName() + " 更新成功"); + } + else + { + failureNum++; + failureMsg.append("
                            " + failureNum + "、账号 " + user.getLoginName() + " 已存在"); + } + } + catch (Exception e) + { + failureNum++; + String msg = "
                            " + failureNum + "、账号 " + user.getLoginName() + " 导入失败:"; + failureMsg.append(msg + e.getMessage()); + log.error(msg, e); + } + } + if (failureNum > 0) + { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new BusinessException(failureMsg.toString()); + } + else + { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } + + /** + * 用户状态修改 + * + * @param user 用户信息 + * @return 结果 + */ + @Override + public int changeStatus(SysUser user) + { + if (SysUser.isAdmin(user.getUserId())) + { + throw new BusinessException("不允许修改超级管理员用户"); + } + return userMapper.updateUser(user); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml b/bmw-system/src/main/resources/mapper/system/SysConfigMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysConfigMapper.xml index 4756c1f18..33cb5658b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysConfigMapper.xml @@ -1,108 +1,108 @@ - - - - - - - - - - - - - - - - - - select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark - from sys_config - - - - - - - and config_id = #{configId} - - - and config_key = #{configKey} - - - - - - - - - - - - insert into sys_config ( - config_name, - config_key, - config_value, - config_type, - create_by, - remark, - create_time - )values( - #{configName}, - #{configKey}, - #{configValue}, - #{configType}, - #{createBy}, - #{remark}, - sysdate() - ) - - - - update sys_config - - config_name = #{configName}, - config_key = #{configKey}, - config_value = #{configValue}, - config_type = #{configType}, - update_by = #{updateBy}, - remark = #{remark}, - update_time = sysdate() - - where config_id = #{configId} - - - - delete from sys_config where config_id in - - #{configId} - - - + + + + + + + + + + + + + + + + + + select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark + from sys_config + + + + + + + and config_id = #{configId} + + + and config_key = #{configKey} + + + + + + + + + + + + insert into sys_config ( + config_name, + config_key, + config_value, + config_type, + create_by, + remark, + create_time + )values( + #{configName}, + #{configKey}, + #{configValue}, + #{configType}, + #{createBy}, + #{remark}, + sysdate() + ) + + + + update sys_config + + config_name = #{configName}, + config_key = #{configKey}, + config_value = #{configValue}, + config_type = #{configType}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where config_id = #{configId} + + + + delete from sys_config where config_id in + + #{configId} + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/bmw-system/src/main/resources/mapper/system/SysDeptMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysDeptMapper.xml index 02a1017c5..a90ddfb79 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -1,154 +1,154 @@ - - - - - - - - - - - - - - - - - - - - - - - - select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time - from sys_dept d - - - - - - - - - - - - - - - - - - insert into sys_dept( - dept_id, - parent_id, - dept_name, - ancestors, - order_num, - leader, - phone, - email, - status, - create_by, - create_time - )values( - #{deptId}, - #{parentId}, - #{deptName}, - #{ancestors}, - #{orderNum}, - #{leader}, - #{phone}, - #{email}, - #{status}, - #{createBy}, - sysdate() - ) - - - - update sys_dept - - parent_id = #{parentId}, - dept_name = #{deptName}, - ancestors = #{ancestors}, - order_num = #{orderNum}, - leader = #{leader}, - phone = #{phone}, - email = #{email}, - status = #{status}, - update_by = #{updateBy}, - update_time = sysdate() - - where dept_id = #{deptId} - - - - update sys_dept set ancestors = - - when #{item.deptId} then #{item.ancestors} - - where dept_id in - - #{item.deptId} - - - - - update sys_dept set del_flag = '2' where dept_id = #{deptId} - - - - update sys_dept - - status = #{status}, - update_by = #{updateBy}, - update_time = sysdate() - - where dept_id in (${ancestors}) - - + + + + + + + + + + + + + + + + + + + + + + + + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time + from sys_dept d + + + + + + + + + + + + + + + + + + insert into sys_dept( + dept_id, + parent_id, + dept_name, + ancestors, + order_num, + leader, + phone, + email, + status, + create_by, + create_time + )values( + #{deptId}, + #{parentId}, + #{deptName}, + #{ancestors}, + #{orderNum}, + #{leader}, + #{phone}, + #{email}, + #{status}, + #{createBy}, + sysdate() + ) + + + + update sys_dept + + parent_id = #{parentId}, + dept_name = #{deptName}, + ancestors = #{ancestors}, + order_num = #{orderNum}, + leader = #{leader}, + phone = #{phone}, + email = #{email}, + status = #{status}, + update_by = #{updateBy}, + update_time = sysdate() + + where dept_id = #{deptId} + + + + update sys_dept set ancestors = + + when #{item.deptId} then #{item.ancestors} + + where dept_id in + + #{item.deptId} + + + + + update sys_dept set del_flag = '2' where dept_id = #{deptId} + + + + update sys_dept + + status = #{status}, + update_by = #{updateBy}, + update_time = sysdate() + + where dept_id in (${ancestors}) + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDictDataMapper.xml b/bmw-system/src/main/resources/mapper/system/SysDictDataMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysDictDataMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysDictDataMapper.xml index ccfea4d74..5f9c09dae 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDictDataMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysDictDataMapper.xml @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark - from sys_dict_data - - - - - - - - - - - - - - delete from sys_dict_data where dict_code = #{dictCode} - - - - delete from sys_dict_data where dict_code in - - #{dictCode} - - - - - update sys_dict_data - - dict_sort = #{dictSort}, - dict_label = #{dictLabel}, - dict_value = #{dictValue}, - dict_type = #{dictType}, - css_class = #{cssClass}, - list_class = #{listClass}, - is_default = #{isDefault}, - status = #{status}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = sysdate() - - where dict_code = #{dictCode} - - - - update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType} - - - - insert into sys_dict_data( - dict_sort, - dict_label, - dict_value, - dict_type, - css_class, - list_class, - is_default, - status, - remark, - create_by, - create_time - )values( - #{dictSort}, - #{dictLabel}, - #{dictValue}, - #{dictType}, - #{cssClass}, - #{listClass}, - #{isDefault}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + + + + + + select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark + from sys_dict_data + + + + + + + + + + + + + + delete from sys_dict_data where dict_code = #{dictCode} + + + + delete from sys_dict_data where dict_code in + + #{dictCode} + + + + + update sys_dict_data + + dict_sort = #{dictSort}, + dict_label = #{dictLabel}, + dict_value = #{dictValue}, + dict_type = #{dictType}, + css_class = #{cssClass}, + list_class = #{listClass}, + is_default = #{isDefault}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where dict_code = #{dictCode} + + + + update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType} + + + + insert into sys_dict_data( + dict_sort, + dict_label, + dict_value, + dict_type, + css_class, + list_class, + is_default, + status, + remark, + create_by, + create_time + )values( + #{dictSort}, + #{dictLabel}, + #{dictValue}, + #{dictType}, + #{cssClass}, + #{listClass}, + #{isDefault}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml b/bmw-system/src/main/resources/mapper/system/SysDictTypeMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysDictTypeMapper.xml index e2f69f92a..1f110e3f0 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysDictTypeMapper.xml @@ -1,100 +1,100 @@ - - - - - - - - - - - - - - - - - select dict_id, dict_name, dict_type, status, create_by, create_time, remark - from sys_dict_type - - - - - - - - - - - - delete from sys_dict_type where dict_id = #{dictId} - - - - delete from sys_dict_type where dict_id in - - #{dictId} - - - - - update sys_dict_type - - dict_name = #{dictName}, - dict_type = #{dictType}, - status = #{status}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = sysdate() - - where dict_id = #{dictId} - - - - insert into sys_dict_type( - dict_name, - dict_type, - status, - remark, - create_by, - create_time - )values( - #{dictName}, - #{dictType}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + select dict_id, dict_name, dict_type, status, create_by, create_time, remark + from sys_dict_type + + + + + + + + + + + + delete from sys_dict_type where dict_id = #{dictId} + + + + delete from sys_dict_type where dict_id in + + #{dictId} + + + + + update sys_dict_type + + dict_name = #{dictName}, + dict_type = #{dictType}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where dict_id = #{dictId} + + + + insert into sys_dict_type( + dict_name, + dict_type, + status, + remark, + create_by, + create_time + )values( + #{dictName}, + #{dictType}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml b/bmw-system/src/main/resources/mapper/system/SysLogininforMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysLogininforMapper.xml index a2ac5b4e5..cd42fff48 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysLogininforMapper.xml @@ -1,56 +1,56 @@ - - - - - - - - - - - - - - - - - - insert into sys_logininfor (login_name, status, ipaddr, login_location, browser, os, msg, login_time) - values (#{loginName}, #{status}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{msg}, sysdate()) - - - - - - delete from sys_logininfor where info_id in - - #{infoId} - - - - - truncate table sys_logininfor - - + + + + + + + + + + + + + + + + + + insert into sys_logininfor (login_name, status, ipaddr, login_location, browser, os, msg, login_time) + values (#{loginName}, #{status}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{msg}, sysdate()) + + + + + + delete from sys_logininfor where info_id in + + #{infoId} + + + + + truncate table sys_logininfor + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml b/bmw-system/src/main/resources/mapper/system/SysMenuMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysMenuMapper.xml index 47f9b8376..dd2cf40cc 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysMenuMapper.xml @@ -1,179 +1,179 @@ - - - - - - - - - - - - - - - - - - - - - - - - - select menu_id, menu_name, parent_id, order_num, url, target, menu_type, visible, ifnull(perms,'') as perms, icon, create_by, create_time - from sys_menu - - - - - - - - - - - - - - - - - - - - delete from sys_menu where menu_id = #{menuId} or parent_id = #{menuId} - - - - - - - - - - update sys_menu - - menu_name = #{menuName}, - parent_id = #{parentId}, - order_num = #{orderNum}, - url = #{url}, - target = #{target}, - menu_type = #{menuType}, - visible = #{visible}, - perms = #{perms}, - icon = #{icon}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = sysdate() - - where menu_id = #{menuId} - - - - insert into sys_menu( - menu_id, - parent_id, - menu_name, - order_num, - url, - target, - menu_type, - visible, - perms, - icon, - remark, - create_by, - create_time - )values( - #{menuId}, - #{parentId}, - #{menuName}, - #{orderNum}, - #{url}, - #{target}, - #{menuType}, - #{visible}, - #{perms}, - #{icon}, - #{remark}, - #{createBy}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + + + + + + + + + select menu_id, menu_name, parent_id, order_num, url, target, menu_type, visible, ifnull(perms,'') as perms, icon, create_by, create_time + from sys_menu + + + + + + + + + + + + + + + + + + + + delete from sys_menu where menu_id = #{menuId} or parent_id = #{menuId} + + + + + + + + + + update sys_menu + + menu_name = #{menuName}, + parent_id = #{parentId}, + order_num = #{orderNum}, + url = #{url}, + target = #{target}, + menu_type = #{menuType}, + visible = #{visible}, + perms = #{perms}, + icon = #{icon}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where menu_id = #{menuId} + + + + insert into sys_menu( + menu_id, + parent_id, + menu_name, + order_num, + url, + target, + menu_type, + visible, + perms, + icon, + remark, + create_by, + create_time + )values( + #{menuId}, + #{parentId}, + #{menuName}, + #{orderNum}, + #{url}, + #{target}, + #{menuType}, + #{visible}, + #{perms}, + #{icon}, + #{remark}, + #{createBy}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/bmw-system/src/main/resources/mapper/system/SysNoticeMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysNoticeMapper.xml index dfca13c04..588357393 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -1,85 +1,85 @@ - - - - - - - - - - - - - - - - - - - select notice_id, notice_title, notice_type, notice_content, status, create_by, create_time, update_by, update_time, remark - from sys_notice - - - - - - - - insert into sys_notice ( - notice_title, - notice_type, - notice_content, - status, - remark, - create_by, - create_time - )values( - #{noticeTitle}, - #{noticeType}, - #{noticeContent}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - - - update sys_notice - - notice_title = #{noticeTitle}, - notice_type = #{noticeType}, - notice_content = #{noticeContent}, - status = #{status}, - update_by = #{updateBy}, - update_time = sysdate() - - where notice_id = #{noticeId} - - - - delete from sys_notice where notice_id in - - #{noticeId} - - - + + + + + + + + + + + + + + + + + + + select notice_id, notice_title, notice_type, notice_content, status, create_by, create_time, update_by, update_time, remark + from sys_notice + + + + + + + + insert into sys_notice ( + notice_title, + notice_type, + notice_content, + status, + remark, + create_by, + create_time + )values( + #{noticeTitle}, + #{noticeType}, + #{noticeContent}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + + update sys_notice + + notice_title = #{noticeTitle}, + notice_type = #{noticeType}, + notice_content = #{noticeContent}, + status = #{status}, + update_by = #{updateBy}, + update_time = sysdate() + + where notice_id = #{noticeId} + + + + delete from sys_notice where notice_id in + + #{noticeId} + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml b/bmw-system/src/main/resources/mapper/system/SysOperLogMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysOperLogMapper.xml index b75e78dc3..02e890b9e 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysOperLogMapper.xml @@ -1,80 +1,80 @@ - - - - - - - - - - - - - - - - - - - - - - - select oper_id, title, business_type, method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, status, error_msg, oper_time - from sys_oper_log - - - - insert into sys_oper_log(title, business_type, method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, status, error_msg, oper_time) - values (#{title}, #{businessType}, #{method}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{status}, #{errorMsg}, sysdate()) - - - - - - delete from sys_oper_log where oper_id in - - #{operId} - - - - - - - truncate table sys_oper_log - - + + + + + + + + + + + + + + + + + + + + + + + select oper_id, title, business_type, method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, status, error_msg, oper_time + from sys_oper_log + + + + insert into sys_oper_log(title, business_type, method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, status, error_msg, oper_time) + values (#{title}, #{businessType}, #{method}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{status}, #{errorMsg}, sysdate()) + + + + + + delete from sys_oper_log where oper_id in + + #{operId} + + + + + + + truncate table sys_oper_log + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml b/bmw-system/src/main/resources/mapper/system/SysPostMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysPostMapper.xml index 8b0c0292c..c45491972 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysPostMapper.xml @@ -1,110 +1,110 @@ - - - - - - - - - - - - - - - - - - - select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark - from sys_post - - - - - - - - - - - - - - - - delete from sys_post where post_id in - - #{postId} - - - - - update sys_post - - post_code = #{postCode}, - post_name = #{postName}, - post_sort = #{postSort}, - status = #{status}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = sysdate() - - where post_id = #{postId} - - - - insert into sys_post( - post_id, - post_code, - post_name, - post_sort, - status, - remark, - create_by, - create_time - )values( - #{postId}, - #{postCode}, - #{postName}, - #{postSort}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + + + select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark + from sys_post + + + + + + + + + + + + + + + + delete from sys_post where post_id in + + #{postId} + + + + + update sys_post + + post_code = #{postCode}, + post_name = #{postName}, + post_sort = #{postSort}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where post_id = #{postId} + + + + insert into sys_post( + post_id, + post_code, + post_name, + post_sort, + status, + remark, + create_by, + create_time + )values( + #{postId}, + #{postCode}, + #{postName}, + #{postSort}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml b/bmw-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml index 700671e15..7c4139bce 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml @@ -1,34 +1,34 @@ - - - - - - - - - - - delete from sys_role_dept where role_id=#{roleId} - - - - - - delete from sys_role_dept where role_id in - - #{roleId} - - - - - insert into sys_role_dept(role_id, dept_id) values - - (#{item.roleId},#{item.deptId}) - - - + + + + + + + + + + + delete from sys_role_dept where role_id=#{roleId} + + + + + + delete from sys_role_dept where role_id in + + #{roleId} + + + + + insert into sys_role_dept(role_id, dept_id) values + + (#{item.roleId},#{item.deptId}) + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/bmw-system/src/main/resources/mapper/system/SysRoleMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysRoleMapper.xml index 8d810c395..d1bca839c 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, - r.status, r.del_flag, r.create_time, r.remark - from sys_role r - left join sys_user_role ur on ur.role_id = r.role_id - left join sys_user u on u.user_id = ur.user_id - left join sys_dept d on u.dept_id = d.dept_id - - - - select r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status, r.del_flag, r.create_time, r.remark - from sys_role r - - - - - - - - - - - - - - delete from sys_role where role_id = #{roleId} - - - - update sys_role set del_flag = '2' where role_id in - - #{roleId} - - - - - update sys_role - - role_name = #{roleName}, - role_key = #{roleKey}, - role_sort = #{roleSort}, - data_scope = #{dataScope}, - status = #{status}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = sysdate() - - where role_id = #{roleId} - - - - insert into sys_role( - role_id, - role_name, - role_key, - role_sort, - data_scope, - status, - remark, - create_by, - create_time - )values( - #{roleId}, - #{roleName}, - #{roleKey}, - #{roleSort}, - #{dataScope}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + + + + + select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, + r.status, r.del_flag, r.create_time, r.remark + from sys_role r + left join sys_user_role ur on ur.role_id = r.role_id + left join sys_user u on u.user_id = ur.user_id + left join sys_dept d on u.dept_id = d.dept_id + + + + select r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status, r.del_flag, r.create_time, r.remark + from sys_role r + + + + + + + + + + + + + + delete from sys_role where role_id = #{roleId} + + + + update sys_role set del_flag = '2' where role_id in + + #{roleId} + + + + + update sys_role + + role_name = #{roleName}, + role_key = #{roleKey}, + role_sort = #{roleSort}, + data_scope = #{dataScope}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where role_id = #{roleId} + + + + insert into sys_role( + role_id, + role_name, + role_key, + role_sort, + data_scope, + status, + remark, + create_by, + create_time + )values( + #{roleId}, + #{roleName}, + #{roleKey}, + #{roleSort}, + #{dataScope}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml b/bmw-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml index f509d207e..d213bdde0 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml @@ -1,34 +1,34 @@ - - - - - - - - - - - delete from sys_role_menu where role_id=#{roleId} - - - - - - delete from sys_role_menu where role_id in - - #{roleId} - - - - - insert into sys_role_menu(role_id, menu_id) values - - (#{item.roleId},#{item.menuId}) - - - + + + + + + + + + + + delete from sys_role_menu where role_id=#{roleId} + + + + + + delete from sys_role_menu where role_id in + + #{roleId} + + + + + insert into sys_role_menu(role_id, menu_id) values + + (#{item.roleId},#{item.menuId}) + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/bmw-system/src/main/resources/mapper/system/SysUserMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysUserMapper.xml index d60370bd7..b4b211492 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -1,219 +1,219 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_time, u.remark, - d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status, - r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status - from sys_user u - left join sys_dept d on u.dept_id = d.dept_id - left join sys_user_role ur on u.user_id = ur.user_id - left join sys_role r on r.role_id = ur.role_id - - - - - - - - - - - - - - - - - - - - - - - - delete from sys_user where user_id = #{userId} - - - - update sys_user set del_flag = '2' where user_id in - - #{userId} - - - - - update sys_user - - dept_id = #{deptId}, - login_name = #{loginName}, - user_name = #{userName}, - email = #{email}, - phonenumber = #{phonenumber}, - sex = #{sex}, - avatar = #{avatar}, - password = #{password}, - salt = #{salt}, - status = #{status}, - login_ip = #{loginIp}, - login_date = #{loginDate}, - update_by = #{updateBy}, - remark = #{remark}, - update_time = sysdate() - - where user_id = #{userId} - - - - insert into sys_user( - user_id, - dept_id, - login_name, - user_name, - email, - avatar, - phonenumber, - sex, - password, - salt, - status, - create_by, - remark, - create_time - )values( - #{userId}, - #{deptId}, - #{loginName}, - #{userName}, - #{email}, - #{avatar}, - #{phonenumber}, - #{sex}, - #{password}, - #{salt}, - #{status}, - #{createBy}, - #{remark}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_time, u.remark, + d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status, + r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status + from sys_user u + left join sys_dept d on u.dept_id = d.dept_id + left join sys_user_role ur on u.user_id = ur.user_id + left join sys_role r on r.role_id = ur.role_id + + + + + + + + + + + + + + + + + + + + + + + + delete from sys_user where user_id = #{userId} + + + + update sys_user set del_flag = '2' where user_id in + + #{userId} + + + + + update sys_user + + dept_id = #{deptId}, + login_name = #{loginName}, + user_name = #{userName}, + email = #{email}, + phonenumber = #{phonenumber}, + sex = #{sex}, + avatar = #{avatar}, + password = #{password}, + salt = #{salt}, + status = #{status}, + login_ip = #{loginIp}, + login_date = #{loginDate}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where user_id = #{userId} + + + + insert into sys_user( + user_id, + dept_id, + login_name, + user_name, + email, + avatar, + phonenumber, + sex, + password, + salt, + status, + create_by, + remark, + create_time + )values( + #{userId}, + #{deptId}, + #{loginName}, + #{userName}, + #{email}, + #{avatar}, + #{phonenumber}, + #{sex}, + #{password}, + #{salt}, + #{status}, + #{createBy}, + #{remark}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml b/bmw-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml index 56adfd320..6098ee84a 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml @@ -1,57 +1,57 @@ - - - - - - - - - - - - - - - - - - - - select sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time - from sys_user_online - - - - - - replace into sys_user_online(sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time) - values (#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime}) - - - - delete from sys_user_online where sessionId = #{sessionId} - - - - - - + + + + + + + + + + + + + + + + + + + + select sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time + from sys_user_online + + + + + + replace into sys_user_online(sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time) + values (#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime}) + + + + delete from sys_user_online where sessionId = #{sessionId} + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml b/bmw-system/src/main/resources/mapper/system/SysUserPostMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysUserPostMapper.xml index 21c40981b..2b90bc40b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysUserPostMapper.xml @@ -1,34 +1,34 @@ - - - - - - - - - - - delete from sys_user_post where user_id=#{userId} - - - - - - delete from sys_user_post where user_id in - - #{userId} - - - - - insert into sys_user_post(user_id, post_id) values - - (#{item.userId},#{item.postId}) - - - + + + + + + + + + + + delete from sys_user_post where user_id=#{userId} + + + + + + delete from sys_user_post where user_id in + + #{userId} + + + + + insert into sys_user_post(user_id, post_id) values + + (#{item.userId},#{item.postId}) + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml b/bmw-system/src/main/resources/mapper/system/SysUserRoleMapper.xml similarity index 97% rename from ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml rename to bmw-system/src/main/resources/mapper/system/SysUserRoleMapper.xml index 95e07adb1..dd726891a 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml +++ b/bmw-system/src/main/resources/mapper/system/SysUserRoleMapper.xml @@ -1,44 +1,44 @@ - - - - - - - - - - - delete from sys_user_role where user_id=#{userId} - - - - - - delete from sys_user_role where user_id in - - #{userId} - - - - - insert into sys_user_role(user_id, role_id) values - - (#{item.userId},#{item.roleId}) - - - - - delete from sys_user_role where user_id=#{userId} and role_id=#{roleId} - - - - delete from sys_user_role where role_id=#{roleId} and user_id in - - #{userId} - - + + + + + + + + + + + delete from sys_user_role where user_id=#{userId} + + + + + + delete from sys_user_role where user_id in + + #{userId} + + + + + insert into sys_user_role(user_id, role_id) values + + (#{item.userId},#{item.roleId}) + + + + + delete from sys_user_role where user_id=#{userId} and role_id=#{roleId} + + + + delete from sys_user_role where role_id=#{roleId} and user_id in + + #{userId} + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 09cf4d020..1f3f35756 100644 --- a/pom.xml +++ b/pom.xml @@ -207,12 +207,12 @@ - ruoyi-admin - ruoyi-framework - ruoyi-system - ruoyi-quartz - ruoyi-generator - ruoyi-common + bmw-admin + bmw-framework + bmw-system + bmw-quartz + bmw-generator + bmw-common pom diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java deleted file mode 100644 index a0e726bd4..000000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ruoyi; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; - -/** - * 启动程序 - * - * @author ruoyi - */ -@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) -public class RuoYiApplication -{ - public static void main(String[] args) - { - // System.setProperty("spring.devtools.restart.enabled", "false"); - SpringApplication.run(RuoYiApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); - } -} \ No newline at end of file