\x20\t\r\n\f]*)[^>]*)\/>/gi,Aa=/
-
-
- ```
-
-- **第二步: **
- 在module/config.js里面找到menus变量,添加如下所示:
-
- 
-
-- **第三步: **
- 运行项目,查看效果
-
- 
-
-### 2.3.添加第三方layui扩展模块
-
-> 分离版本和不分离版本添加layui扩展模块都按如下方式来。
-
-请参考项目里面formSelects的添加方法。
-- 第一步: 把下载的模块放在module文件夹下面
-- 第二步: 打开index.html
-
- ```javascript
- layui.config({
- base: 'module/'
- }).extend({
- formSelects: 'formSelects/formSelects-v4'
- }).use(['config', 'admin', 'formSelects'], function () {
- var config = layui.config;
- var admin = layui.admin;
- var formSelects = layui.formSelects;
-
- });
- ```
-
- 如果你的模块没有文件夹直接在module里面就不需要写extend了,如果你的模块有独立的文件夹,像formSelects一样,
-就需要在extend里面明确指出模块的位置。
-
-
-
-
----
-
-## 3.开发指南
-
-### 3.1.开发规范
-
-阅读开发规范之前请先了解前面“项目结构”的介绍。
-
-1. css、图片、第三方lib(layui扩展模块除外)全部放在“/assets/”下面;
-2. layui扩展模块放在“module”下面,例如项目里面“formSelects”模块;
-3. 页面html放在“pages”下面。
-
-> 注意:不分离版本html不需要放在“pages”下面,随便放,因为是后端渲染,前端只需要访问后端的url。
-> 比如我这里不分离版本是放在templates目录下面,templates是SpringBoot默认的视图目录。
-
-
-### 3.2.入口index.html
-
-index.html是项目的主入口,打开index.html你会看到如下代码:
-
-```javascript
-layui.config({
- base: 'module/'
-}).extend({
- formSelects: 'formSelects/formSelects-v4'
-}).use(['config', 'admin','index'], function () {
- var config = layui.config;
- var admin = layui.admin;
- var index = layui.admin;
-
-});
-```
-
- 这段代码首先告诉了lauyui扩展模块都位于“module/”下面,然后扩展模块因为formSelects使用了文件夹
-存放,所以需要在“extend”中明确指出formSelects模块js的位置。 为什么admin.js、config.js不需要写extend,
-因为admin和config是直接放在module里面。
-
- 接着index.html里面使用了“config”、“admin”等模块,所以admin模块里面的一些方法也就即刻执行了。
-admin提供的默认事件也就生效了。
-
-> 注意:不分离版本去除了config.js,所以index.html不需要加载config。
-
-### 3.3.“config”模块介绍
-
-> 注意:不分离版本去除了config.js,不分离的项目也不需要前端做任何配置和缓存。
-
-“config”模块主要是配置项目的一些基本参数。
-
-名称 | 类型 | 描述
-:---|:--- |:---
-base_server | 变量 | 服务器接口地址
-tableName | 变量 | 本地存储表名(token等都会存储在本地中)
-pageTabs | 变量 | 是否开启多标签模式,(**不分离版本在index.js中配置**)
-getToken | 方法 | 获取缓存的token
-putToken | 方法 | 缓存token
-removeToken | 方法 | 清除缓存的token
-menus | 变量 | 侧导航菜单数组,侧导航根据menus自动渲染
-getUser | 方法 | 获取缓存的用户信息
-putUser | 方法 | 缓存用户的信息
-
-注意:因为我这边的后台返回的token是这样的
-```json
-{
- "access_token": "950a7cc9-5a8a-42c9-a693-40e817b1a4b0",
- "token_type": "bearer",
- "refresh_token": "773a0fcd-6023-45f8-8848-e141296cb3cb",
- "expires_in": 27036,
- "scope": "select"
-}
-```
- 所以我这边的token不是一个字符串存储的,是用json存储的,getToken返回的是一个json对象,
-如果你的token只是一个字符串,请修改getToken方法和admin里面的req方法,当然我建议最好
-命令你的后台人员按这个json格式返回数据,这个是一个标准的格式。
-
-#### 3.3.1.“config”使用示例
-```javascript
-layui.use(['config'], function () {
- var config = layui.config;
-
- var token = config.getToken(); // 获取token
- var access_token = token.access_token; //获取access_token
-
- config.putToken(xxx);
-});
-```
-
-#### 3.3.2.“menus”数组介绍
-config.js里面的menus格式如下:
-```javascript
-menus: [{
- name: '主页',
- url: 'javascript:;',
- icon: 'layui-icon-home',
- subMenus: [{
- name: '主页一',
- url: '#!console',
- path: 'console.html'
- }]
-}, {
- name: '系统管理',
- icon: 'layui-icon-set',
- url: 'javascript:;',
- subMenus: [{
- name: '用户管理',
- url: '#!user', // 这里url不能带斜杠
- path: user_search.html,
- auth: 'post:/user/query'
- }, {
- name: '角色管理',
- url: '#!role',
- path: 'system/role.html',
- auth: 'get:/role'
- }]
-}, {
- name: '多级菜单',
- url: 'javascript:;',
- icon: 'layui-icon-unlink',
- subMenus: [{
- name: '二级菜单',
- url: 'javascript:;',
- subMenus: [{
- name: '三级菜单',
- url: 'javascript:;'
- }]
- }]
-}, {
- name: '一级菜单',
- url: 'javascript:;',
- icon: 'layui-icon-unlink'
-},{
- name: '我是隐藏菜单',
- url: '#!userDetail',
- path: 'system/user_detail.html',
- hidden: true
-}]
-```
-
- index.js里面会自动使用menus数组渲染左侧导航栏,并且会使用url作为关键字自动注册路由监听。
-目前只设定了最多支持三菜单,原因是因为模板引擎渲染无法使用递归,所以写了三层循环,如果你需要更多级的菜单,
-继续加循环就可以了,主要是因为无法递归,并不是无法做到无限级。
-
-- `path` 表示html所在的路径,会在pages目录下面寻找。
-- `url` 是路由的关键字,也就是说点击这个菜单,浏览器地址栏的url会变成`/#!xxx`。
-- `auth` 表示这个菜单需要什么权限,index.js渲染的时候会自动判断权限,没有权限不会渲染出来,不写auth不会进行判断。
-- `hidden` 表示菜单是否渲染到左侧导航栏,比如用户详情界面,不需要渲染到左侧导航,name最好也填写,因为在多标签功能中,
- name是作为选项卡的标题。建议隐藏的菜单都写在最后面,不要写在subMenus里面,当然写在哪都可以实现。
- 如何打开隐藏的菜单,直接使用` `即可,或者`Q.go('userDetail')`。
-
- 上面的menus数组已经展示了各种不同的写法,根部不同场景决定某些参数是否填写。
-
-**注意:**
- 路由关键字`url`不能带`/`,在EasyWeb1.0版本中,url是以`#!system/xxx`这种格式作为关键字的,这种注册方法
-是把`system/`开头的所有url一起注册,但是在2.0版本中使用的是循环menus数组一个一个注册,所以url有`/`就会变成第一种格式,是不正确的。
-
-### 3.4.admin模块介绍
-
-admin模块做了很多的操作,这里只重点介绍admin对外封装的一些操作方法。
-
-> 不分离版本admin.js去掉了hasPerm方法,其他方法可以放心使用。
-
-#### 3.4.1.admin提供的默认事件
-使用示例:
-```html
-全屏
-折叠导航
-```
- 只需要在DOM节点上面添加ew-event="xx"即可,此时这个DOM节点就会自动加入相关的点击事件了。全部事件如下表:
-
-事件 | 描述
-:---|:---
-flexible | 折叠侧导航
-refresh | 刷新主体部分
-back | 浏览器后退
-theme | 打开主题设置弹窗
-fullScreen | 全屏切换
-leftPage | 左滚动选项卡
-rightPage | 右滚动选项卡
-closeThisTabs | 关闭当前选项卡
-closeOtherTabs | 关闭其他选项卡
-closeAllTabs | 关闭全部选项卡
-closeDialog | 关闭元素所在的layer弹窗
-
-#### 3.4.2.admin提供的方法
-使用示例:
-```javascript
-layui.use(['admin'], function () {
- var admin = layui.admin;
-
- admin.flexible(true); // 折叠侧导航
-});
-```
-
-全部方法:
-
-方法 | 参数 | 描述
-:---|:--- |:---
-flexible(expand) | true和false | 折叠侧导航
-activeNav(url) | a标签里面的href值 | 设置侧导航栏选中
-refresh() | 无 | 刷新主体部分
- | |
-popupRight(path) | html地址 | 右侧弹出弹窗
-closePopupRight() | 无 | 关闭右侧弹出
- | |
-popupCenter(object) | 见单独说明 | 中间弹出弹窗
-finishPopupCenter() | 无 | 关闭中间弹出弹窗并回调finish方法
-closePopupCenter() | 无 | 关闭中间弹出弹窗
- | |
-open(object) | 见单独说明 | 封装layer弹出弹窗
- | |
-req(url, data, success, method) | 见单独说明 | 封装的ajax请求,req只返回json
-ajax(object) | 见单独说明 | 封装的ajax请求
- | |
-hasPerm(auth) | 权限标识 | 判断用户是否有权限,不分离版本无此方法
- | |
-putTempData(key, value) | key,value | 缓存临时数据
-getTempData(key,) | key | 获取缓存的临时数据
- | |
-rollPage(d) | 方向 | 滚动选项卡tab
-
-
-
-> 首先说明一下admin为什么要封装那么多layer的弹窗,因为admin封装的弹窗都是支持弹窗的内容是一个单独的页面,
-并且不是以iframe的方式嵌入页面,也就是单页面的形式。
-
-
-
-
-##### 3.4.2.1.右侧弹出弹窗popupRight
-使用示例:
-```javascript
-admin.popupRight('pages/tpl/message.html');
-```
-> 分离版本填写独立的html页面即可,不分离版本填写后台的url(Controller)
-
-“message.html”里面也可以有js代码,如下所示:
-```html
-
-
-
-```
-
-> 注意:因为是单页面,不是iframe,所以页面里面请不要写` `之类的东西。
-
-
-效果图:
-
-
-
-##### 3.4.2.2.中间弹出弹窗popupCenter
- admin封装的popupCenter虽然没有什么特别的样式,但是带有回调的功能。
-
-使用示例(一般用在表单弹窗,如添加、修改用户等):
-```javascript
-admin.popupCenter({
- title: '添加用户',
- path: 'pages/system/user_form.html',
- finish: function () {
-
- // 这个方法就是回调的功能,用户添加成功之后让表格reload
- table.reload('user-table', {});
-
- }
-});
-```
-
-**参数说明:**
-
-参数 | 类型 | 是否必须 | 描述
-:---|:--- |:--- |:---
-title | 变量 | 否 | 标题,不写没有标题
-`path` | 变量 | 是 | html路径
-`finish` | 方法 | 否 | finish回调
-success | 方法 | 否 | html渲染完毕的回调
-end | 方法 | 否 | 弹窗关闭的回调
-... | ... | ... | 省略更多参数
-
-
-
-> 请注意,除了`path`和`finish`是popupCenter新增的参数,其他参数均与layer的open参数一样,但是`type`和`content`参数无效,
-> type固定是1(页面层),content会被path的内容覆盖。
-
-
-
-“user_form.html”内容如下:
-```html
-
-
-
-```
-
-示例图:
-
-
-
-完整示例代码:
-```javascript
-// 全部参数都写
-admin.popupCenter({
- title: '添加用户',
- path: 'pages/system/user_form.html',
- finish: function () {
- // finish回调
- },
- success: function() {
- // user_form.html成功渲染到弹窗中
- },
- end: function() {
- // 弹窗关闭
- }
-});
-
-// 只写必须参数
-admin.popupCenter({path: 'pages/system/user_form.html'});
-```
-
-
-
-##### 3.4.2.3.封装的layer弹窗open
-
- 前面讲了admin所封装的弹窗目的是在不使用iframe的前提下支持使用独立的页面,这样便于我们维护代码,减少一个页面里面的代码量。
-
-使用方法:
-
-```javascript
-admin.open({
- title: 'xxx',
- path: 'system/user_form.html',
- success: function(){
-
- }
-});
-```
-
-参数说明:
-
- `path`是新增的参数,其他参数均为layer.open的参数,但是`type`和`content`参数无效,type固定是1(页面层),
-content会被path的内容覆盖,open没有finish方法,popupCenter才有。
-
-
-
-
-**如何让弹窗出现滚动条?**
-
-
- 弹窗的默认高度是自适应的,设置了宽高后内容超出是无法出现滚动条的,因为出现弹窗里面的下拉框select下拉会出现滚动条,所以amdin.css里面
-禁止了弹窗的滚动条,如果你需要弹窗出现滚动条,请使用如下的方式:
-```javascript
-admin.open({
- title: 'xxxxx',
- area: ['500px','300px'],
- path: 'system/user/editForm',
- success: function (layero, index) {
- // 关键代码, ↑↑↑↑↑↑↑↑↑↑↑↑↑(上面的两个参数不要忘了)
- $(layero).children('.layui-layer-content').css('overflow-y', 'scroll');
- }
-});
-```
-只需要在success回调方法里面手动加上样式就可以了。
-```javascript
-// 写scroll可以防止弹窗内表格出现滚动条
-$(layero).children('.layui-layer-content').css('overflow-y', 'scroll');
-
-// 弹窗内没有表格使用auto即可
-$(layero).children('.layui-layer-content').css('overflow-y', 'auto');
-
-// 水平垂直都有滚动条使用overflow
-$(layero).children('.layui-layer-content').css('overflow', 'auto');
-```
-admin.popupCenter也同样支持此使用方法
-
-
-
-##### 3.4.2.4.封装的ajax请求req
-
-> 注意:req不支持指定返回的数据类型(json、html、text等),只会返回json的数据。
-
- admin模块封装的ajax请求会自动传递token(access_token),并且会自动把PUT、DELETE请求转成POST、GET请求
-然后加参数_method,因为浏览器不支持PUT、DELETE请求的参数传递,具体原因请百度一下,**不分离版本不会进行此操作**。
-
- 另外分离版本和不分离版本封装的ajax和req都会检验状态码(401登录过期,403没有权限),登录过期会自动跳转到登录界面。
-
-使用示例:
-
-```javascript
-// 不传递参数的写法
-admin.req('user', {}, function (data) {
- console.log(JSON.stringify(data));
-}, 'GET');
-
-// 传递参数的写法
-admin.req('user', {
- userId: 'xxx',
- userName: '张三'
-}, function (data) {
- console.log(JSON.stringify(data));
-}, 'POST');
-```
-
-**方法参数说明:**
-
-- 第一个参数: 接口地址,会自动在前面加入config.base_server
-- 第二个参数: 传给服务器的参数
-- 第三个参数: 请求成功的回调(如果出现http错误404,401等,也会进入这个回调,并且data里面会有code、msg两个参数,
- code是http的错误码,msg是错误信息)
-- 第四个参数: 请求的方法(GET、POST、PUT、DELETE)
-
- req还会自动判断token是否过期,如果token过期会自动跳转到登录页面,不分离版本是根据code判断401为登录过期。
-
-
-##### 3.4.2.5.封装的ajax请求ajax
-
-使用方法:
-```javascript
-admin.ajax({
- url: 'xxxx',
- data: {
- aa:''
- },
- dataType: 'json',
- type: 'POST',
- success: function(result,status,xhr) {
-
- }
-});
-```
-
- 使用方法跟`$.ajax`一模一样,admin封装只是在success之后先判断是否为登录过期和没有权限,然后再执行你的success方法。
-
- 使用参数也跟`$.ajax`一样,请到[http://www.runoob.com/jquery/ajax-ajax.html](http://www.runoob.com/jquery/ajax-ajax.html)文档中查看`$.ajax`的参数说明。
-
-
-
-
-
-##### 3.4.2.6.判断是否有权限hasPerm
-
-> 注意:不分离版本没有此方法。
-
- 这个方法是用来判断当前登录的用户是否有某一权限的操作,使用这个方法的前提是在index.js里面有一个获取
-服务器的user信息并使用config.putUser方法缓存,并且user里面包含了权限列表,因为admin会调用config.getUser获取
-用户信息从而获取用户的权限列表。
-
- 我这里面服务器返回的用户json信息如下所示,如果你的服务器返回的信息跟下面不一样,请修改hasPerm方法:
-
-```json
-{
- "userId": "admin",
- "username": "admin",
- "nickName": "管理员",
- "authorities": [{
- "authority": "get:/role"
- }, {
- "authority": "put:/role"
- }]
-}
-```
-
-authorities就是用户的权限集合,authority是权限标识。
-
-使用示例,下面的示例是演示没有删除用户的权限隐藏删除按钮:
-```html
-
- 删除
-
-
-
-```
-
-> 如果你担心把按钮隐藏了没有什么卵用,会点技术就可以把按钮在弄出来了,这个担心完全是多余的。
-> 因为后台的接口也会有权限验证的,如果没有权限接口会返回{ code: 401, msg: "没有访问权限" },
-> 既然后台限制了,界面为什么还要限制,因为这是需求,如你项目没有隐藏按钮的需求可以不用隐藏。
-
-
-##### 3.4.2.7.缓存临时数据putTempData
- 这个方法是用来把一些临时数据放在session中,页面关闭数据就会失效。 适当使用缓存可以
-减少接口请求次数,提升用户体验。
-
-使用示例:
-```javascript
-
-admin.putTempData('t_name', '张三'); // 缓存数据
-
-var tName = admin.getTempData('t_name'); // 获取缓存数据
-
-console.log(tName);
-
-```
-
-**使用场景:**
-
- 前面讲了popupCenter弹出添加用户的界面,如果是修改用户,是不是应该传递user的信息呢,
-因为修改界面需要回显user的信息,这时就可以用putTempData了,当然也有别的办法传递,这里就不一一演示了。
-
-修改用户按钮的界面(user.html):
-```html
-修改用户
-
-
-```
-修改用户弹窗的界面(user_form.html):
-```html
-
-
-
-```
-
-##### 3.4.2.8 滚动选项卡 rollPage
-使用示例:
-```javascript
-// 向左滚动
-admin.rollPage('left');
-
-// 滚动到当前选中的选项卡
-admin.rollPage('auto');
-
-// 向右滚动
-admin.rollPage();
-```
-参数说明:
-- left - 向左滚动
-- auto - 滚动到当前选项卡
-- 其他 - 向右滚动,不写参数就是向右滚动
-
-
-
-### 3.5.index模块介绍
-
- index模块主要是用于加载index.html的
-header、side等,获取用户的信息,判断是否开启选项卡改变页面局部等操作,说白了就是用来初始化后台布局的,用于给主体部分的界面
-做准备,虽然index.js里面代码行数也不少,但是仔细看就能看懂,注释也都写了,如果你需要
-微微修改阅读几遍就可以上手修改了,下面只介绍两个其他页面会用到的封装方法。
-
-> 需要注意的是:分离和不分离版本的index.js和index.html里面的一些写法有很些不同,请注意不要用混淆了。
-
-
-#### 3.5.1.打开新页面或选项卡Tab
-
-```javascript
-layui.use(['index'], function () {
- var index = layui.index;
-
- // 不分离用后台地址
- index.openNewTab({
- title:'个人信息',
- url:'system/user/myInfo?userId=1',
- menuId: 'myInfo'
- });
-
- // 分离用html页面
- index.openNewTab({
- title: '个人信息',
- url: 'pages/system/myInfo.html',
- menuId: 'myInfo'
- });
-
- // 当然这行代码一般会写在按钮点击事件里面,直接写在这里就立即打开新页面了
-});
-```
-
-- `title` 如果开启了多标签,title是选项卡的标题
-- `url` 打开的页面地址
-- `menuId` 这个参数是一个id标识,浏览器地址栏会变成`#!menuId`。
-
-这个功能的使用场景请见`3.8.1`章节
-
-
-#### 3.5.2.关闭选项卡
-
-```javascript
-layui.use(['index'], function () {
- var index = layui.index;
-
- var menuId = 'myInfo';
- index.closeTab(menuId);
-});
-```
-
-
----
-
-
-
-### 3.6.admin提供的css公共类
-
-> 分离和不分离版本css都是一样的,这部分文档就不需要注意什么了,哈哈😄~
-
-#### 3.6.1.辅助类
-
-类名(class) | 说明
-:---|:---
-icon-btn | 带图标的按钮,如果你的按钮用了图标加上类这个更好看
-date-icon | 在元素的右边加入日期的图标
-layui-link | 用于a标签,字体颜色为layui的绿色风格
-layui-text | 用于a标签的上层,a标签字体颜色为蓝色
-pull-right | 右浮动
-inline-block | 设置元素display为inline-block
-
-
-
----
-
-
-
----
-
-
-
----
-
-
-
-```html
-
-
-
-
- 搜索
- 添加
-
-
-帐号注册
-忘记密码?
-
-
-
-
-```
-
-
-#### 3.6.2.表格上方的工具栏
-
-类名(class) | 说明
-:---|:---
-search-input | 表格上面的输入框样式
-toolbar | 表格上方工具栏样式
-
-```html
-
-
-
- 搜索:
-
- -请选择-
- ID
- 账号
-
-
-
-
-
- 搜索
- 添加
-
-
-
-
-```
-
-
-
-
-#### 3.6.3.弹窗里面的表单
-
-类名(class) | 说明
-:---|:---
-model-form | 弹窗里面的表单样式
-model-form-footer | 弹窗里面表单底部操作按钮容器的样式
-
-```html
-
-```
-
-
-
-
-#### 3.6.4.完全基于layui后台大布局
- EasyWeb完全基于layui的后台大布局进行样式修改,html结构是完全基于layui的后台大布局的,所以项目里面的
-admin.css你可以用于任何layui后台大布局的页面,加入之后你的页面就得到EasyWeb的样式了, 但是侧导航栏
-的折叠事件、全屏等事件是写在admin.js里面的,所以建议你直接使用EasyWeb的框架,当然如果你有自己的基于layui后台
-大布局的框架,完全可以使用我的admin.css。
-
-
-### 3.7.鼠标经过自动弹出tips层
-使用示例:
-```html
-按钮
-```
- 只需要在你的DOM节点上面添加`lay-tips="xxx"`,然后这个节点在鼠标滑过的时候就会自动显示tips层了,简单吧!
-
-**默认提示位置在元素的上面,修改位置可以这样做:**
-```html
-按钮
-```
-再加一个`lay-direction`属性就可以了,参数如下:
-- 1 - 上面,默认,可以不写
-- 2 - 右边
-- 3 - 下面
-- 4 - 左边
-
-效果图:
-
-
-
-
-### 3.8.路由的使用
- 路由这里使用的是Q.js框架,如果你的左侧菜单是配置在config.menus里面的话,不需要自己注册路由监听,
-index.js里面会自动帮你注册。
-
- 如果你需要自己添加路由注册监听的话,请参考q.js的开发文档:[Q.js](https://github.com/itorr/q.js)。
-
-**注意:**
- EasyWeb里面使用的q.js进行过修改,我在里面加了一个刷新的方法,所以请不要擅自替换q.js文件,如果你发现
-q.js框架出来新版本了,请联系我进行替换,请多多包含,不要嫌麻烦,以免出问题。
-
-
-#### 3.8.1.打开不在导航栏中的页面
-
- 比如用户详情、个人信息这些页面,它们不在左侧导航中,但是想打开新页面或者选项卡,
-又比如添加用户、修改用户这个页面现在是用弹窗的形式,如果想用新页面的形式该怎么实现:
-
-**第一种实现方式:**
- 在分离版本中,你只需要在config.js的menus数组中添加一个隐藏的菜单:
-```javascript
-menus: [{
- name: '个人信息',
- url: '#!myInfo',
- path: 'system/my_info.html',
- hidden: true
-}]
-```
-html中跳转:
-```html
-个人信息
-```
-js中跳转:
-```javascript
-Q.go('myInfo');
-```
-
-> 或许你已经注意到了,这种方式跳转的界面是一个固定页面,如果我们想要传递一些参数,
-> 它就无法满足,所以有了第二种实现方式。
-
-
-**第二种实现方式:**
-```javascript
-layui.use(['index'], function () {
- var index = layui.index;
-
- // 不分离用后台地址
- index.openNewTab({
- title:'个人信息',
- url:'system/user/myInfo?userId=1',
- menuId: 'myInfo'
- });
-
- // 分离用html页面
- index.openNewTab({
- title: '个人信息',
- url: 'pages/system/myInfo.html',
- menuId: 'myInfo'
- });
-
- // 当然这行代码一般会写在按钮点击事件里面,直接写在这里就立即打开新页面了
-});
-```
-
-- `title` 如果开启了多标签,title是选项卡的标题
-- `url` 打开的页面地址
-- `menuId` 这个参数是一个id标识,如果id一样就只会存在一个tab,也就是说打开一次没有关闭就不会再打开新的页面,
- 比如用户详情页面,如果你想userA的详情和userB的详情是两个页面,可以同时存在选项卡中,menuId就不要写一样的。
-
-
-> 注意:
-> 分离版本两种方式都可以用,不分离版本只能用第二种方式,再分离版本中不能使用`?`问号传递参数,建议使用
-> 临时缓存的方式传递参数。
-
-
-请到`3.5.1`和`3.5.2`章节查看跟这个使用场景相关的其他功能方法。
-
-
----
-
-
-### 3.9.mvvm数据绑定、组件等
- 虽然现在vue很流行,但是jquery的许多方法仍然很好用,所以现在很多项目里面既有vue,又有jquery,
-然而对于开发一个后台管理系统来说,我们仅仅用了vue的数据渲染功能,大部分还是用的jquery的代码,这样一来项目
-就显得有点不伦不类了。
-
- 但是对于前后端分离来说,mvvm的框架渲染数据确实很方便,很强大,layui虽然提供了模板引擎,
-但是写法别扭,还麻烦,pandyle.js是一个为jquery打造的mvvm框架,还提供了类似vue组件的写法。
-
- EasyWeb里面的头部header、side等都是使用的它的组件的写法,还有一些下拉框select的渲染也是用的它提供的mvvm的写法。
-
- 我这里就不提供pandyle.js的用法了,以免跟不上pandyle作者的更新脚步,
-大家可以到这里[pandyle.js](https://gitee.com/pandarrr/pandyle)查看pandyle的开发文档。
-
-> 注意:
-> 不分离版本没有引入pandyle.js,不分离版本的header和side是使用beetl的布局功能实现的,如果你需要在
-> 不分离版本中使用mvvm,请自行在idnex.html中引入pandyle.js。
-
-
-### 3.10.主题功能
- EasyWeb包含前后台,所以开发时间比较紧张,暂时只提供了两套主题,但是提供了一个主题生成器,
-请使用主题生成器定制化你的样式:[EasyWeb主题生成器](https://whvse.gitee.io/easywebpage/docs/generater_theme.html)。
-
- EasyWeb的主题生成器可以深度定制主题,样式深度到按钮、单选框、下拉框、选项卡等样式。
-
-
-
-### 3.11.不分离版本
-
-注意:
-
- 你从EasyWebPage这个地址下载下来的项目是前后端分离版本的,如果你需要前后端不分离版本的页面和后台,
-请从[easyweb-shiro](https://gitee.com/whvse/easyweb-shiro)下载。 easyweb-shiro是Java语言开发的,如果你是
-php或其他后台语言,想要使用不分离版的页面,请联系作者辅助你结合到你的项目中,因为不分离版本页面跟后台耦合比较大,
-分离出静态页面意义不大,所以不分离版本作者就没有独立再维护成纯静态页面了。
-
-
-
-### 3.12.树形表格treeTable
-
-在layui的数据表格上进行扩展实现的。
-
-treeTable项目地址:[https://gitee.com/whvse/treetable-lay](https://gitee.com/whvse/treetable-lay)。
-
-- 演示地址: [https://whvse.gitee.io/treetable-lay/](https://whvse.gitee.io/treetable-lay/)
-
-截图:
-
-树形表格1:
-
-
-
-树形表格2:
-
-
-
-
-## 4.项目截图
-
-
-
-
-
-
-
-
-
----
-
-## 5.更新日志
-
-- **2018-07-22 - 增加树形表格的功能**
-
- - 增加树形表格的功能 [treeTable](#_312树形表格treeTable)
-
-- **2018-07-20 - 发布不分离版的easyweb-shiro稳定版本**
-
- - 不分离版没有config.js,但是同样支持分离版的所有功能
- - 改进路由的注册方法,全部由框架自动完成,开发方式与传统一样,但是可以轻松的使用路由功能提升操作体验
-
-- **2018-07-12 - 增加主题、多标签**
-
- - 增加多标签tab功能,并且增加自由切换是否开启多标签功能
- - 增加主题切换功能,上线 [主题生成器](#_310主题功能) ,自由生成主题样式
-
-- **2018-06-28 - 发布全新2.0版本**
-
- - 引入pandyle.js(mvvm框架),填补layui模板引擎的短板
- - 采用模块化开发方式,定义admin、config等公用模块,封装ajax请求
- - 界面优化,借鉴layadmin的设计风格,改版登录页面
-
-- **2018-02-11 - 发布EasyWeb1.0版本**
-
- - 基于layui后台大布局、q.js路由框架搭建出第一个版本
- - 1.0 版本在easyweb的gitee附件中下载
-
-
-## 6.联系方式
-### 6.1.欢迎加入“前后端分离技术交流群”
-
-
-### 6.2.我要打赏
- 都是猿友,撸码不易,如果这个轮子对你有用,不妨打赏一下!
-[码云](https://gitee.com/whvse/EasyWebPage)已开启捐赠功能,谢谢支持!
-
- EasyWeb目前提供了“路由+mvvm分离版”、“基于oauth2的后台”、“基于shiro的不分离版”、“不分离版的页面”、
-“EasyWeb主题生成器”、“前端开发文档”等项目,并且全部开源,欢迎加入一起开发,或者提交pull requests。
+# EasyWeb 前端开发文档
+
+
+## 1.简介
+
+> 基于jquery、layui的管理系统模板,单页面、响应式、支持mvvm、极易上手!
+
+* 演示地址:[https://whvse.gitee.io/easywebpage/](https://whvse.gitee.io/easywebpage/login.html)
+* 演示账号:随便输 密码:随便输
+
+ EasyWeb包含前后台,
+[前台地址](https://gitee.com/whvse/EasyWebPage),
+[分离版后台地址](https://gitee.com/whvse/EasyWeb),
+[不分离版后台地址](https://gitee.com/whvse/easyweb-shiro),
+后台基于springboot、mybatis、mybatis-plus、Security、OAuth2等,不分离版权限使用shiro。
+
+ 此文档包含分离和不分离版本的前端开发指南,两者的使用是有些区别的,
+不同的地方在文档中都着重指明了,参考文档使用即可。
+
+### 1.1.使用框架
+
+描述 | 框架
+:---|:---
+核心框架 | [Layui](http://www.layui.com/)、[jQuery](http://jquery.cuishifeng.cn/)
+路由框架 | [Q.js](https://github.com/itorr/q.js) (纯js轻量级路由框架)
+mvvm框架 | [pandyle.js](https://gitee.com/pandarrr/pandyle) (专为jquery编写的mvvm)
+主要特色 | 单页面 / 响应式 / 简约 / 极易上手
+
+### 1.2.项目结构
+
+```
+|-assets
+| |-css // 样式
+| |-images // 图片
+| |-libs // 第三方库
+|
+|-pages // html组件
+| |-system // 系统管理页面
+| |-xxxxxx // 其他业务页面
+| |-tpl // 公用组件
+| | |-message.html // 消息
+| |-console.html // 主页一
+| |-header.html // 头部
+| |-side.html // 侧导航
+|
+|-module // js模块 (使用layui的模块开发方式)
+| |-admin.js // admin模块
+| |-config.js // config模块
+| |-index.js // index模块
+|
+|-index.html // 主界面
+|-login.html // 登陆界面
+```
+
+> 不分离版没有pages目录,不分离版的页面由后台输出,前端只有assets和module
+
+
+## 2.快速开始
+
+ 快速开始之前请确保你已经接触过[layui](http://www.layui.com/doc/)并了解layui的使用,
+尤其是layui模块的使用。否则看本文档会比较吃力。
+
+### 2.1.导入项目
+
+1. 直接下载项目,或使用git下载;
+2. 使用IDEA(WebStorm)或者HBuilder等前端开发工具进行开发;
+3. 运行login.html或者index.html启动:
+
+ 
+
+
+### 2.2.添加一个业务界面
+
+> 注意:以下操作针对于分离版本,不分离版本菜单维护在数据库,页面由后台渲染,不需要前端有复杂的操作。
+
+比如你要做一个CMS系统,添加一个文章管理界面:
+
+- **第一步: **
+ 在pages文件夹下面建一个目录cms,然后新建一个页面article.html
+
+ 
+
+ article.html完整代码:
+
+ ```html
+
+
+
+
+
+
+ ```
+
+- **第二步: **
+ 在module/config.js里面找到menus变量,添加如下所示:
+
+ 
+
+- **第三步: **
+ 运行项目,查看效果
+
+ 
+
+### 2.3.添加第三方layui扩展模块
+
+> 分离版本和不分离版本添加layui扩展模块都按如下方式来。
+
+请参考项目里面formSelects的添加方法。
+- 第一步: 把下载的模块放在module文件夹下面
+- 第二步: 打开index.html
+
+ ```javascript
+ layui.config({
+ base: 'module/'
+ }).extend({
+ formSelects: 'formSelects/formSelects-v4'
+ }).use(['config', 'admin', 'formSelects'], function () {
+ var config = layui.config;
+ var admin = layui.admin;
+ var formSelects = layui.formSelects;
+
+ });
+ ```
+
+ 如果你的模块没有文件夹直接在module里面就不需要写extend了,如果你的模块有独立的文件夹,像formSelects一样,
+就需要在extend里面明确指出模块的位置。
+
+
+
+
+---
+
+## 3.开发指南
+
+### 3.1.开发规范
+
+阅读开发规范之前请先了解前面“项目结构”的介绍。
+
+1. css、图片、第三方lib(layui扩展模块除外)全部放在“/assets/”下面;
+2. layui扩展模块放在“module”下面,例如项目里面“formSelects”模块;
+3. 页面html放在“pages”下面。
+
+> 注意:不分离版本html不需要放在“pages”下面,随便放,因为是后端渲染,前端只需要访问后端的url。
+> 比如我这里不分离版本是放在templates目录下面,templates是SpringBoot默认的视图目录。
+
+
+### 3.2.入口index.html
+
+index.html是项目的主入口,打开index.html你会看到如下代码:
+
+```javascript
+layui.config({
+ base: 'module/'
+}).extend({
+ formSelects: 'formSelects/formSelects-v4'
+}).use(['config', 'admin','index'], function () {
+ var config = layui.config;
+ var admin = layui.admin;
+ var index = layui.admin;
+
+});
+```
+
+ 这段代码首先告诉了lauyui扩展模块都位于“module/”下面,然后扩展模块因为formSelects使用了文件夹
+存放,所以需要在“extend”中明确指出formSelects模块js的位置。 为什么admin.js、config.js不需要写extend,
+因为admin和config是直接放在module里面。
+
+ 接着index.html里面使用了“config”、“admin”等模块,所以admin模块里面的一些方法也就即刻执行了。
+admin提供的默认事件也就生效了。
+
+> 注意:不分离版本去除了config.js,所以index.html不需要加载config。
+
+### 3.3.“config”模块介绍
+
+> 注意:不分离版本去除了config.js,不分离的项目也不需要前端做任何配置和缓存。
+
+“config”模块主要是配置项目的一些基本参数。
+
+名称 | 类型 | 描述
+:---|:--- |:---
+base_server | 变量 | 服务器接口地址
+tableName | 变量 | 本地存储表名(token等都会存储在本地中)
+pageTabs | 变量 | 是否开启多标签模式,(**不分离版本在index.js中配置**)
+getToken | 方法 | 获取缓存的token
+putToken | 方法 | 缓存token
+removeToken | 方法 | 清除缓存的token
+menus | 变量 | 侧导航菜单数组,侧导航根据menus自动渲染
+getUser | 方法 | 获取缓存的用户信息
+putUser | 方法 | 缓存用户的信息
+
+注意:因为我这边的后台返回的token是这样的
+```json
+{
+ "access_token": "950a7cc9-5a8a-42c9-a693-40e817b1a4b0",
+ "token_type": "bearer",
+ "refresh_token": "773a0fcd-6023-45f8-8848-e141296cb3cb",
+ "expires_in": 27036,
+ "scope": "select"
+}
+```
+ 所以我这边的token不是一个字符串存储的,是用json存储的,getToken返回的是一个json对象,
+如果你的token只是一个字符串,请修改getToken方法和admin里面的req方法,当然我建议最好
+命令你的后台人员按这个json格式返回数据,这个是一个标准的格式。
+
+#### 3.3.1.“config”使用示例
+```javascript
+layui.use(['config'], function () {
+ var config = layui.config;
+
+ var token = config.getToken(); // 获取token
+ var access_token = token.access_token; //获取access_token
+
+ config.putToken(xxx);
+});
+```
+
+#### 3.3.2.“menus”数组介绍
+config.js里面的menus格式如下:
+```javascript
+menus: [{
+ name: '主页',
+ url: 'javascript:;',
+ icon: 'layui-icon-home',
+ subMenus: [{
+ name: '主页一',
+ url: '#!console',
+ path: 'console.html'
+ }]
+}, {
+ name: '系统管理',
+ icon: 'layui-icon-set',
+ url: 'javascript:;',
+ subMenus: [{
+ name: '用户管理',
+ url: '#!user', // 这里url不能带斜杠
+ path: user_search.html,
+ auth: 'post:/user/query'
+ }, {
+ name: '角色管理',
+ url: '#!role',
+ path: 'system/role.html',
+ auth: 'get:/role'
+ }]
+}, {
+ name: '多级菜单',
+ url: 'javascript:;',
+ icon: 'layui-icon-unlink',
+ subMenus: [{
+ name: '二级菜单',
+ url: 'javascript:;',
+ subMenus: [{
+ name: '三级菜单',
+ url: 'javascript:;'
+ }]
+ }]
+}, {
+ name: '一级菜单',
+ url: 'javascript:;',
+ icon: 'layui-icon-unlink'
+},{
+ name: '我是隐藏菜单',
+ url: '#!userDetail',
+ path: 'system/user_detail.html',
+ hidden: true
+}]
+```
+
+ index.js里面会自动使用menus数组渲染左侧导航栏,并且会使用url作为关键字自动注册路由监听。
+目前只设定了最多支持三菜单,原因是因为模板引擎渲染无法使用递归,所以写了三层循环,如果你需要更多级的菜单,
+继续加循环就可以了,主要是因为无法递归,并不是无法做到无限级。
+
+- `path` 表示html所在的路径,会在pages目录下面寻找。
+- `url` 是路由的关键字,也就是说点击这个菜单,浏览器地址栏的url会变成`/#!xxx`。
+- `auth` 表示这个菜单需要什么权限,index.js渲染的时候会自动判断权限,没有权限不会渲染出来,不写auth不会进行判断。
+- `hidden` 表示菜单是否渲染到左侧导航栏,比如用户详情界面,不需要渲染到左侧导航,name最好也填写,因为在多标签功能中,
+ name是作为选项卡的标题。建议隐藏的菜单都写在最后面,不要写在subMenus里面,当然写在哪都可以实现。
+ 如何打开隐藏的菜单,直接使用` `即可,或者`Q.go('userDetail')`。
+
+ 上面的menus数组已经展示了各种不同的写法,根部不同场景决定某些参数是否填写。
+
+**注意:**
+ 路由关键字`url`不能带`/`,在EasyWeb1.0版本中,url是以`#!system/xxx`这种格式作为关键字的,这种注册方法
+是把`system/`开头的所有url一起注册,但是在2.0版本中使用的是循环menus数组一个一个注册,所以url有`/`就会变成第一种格式,是不正确的。
+
+### 3.4.admin模块介绍
+
+admin模块做了很多的操作,这里只重点介绍admin对外封装的一些操作方法。
+
+> 不分离版本admin.js去掉了hasPerm方法,其他方法可以放心使用。
+
+#### 3.4.1.admin提供的默认事件
+使用示例:
+```html
+全屏
+折叠导航
+```
+ 只需要在DOM节点上面添加ew-event="xx"即可,此时这个DOM节点就会自动加入相关的点击事件了。全部事件如下表:
+
+事件 | 描述
+:---|:---
+flexible | 折叠侧导航
+refresh | 刷新主体部分
+back | 浏览器后退
+theme | 打开主题设置弹窗
+fullScreen | 全屏切换
+leftPage | 左滚动选项卡
+rightPage | 右滚动选项卡
+closeThisTabs | 关闭当前选项卡
+closeOtherTabs | 关闭其他选项卡
+closeAllTabs | 关闭全部选项卡
+closeDialog | 关闭元素所在的layer弹窗
+
+#### 3.4.2.admin提供的方法
+使用示例:
+```javascript
+layui.use(['admin'], function () {
+ var admin = layui.admin;
+
+ admin.flexible(true); // 折叠侧导航
+});
+```
+
+全部方法:
+
+方法 | 参数 | 描述
+:---|:--- |:---
+flexible(expand) | true和false | 折叠侧导航
+activeNav(url) | a标签里面的href值 | 设置侧导航栏选中
+refresh() | 无 | 刷新主体部分
+ | |
+popupRight(path) | html地址 | 右侧弹出弹窗
+closePopupRight() | 无 | 关闭右侧弹出
+ | |
+popupCenter(object) | 见单独说明 | 中间弹出弹窗
+finishPopupCenter() | 无 | 关闭中间弹出弹窗并回调finish方法
+closePopupCenter() | 无 | 关闭中间弹出弹窗
+ | |
+open(object) | 见单独说明 | 封装layer弹出弹窗
+ | |
+req(url, data, success, method) | 见单独说明 | 封装的ajax请求,req只返回json
+ajax(object) | 见单独说明 | 封装的ajax请求
+ | |
+hasPerm(auth) | 权限标识 | 判断用户是否有权限,不分离版本无此方法
+ | |
+putTempData(key, value) | key,value | 缓存临时数据
+getTempData(key,) | key | 获取缓存的临时数据
+ | |
+rollPage(d) | 方向 | 滚动选项卡tab
+
+
+
+> 首先说明一下admin为什么要封装那么多layer的弹窗,因为admin封装的弹窗都是支持弹窗的内容是一个单独的页面,
+并且不是以iframe的方式嵌入页面,也就是单页面的形式。
+
+
+
+
+##### 3.4.2.1.右侧弹出弹窗popupRight
+使用示例:
+```javascript
+admin.popupRight('pages/tpl/message.html');
+```
+> 分离版本填写独立的html页面即可,不分离版本填写后台的url(Controller)
+
+“message.html”里面也可以有js代码,如下所示:
+```html
+
+
+
+```
+
+> 注意:因为是单页面,不是iframe,所以页面里面请不要写` `之类的东西。
+
+
+效果图:
+
+
+
+##### 3.4.2.2.中间弹出弹窗popupCenter
+ admin封装的popupCenter虽然没有什么特别的样式,但是带有回调的功能。
+
+使用示例(一般用在表单弹窗,如添加、修改用户等):
+```javascript
+admin.popupCenter({
+ title: '添加用户',
+ path: 'pages/system/user_form.html',
+ finish: function () {
+
+ // 这个方法就是回调的功能,用户添加成功之后让表格reload
+ table.reload('user-table', {});
+
+ }
+});
+```
+
+**参数说明:**
+
+参数 | 类型 | 是否必须 | 描述
+:---|:--- |:--- |:---
+title | 变量 | 否 | 标题,不写没有标题
+`path` | 变量 | 是 | html路径
+`finish` | 方法 | 否 | finish回调
+success | 方法 | 否 | html渲染完毕的回调
+end | 方法 | 否 | 弹窗关闭的回调
+... | ... | ... | 省略更多参数
+
+
+
+> 请注意,除了`path`和`finish`是popupCenter新增的参数,其他参数均与layer的open参数一样,但是`type`和`content`参数无效,
+> type固定是1(页面层),content会被path的内容覆盖。
+
+
+
+“user_form.html”内容如下:
+```html
+
+
+
+```
+
+示例图:
+
+
+
+完整示例代码:
+```javascript
+// 全部参数都写
+admin.popupCenter({
+ title: '添加用户',
+ path: 'pages/system/user_form.html',
+ finish: function () {
+ // finish回调
+ },
+ success: function() {
+ // user_form.html成功渲染到弹窗中
+ },
+ end: function() {
+ // 弹窗关闭
+ }
+});
+
+// 只写必须参数
+admin.popupCenter({path: 'pages/system/user_form.html'});
+```
+
+
+
+##### 3.4.2.3.封装的layer弹窗open
+
+ 前面讲了admin所封装的弹窗目的是在不使用iframe的前提下支持使用独立的页面,这样便于我们维护代码,减少一个页面里面的代码量。
+
+使用方法:
+
+```javascript
+admin.open({
+ title: 'xxx',
+ path: 'system/user_form.html',
+ success: function(){
+
+ }
+});
+```
+
+参数说明:
+
+ `path`是新增的参数,其他参数均为layer.open的参数,但是`type`和`content`参数无效,type固定是1(页面层),
+content会被path的内容覆盖,open没有finish方法,popupCenter才有。
+
+
+
+
+**如何让弹窗出现滚动条?**
+
+
+ 弹窗的默认高度是自适应的,设置了宽高后内容超出是无法出现滚动条的,因为出现弹窗里面的下拉框select下拉会出现滚动条,所以amdin.css里面
+禁止了弹窗的滚动条,如果你需要弹窗出现滚动条,请使用如下的方式:
+```javascript
+admin.open({
+ title: 'xxxxx',
+ area: ['500px','300px'],
+ path: 'system/user/editForm',
+ success: function (layero, index) {
+ // 关键代码, ↑↑↑↑↑↑↑↑↑↑↑↑↑(上面的两个参数不要忘了)
+ $(layero).children('.layui-layer-content').css('overflow-y', 'scroll');
+ }
+});
+```
+只需要在success回调方法里面手动加上样式就可以了。
+```javascript
+// 写scroll可以防止弹窗内表格出现滚动条
+$(layero).children('.layui-layer-content').css('overflow-y', 'scroll');
+
+// 弹窗内没有表格使用auto即可
+$(layero).children('.layui-layer-content').css('overflow-y', 'auto');
+
+// 水平垂直都有滚动条使用overflow
+$(layero).children('.layui-layer-content').css('overflow', 'auto');
+```
+admin.popupCenter也同样支持此使用方法
+
+
+
+##### 3.4.2.4.封装的ajax请求req
+
+> 注意:req不支持指定返回的数据类型(json、html、text等),只会返回json的数据。
+
+ admin模块封装的ajax请求会自动传递token(access_token),并且会自动把PUT、DELETE请求转成POST、GET请求
+然后加参数_method,因为浏览器不支持PUT、DELETE请求的参数传递,具体原因请百度一下,**不分离版本不会进行此操作**。
+
+ 另外分离版本和不分离版本封装的ajax和req都会检验状态码(401登录过期,403没有权限),登录过期会自动跳转到登录界面。
+
+使用示例:
+
+```javascript
+// 不传递参数的写法
+admin.req('user', {}, function (data) {
+ console.log(JSON.stringify(data));
+}, 'GET');
+
+// 传递参数的写法
+admin.req('user', {
+ userId: 'xxx',
+ userName: '张三'
+}, function (data) {
+ console.log(JSON.stringify(data));
+}, 'POST');
+```
+
+**方法参数说明:**
+
+- 第一个参数: 接口地址,会自动在前面加入config.base_server
+- 第二个参数: 传给服务器的参数
+- 第三个参数: 请求成功的回调(如果出现http错误404,401等,也会进入这个回调,并且data里面会有code、msg两个参数,
+ code是http的错误码,msg是错误信息)
+- 第四个参数: 请求的方法(GET、POST、PUT、DELETE)
+
+ req还会自动判断token是否过期,如果token过期会自动跳转到登录页面,不分离版本是根据code判断401为登录过期。
+
+
+##### 3.4.2.5.封装的ajax请求ajax
+
+使用方法:
+```javascript
+admin.ajax({
+ url: 'xxxx',
+ data: {
+ aa:''
+ },
+ dataType: 'json',
+ type: 'POST',
+ success: function(result,status,xhr) {
+
+ }
+});
+```
+
+ 使用方法跟`$.ajax`一模一样,admin封装只是在success之后先判断是否为登录过期和没有权限,然后再执行你的success方法。
+
+ 使用参数也跟`$.ajax`一样,请到[http://www.runoob.com/jquery/ajax-ajax.html](http://www.runoob.com/jquery/ajax-ajax.html)文档中查看`$.ajax`的参数说明。
+
+
+
+
+
+##### 3.4.2.6.判断是否有权限hasPerm
+
+> 注意:不分离版本没有此方法。
+
+ 这个方法是用来判断当前登录的用户是否有某一权限的操作,使用这个方法的前提是在index.js里面有一个获取
+服务器的user信息并使用config.putUser方法缓存,并且user里面包含了权限列表,因为admin会调用config.getUser获取
+用户信息从而获取用户的权限列表。
+
+ 我这里面服务器返回的用户json信息如下所示,如果你的服务器返回的信息跟下面不一样,请修改hasPerm方法:
+
+```json
+{
+ "userId": "admin",
+ "username": "admin",
+ "nickName": "管理员",
+ "authorities": [{
+ "authority": "get:/role"
+ }, {
+ "authority": "put:/role"
+ }]
+}
+```
+
+authorities就是用户的权限集合,authority是权限标识。
+
+使用示例,下面的示例是演示没有删除用户的权限隐藏删除按钮:
+```html
+
+ 删除
+
+
+
+```
+
+> 如果你担心把按钮隐藏了没有什么卵用,会点技术就可以把按钮在弄出来了,这个担心完全是多余的。
+> 因为后台的接口也会有权限验证的,如果没有权限接口会返回{ code: 401, msg: "没有访问权限" },
+> 既然后台限制了,界面为什么还要限制,因为这是需求,如你项目没有隐藏按钮的需求可以不用隐藏。
+
+
+##### 3.4.2.7.缓存临时数据putTempData
+ 这个方法是用来把一些临时数据放在session中,页面关闭数据就会失效。 适当使用缓存可以
+减少接口请求次数,提升用户体验。
+
+使用示例:
+```javascript
+
+admin.putTempData('t_name', '张三'); // 缓存数据
+
+var tName = admin.getTempData('t_name'); // 获取缓存数据
+
+console.log(tName);
+
+```
+
+**使用场景:**
+
+ 前面讲了popupCenter弹出添加用户的界面,如果是修改用户,是不是应该传递user的信息呢,
+因为修改界面需要回显user的信息,这时就可以用putTempData了,当然也有别的办法传递,这里就不一一演示了。
+
+修改用户按钮的界面(user.html):
+```html
+修改用户
+
+
+```
+修改用户弹窗的界面(user_form.html):
+```html
+
+
+
+```
+
+##### 3.4.2.8 滚动选项卡 rollPage
+使用示例:
+```javascript
+// 向左滚动
+admin.rollPage('left');
+
+// 滚动到当前选中的选项卡
+admin.rollPage('auto');
+
+// 向右滚动
+admin.rollPage();
+```
+参数说明:
+- left - 向左滚动
+- auto - 滚动到当前选项卡
+- 其他 - 向右滚动,不写参数就是向右滚动
+
+
+
+### 3.5.index模块介绍
+
+ index模块主要是用于加载index.html的
+header、side等,获取用户的信息,判断是否开启选项卡改变页面局部等操作,说白了就是用来初始化后台布局的,用于给主体部分的界面
+做准备,虽然index.js里面代码行数也不少,但是仔细看就能看懂,注释也都写了,如果你需要
+微微修改阅读几遍就可以上手修改了,下面只介绍两个其他页面会用到的封装方法。
+
+> 需要注意的是:分离和不分离版本的index.js和index.html里面的一些写法有很些不同,请注意不要用混淆了。
+
+
+#### 3.5.1.打开新页面或选项卡Tab
+
+```javascript
+layui.use(['index'], function () {
+ var index = layui.index;
+
+ // 不分离用后台地址
+ index.openNewTab({
+ title:'个人信息',
+ url:'system/user/myInfo?userId=1',
+ menuId: 'myInfo'
+ });
+
+ // 分离用html页面
+ index.openNewTab({
+ title: '个人信息',
+ url: 'pages/system/myInfo.html',
+ menuId: 'myInfo'
+ });
+
+ // 当然这行代码一般会写在按钮点击事件里面,直接写在这里就立即打开新页面了
+});
+```
+
+- `title` 如果开启了多标签,title是选项卡的标题
+- `url` 打开的页面地址
+- `menuId` 这个参数是一个id标识,浏览器地址栏会变成`#!menuId`。
+
+这个功能的使用场景请见`3.8.1`章节
+
+
+#### 3.5.2.关闭选项卡
+
+```javascript
+layui.use(['index'], function () {
+ var index = layui.index;
+
+ var menuId = 'myInfo';
+ index.closeTab(menuId);
+});
+```
+
+
+---
+
+
+
+### 3.6.admin提供的css公共类
+
+> 分离和不分离版本css都是一样的,这部分文档就不需要注意什么了,哈哈😄~
+
+#### 3.6.1.辅助类
+
+类名(class) | 说明
+:---|:---
+icon-btn | 带图标的按钮,如果你的按钮用了图标加上类这个更好看
+date-icon | 在元素的右边加入日期的图标
+layui-link | 用于a标签,字体颜色为layui的绿色风格
+layui-text | 用于a标签的上层,a标签字体颜色为蓝色
+pull-right | 右浮动
+inline-block | 设置元素display为inline-block
+
+
+
+---
+
+
+
+---
+
+
+
+---
+
+
+
+```html
+
+
+
+
+ 搜索
+ 添加
+
+
+帐号注册
+忘记密码?
+
+
+
+
+```
+
+
+#### 3.6.2.表格上方的工具栏
+
+类名(class) | 说明
+:---|:---
+search-input | 表格上面的输入框样式
+toolbar | 表格上方工具栏样式
+
+```html
+
+
+
+ 搜索:
+
+ -请选择-
+ ID
+ 账号
+
+
+
+
+
+ 搜索
+ 添加
+
+
+
+
+```
+
+
+
+
+#### 3.6.3.弹窗里面的表单
+
+类名(class) | 说明
+:---|:---
+model-form | 弹窗里面的表单样式
+model-form-footer | 弹窗里面表单底部操作按钮容器的样式
+
+```html
+
+```
+
+
+
+
+#### 3.6.4.完全基于layui后台大布局
+ EasyWeb完全基于layui的后台大布局进行样式修改,html结构是完全基于layui的后台大布局的,所以项目里面的
+admin.css你可以用于任何layui后台大布局的页面,加入之后你的页面就得到EasyWeb的样式了, 但是侧导航栏
+的折叠事件、全屏等事件是写在admin.js里面的,所以建议你直接使用EasyWeb的框架,当然如果你有自己的基于layui后台
+大布局的框架,完全可以使用我的admin.css。
+
+
+### 3.7.鼠标经过自动弹出tips层
+使用示例:
+```html
+按钮
+```
+ 只需要在你的DOM节点上面添加`lay-tips="xxx"`,然后这个节点在鼠标滑过的时候就会自动显示tips层了,简单吧!
+
+**默认提示位置在元素的上面,修改位置可以这样做:**
+```html
+按钮
+```
+再加一个`lay-direction`属性就可以了,参数如下:
+- 1 - 上面,默认,可以不写
+- 2 - 右边
+- 3 - 下面
+- 4 - 左边
+
+效果图:
+
+
+
+
+### 3.8.路由的使用
+ 路由这里使用的是Q.js框架,如果你的左侧菜单是配置在config.menus里面的话,不需要自己注册路由监听,
+index.js里面会自动帮你注册。
+
+ 如果你需要自己添加路由注册监听的话,请参考q.js的开发文档:[Q.js](https://github.com/itorr/q.js)。
+
+**注意:**
+ EasyWeb里面使用的q.js进行过修改,我在里面加了一个刷新的方法,所以请不要擅自替换q.js文件,如果你发现
+q.js框架出来新版本了,请联系我进行替换,请多多包含,不要嫌麻烦,以免出问题。
+
+
+#### 3.8.1.打开不在导航栏中的页面
+
+ 比如用户详情、个人信息这些页面,它们不在左侧导航中,但是想打开新页面或者选项卡,
+又比如添加用户、修改用户这个页面现在是用弹窗的形式,如果想用新页面的形式该怎么实现:
+
+**第一种实现方式:**
+ 在分离版本中,你只需要在config.js的menus数组中添加一个隐藏的菜单:
+```javascript
+menus: [{
+ name: '个人信息',
+ url: '#!myInfo',
+ path: 'system/my_info.html',
+ hidden: true
+}]
+```
+html中跳转:
+```html
+个人信息
+```
+js中跳转:
+```javascript
+Q.go('myInfo');
+```
+
+> 或许你已经注意到了,这种方式跳转的界面是一个固定页面,如果我们想要传递一些参数,
+> 它就无法满足,所以有了第二种实现方式。
+
+
+**第二种实现方式:**
+```javascript
+layui.use(['index'], function () {
+ var index = layui.index;
+
+ // 不分离用后台地址
+ index.openNewTab({
+ title:'个人信息',
+ url:'system/user/myInfo?userId=1',
+ menuId: 'myInfo'
+ });
+
+ // 分离用html页面
+ index.openNewTab({
+ title: '个人信息',
+ url: 'pages/system/myInfo.html',
+ menuId: 'myInfo'
+ });
+
+ // 当然这行代码一般会写在按钮点击事件里面,直接写在这里就立即打开新页面了
+});
+```
+
+- `title` 如果开启了多标签,title是选项卡的标题
+- `url` 打开的页面地址
+- `menuId` 这个参数是一个id标识,如果id一样就只会存在一个tab,也就是说打开一次没有关闭就不会再打开新的页面,
+ 比如用户详情页面,如果你想userA的详情和userB的详情是两个页面,可以同时存在选项卡中,menuId就不要写一样的。
+
+
+> 注意:
+> 分离版本两种方式都可以用,不分离版本只能用第二种方式,再分离版本中不能使用`?`问号传递参数,建议使用
+> 临时缓存的方式传递参数。
+
+
+请到`3.5.1`和`3.5.2`章节查看跟这个使用场景相关的其他功能方法。
+
+
+---
+
+
+### 3.9.mvvm数据绑定、组件等
+ 虽然现在vue很流行,但是jquery的许多方法仍然很好用,所以现在很多项目里面既有vue,又有jquery,
+然而对于开发一个后台管理系统来说,我们仅仅用了vue的数据渲染功能,大部分还是用的jquery的代码,这样一来项目
+就显得有点不伦不类了。
+
+ 但是对于前后端分离来说,mvvm的框架渲染数据确实很方便,很强大,layui虽然提供了模板引擎,
+但是写法别扭,还麻烦,pandyle.js是一个为jquery打造的mvvm框架,还提供了类似vue组件的写法。
+
+ EasyWeb里面的头部header、side等都是使用的它的组件的写法,还有一些下拉框select的渲染也是用的它提供的mvvm的写法。
+
+ 我这里就不提供pandyle.js的用法了,以免跟不上pandyle作者的更新脚步,
+大家可以到这里[pandyle.js](https://gitee.com/pandarrr/pandyle)查看pandyle的开发文档。
+
+> 注意:
+> 不分离版本没有引入pandyle.js,不分离版本的header和side是使用beetl的布局功能实现的,如果你需要在
+> 不分离版本中使用mvvm,请自行在idnex.html中引入pandyle.js。
+
+
+### 3.10.主题功能
+ EasyWeb包含前后台,所以开发时间比较紧张,暂时只提供了两套主题,但是提供了一个主题生成器,
+请使用主题生成器定制化你的样式:[EasyWeb主题生成器](https://whvse.gitee.io/easywebpage/docs/generater_theme.html)。
+
+ EasyWeb的主题生成器可以深度定制主题,样式深度到按钮、单选框、下拉框、选项卡等样式。
+
+
+
+### 3.11.不分离版本
+
+注意:
+
+ 你从EasyWebPage这个地址下载下来的项目是前后端分离版本的,如果你需要前后端不分离版本的页面和后台,
+请从[easyweb-shiro](https://gitee.com/whvse/easyweb-shiro)下载。 easyweb-shiro是Java语言开发的,如果你是
+php或其他后台语言,想要使用不分离版的页面,请联系作者辅助你结合到你的项目中,因为不分离版本页面跟后台耦合比较大,
+分离出静态页面意义不大,所以不分离版本作者就没有独立再维护成纯静态页面了。
+
+
+
+### 3.12.树形表格treeTable
+
+在layui的数据表格上进行扩展实现的。
+
+treeTable项目地址:[https://gitee.com/whvse/treetable-lay](https://gitee.com/whvse/treetable-lay)。
+
+- 演示地址: [https://whvse.gitee.io/treetable-lay/](https://whvse.gitee.io/treetable-lay/)
+
+截图:
+
+树形表格1:
+
+
+
+树形表格2:
+
+
+
+
+## 4.项目截图
+
+
+
+
+
+
+
+
+
+---
+
+## 5.更新日志
+
+- **2018-07-22 - 增加树形表格的功能**
+
+ - 增加树形表格的功能 [treeTable](#_312树形表格treeTable)
+
+- **2018-07-20 - 发布不分离版的easyweb-shiro稳定版本**
+
+ - 不分离版没有config.js,但是同样支持分离版的所有功能
+ - 改进路由的注册方法,全部由框架自动完成,开发方式与传统一样,但是可以轻松的使用路由功能提升操作体验
+
+- **2018-07-12 - 增加主题、多标签**
+
+ - 增加多标签tab功能,并且增加自由切换是否开启多标签功能
+ - 增加主题切换功能,上线 [主题生成器](#_310主题功能) ,自由生成主题样式
+
+- **2018-06-28 - 发布全新2.0版本**
+
+ - 引入pandyle.js(mvvm框架),填补layui模板引擎的短板
+ - 采用模块化开发方式,定义admin、config等公用模块,封装ajax请求
+ - 界面优化,借鉴layadmin的设计风格,改版登录页面
+
+- **2018-02-11 - 发布EasyWeb1.0版本**
+
+ - 基于layui后台大布局、q.js路由框架搭建出第一个版本
+ - 1.0 版本在easyweb的gitee附件中下载
+
+
+## 6.联系方式
+### 6.1.欢迎加入“前后端分离技术交流群”
+
+
+### 6.2.我要打赏
+ 都是猿友,撸码不易,如果这个轮子对你有用,不妨打赏一下!
+[码云](https://gitee.com/whvse/EasyWebPage)已开启捐赠功能,谢谢支持!
+
+ EasyWeb目前提供了“路由+mvvm分离版”、“基于oauth2的后台”、“基于shiro的不分离版”、“不分离版的页面”、
+“EasyWeb主题生成器”、“前端开发文档”等项目,并且全部开源,欢迎加入一起开发,或者提交pull requests。
diff --git a/zlt-web/back-web/src/main/resources/static/docs/cover.md b/zlt-web/layui-web/src/main/resources/static/docs/cover.md
similarity index 95%
rename from zlt-web/back-web/src/main/resources/static/docs/cover.md
rename to zlt-web/layui-web/src/main/resources/static/docs/cover.md
index 2d642c30..3a2bc718 100644
--- a/zlt-web/back-web/src/main/resources/static/docs/cover.md
+++ b/zlt-web/layui-web/src/main/resources/static/docs/cover.md
@@ -1,12 +1,12 @@
-
-
-# [EasyWeb](/)
-
-> 基于layui的管理系统模板
-
-* 支持mvvm、路由,单页面、响应式、易上手
-*
-
-[Gitee](https://gitee.com/whvse/EasyWebPage)
-[GitHub](https://github.com/whvcse/EasyWebPage)
+
+
+# [EasyWeb](/)
+
+> 基于layui的管理系统模板
+
+* 支持mvvm、路由,单页面、响应式、易上手
+*
+
+[Gitee](https://gitee.com/whvse/EasyWebPage)
+[GitHub](https://github.com/whvcse/EasyWebPage)
[Get Started](#_1简介)
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/docs/generater_theme.html b/zlt-web/layui-web/src/main/resources/static/docs/generater_theme.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/docs/generater_theme.html
rename to zlt-web/layui-web/src/main/resources/static/docs/generater_theme.html
index da24c0a6..d4386b7c 100644
--- a/zlt-web/back-web/src/main/resources/static/docs/generater_theme.html
+++ b/zlt-web/layui-web/src/main/resources/static/docs/generater_theme.html
@@ -1,209 +1,209 @@
-
-
-
-
-
-
- EasyWeb主题生成器
-
-
-
-
-
-
-
-
EasyWeb主题生成器
-
-
-
-
生成结果
-
-
-
-
-
使用方法
-
将下载好的css放在项目里面,然后打开index.html,引入下载的css即可生效,如果样式有生成的不全的,请联系作者增加:
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ EasyWeb主题生成器
+
+
+
+
+
+
+
+
EasyWeb主题生成器
+
+
+
+
生成结果
+
+
+
+
+
使用方法
+
将下载好的css放在项目里面,然后打开index.html,引入下载的css即可生效,如果样式有生成的不全的,请联系作者增加:
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/docs/index.html b/zlt-web/layui-web/src/main/resources/static/docs/index.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/docs/index.html
rename to zlt-web/layui-web/src/main/resources/static/docs/index.html
index d2bd977d..8e80577c 100644
--- a/zlt-web/back-web/src/main/resources/static/docs/index.html
+++ b/zlt-web/layui-web/src/main/resources/static/docs/index.html
@@ -1,31 +1,31 @@
-
-
-
-
- EasyWeb前端开发文档
-
-
-
-
-
-
-
-加载中..
-
-
-
-
-
+
+
+
+
+ EasyWeb前端开发文档
+
+
+
+
+
+
+
+加载中..
+
+
+
+
+
diff --git a/zlt-web/back-web/src/main/resources/static/docs/logo.png b/zlt-web/layui-web/src/main/resources/static/docs/logo.png
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/docs/logo.png
rename to zlt-web/layui-web/src/main/resources/static/docs/logo.png
diff --git a/zlt-web/back-web/src/main/resources/static/docs/theme.tpl b/zlt-web/layui-web/src/main/resources/static/docs/theme.tpl
similarity index 96%
rename from zlt-web/back-web/src/main/resources/static/docs/theme.tpl
rename to zlt-web/layui-web/src/main/resources/static/docs/theme.tpl
index cc422eab..8e2cec33 100644
--- a/zlt-web/back-web/src/main/resources/static/docs/theme.tpl
+++ b/zlt-web/layui-web/src/main/resources/static/docs/theme.tpl
@@ -1,102 +1,102 @@
-/** logo部分样式 */
-.layui-layout-admin .layui-header .layui-logo {
- background-color: {{logo}};
- color: {{logo_font}};
-}
-
-/** header样式 */
-.layui-layout-admin .layui-header {
- background-color: {{header}};
-}
-
-.layui-layout-admin .layui-header a {
- color: {{header_font}};
-}
-
-.layui-layout-admin .layui-header a:hover {
- color: {{header_font}};
-}
-
-.layui-layout-admin .layui-header .layui-nav .layui-nav-more {
- border-color: {{header_font}} transparent transparent;
-}
-
-.layui-layout-admin .layui-header .layui-nav .layui-nav-mored {
- border-color: transparent transparent {{header_font}};
-}
-
-/** 导航栏下面的线条 */
-.layui-layout-admin .layui-header .layui-nav .layui-this:after, .layui-layout-admin .layui-header .layui-nav-bar {
- background-color: {{header_font}};
-}
-
-/** 侧边栏样式 */
-.layui-layout-admin .layui-side {
- background-color: {{side}};
-}
-
-.layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a, .layui-nav-tree .layui-this, .layui-nav-tree .layui-this > a, .layui-nav-tree .layui-this > a:hover {
- background-color: {{primary}};
-}
-
-.layui-nav-tree .layui-nav-bar {
- background-color: {{primary}};
-}
-
-/** 主题颜色 */
-
-/** 按钮 */
-.layui-btn:not(.layui-btn-primary):not(.layui-btn-normal):not(.layui-btn-warm):not(.layui-btn-danger):not(.layui-btn-disabled) {
- background-color: {{primary}};
-}
-
-.layui-btn.layui-btn-primary:hover {
- border-color: {{primary}};
-}
-
-/** 开关 */
-.layui-form-onswitch {
- border-color: {{primary}};
- background-color: {{primary}};
-}
-
-/** 分页插件 */
-.layui-laypage .layui-laypage-curr .layui-laypage-em {
- background-color: {{primary}};
-}
-
-.layui-table-page .layui-laypage input:focus {
- border-color: {{primary}} !important;
-}
-
-.layui-table-view select:focus {
- border-color: {{primary}} !important;
-}
-
-.layui-table-page .layui-laypage a:hover {
- color: {{primary}};
-}
-
-/** 单选按钮 */
-.layui-form-radio > i:hover, .layui-form-radioed > i {
- color: {{primary}};
-}
-
-/** 下拉条目选中 */
-.layui-form-select dl dd.layui-this {
- background-color: {{primary}};
-}
-
-/** 选项卡 */
-.layui-tab-brief > .layui-tab-title .layui-this {
- color: {{primary}};
-}
-
-.layui-tab-brief > .layui-tab-more li.layui-this:after, .layui-tab-brief > .layui-tab-title .layui-this:after {
- border-color: {{primary}} !important;
-}
-
-/** 面包屑导航 */
-.layui-breadcrumb a:hover {
- color: {{primary}} !important;
+/** logo部分样式 */
+.layui-layout-admin .layui-header .layui-logo {
+ background-color: {{logo}};
+ color: {{logo_font}};
+}
+
+/** header样式 */
+.layui-layout-admin .layui-header {
+ background-color: {{header}};
+}
+
+.layui-layout-admin .layui-header a {
+ color: {{header_font}};
+}
+
+.layui-layout-admin .layui-header a:hover {
+ color: {{header_font}};
+}
+
+.layui-layout-admin .layui-header .layui-nav .layui-nav-more {
+ border-color: {{header_font}} transparent transparent;
+}
+
+.layui-layout-admin .layui-header .layui-nav .layui-nav-mored {
+ border-color: transparent transparent {{header_font}};
+}
+
+/** 导航栏下面的线条 */
+.layui-layout-admin .layui-header .layui-nav .layui-this:after, .layui-layout-admin .layui-header .layui-nav-bar {
+ background-color: {{header_font}};
+}
+
+/** 侧边栏样式 */
+.layui-layout-admin .layui-side {
+ background-color: {{side}};
+}
+
+.layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a, .layui-nav-tree .layui-this, .layui-nav-tree .layui-this > a, .layui-nav-tree .layui-this > a:hover {
+ background-color: {{primary}};
+}
+
+.layui-nav-tree .layui-nav-bar {
+ background-color: {{primary}};
+}
+
+/** 主题颜色 */
+
+/** 按钮 */
+.layui-btn:not(.layui-btn-primary):not(.layui-btn-normal):not(.layui-btn-warm):not(.layui-btn-danger):not(.layui-btn-disabled) {
+ background-color: {{primary}};
+}
+
+.layui-btn.layui-btn-primary:hover {
+ border-color: {{primary}};
+}
+
+/** 开关 */
+.layui-form-onswitch {
+ border-color: {{primary}};
+ background-color: {{primary}};
+}
+
+/** 分页插件 */
+.layui-laypage .layui-laypage-curr .layui-laypage-em {
+ background-color: {{primary}};
+}
+
+.layui-table-page .layui-laypage input:focus {
+ border-color: {{primary}} !important;
+}
+
+.layui-table-view select:focus {
+ border-color: {{primary}} !important;
+}
+
+.layui-table-page .layui-laypage a:hover {
+ color: {{primary}};
+}
+
+/** 单选按钮 */
+.layui-form-radio > i:hover, .layui-form-radioed > i {
+ color: {{primary}};
+}
+
+/** 下拉条目选中 */
+.layui-form-select dl dd.layui-this {
+ background-color: {{primary}};
+}
+
+/** 选项卡 */
+.layui-tab-brief > .layui-tab-title .layui-this {
+ color: {{primary}};
+}
+
+.layui-tab-brief > .layui-tab-more li.layui-this:after, .layui-tab-brief > .layui-tab-title .layui-this:after {
+ border-color: {{primary}} !important;
+}
+
+/** 面包屑导航 */
+.layui-breadcrumb a:hover {
+ color: {{primary}} !important;
}
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/index.html b/zlt-web/layui-web/src/main/resources/static/index.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/index.html
rename to zlt-web/layui-web/src/main/resources/static/index.html
index b8ba735d..75b6aa82 100644
--- a/zlt-web/back-web/src/main/resources/static/index.html
+++ b/zlt-web/layui-web/src/main/resources/static/index.html
@@ -1,95 +1,95 @@
-
-
-
-
-
-
- zlt-mp
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ zlt-mp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/login.html b/zlt-web/layui-web/src/main/resources/static/login.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/login.html
rename to zlt-web/layui-web/src/main/resources/static/login.html
index 59807664..643b16f1 100644
--- a/zlt-web/back-web/src/main/resources/static/login.html
+++ b/zlt-web/layui-web/src/main/resources/static/login.html
@@ -1,129 +1,129 @@
-
-
-
-
-
-
-
- 用户登录
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ 用户登录
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/module/Math.uuid.js b/zlt-web/layui-web/src/main/resources/static/module/Math.uuid.js
similarity index 96%
rename from zlt-web/back-web/src/main/resources/static/module/Math.uuid.js
rename to zlt-web/layui-web/src/main/resources/static/module/Math.uuid.js
index 63f9528e..718824e5 100644
--- a/zlt-web/back-web/src/main/resources/static/module/Math.uuid.js
+++ b/zlt-web/layui-web/src/main/resources/static/module/Math.uuid.js
@@ -1,63 +1,63 @@
-/*!
-Math.uuid.js (v1.4)
-http://www.broofa.com
-mailto:robert@broofa.com
-
-Copyright (c) 2010 Robert Kieffer
-Dual licensed under the MIT and GPL licenses.
-*/
-
-/*
- * Generate a random uuid.
- *
- * USAGE: Math.uuid(length, radix)
- * length - the desired number of characters
- * radix - the number of allowable values for each character.
- *
- * EXAMPLES:
- * // No arguments - returns RFC4122, version 4 ID
- * >>> Math.uuid()
- * "92329D39-6F5C-4520-ABFC-AAB64544E172"
- *
- * // One argument - returns ID of the specified length
- * >>> Math.uuid(15) // 15 character ID (default base=62)
- * "VcydxgltxrVZSTV"
- *
- * // Two arguments - returns ID of the specified length, and radix. (Radix must be <= 62)
- * >>> Math.uuid(8, 2) // 8 character ID (base=2)
- * "01001010"
- * >>> Math.uuid(8, 10) // 8 character ID (base=10)
- * "47473046"
- * >>> Math.uuid(8, 16) // 8 character ID (base=16)
- * "098F4D35"
- */
-(function() {
- // Private array of chars to use
- var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
-
- Math.uuid = function (len, radix) {
- var chars = CHARS, uuid = [], i;
- radix = radix || chars.length;
- if (len) {
- // Compact form
- for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
- } else {
- // rfc4122, version 4 form
- var r;
-
- // rfc4122 requires these characters
- uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
- uuid[14] = '4';
-
- // Fill in random data. At i==19 set the high bits of clock sequence as
- // per rfc4122, sec. 4.1.5
- for (i = 0; i < 36; i++) {
- if (!uuid[i]) {
- r = 0 | Math.random()*16;
- uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
- }
- }
- }
- return uuid.join('');
- };
-})();
+/*!
+Math.uuid.js (v1.4)
+http://www.broofa.com
+mailto:robert@broofa.com
+
+Copyright (c) 2010 Robert Kieffer
+Dual licensed under the MIT and GPL licenses.
+*/
+
+/*
+ * Generate a random uuid.
+ *
+ * USAGE: Math.uuid(length, radix)
+ * length - the desired number of characters
+ * radix - the number of allowable values for each character.
+ *
+ * EXAMPLES:
+ * // No arguments - returns RFC4122, version 4 ID
+ * >>> Math.uuid()
+ * "92329D39-6F5C-4520-ABFC-AAB64544E172"
+ *
+ * // One argument - returns ID of the specified length
+ * >>> Math.uuid(15) // 15 character ID (default base=62)
+ * "VcydxgltxrVZSTV"
+ *
+ * // Two arguments - returns ID of the specified length, and radix. (Radix must be <= 62)
+ * >>> Math.uuid(8, 2) // 8 character ID (base=2)
+ * "01001010"
+ * >>> Math.uuid(8, 10) // 8 character ID (base=10)
+ * "47473046"
+ * >>> Math.uuid(8, 16) // 8 character ID (base=16)
+ * "098F4D35"
+ */
+(function() {
+ // Private array of chars to use
+ var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
+
+ Math.uuid = function (len, radix) {
+ var chars = CHARS, uuid = [], i;
+ radix = radix || chars.length;
+ if (len) {
+ // Compact form
+ for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
+ } else {
+ // rfc4122, version 4 form
+ var r;
+
+ // rfc4122 requires these characters
+ uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
+ uuid[14] = '4';
+
+ // Fill in random data. At i==19 set the high bits of clock sequence as
+ // per rfc4122, sec. 4.1.5
+ for (i = 0; i < 36; i++) {
+ if (!uuid[i]) {
+ r = 0 | Math.random()*16;
+ uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
+ }
+ }
+ }
+ return uuid.join('');
+ };
+})();
diff --git a/zlt-web/back-web/src/main/resources/static/module/admin.js b/zlt-web/layui-web/src/main/resources/static/module/admin.js
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/module/admin.js
rename to zlt-web/layui-web/src/main/resources/static/module/admin.js
index 931cf024..7954ed6a 100644
--- a/zlt-web/back-web/src/main/resources/static/module/admin.js
+++ b/zlt-web/layui-web/src/main/resources/static/module/admin.js
@@ -1,341 +1,341 @@
-layui.define(['config', 'layer'], function (exports) {
- var config = layui.config;
- var layer = layui.layer;
- var popupRightIndex, popupCenterIndex, popupCenterParam;
-
- var admin = {
- isRefresh: false,
- // 设置侧栏折叠
- flexible: function (expand) {
- var isExapnd = $('.layui-layout-admin').hasClass('admin-nav-mini');
- if (isExapnd == !expand) {
- return;
- }
- if (expand) {
- $('.layui-layout-admin').removeClass('admin-nav-mini');
- } else {
- $('.layui-layout-admin').addClass('admin-nav-mini');
- }
- admin.onResize();
- },
- // 设置导航栏选中
- activeNav: function (url) {
- $('.layui-layout-admin .layui-side .layui-nav .layui-nav-item .layui-nav-child dd').removeClass('layui-this');
- $('.layui-layout-admin .layui-side .layui-nav .layui-nav-item').removeClass('layui-this');
- if (url && url != '') {
- $('.layui-layout-admin .layui-side .layui-nav .layui-nav-item').removeClass('layui-nav-itemed');
- var $a = $('.layui-layout-admin .layui-side .layui-nav>.layui-nav-item>.layui-nav-child>dd>a[href="#!' + url + '"]');
- $a.parent('dd').addClass('layui-this');
- $a.parent('li').addClass('layui-this');
- $a.parent('dd').parent('.layui-nav-child').parent('.layui-nav-item').addClass('layui-nav-itemed');
- }
- },
- // 右侧弹出
- popupRight: function (path) {
- var param = new Object();
- param.path = path;
- param.id = 'adminPopupR';
- param.title = false;
- param.anim = 2;
- param.isOutAnim = false;
- param.closeBtn = false;
- param.offset = 'r';
- param.shadeClose = true;
- param.area = '336px';
- param.skin = 'layui-layer-adminRight';
- param.end = function () {
- layer.closeAll('tips');
- };
- popupRightIndex = admin.open(param);
- return popupRightIndex;
- },
- // 关闭右侧弹出
- closePopupRight: function () {
- layer.close(popupRightIndex);
- },
- // 中间弹出
- popupCenter: function (param) {
- param.id = 'adminPopupC';
- popupCenterParam = param;
- popupCenterIndex = admin.open(param);
- return popupCenterIndex;
- },
- // 关闭中间弹出并且触发finish回调
- finishPopupCenter: function () {
- layer.close(popupCenterIndex);
- popupCenterParam.finish ? popupCenterParam.finish() : '';
- },
- // 关闭中间弹出
- closePopupCenter: function () {
- layer.close(popupCenterIndex);
- },
- // 封装layer.open
- open: function (param) {
- var sCallBack = param.success;
- param.type = 1;
- param.area = param.area ? param.area : '450px';
- param.offset = param.offset ? param.offset : '120px';
- param.resize ? param.resize : false;
- param.shade ? param.shade : .2;
- param.success = function (layero, index) {
- sCallBack ? sCallBack(layero, index) : '';
- $(layero).children('.layui-layer-content').load(param.path);
- };
- return layer.open(param);
- },
- // 封装ajax请求,返回数据类型为json
- req: function (url, data, success, method, noHeaderToken) {
- if ('put' == method.toLowerCase()) {
- method = 'PUT';
- } else if ('delete' == method.toLowerCase()) {
- method = 'DELETE';
- }
- //add by owen ajax 执行前置处理器
- admin.ajax({
- url: config.base_server + url,
- data: data,
- type: method,
- dataType: 'json',
- contentType: "application/json",
- success: success,
- beforeSend: function (xhr) {
- if (!noHeaderToken) {
- let token = config.getToken();
- if (token) {
- xhr.setRequestHeader('Authorization', 'Bearer ' + token.access_token);
- }
- }
- let isolationVersion = config.isolationVersion;
- if (isolationVersion) {
- xhr.setRequestHeader('z-l-t-version', isolationVersion);
- }
- }
- });
- },
-
- // 封装ajax请求
- ajax: function (param) {
- var successCallback = param.success;
- param.success = function (result, status, xhr) {
- // 判断登录过期和没有权限
- var jsonRs;
- if ('json' == param.dataType.toLowerCase()) {
- jsonRs = result;
- } else if ('html' == param.dataType.toLowerCase() || 'text' == param.dataType.toLowerCase()) {
- jsonRs = admin.parseJSON(result);
- }
- if (jsonRs) {
- if (jsonRs.code == 401) {
- config.removeToken();
- layer.msg('登录过期', {icon: 2, time: 1500}, function () {
- location.replace('/login.html');
- }, 1000);
- return;
- } else if (jsonRs.code == 403) {
- layer.msg('没有权限', {icon: 2});
- layer.closeAll('loading');
- return;
- }
- }
- successCallback(result, status, xhr);
- };
- param.error = function (xhr) {
- param.success({code: xhr.status, msg: xhr.statusText});
- };
- //发送同步ajax请求
- param.async = false;
- //console.log(param);
- $.ajax(param);
- },
- // 判断是否有权限
- hasPerm: function (auth) {
- var permissions = admin.getTempData("permissions");
- if (permissions){
- for (var i = 0; i < permissions.length; i++) {
- if (auth == permissions[i]) {
- return true;
- }
- }
- }
- return false;
- },
- // 窗口大小改变监听
- onResize: function () {
- if (config.autoRender) {
- if ($('.layui-table-view').length > 0) {
- setTimeout(function () {
- admin.events.refresh();
- }, 800);
- }
- }
- },
- // 显示加载动画
- showLoading: function (element) {
- $(element).append(' ');
- },
- // 移除加载动画
- removeLoading: function (element) {
- $(element + '>.admin-loading').remove();
- },
- // 缓存临时数据
- putTempData: function (key, value) {
- if (value) {
- layui.sessionData('tempData', {key: key, value: value});
- } else {
- layui.sessionData('tempData', {key: key, remove: true});
- }
- },
- // 获取缓存临时数据
- getTempData: function (key) {
- return layui.sessionData('tempData')[key];
- },
- // 滑动选项卡
- rollPage: function (d) {
- var $tabTitle = $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title');
- var left = $tabTitle.scrollLeft();
- if ('left' === d) {
- $tabTitle.scrollLeft(left - 120);
- } else if ('auto' === d) {
- var autoLeft = 0;
- $tabTitle.children("li").each(function () {
- if ($(this).hasClass('layui-this')) {
- return false;
- } else {
- autoLeft += $(this).outerWidth();
- }
- });
- $tabTitle.scrollLeft(autoLeft - 47);
- } else {
- $tabTitle.scrollLeft(left + 120);
- }
- },
- refresh: function () {
- admin.isRefresh = true;
- Q.refresh();
- },
- // 判断是否为json
- parseJSON: function (str) {
- if (typeof str == 'string') {
- try {
- var obj = JSON.parse(str);
- if (typeof obj == 'object' && obj) {
- return obj;
- }
- } catch (e) {
- }
- }
- }
- };
-
- // ewAdmin提供的事件
- admin.events = {
- flexible: function (e) { // 折叠侧导航
- var expand = $('.layui-layout-admin').hasClass('admin-nav-mini');
- admin.flexible(expand);
- },
- refresh: function () { // 刷新主体部分
- admin.refresh();
- },
- back: function () { //后退
- history.back();
- },
- theme: function () { // 设置主题
- admin.popupRight('pages/tpl/theme.html');
- },
- fullScreen: function (e) { // 全屏
- var ac = 'layui-icon-screen-full', ic = 'layui-icon-screen-restore';
- var ti = $(this).find('i');
-
- var isFullscreen = document.fullscreenElement || document.msFullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || false;
- if (isFullscreen) {
- var efs = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen;
- if (efs) {
- efs.call(document);
- } else if (window.ActiveXObject) {
- var ws = new ActiveXObject('WScript.Shell');
- ws && ws.SendKeys('{F11}');
- }
- ti.addClass(ac).removeClass(ic);
- } else {
- var el = document.documentElement;
- var rfs = el.requestFullscreen || el.webkitRequestFullscreen || el.mozRequestFullScreen || el.msRequestFullscreen;
- if (rfs) {
- rfs.call(el);
- } else if (window.ActiveXObject) {
- var ws = new ActiveXObject('WScript.Shell');
- ws && ws.SendKeys('{F11}');
- }
- ti.addClass(ic).removeClass(ac);
- }
- },
- // 左滑动tab
- leftPage: function () {
- admin.rollPage("left");
- },
- // 右滑动tab
- rightPage: function () {
- admin.rollPage();
- },
- // 关闭当前选项卡
- closeThisTabs: function () {
- var $title = $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title');
- if ($title.find('li').first().hasClass('layui-this')) {
- return;
- }
- $title.find('li.layui-this').find(".layui-tab-close").trigger("click");
- },
- // 关闭其他选项卡
- closeOtherTabs: function () {
- $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title li:gt(0):not(.layui-this)').find(".layui-tab-close").trigger("click");
- },
- // 关闭所有选项卡
- closeAllTabs: function () {
- $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title li:gt(0)').find(".layui-tab-close").trigger("click");
- },
- // 关闭所有弹窗
- closeDialog: function () {
- layer.closeAll('page');
- }
- };
-
- // 所有ew-event
- $('body').on('click', '*[ew-event]', function () {
- var event = $(this).attr('ew-event');
- var te = admin.events[event];
- te && te.call(this, $(this));
- });
-
- // 移动设备遮罩层点击事件
- $('.site-mobile-shade').click(function () {
- admin.flexible(true);
- });
-
- // 侧导航折叠状态下鼠标经过显示提示
- $('body').on('mouseenter', '.layui-layout-admin.admin-nav-mini .layui-side .layui-nav .layui-nav-item>a', function () {
- var tipText = $(this).find('cite').text();
- if (document.body.clientWidth > 750) {
- layer.tips(tipText, this);
- }
- }).on('mouseleave', '.layui-layout-admin.admin-nav-mini .layui-side .layui-nav .layui-nav-item>a', function () {
- layer.closeAll('tips');
- });
-
- // 侧导航折叠状态下点击展开
- $('body').on('click', '.layui-layout-admin.admin-nav-mini .layui-side .layui-nav .layui-nav-item>a', function () {
- if (document.body.clientWidth > 750) {
- layer.closeAll('tips');
- admin.flexible(true);
- }
- });
-
- // 所有lay-tips处理
- $('body').on('mouseenter', '*[lay-tips]', function () {
- var tipText = $(this).attr('lay-tips');
- var dt = $(this).attr('lay-direction');
- layer.tips(tipText, this, {tips: dt || 1, time: -1});
- }).on('mouseleave', '*[lay-tips]', function () {
- layer.closeAll('tips');
- });
-
- exports('admin', admin);
-});
+layui.define(['config', 'layer'], function (exports) {
+ var config = layui.config;
+ var layer = layui.layer;
+ var popupRightIndex, popupCenterIndex, popupCenterParam;
+
+ var admin = {
+ isRefresh: false,
+ // 设置侧栏折叠
+ flexible: function (expand) {
+ var isExapnd = $('.layui-layout-admin').hasClass('admin-nav-mini');
+ if (isExapnd == !expand) {
+ return;
+ }
+ if (expand) {
+ $('.layui-layout-admin').removeClass('admin-nav-mini');
+ } else {
+ $('.layui-layout-admin').addClass('admin-nav-mini');
+ }
+ admin.onResize();
+ },
+ // 设置导航栏选中
+ activeNav: function (url) {
+ $('.layui-layout-admin .layui-side .layui-nav .layui-nav-item .layui-nav-child dd').removeClass('layui-this');
+ $('.layui-layout-admin .layui-side .layui-nav .layui-nav-item').removeClass('layui-this');
+ if (url && url != '') {
+ $('.layui-layout-admin .layui-side .layui-nav .layui-nav-item').removeClass('layui-nav-itemed');
+ var $a = $('.layui-layout-admin .layui-side .layui-nav>.layui-nav-item>.layui-nav-child>dd>a[href="#!' + url + '"]');
+ $a.parent('dd').addClass('layui-this');
+ $a.parent('li').addClass('layui-this');
+ $a.parent('dd').parent('.layui-nav-child').parent('.layui-nav-item').addClass('layui-nav-itemed');
+ }
+ },
+ // 右侧弹出
+ popupRight: function (path) {
+ var param = new Object();
+ param.path = path;
+ param.id = 'adminPopupR';
+ param.title = false;
+ param.anim = 2;
+ param.isOutAnim = false;
+ param.closeBtn = false;
+ param.offset = 'r';
+ param.shadeClose = true;
+ param.area = '336px';
+ param.skin = 'layui-layer-adminRight';
+ param.end = function () {
+ layer.closeAll('tips');
+ };
+ popupRightIndex = admin.open(param);
+ return popupRightIndex;
+ },
+ // 关闭右侧弹出
+ closePopupRight: function () {
+ layer.close(popupRightIndex);
+ },
+ // 中间弹出
+ popupCenter: function (param) {
+ param.id = 'adminPopupC';
+ popupCenterParam = param;
+ popupCenterIndex = admin.open(param);
+ return popupCenterIndex;
+ },
+ // 关闭中间弹出并且触发finish回调
+ finishPopupCenter: function () {
+ layer.close(popupCenterIndex);
+ popupCenterParam.finish ? popupCenterParam.finish() : '';
+ },
+ // 关闭中间弹出
+ closePopupCenter: function () {
+ layer.close(popupCenterIndex);
+ },
+ // 封装layer.open
+ open: function (param) {
+ var sCallBack = param.success;
+ param.type = 1;
+ param.area = param.area ? param.area : '450px';
+ param.offset = param.offset ? param.offset : '120px';
+ param.resize ? param.resize : false;
+ param.shade ? param.shade : .2;
+ param.success = function (layero, index) {
+ sCallBack ? sCallBack(layero, index) : '';
+ $(layero).children('.layui-layer-content').load(param.path);
+ };
+ return layer.open(param);
+ },
+ // 封装ajax请求,返回数据类型为json
+ req: function (url, data, success, method, noHeaderToken) {
+ if ('put' == method.toLowerCase()) {
+ method = 'PUT';
+ } else if ('delete' == method.toLowerCase()) {
+ method = 'DELETE';
+ }
+ //add by owen ajax 执行前置处理器
+ admin.ajax({
+ url: config.base_server + url,
+ data: data,
+ type: method,
+ dataType: 'json',
+ contentType: "application/json",
+ success: success,
+ beforeSend: function (xhr) {
+ if (!noHeaderToken) {
+ let token = config.getToken();
+ if (token) {
+ xhr.setRequestHeader('Authorization', 'Bearer ' + token.access_token);
+ }
+ }
+ let isolationVersion = config.isolationVersion;
+ if (isolationVersion) {
+ xhr.setRequestHeader('z-l-t-version', isolationVersion);
+ }
+ }
+ });
+ },
+
+ // 封装ajax请求
+ ajax: function (param) {
+ var successCallback = param.success;
+ param.success = function (result, status, xhr) {
+ // 判断登录过期和没有权限
+ var jsonRs;
+ if ('json' == param.dataType.toLowerCase()) {
+ jsonRs = result;
+ } else if ('html' == param.dataType.toLowerCase() || 'text' == param.dataType.toLowerCase()) {
+ jsonRs = admin.parseJSON(result);
+ }
+ if (jsonRs) {
+ if (jsonRs.code == 401) {
+ config.removeToken();
+ layer.msg('登录过期', {icon: 2, time: 1500}, function () {
+ location.replace('/login.html');
+ }, 1000);
+ return;
+ } else if (jsonRs.code == 403) {
+ layer.msg('没有权限', {icon: 2});
+ layer.closeAll('loading');
+ return;
+ }
+ }
+ successCallback(result, status, xhr);
+ };
+ param.error = function (xhr) {
+ param.success({code: xhr.status, msg: xhr.statusText});
+ };
+ //发送同步ajax请求
+ param.async = false;
+ //console.log(param);
+ $.ajax(param);
+ },
+ // 判断是否有权限
+ hasPerm: function (auth) {
+ var permissions = admin.getTempData("permissions");
+ if (permissions){
+ for (var i = 0; i < permissions.length; i++) {
+ if (auth == permissions[i]) {
+ return true;
+ }
+ }
+ }
+ return false;
+ },
+ // 窗口大小改变监听
+ onResize: function () {
+ if (config.autoRender) {
+ if ($('.layui-table-view').length > 0) {
+ setTimeout(function () {
+ admin.events.refresh();
+ }, 800);
+ }
+ }
+ },
+ // 显示加载动画
+ showLoading: function (element) {
+ $(element).append(' ');
+ },
+ // 移除加载动画
+ removeLoading: function (element) {
+ $(element + '>.admin-loading').remove();
+ },
+ // 缓存临时数据
+ putTempData: function (key, value) {
+ if (value) {
+ layui.sessionData('tempData', {key: key, value: value});
+ } else {
+ layui.sessionData('tempData', {key: key, remove: true});
+ }
+ },
+ // 获取缓存临时数据
+ getTempData: function (key) {
+ return layui.sessionData('tempData')[key];
+ },
+ // 滑动选项卡
+ rollPage: function (d) {
+ var $tabTitle = $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title');
+ var left = $tabTitle.scrollLeft();
+ if ('left' === d) {
+ $tabTitle.scrollLeft(left - 120);
+ } else if ('auto' === d) {
+ var autoLeft = 0;
+ $tabTitle.children("li").each(function () {
+ if ($(this).hasClass('layui-this')) {
+ return false;
+ } else {
+ autoLeft += $(this).outerWidth();
+ }
+ });
+ $tabTitle.scrollLeft(autoLeft - 47);
+ } else {
+ $tabTitle.scrollLeft(left + 120);
+ }
+ },
+ refresh: function () {
+ admin.isRefresh = true;
+ Q.refresh();
+ },
+ // 判断是否为json
+ parseJSON: function (str) {
+ if (typeof str == 'string') {
+ try {
+ var obj = JSON.parse(str);
+ if (typeof obj == 'object' && obj) {
+ return obj;
+ }
+ } catch (e) {
+ }
+ }
+ }
+ };
+
+ // ewAdmin提供的事件
+ admin.events = {
+ flexible: function (e) { // 折叠侧导航
+ var expand = $('.layui-layout-admin').hasClass('admin-nav-mini');
+ admin.flexible(expand);
+ },
+ refresh: function () { // 刷新主体部分
+ admin.refresh();
+ },
+ back: function () { //后退
+ history.back();
+ },
+ theme: function () { // 设置主题
+ admin.popupRight('pages/tpl/theme.html');
+ },
+ fullScreen: function (e) { // 全屏
+ var ac = 'layui-icon-screen-full', ic = 'layui-icon-screen-restore';
+ var ti = $(this).find('i');
+
+ var isFullscreen = document.fullscreenElement || document.msFullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || false;
+ if (isFullscreen) {
+ var efs = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen;
+ if (efs) {
+ efs.call(document);
+ } else if (window.ActiveXObject) {
+ var ws = new ActiveXObject('WScript.Shell');
+ ws && ws.SendKeys('{F11}');
+ }
+ ti.addClass(ac).removeClass(ic);
+ } else {
+ var el = document.documentElement;
+ var rfs = el.requestFullscreen || el.webkitRequestFullscreen || el.mozRequestFullScreen || el.msRequestFullscreen;
+ if (rfs) {
+ rfs.call(el);
+ } else if (window.ActiveXObject) {
+ var ws = new ActiveXObject('WScript.Shell');
+ ws && ws.SendKeys('{F11}');
+ }
+ ti.addClass(ic).removeClass(ac);
+ }
+ },
+ // 左滑动tab
+ leftPage: function () {
+ admin.rollPage("left");
+ },
+ // 右滑动tab
+ rightPage: function () {
+ admin.rollPage();
+ },
+ // 关闭当前选项卡
+ closeThisTabs: function () {
+ var $title = $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title');
+ if ($title.find('li').first().hasClass('layui-this')) {
+ return;
+ }
+ $title.find('li.layui-this').find(".layui-tab-close").trigger("click");
+ },
+ // 关闭其他选项卡
+ closeOtherTabs: function () {
+ $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title li:gt(0):not(.layui-this)').find(".layui-tab-close").trigger("click");
+ },
+ // 关闭所有选项卡
+ closeAllTabs: function () {
+ $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title li:gt(0)').find(".layui-tab-close").trigger("click");
+ },
+ // 关闭所有弹窗
+ closeDialog: function () {
+ layer.closeAll('page');
+ }
+ };
+
+ // 所有ew-event
+ $('body').on('click', '*[ew-event]', function () {
+ var event = $(this).attr('ew-event');
+ var te = admin.events[event];
+ te && te.call(this, $(this));
+ });
+
+ // 移动设备遮罩层点击事件
+ $('.site-mobile-shade').click(function () {
+ admin.flexible(true);
+ });
+
+ // 侧导航折叠状态下鼠标经过显示提示
+ $('body').on('mouseenter', '.layui-layout-admin.admin-nav-mini .layui-side .layui-nav .layui-nav-item>a', function () {
+ var tipText = $(this).find('cite').text();
+ if (document.body.clientWidth > 750) {
+ layer.tips(tipText, this);
+ }
+ }).on('mouseleave', '.layui-layout-admin.admin-nav-mini .layui-side .layui-nav .layui-nav-item>a', function () {
+ layer.closeAll('tips');
+ });
+
+ // 侧导航折叠状态下点击展开
+ $('body').on('click', '.layui-layout-admin.admin-nav-mini .layui-side .layui-nav .layui-nav-item>a', function () {
+ if (document.body.clientWidth > 750) {
+ layer.closeAll('tips');
+ admin.flexible(true);
+ }
+ });
+
+ // 所有lay-tips处理
+ $('body').on('mouseenter', '*[lay-tips]', function () {
+ var tipText = $(this).attr('lay-tips');
+ var dt = $(this).attr('lay-direction');
+ layer.tips(tipText, this, {tips: dt || 1, time: -1});
+ }).on('mouseleave', '*[lay-tips]', function () {
+ layer.closeAll('tips');
+ });
+
+ exports('admin', admin);
+});
diff --git a/zlt-web/back-web/src/main/resources/static/module/apiUrl.js b/zlt-web/layui-web/src/main/resources/static/module/apiUrl.js
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/module/apiUrl.js
rename to zlt-web/layui-web/src/main/resources/static/module/apiUrl.js
diff --git a/zlt-web/back-web/src/main/resources/static/module/config.js b/zlt-web/layui-web/src/main/resources/static/module/config.js
similarity index 96%
rename from zlt-web/back-web/src/main/resources/static/module/config.js
rename to zlt-web/layui-web/src/main/resources/static/module/config.js
index 38c8f6fa..619f5edc 100644
--- a/zlt-web/back-web/src/main/resources/static/module/config.js
+++ b/zlt-web/layui-web/src/main/resources/static/module/config.js
@@ -1,63 +1,63 @@
-layui.define(function (exports) {
- /**
- * 用于动态切换环境地址
- */
- //默认地址
- var defUrl = 'http://127.0.0.1:9900/';
- //当前环境的api地址
- var apiUrl;
- try{
- if (my_api_server_url.length > 0) {
- apiUrl = my_api_server_url;
- } else {
- apiUrl = defUrl;
- }
- } catch(e) {
- apiUrl = defUrl;
- }
- var config = {
- base_server: apiUrl,
- tableName: 'easyweb', // 存储表名
- clientId: 'webApp', // 应用id
- isolationVersion: '', // 隔离版本
- clientSecret: 'webApp', // 应用秘钥
- autoRender: false, // 窗口大小改变后是否自动重新渲染表格,解决layui数据表格非响应式的问题,目前实现的还不是很好,暂时关闭该功能
- pageTabs: true, // 是否开启多标签
- // 获取缓存的token
- getToken: function () {
- var t = layui.data(config.tableName).token;
- if (t) {
- return JSON.parse(t);
- }
- },
- // 清除user
- removeToken: function () {
- layui.data(config.tableName, {
- key: 'token',
- remove: true
- });
- },
- // 缓存token
- putToken: function (token) {
- layui.data(config.tableName, {
- key: 'token',
- value: JSON.stringify(token)
- });
- },
- // 当前登录的用户
- getUser: function () {
- var u = layui.data(config.tableName).login_user;
- if (u) {
- return JSON.parse(u);
- }
- },
- // 缓存user
- putUser: function (user) {
- layui.data(config.tableName, {
- key: 'login_user',
- value: JSON.stringify(user)
- });
- }
- };
- exports('config', config);
-});
+layui.define(function (exports) {
+ /**
+ * 用于动态切换环境地址
+ */
+ //默认地址
+ var defUrl = 'http://127.0.0.1:9900/';
+ //当前环境的api地址
+ var apiUrl;
+ try{
+ if (my_api_server_url.length > 0) {
+ apiUrl = my_api_server_url;
+ } else {
+ apiUrl = defUrl;
+ }
+ } catch(e) {
+ apiUrl = defUrl;
+ }
+ var config = {
+ base_server: apiUrl,
+ tableName: 'easyweb', // 存储表名
+ clientId: 'webApp', // 应用id
+ isolationVersion: '', // 隔离版本
+ clientSecret: 'webApp', // 应用秘钥
+ autoRender: false, // 窗口大小改变后是否自动重新渲染表格,解决layui数据表格非响应式的问题,目前实现的还不是很好,暂时关闭该功能
+ pageTabs: true, // 是否开启多标签
+ // 获取缓存的token
+ getToken: function () {
+ var t = layui.data(config.tableName).token;
+ if (t) {
+ return JSON.parse(t);
+ }
+ },
+ // 清除user
+ removeToken: function () {
+ layui.data(config.tableName, {
+ key: 'token',
+ remove: true
+ });
+ },
+ // 缓存token
+ putToken: function (token) {
+ layui.data(config.tableName, {
+ key: 'token',
+ value: JSON.stringify(token)
+ });
+ },
+ // 当前登录的用户
+ getUser: function () {
+ var u = layui.data(config.tableName).login_user;
+ if (u) {
+ return JSON.parse(u);
+ }
+ },
+ // 缓存user
+ putUser: function (user) {
+ layui.data(config.tableName, {
+ key: 'login_user',
+ value: JSON.stringify(user)
+ });
+ }
+ };
+ exports('config', config);
+});
diff --git a/zlt-web/back-web/src/main/resources/static/module/echarts.js b/zlt-web/layui-web/src/main/resources/static/module/echarts.js
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/module/echarts.js
rename to zlt-web/layui-web/src/main/resources/static/module/echarts.js
diff --git a/zlt-web/back-web/src/main/resources/static/module/echartsTheme.js b/zlt-web/layui-web/src/main/resources/static/module/echartsTheme.js
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/module/echartsTheme.js
rename to zlt-web/layui-web/src/main/resources/static/module/echartsTheme.js
diff --git a/zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.all.js b/zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.all.js
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.all.js
rename to zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.all.js
index f0c341c3..6599c172 100644
--- a/zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.all.js
+++ b/zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.all.js
@@ -1,1415 +1,1415 @@
-'use strict';
-
-var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
-
-/**
- * name: formSelects
- * 基于Layui Select多选
- * version: 4.0.0.formSelects
- * http://sun.faysunshine.com/layui/formSelects-v4/dist/formSelects-v4.js
- */
-(function (layui, window, factory) {
- if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
- // 支持 CommonJS
- module.exports = factory();
- } else if (typeof define === 'function' && define.amd) {
- // 支持 AMD
- define(factory);
- } else if (window.layui && layui.define) {
- //layui加载
- layui.define(['jquery'], function (exports) {
- exports('formSelects', factory());
- });
- } else {
- window.formSelects = factory();
- }
-})(typeof layui == 'undefined' ? null : layui, window, function () {
- var v = '4.0.0.formSelects',
- NAME = 'xm-select',
- PNAME = 'xm-select-parent',
- INPUT = 'xm-select-input',
- TDIV = 'xm-select--suffix',
- THIS = 'xm-select-this',
- LABEL = 'xm-select-label',
- SEARCH = 'xm-select-search',
- CREATE = 'xm-select-create',
- CREATE_LONG = 'xm-select-create-long',
- MAX = 'xm-select-max',
- SKIN = 'xm-select-skin',
- DIRECTION = "xm-select-direction",
- HEIGHT = 'xm-select-height',
- DISABLED = 'xm-dis-disabled',
- DIS = 'xm-select-dis',
- TEMP = 'xm-select-temp',
- RADIO = 'xm-select-radio',
- LINKAGE = 'xm-select-linkage',
- DL = 'xm-select-dl',
- HIDE_INPUT = 'xm-hide-input',
- SANJIAO = 'xm-select-sj',
- ICON_CLOSE = 'xm-icon-close',
- FORM_TITLE = 'xm-select-title',
- FORM_SELECT = 'xm-form-select',
- FORM_SELECTED = 'xm-form-selected',
- FORM_NONE = 'xm-select-none',
- FORM_EMPTY = 'xm-select-empty',
- FORM_INPUT = 'xm-input',
- FORM_SELECT_TIPS = 'xm-select-tips',
- CHECKBOX_YES = 'xm-icon-yes',
- CZ = 'xm-cz',
- CZ_GROUP = 'xm-cz-group',
- TIPS = '请选择',
- data = {},
- events = {
- on: {},
- filter: {},
- maxTips: {}
- },
- ajax = {
- type: 'get',
- header: {},
- first: true,
- data: {},
- searchUrl: '',
- searchName: 'keyword',
- searchVal: null,
- keyName: 'name',
- keyVal: 'value',
- keySel: 'selected',
- keyDis: 'disabled',
- keyChildren: 'children',
- dataType: '',
- delay: 500,
- beforeSuccess: null,
- success: null,
- error: null,
- beforeSearch: null,
- clearInput: false
- },
- quickBtns = [{ icon: 'iconfont icon-quanxuan', name: '全选', click: function click(id, cm) {
- cm.selectAll(id, true, true);
- } }, { icon: 'iconfont icon-qingkong', name: '清空', click: function click(id, cm) {
- cm.removeAll(id, true, true);
- } }, { icon: 'iconfont icon-fanxuan', name: '反选', click: function click(id, cm) {
- cm.reverse(id, true, true);
- } }, { icon: 'iconfont icon-pifu', name: '换肤', click: function click(id, cm) {
- cm.skin(id);
- } }],
- $ = window.$ || window.layui && window.layui.jquery,
- $win = $(window),
- ajaxs = {},
- FormSelects = function FormSelects(options) {
- var _this = this;
-
- this.config = {
- name: null, //xm-select="xxx"
- max: null,
- maxTips: function maxTips(vals, val, max) {
- var ipt = $('[xid="' + _this.config.name + '"]').prev().find('.' + NAME);
- if (ipt.parents('.layui-form-item[pane]').length) {
- ipt = ipt.parents('.layui-form-item[pane]');
- }
- ipt.attr('style', 'border-color: red !important');
- setTimeout(function () {
- ipt.removeAttr('style');
- }, 300);
- },
- init: null, //初始化的选择值,
- on: null, //select值发生变化
- filter: function filter(id, inputVal, val, isDisabled) {
- return val.name.indexOf(inputVal) == -1;
- },
- clearid: -1,
- direction: 'auto',
- height: null,
- isEmpty: false,
- btns: [quickBtns[0], quickBtns[1], quickBtns[2]]
- };
- this.select = null;
- this.values = [];
- $.extend(true, this.config, options);
- };
-
- //一些简单的处理方法
- var Common = function Common() {
- this.loadingCss();
- this.appender();
- this.init();
- this.on();
- this.initVal();
- this.onreset();
- this.listening();
- };
-
- Common.prototype.appender = function () {
- //针对IE做的一些拓展
- if (!Array.prototype.map) {
- Array.prototype.map = function (callback, thisArg) {
- var T,
- A,
- k,
- O = Object(this),
- len = O.length >>> 0;
- if (thisArg) {
- T = thisArg;
- }
- A = new Array(len);
- k = 0;
- while (k < len) {
- var kValue, mappedValue;
- if (k in O) {
- kValue = O[k];
- mappedValue = callback.call(T, kValue, k, O);
- A[k] = mappedValue;
- }
- k++;
- }
- return A;
- };
- }
- if (!Array.prototype.forEach) {
- Array.prototype.forEach = function forEach(callback, thisArg) {
- var T, k;
- if (this == null) {
- throw new TypeError("this is null or not defined");
- }
- var O = Object(this);
- var len = O.length >>> 0;
- if (typeof callback !== "function") {
- throw new TypeError(callback + " is not a function");
- }
- if (arguments.length > 1) {
- T = thisArg;
- }
- k = 0;
- while (k < len) {
- var kValue;
- if (k in O) {
-
- kValue = O[k];
- callback.call(T, kValue, k, O);
- }
- k++;
- }
- };
- }
- };
-
- Common.prototype.init = function (target) {
- var _this2 = this;
-
- //初始化页面上已有的select
- $(target ? target : 'select[' + NAME + ']').each(function (index, select) {
- var othis = $(select),
- id = othis.attr(NAME),
- hasRender = othis.next('.layui-form-select'),
- disabled = select.disabled,
- max = othis.attr(MAX) - 0,
- isSearch = othis.attr(SEARCH) != undefined,
- searchUrl = isSearch ? othis.attr(SEARCH) : null,
- isCreate = othis.attr(CREATE) != undefined,
- isRadio = othis.attr(RADIO) != undefined,
- skin = othis.attr(SKIN),
- direction = othis.attr(DIRECTION),
- optionsFirst = select.options[0],
- height = othis.attr(HEIGHT),
- formname = othis.attr('name'),
- layverify = othis.attr('lay-verify'),
- placeholder = optionsFirst ? optionsFirst.value ? TIPS : optionsFirst.innerHTML || TIPS : TIPS,
- value = othis.find('option[selected]').toArray().map(function (option) {
- //获取已选中的数据
- return {
- name: option.innerHTML,
- val: option.value
- };
- }),
- fs = new FormSelects();
- data[id] = fs;
- //先取消layui对select的渲染
- hasRender[0] && hasRender.remove();
-
- //包裹一个div
- othis.wrap('
');
-
- //构造渲染div
- var dinfo = _this2.renderSelect(id, placeholder, select);
- var heightStyle = height ? 'style="height: ' + height + ';"' : '';
- var inputHtml = height ? ['
', ' '] : ['', ' ', '
'];
- var reElem = $('');
- othis.after(reElem);
- fs.select = othis.remove(); //去掉layui.form.render
- fs.values = value;
- fs.config.name = id;
- fs.config.init = value.concat([]);
- fs.config.direction = direction;
- fs.config.height = height;
- fs.config.radio = isRadio;
-
- if (max) {
- //有最大值
- fs.config.max = max;
- }
-
- //如果可搜索, 加上事件
- if (isSearch) {
- reElem.find('.' + INPUT).on('input propertychange', function (e) {
- var input = e.target,
- inputValue = $.trim(input.value),
- keyCode = e.keyCode;
- if (keyCode === 9 || keyCode === 13 || keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
- return false;
- }
-
- //过滤一下tips
- _this2.changePlaceHolder($(input));
-
- var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
- searchUrl = ajaxConfig.searchUrl || searchUrl;
- //如果开启了远程搜索
- if (searchUrl) {
- if (ajaxConfig.searchVal) {
- inputValue = ajaxConfig.searchVal;
- ajaxConfig.searchVal = '';
- }
- if (!ajaxConfig.beforeSearch || ajaxConfig.beforeSearch && ajaxConfig.beforeSearch instanceof Function && ajaxConfig.beforeSearch(id, searchUrl, inputValue)) {
- var delay = ajaxConfig.delay;
- if (ajaxConfig.first) {
- ajaxConfig.first = false;
- delay = 10;
- }
- clearTimeout(fs.clearid);
- fs.clearid = setTimeout(function () {
- reElem.find('dl > *:not(.' + FORM_SELECT_TIPS + ')').remove();
- reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('请求中');
- _this2.ajax(id, searchUrl, inputValue, false, null, true);
- }, delay);
- }
- } else {
- reElem.find('dl .layui-hide').removeClass('layui-hide');
- //遍历选项, 选择可以显示的值
- reElem.find('dl dd:not(.' + FORM_SELECT_TIPS + ')').each(function (idx, item) {
- var _item = $(item);
- var searchFun = data[id].config.filter || events.filter[id];
- if (searchFun && searchFun(id, inputValue, {
- name: _item.find('span').text(),
- val: _item.attr('lay-value')
- }, _item.hasClass(DISABLED)) == true) {
- _item.addClass('layui-hide');
- }
- });
- //控制分组名称
- reElem.find('dl dt').each(function (index, item) {
- if (!$(item).nextUntil('dt', ':not(.layui-hide)').length) {
- $(item).addClass('layui-hide');
- }
- });
- //动态创建
- _this2.create(id, isCreate, inputValue);
- var shows = reElem.find('dl dd:not(.' + FORM_SELECT_TIPS + '):not(.layui-hide)');
- if (!shows.length) {
- reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('无匹配项');
- } else {
- reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
- }
- }
- });
- if (searchUrl) {
- //触发第一次请求事件
- _this2.triggerSearch(reElem, true);
- }
- }
- });
- };
-
- Common.prototype.isArray = function (obj) {
- return Object.prototype.toString.call(obj) == "[object Array]";
- };
-
- Common.prototype.triggerSearch = function (div, isCall) {
- (div ? [div] : $('.' + FORM_SELECT).toArray()).forEach(function (reElem, index) {
- reElem = $(reElem);
- var id = reElem.find('dl').attr('xid');
- if (id && data[id] && data[id].config.isEmpty || isCall) {
- var obj_caller = reElem.find('.' + INPUT)[0];
- if (document.createEventObject) {
- obj_caller.fireEvent("onchange");
- } else {
- var evt = document.createEvent("HTMLEvents");
- evt.initEvent("input", false, true);
- obj_caller.dispatchEvent(evt);
- }
- }
- });
- };
-
- Common.prototype.ajax = function (id, searchUrl, inputValue, isLinkage, linkageWidth, isSearch) {
- var _this3 = this;
-
- var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
- if (!reElem[0] || !searchUrl) {
- return;
- }
-
- var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
- var ajaxData = $.extend(true, {}, ajaxConfig.data);
- ajaxData[ajaxConfig.searchName] = inputValue;
- ajaxData['_'] = Date.now();
- $.ajax({
- type: ajaxConfig.type,
- headers: ajaxConfig.header,
- url: searchUrl,
- data: ajaxConfig.dataType == 'json' ? JSON.stringify(ajaxData) : ajaxData,
- success: function success(res) {
- if (typeof res == 'string') {
- res = JSON.parse(res);
- }
- ajaxConfig.beforeSuccess && ajaxConfig.beforeSuccess instanceof Function && (res = ajaxConfig.beforeSuccess(id, searchUrl, inputValue, res));
- if (_this3.isArray(res)) {
- res = {
- code: 0,
- msg: "",
- data: res
- };
- }
- if (res.code != 0) {
- reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text(res.msg);
- } else {
- reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
- //获得已选择的values
- _this3.renderData(id, res.data, isLinkage, linkageWidth, isSearch);
- data[id].config.isEmpty = res.data.length == 0;
- }
- ajaxConfig.success && ajaxConfig.success instanceof Function && ajaxConfig.success(id, searchUrl, inputValue, res);
- },
- error: function error(err) {
- reElem.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + ')').remove();
- reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('服务异常');
- ajaxConfig.error && ajaxConfig.error instanceof Function && ajaxConfig.error(id, searchUrl, inputValue, err);
- }
- });
- };
-
- Common.prototype.renderData = function (id, dataArr, linkage, linkageWidth, isSearch) {
- var _this4 = this;
-
- if (linkage) {
- var _ret = function () {
- //渲染多级联动
- var result = [],
- index = 0,
- temp = { "0": dataArr },
- ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
-
- var _loop = function _loop() {
- var group = result[index++] = [],
- _temp = temp;
- temp = {};
- $.each(_temp, function (pid, arr) {
- $.each(arr, function (idx, item) {
- var val = {
- pid: pid,
- name: item[ajaxConfig.keyName],
- val: item[ajaxConfig.keyVal]
- };
- group.push(val);
- var children = item[ajaxConfig.keyChildren];
- if (children && children.length) {
- temp[val.val] = children;
- }
- });
- });
- };
-
- do {
- _loop();
- } while (Object.getOwnPropertyNames(temp).length);
-
- var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
- var html = [''];
-
- $.each(result, function (idx, arr) {
- var groupDiv = ['
'];
- $.each(arr, function (idx2, item) {
- var span = '
' + item.name + ' ';
- groupDiv.push(span);
- });
- groupDiv.push('');
- html = html.concat(groupDiv);
- });
- //
123
- html.push('
');
- html.push('
');
- reElem.find('dl').html(html.join(''));
- reElem.find('.' + INPUT).css('display', 'none'); //联动暂时不支持搜索
- return {
- v: void 0
- };
- }();
-
- if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
- }
-
- var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
- var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
- var pcInput = reElem.find('.' + TDIV + ' input');
-
- var values = [];
- reElem.find('dl').html(this.renderSelect(id, pcInput.attr('placeholder') || pcInput.attr('back'), dataArr.map(function (item) {
- if (item[ajaxConfig.keySel]) {
- values.push({
- name: item[ajaxConfig.keyName],
- val: item[ajaxConfig.keyVal]
- });
- }
- return {
- innerHTML: item[ajaxConfig.keyName],
- value: item[ajaxConfig.keyVal],
- sel: item[ajaxConfig.keySel],
- disabled: item[ajaxConfig.keyDis],
- type: item.type,
- name: item.name
- };
- })));
-
- var label = reElem.find('.' + LABEL);
- var dl = reElem.find('dl[xid]');
- if (isSearch) {
- //如果是远程搜索, 这里需要判重
- var oldVal = data[id].values;
- oldVal.forEach(function (item, index) {
- dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
- });
- values.forEach(function (item, index) {
- if (_this4.indexOf(oldVal, item) == -1) {
- _this4.addLabel(id, label, item);
- dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
- oldVal.push(item);
- }
- });
- } else {
- values.forEach(function (item, index) {
- _this4.addLabel(id, label, item);
- dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
- });
- data[id].values = values;
- }
- this.commonHanler(id, label);
- };
-
- Common.prototype.create = function (id, isCreate, inputValue) {
- if (isCreate && inputValue) {
- var fs = data[id],
- dl = $('[xid="' + id + '"]'),
- tips = dl.find('dd.' + FORM_SELECT_TIPS + ':first'),
- tdd = null,
- temp = dl.find('dd.' + TEMP);
- dl.find('dd:not(.' + FORM_SELECT_TIPS + '):not(.' + TEMP + ')').each(function (index, item) {
- if (inputValue == $(item).find('span').text()) {
- tdd = item;
- }
- });
- if (!tdd) {
- //如果不存在, 则创建
- if (temp[0]) {
- temp.attr('lay-value', inputValue);
- temp.find('span').text(inputValue);
- temp.removeClass('layui-hide');
- } else {
- tips.after($(this.createDD({
- innerHTML: inputValue,
- value: Date.now()
- }, TEMP + ' ' + CREATE_LONG)));
- }
- }
- } else {
- $('[xid=' + id + '] dd.' + TEMP).remove();
- }
- };
-
- Common.prototype.createDD = function (item, clz) {
- return '\n\t\t\t\t\t\n\t\t\t\t\t\t' + $.trim(item.innerHTML) + ' \n\t\t\t\t\t\t \n\t\t\t\t\t
\n\t\t\t\t ';
- };
-
- Common.prototype.createQuickBtn = function (obj, right) {
- return '' + obj.name + '
';
- };
-
- Common.prototype.renderBtns = function (id, show, right) {
- var _this5 = this;
-
- var quickBtn = [];
- var dl = $('dl[xid="' + id + '"]');
- quickBtn.push('');
- $.each(data[id].config.btns, function (index, item) {
- quickBtn.push(_this5.createQuickBtn(item, right));
- });
- quickBtn.push('
');
- quickBtn.push(this.createQuickBtn({ icon: 'iconfont icon-caidan', name: '' }));
- return quickBtn.join('');
- };
-
- Common.prototype.renderSelect = function (id, tips, select) {
- var _this6 = this;
-
- var arr = [];
- if (data[id].config.btns.length) {
- setTimeout(function () {
- var dl = $('dl[xid="' + id + '"]');
- dl.find('.' + CZ_GROUP).css('max-width', dl.prev().width() - 54 + 'px');
- }, 10);
- arr.push(['', this.renderBtns(id, null, '30px'), ' '].join(''));
- } else {
- arr.push('' + tips + ' ');
- }
- if (this.isArray(select)) {
- $(select).each(function (index, item) {
- if (item.type === 'optgroup') {
- arr.push('' + item.name + ' ');
- } else {
- arr.push(_this6.createDD(item));
- }
- });
- } else {
- $(select).find('*').each(function (index, item) {
- if (item.tagName.toLowerCase() == 'option' && index == 0 && !item.value) {
- return;
- }
- if (item.tagName.toLowerCase() === 'optgroup') {
- arr.push('' + item.label + ' ');
- } else {
- arr.push(_this6.createDD(item));
- }
- });
- }
- arr.push(' ');
- arr.push('\u6CA1\u6709\u9009\u9879 ');
- return arr.join('');
- };
-
- Common.prototype.on = function () {
- var _this7 = this;
-
- //事件绑定
- this.one();
-
- $(document).on('click', function (e) {
- if (!$(e.target).parents('.' + FORM_TITLE)[0]) {
- //清空input中的值
- $('.' + INPUT).val('');
- $('.' + PNAME + ' dl .layui-hide').removeClass('layui-hide');
- $('.' + PNAME + ' dl dd.' + TEMP).remove();
- _this7.triggerSearch();
- }
- $('.' + PNAME + ' .' + FORM_SELECTED).removeClass(FORM_SELECTED);
- });
- };
-
- Common.prototype.one = function (target) {
- var _this8 = this;
-
- //一次性事件绑定
- $(target ? target : document).find('.' + FORM_TITLE).off('click').on('click', function (e) {
- var othis = $(e.target),
- title = othis.is(FORM_TITLE) ? othis : othis.parents('.' + FORM_TITLE),
- dl = title.next(),
- id = dl.attr('xid');
-
- //清空非本select的input val
- $('dl[xid]').not(dl).prev().find('.' + INPUT).val('');
- $('dl[xid]').not(dl).find('dd.layui-hide').removeClass('layui-hide');
-
- //如果是disabled select
- if (title.hasClass(DIS)) {
- return false;
- }
- //如果点击的是右边的三角或者只读的input
- if (othis.is('.' + SANJIAO) || othis.is('.' + INPUT + '[readonly]')) {
- _this8.changeShow(title, !title.parents('.' + FORM_SELECT).hasClass(FORM_SELECTED));
- return false;
- }
- //如果点击的是input的右边, focus一下
- if (title.find('.' + INPUT + ':not(readonly)')[0]) {
- var input = title.find('.' + INPUT),
- epos = { x: e.pageX, y: e.pageY },
- pos = _this8.getPosition(title[0]),
- width = title.width();
- while (epos.x > pos.x) {
- if ($(document.elementFromPoint(epos.x, epos.y)).is(input)) {
- input.focus();
- _this8.changeShow(title, true);
- return false;
- }
- epos.x -= 50;
- }
- }
-
- //如果点击的是可搜索的input
- if (othis.is('.' + INPUT)) {
- _this8.changeShow(title, true);
- return false;
- }
- //如果点击的是x按钮
- if (othis.is('i[fsw="' + NAME + '"]')) {
- var val = {
- name: othis.prev().text(),
- val: othis.parent().attr("value")
- },
- dd = dl.find('dd[lay-value=\'' + val.val + '\']');
- if (dd.hasClass(DISABLED)) {
- //如果是disabled状态, 不可选, 不可删
- return false;
- }
- _this8.handlerLabel(id, dd, false, val);
- return false;
- }
-
- _this8.changeShow(title, !title.parents('.' + FORM_SELECT).hasClass(FORM_SELECTED));
- return false;
- });
- $(target ? target : document).find('dl.' + DL).off('click').on('click', function (e) {
- var othis = $(e.target);
- if (othis.is('.' + LINKAGE) || othis.parents('.' + LINKAGE)[0]) {
- //linkage的处理
- othis = othis.is('li') ? othis : othis.parents('li');
- var _group = othis.parents('.xm-select-linkage-group'),
- _id = othis.parents('dl').attr('xid');
- //激活li
- _group.find('.xm-select-active').removeClass('xm-select-active');
- othis.addClass('xm-select-active');
- //激活下一个group, 激活前显示对应数据
- _group.nextAll('.xm-select-linkage-group').addClass('xm-select-linkage-hide');
- var nextGroup = _group.next('.xm-select-linkage-group');
- nextGroup.find('li').addClass('xm-select-linkage-hide');
- nextGroup.find('li[pid="' + othis.attr('value') + '"]').removeClass('xm-select-linkage-hide');
- //如果没有下一个group, 或没有对应的值
- if (!nextGroup[0] || nextGroup.find('li:not(.xm-select-linkage-hide)').length == 0) {
- var vals = [],
- index = 0,
- _isAdd = !othis.hasClass('xm-select-this');
- if (data[_id].config.radio) {
- othis.parents('.xm-select-linkage').find('.xm-select-this').removeClass('xm-select-this');
- }
- do {
- vals[index++] = {
- name: othis.find('span').text(),
- val: othis.attr('value')
- /*isAdd ? (
- othis.addClass('xm-select-this')
- ) : (
- !othis.parent('.xm-select-linkage-group').next().find(`li[pid="${othis.attr('value')}"].xm-select-this`).length && othis.removeClass('xm-select-this')
- );*/
- };othis = othis.parents('.xm-select-linkage-group').prev().find('li[value="' + othis.attr('pid') + '"]');
- } while (othis.length);
- vals.reverse();
- var val = {
- name: vals.map(function (item) {
- return item.name;
- }).join('/'),
- val: vals.map(function (item) {
- return item.val;
- }).join('/')
- };
- _this8.handlerLabel(_id, null, _isAdd, val);
- } else {
- nextGroup.removeClass('xm-select-linkage-hide');
- }
- return false;
- } //xm-select-this xm-select-active
-
- if (othis.is('dt') || othis.is('dl')) {
- return false;
- }
- var dd = othis.is('dd') ? othis : othis.parents('dd');
- var id = dd.parent('dl').attr('xid');
- if (dd.hasClass(DISABLED)) {
- //被禁用选项的处理
- return false;
- }
- if (dd.hasClass(FORM_SELECT_TIPS)) {
- //tips的处理
- var btn = othis.is('.' + CZ) ? othis : othis.parents('.' + CZ);
- if (!btn[0]) {
- return false;
- }
- //TODO 快捷操作
- var method = btn.attr('method');
- var obj = data[id].config.btns.filter(function (bean) {
- return bean.name == method;
- })[0];
- obj && obj.click && obj.click instanceof Function && obj.click(id, _this8);
- return false;
- }
- var isAdd = !dd.hasClass(THIS);
- _this8.handlerLabel(id, dd, isAdd);
- return false;
- });
- };
-
- Common.prototype.linkageAdd = function (id, val) {
- var dl = $('dl[xid="' + id + '"]');
- dl.find('.xm-select-active').removeClass('xm-select-active');
- var vs = val.val.split('/');
- var pid = void 0,
- li = void 0,
- index = 0;
- var lis = [];
- do {
- pid = vs[index];
- li = dl.find('.xm-select-linkage-group' + (index + 1) + ' li[value="' + pid + '"]');
- li[0] && lis.push(li);
- index++;
- } while (li.length && pid != undefined);
- if (lis.length == vs.length) {
- $.each(lis, function (idx, item) {
- item.addClass('xm-select-this');
- });
- }
- };
-
- Common.prototype.linkageDel = function (id, val) {
- var dl = $('dl[xid="' + id + '"]');
- var vs = val.val.split('/');
- var pid = void 0,
- li = void 0,
- index = vs.length - 1;
- do {
- pid = vs[index];
- li = dl.find('.xm-select-linkage-group' + (index + 1) + ' li[value="' + pid + '"]');
- if (!li.parent().next().find('li[pid=' + pid + '].xm-select-this').length) {
- li.removeClass('xm-select-this');
- }
- index--;
- } while (li.length && pid != undefined);
- };
-
- Common.prototype.valToName = function (id, val) {
- var dl = $('dl[xid="' + id + '"]');
- var vs = (val + "").split('/');
- var names = [];
- $.each(vs, function (idx, item) {
- var name = dl.find('.xm-select-linkage-group' + (idx + 1) + ' li[value="' + item + '"] span').text();
- names.push(name);
- });
- return names.length == vs.length ? names.join('/') : null;
- };
-
- Common.prototype.commonHanler = function (key, label) {
- //计算input的提示语
- this.changePlaceHolder(label);
- //计算高度
- this.retop(label.parents('.' + FORM_SELECT));
- this.checkHideSpan(label);
- this.calcLeft(key, label);
- //表单默认值
- label.parents('.' + PNAME).find('.' + HIDE_INPUT).val(data[key].values.map(function (val) {
- return val.val;
- }).join(','));
- //title值
- label.parents('.' + FORM_TITLE + ' .' + NAME).attr('title', data[key].values.map(function (val) {
- return val.name;
- }).join(','));
- };
-
- Common.prototype.initVal = function (id) {
- var _this9 = this;
-
- var target = {};
- if (id) {
- target[id] = data[id];
- } else {
- target = data;
- }
- $.each(target, function (key, val) {
- var values = val.values,
- div = $('dl[xid="' + key + '"]').parent(),
- label = div.find('.' + LABEL),
- dl = div.find('dl');
- dl.find('dd.' + THIS).removeClass(THIS);
-
- var _vals = values.concat([]);
- _vals.concat([]).forEach(function (item, index) {
- _this9.addLabel(key, label, item);
- dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
- });
- if (val.config.radio) {
- _vals.length && values.push(_vals[_vals.length - 1]);
- }
- _this9.commonHanler(key, label);
- });
- };
-
- Common.prototype.handlerLabel = function (id, dd, isAdd, oval, notOn) {
- var div = $('[xid="' + id + '"]').prev().find('.' + LABEL),
- val = dd && {
- name: dd.find('span').text(),
- val: dd.attr('lay-value')
- },
- vals = data[id].values,
- on = data[id].config.on || events.on[id];
- if (oval) {
- val = oval;
- }
- var fs = data[id];
- if (isAdd && fs.config.max && fs.values.length >= fs.config.max) {
- var maxTipsFun = data[id].config.maxTips || events.maxTips[id];
- maxTipsFun && maxTipsFun(id, vals.concat([]), val, fs.max);
- return;
- }
- if (!notOn) {
- if (on && on instanceof Function && on(id, vals.concat([]), val, isAdd, dd && dd.hasClass(DISABLED) == false)) {
- return;
- }
- }
- var dl = $('dl[xid="' + id + '"]');
- isAdd ? (dd && dd[0] ? (dd.addClass(THIS), dd.removeClass(TEMP)) : dl.find('.xm-select-linkage')[0] && this.linkageAdd(id, val), this.addLabel(id, div, val), vals.push(val)) : (dd && dd[0] ? dd.removeClass(THIS) : dl.find('.xm-select-linkage')[0] && this.linkageDel(id, val), this.delLabel(id, div, val), this.remove(vals, val));
- if (!div[0]) return;
- //单选选完后直接关闭选择域
- if (fs.config.radio) {
- this.changeShow(div, false);
- }
- //移除表单验证的红色边框
- div.parents('.' + FORM_TITLE).prev().removeClass('layui-form-danger');
-
- //清空搜索值
- fs.config.clearInput && div.parents('.' + PNAME).find('.' + INPUT).val('');
-
- this.commonHanler(id, div);
- };
-
- Common.prototype.addLabel = function (id, div, val) {
- if (!val) return;
- var tips = 'fsw="' + NAME + '"';
- var _ref = [$('' + val.name + ' '), $('\xD7 ')],
- $label = _ref[0],
- $close = _ref[1];
-
- $label.append($close);
- //如果是radio模式
- var fs = data[id];
- if (fs.config.radio) {
- fs.values.length = 0;
- $('dl[xid="' + id + '"]').find('dd.' + THIS + ':not([lay-value="' + val.val + '"])').removeClass(THIS);
- div.find('span').remove();
- }
- //如果是固定高度
- if (fs.config.height) {
- div.append($label);
- } else {
- div.find('input').css('width', '50px');
- div.find('input').before($label);
- }
- };
-
- Common.prototype.delLabel = function (id, div, val) {
- if (!val) return;
- div.find('span[value="' + val.val + '"]:first').remove();
- };
-
- Common.prototype.calcLeft = function (id, div) {
- if (data[id].config.height) {
- var showLastSpan = div.find('span:not(.xm-span-hide):last')[0];
- div.next().css('left', (showLastSpan ? this.getPosition(showLastSpan).x - this.getPosition(div[0]).x + showLastSpan.offsetWidth + 20 : 10) + 'px');
- }
- };
-
- Common.prototype.checkHideSpan = function (div) {
- var _this10 = this;
-
- var parentHeight = div.parents('.' + NAME)[0].offsetHeight + 5;
- div.find('span.xm-span-hide').removeClass('xm-span-hide');
- div.find('span').each(function (index, item) {
- if (item.offsetHeight + item.offsetTop > parentHeight || _this10.getPosition(item).y + item.offsetHeight > _this10.getPosition(div[0]).y + div[0].offsetHeight + 5) {
- $(item).addClass('xm-span-hide');
- }
- });
- };
-
- Common.prototype.retop = function (div) {
- //计算dl显示的位置
- var dl = div.find('dl'),
- top = div.offset().top + div.outerHeight() + 5 - $win.scrollTop(),
- dlHeight = dl.outerHeight();
- var up = div.hasClass('layui-form-selectup') || dl.css('top').indexOf('-') != -1 || top + dlHeight > $win.height() && top >= dlHeight;
- div = div.find('.' + NAME);
-
- var fs = data[dl.attr('xid')];
- var base = dl.parents('.layui-form-pane')[0] && dl.prev()[0].clientHeight > 38 ? 14 : 10;
- if (fs) {
- if (fs.config.direction == 'up') {
- dl.css({
- top: 'auto',
- bottom: '42px'
- });
- return;
- }
- if (fs.direction == 'down') {
- dl.css({
- top: div[0].offsetTop + div.height() + base + 'px',
- bottom: 'auto'
- });
- return;
- }
- }
-
- if (up) {
- dl.css({
- top: 'auto',
- bottom: '42px'
- });
- } else {
- dl.css({
- top: div[0].offsetTop + div.height() + base + 'px',
- bottom: 'auto'
- });
- }
- };
-
- Common.prototype.changeShow = function (children, isShow) {
- //显示于隐藏
- var top = children.parents('.' + FORM_SELECT);
- $('.' + PNAME + ' .' + FORM_SELECT).not(top).removeClass(FORM_SELECTED);
- if (isShow) {
- this.retop(top);
- top.addClass(FORM_SELECTED);
- top.find('.' + INPUT).focus();
- } else {
- top.removeClass(FORM_SELECTED);
- top.find('.' + INPUT).val('');
- top.find('dl .layui-hide').removeClass('layui-hide');
- top.find('dl dd.' + TEMP).remove();
- //计算ajax数据是否为空, 然后重新请求数据
- var id = top.find('dl').attr('xid');
- if (id && data[id] && data[id].config.isEmpty) {
- this.triggerSearch(top);
- }
- }
- };
-
- Common.prototype.changePlaceHolder = function (div) {
- //显示于隐藏提示语
- //调整pane模式下的高度
- var title = div.parents('.' + FORM_TITLE);
-
- var id = div.parents('.' + PNAME).find('dl[xid]').attr('xid');
- if (data[id] && data[id].config.height) {//既然固定高度了, 那就看着办吧
-
- } else {
- var height = title.find('.' + NAME)[0].clientHeight;
- title.css('height', (height > 34 ? height + 4 : height) + 'px');
- //如果是layui pane模式, 处理label的高度
- var label = title.parents('.' + PNAME).parent().prev();
- if (label.is('.layui-form-label') && title.parents('.layui-form-pane')[0]) {
- height = height > 36 ? height + 4 : height;
- title.css('height', height + 'px');
- label.css({
- height: height + 2 + 'px',
- lineHeight: height - 18 + 'px'
- });
- }
- }
-
- var input = title.find('.' + TDIV + ' input'),
- isShow = !div.find('span:last')[0] && !title.find('.' + INPUT).val();
- if (isShow) {
- var ph = input.attr('back');
- input.removeAttr('back');
- input.attr('placeholder', ph);
- } else {
- var _ph = input.attr('placeholder');
- input.removeAttr('placeholder');
- input.attr('back', _ph);
- }
- };
-
- Common.prototype.indexOf = function (arr, val) {
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].val == val || arr[i].val == (val ? val.val : val) || arr[i] == val || JSON.stringify(arr[i]) == JSON.stringify(val)) {
- return i;
- }
- }
- return -1;
- };
-
- Common.prototype.remove = function (arr, val) {
- var idx = this.indexOf(arr, val ? val.val : val);
- if (idx > -1) {
- arr.splice(idx, 1);
- return true;
- }
- return false;
- };
-
- Common.prototype.selectAll = function (id, isOn, skipDis) {
- var _this11 = this;
-
- var dl = $('[xid="' + id + '"]');
- if (dl.find('.xm-select-linkage')[0]) {
- return;
- }
- dl.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + '):not(.' + THIS + ')' + (skipDis ? ':not(.' + DISABLED + ')' : '')).each(function (index, item) {
- item = $(item);
- var val = {
- name: item.find('span').text(),
- val: item.attr('lay-value')
- };
- _this11.handlerLabel(id, dl.find('dd[lay-value="' + val.val + '"]'), true, val, !isOn);
- });
- };
-
- Common.prototype.removeAll = function (id, isOn, skipDis) {
- var _this12 = this;
-
- var dl = $('[xid="' + id + '"]');
- if (dl.find('.xm-select-linkage')[0]) {
- //针对多级联动的处理
- data[id].values.concat([]).forEach(function (item, idx) {
- var vs = item.val.split('/');
- var pid = void 0,
- li = void 0,
- index = 0;
- do {
- pid = vs[index++];
- li = dl.find('.xm-select-linkage-group' + index + ':not(.xm-select-linkage-hide) li[value="' + pid + '"]');
- li.click();
- } while (li.length && pid != undefined);
- });
- return;
- }
- data[id].values.concat([]).forEach(function (item, index) {
- if (skipDis && dl.find('dd[lay-value="' + item.val + '"]').hasClass(DISABLED)) {} else {
- _this12.handlerLabel(id, dl.find('dd[lay-value="' + item.val + '"]'), false, item, !isOn);
- }
- });
- };
-
- Common.prototype.reverse = function (id, isOn, skipDis) {
- var _this13 = this;
-
- var dl = $('[xid="' + id + '"]');
- if (dl.find('.xm-select-linkage')[0]) {
- return;
- }
- dl.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + ')' + (skipDis ? ':not(.' + DISABLED + ')' : '')).each(function (index, item) {
- item = $(item);
- var val = {
- name: item.find('span').text(),
- val: item.attr('lay-value')
- };
- _this13.handlerLabel(id, dl.find('dd[lay-value="' + val.val + '"]'), !item.hasClass(THIS), val, !isOn);
- });
- };
-
- Common.prototype.skin = function (id) {
- var skins = ['default', 'primary', 'normal', 'warm', 'danger'];
- var skin = skins[Math.floor(Math.random() * skins.length)];
- $('dl[xid="' + id + '"]').parents('.' + PNAME).find('.' + FORM_SELECT).attr('xm-select-skin', skin);
- this.commonHanler(id, $('dl[xid="' + id + '"]').parents('.' + PNAME).find('.' + LABEL));
- };
-
- Common.prototype.getPosition = function (e) {
- var x = 0,
- y = 0;
- while (e != null) {
- x += e.offsetLeft;
- y += e.offsetTop;
- e = e.offsetParent;
- }
- return { x: x, y: y };
- };
-
- Common.prototype.onreset = function () {
- //监听reset按钮, 然后重置多选
- $(document).on('click', '[type=reset]', function (e) {
- $(e.target).parents('form').find('.' + PNAME + ' dl[xid]').each(function (index, item) {
- var id = item.getAttribute('xid'),
- dl = $(item),
- dd = void 0,
- temp = {};
- common.removeAll(id);
- data[id].config.init.forEach(function (val, idx) {
- if (val && (!temp[val] || data[id].config.repeat) && (dd = dl.find('dd[lay-value="' + val.val + '"]'))[0]) {
- common.handlerLabel(id, dd, true);
- temp[val] = 1;
- }
- });
- });
- });
- };
-
- Common.prototype.loadingCss = function () {
- var cssStyle = $('' + ' ');
- $('head link:last')[0] && $('head link:last').after(cssStyle) || $('head').append(cssStyle);
- };
-
- Common.prototype.listening = function () {
- //TODO 用于监听dom结构变化, 如果出现新的为渲染select, 则自动进行渲染
- var flag = false;
- var index = 0;
- $(document).on('DOMNodeInserted', function (e) {
- if (flag) {
- //避免递归渲染
- return;
- }
- flag = true;
- //渲染select
- $('select[' + NAME + ']').each(function (index, select) {
- var sid = select.getAttribute(NAME);
- common.init(select);
- common.one($('dl[xid="' + sid + '"]').parents('.' + PNAME));
- common.initVal(sid);
- });
-
- flag = false;
- });
- };
-
- var Select4 = function Select4() {
- this.v = v;
- };
- var common = new Common();
-
- Select4.prototype.value = function (id, type, isAppend) {
- if (typeof id != 'string') {
- return [];
- }
- var fs = data[id];
- if (!fs) {
- return [];
- }
- if (typeof type == 'string' || type == undefined) {
- var arr = fs.values.concat([]) || [];
- if (type == 'val') {
- return arr.map(function (val) {
- return val.val;
- });
- }
- if (type == 'valStr') {
- return arr.map(function (val) {
- return val.val;
- }).join(',');
- }
- if (type == 'name') {
- return arr.map(function (val) {
- return val.name;
- });
- }
- if (type == 'nameStr') {
- return arr.map(function (val) {
- return val.name;
- }).join(',');
- }
- return arr;
- }
- if (common.isArray(type)) {
- var dl = $('[xid="' + id + '"]'),
- temp = {},
- dd = void 0,
- isAdd = true;
- if (isAppend == false) {
- //删除传入的数组
- isAdd = false;
- } else if (isAppend == true) {
- //追加模式
- isAdd = true;
- } else {
- //删除原有的数据
- common.removeAll(id);
- }
- if (isAdd) {
- fs.values.forEach(function (val, index) {
- temp[val.val] = 1;
- });
- }
- type.forEach(function (val, index) {
- if (val && (!temp[val] || fs.config.repeat)) {
- if ((dd = dl.find('dd[lay-value="' + val + '"]'))[0]) {
- common.handlerLabel(id, dd, isAdd, null, true);
- temp[val] = 1;
- } else {
- var name = common.valToName(id, val);
- if (name) {
- common.handlerLabel(id, dd, isAdd, {
- name: name,
- val: val
- }, true);
- temp[val] = 1;
- }
- }
- }
- });
- }
- };
-
- Common.prototype.bindEvent = function (name, id, fun) {
- if (id && id instanceof Function) {
- fun = id;
- id = null;
- }
- if (fun && fun instanceof Function) {
- if (!id) {
- $.each(data, function (id, val) {
- data[id] ? data[id].config[name] = fun : events[name][id] = fun;
- });
- } else {
- data[id] ? data[id].config[name] = fun : events[name][id] = fun;
- }
- }
- };
-
- Select4.prototype.on = function (id, fun) {
- common.bindEvent('on', id, fun);
- return this;
- };
-
- Select4.prototype.filter = function (id, fun) {
- common.bindEvent('filter', id, fun);
- return this;
- };
-
- Select4.prototype.maxTips = function (id, fun) {
- common.bindEvent('maxTips', id, fun);
- return this;
- };
-
- Select4.prototype.config = function (id, config, isJson) {
- if (id && (typeof id === 'undefined' ? 'undefined' : _typeof(id)) == 'object') {
- isJson = config == true;
- config = id;
- id = null;
- }
- if (config && (typeof config === 'undefined' ? 'undefined' : _typeof(config)) == 'object') {
- if (isJson) {
- config.header || (config.header = {});
- config.header['Content-Type'] = 'application/json; charset=UTF-8';
- config.dataType = 'json';
- }
- id ? (ajaxs[id] = $.extend(true, {}, ajax, config), data[id] && (data[id].config.direction = config.direction), config.searchUrl && data[id] && common.triggerSearch($('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT), true)) : $.extend(true, ajax, config);
- }
- return this;
- };
-
- Select4.prototype.render = function (id) {
- var _this14 = this;
-
- var target = {};
- id ? data[id] && (target[id] = data[id]) : data;
-
- if (Object.getOwnPropertyNames(target).length) {
- $.each(target, function (key, val) {
- //恢复初始值
- var dl = $('dl[xid="' + key + '"]'),
- vals = [];
- val.select.find('option[selected]').each(function (index, item) {
- vals.push(item.value);
- });
- //移除创建元素
- dl.find('.' + CREATE_LONG).remove();
- //清空INPUT
- dl.prev().find('.' + INPUT).val('');
- //触发search
- common.triggerSearch(dl.parents('.' + FORM_SELECT), true);
- //移除hidn
- dl.find('.layui-hide').removeClass('layui-hide');
- //重新赋值
- _this14.value(key, vals);
- });
- }
- ($('select[' + NAME + '="' + id + '"]')[0] ? $('select[' + NAME + '="' + id + '"]') : $('select[' + NAME + ']')).each(function (index, select) {
- var sid = select.getAttribute(NAME);
- common.init(select);
- common.one($('dl[xid="' + sid + '"]').parents('.' + PNAME));
- common.initVal(sid);
- });
- return this;
- };
-
- Select4.prototype.disabled = function (id) {
- var target = {};
- id ? data[id] && (target[id] = data[id]) : target = data;
-
- $.each(target, function (key, val) {
- $('dl[xid="' + key + '"]').prev().addClass(DIS);
- });
- return this;
- };
-
- Select4.prototype.undisabled = function (id) {
- var target = {};
- id ? data[id] && (target[id] = data[id]) : target = data;
-
- $.each(target, function (key, val) {
- $('dl[xid="' + key + '"]').prev().removeClass(DIS);
- });
- return this;
- };
-
- Select4.prototype.data = function (id, type, config) {
- if (!id || !type || !config) {
- return this;
- }
- //检测该id是否尚未渲染
- !data[id] && this.render(id).value(id, []);
- this.config(id, config);
- if (type == 'local') {
- common.renderData(id, config.arr, config.linkage == true, config.linkageWidth ? config.linkageWidth : '100');
- } else if (type == 'server') {
- common.ajax(id, config.url, config.keyword, config.linkage == true, config.linkageWidth ? config.linkageWidth : '100');
- }
- return this;
- };
-
- Select4.prototype.btns = function (id, btns, config) {
- if (!btns || !common.isArray(btns)) {
- return this;
- };
- var target = {};
- id ? data[id] && (target[id] = data[id]) : target = data;
-
- btns = btns.map(function (obj) {
- if (typeof obj == 'string') {
- if (obj == 'select') {
- return quickBtns[0];
- }
- if (obj == 'remove') {
- return quickBtns[1];
- }
- if (obj == 'reverse') {
- return quickBtns[2];
- }
- if (obj == 'skin') {
- return quickBtns[3];
- }
- }
- return obj;
- });
-
- $.each(target, function (key, val) {
- val.config.btns = btns;
- var dd = $('dl[xid="' + key + '"]').find('.' + FORM_SELECT_TIPS + ':first');
- if (btns.length) {
- var show = config && config.show && (config.show == 'name' || config.show == 'icon') ? config.show : '';
- var html = common.renderBtns(key, show, config && config.space ? config.space : '30px');
- dd.html(html);
- } else {
- var pcInput = dd.parents('.' + FORM_SELECT).find('.' + TDIV + ' input');
- var _html = pcInput.attr('placeholder') || pcInput.attr('back');
- dd.html(_html);
- dd.removeAttr('style');
- }
- });
-
- return this;
- };
-
- Select4.prototype.search = function (id, val) {
- if (id && data[id]) {
- ajaxs[id] = $.extend(true, {}, ajax, {
- first: true,
- searchVal: val
- });
- common.triggerSearch($('dl[xid="' + id + '"]').parents('.' + FORM_SELECT), true);
- }
- return this;
- };
-
- return new Select4();
+'use strict';
+
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+
+/**
+ * name: formSelects
+ * 基于Layui Select多选
+ * version: 4.0.0.formSelects
+ * http://sun.faysunshine.com/layui/formSelects-v4/dist/formSelects-v4.js
+ */
+(function (layui, window, factory) {
+ if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
+ // 支持 CommonJS
+ module.exports = factory();
+ } else if (typeof define === 'function' && define.amd) {
+ // 支持 AMD
+ define(factory);
+ } else if (window.layui && layui.define) {
+ //layui加载
+ layui.define(['jquery'], function (exports) {
+ exports('formSelects', factory());
+ });
+ } else {
+ window.formSelects = factory();
+ }
+})(typeof layui == 'undefined' ? null : layui, window, function () {
+ var v = '4.0.0.formSelects',
+ NAME = 'xm-select',
+ PNAME = 'xm-select-parent',
+ INPUT = 'xm-select-input',
+ TDIV = 'xm-select--suffix',
+ THIS = 'xm-select-this',
+ LABEL = 'xm-select-label',
+ SEARCH = 'xm-select-search',
+ CREATE = 'xm-select-create',
+ CREATE_LONG = 'xm-select-create-long',
+ MAX = 'xm-select-max',
+ SKIN = 'xm-select-skin',
+ DIRECTION = "xm-select-direction",
+ HEIGHT = 'xm-select-height',
+ DISABLED = 'xm-dis-disabled',
+ DIS = 'xm-select-dis',
+ TEMP = 'xm-select-temp',
+ RADIO = 'xm-select-radio',
+ LINKAGE = 'xm-select-linkage',
+ DL = 'xm-select-dl',
+ HIDE_INPUT = 'xm-hide-input',
+ SANJIAO = 'xm-select-sj',
+ ICON_CLOSE = 'xm-icon-close',
+ FORM_TITLE = 'xm-select-title',
+ FORM_SELECT = 'xm-form-select',
+ FORM_SELECTED = 'xm-form-selected',
+ FORM_NONE = 'xm-select-none',
+ FORM_EMPTY = 'xm-select-empty',
+ FORM_INPUT = 'xm-input',
+ FORM_SELECT_TIPS = 'xm-select-tips',
+ CHECKBOX_YES = 'xm-icon-yes',
+ CZ = 'xm-cz',
+ CZ_GROUP = 'xm-cz-group',
+ TIPS = '请选择',
+ data = {},
+ events = {
+ on: {},
+ filter: {},
+ maxTips: {}
+ },
+ ajax = {
+ type: 'get',
+ header: {},
+ first: true,
+ data: {},
+ searchUrl: '',
+ searchName: 'keyword',
+ searchVal: null,
+ keyName: 'name',
+ keyVal: 'value',
+ keySel: 'selected',
+ keyDis: 'disabled',
+ keyChildren: 'children',
+ dataType: '',
+ delay: 500,
+ beforeSuccess: null,
+ success: null,
+ error: null,
+ beforeSearch: null,
+ clearInput: false
+ },
+ quickBtns = [{ icon: 'iconfont icon-quanxuan', name: '全选', click: function click(id, cm) {
+ cm.selectAll(id, true, true);
+ } }, { icon: 'iconfont icon-qingkong', name: '清空', click: function click(id, cm) {
+ cm.removeAll(id, true, true);
+ } }, { icon: 'iconfont icon-fanxuan', name: '反选', click: function click(id, cm) {
+ cm.reverse(id, true, true);
+ } }, { icon: 'iconfont icon-pifu', name: '换肤', click: function click(id, cm) {
+ cm.skin(id);
+ } }],
+ $ = window.$ || window.layui && window.layui.jquery,
+ $win = $(window),
+ ajaxs = {},
+ FormSelects = function FormSelects(options) {
+ var _this = this;
+
+ this.config = {
+ name: null, //xm-select="xxx"
+ max: null,
+ maxTips: function maxTips(vals, val, max) {
+ var ipt = $('[xid="' + _this.config.name + '"]').prev().find('.' + NAME);
+ if (ipt.parents('.layui-form-item[pane]').length) {
+ ipt = ipt.parents('.layui-form-item[pane]');
+ }
+ ipt.attr('style', 'border-color: red !important');
+ setTimeout(function () {
+ ipt.removeAttr('style');
+ }, 300);
+ },
+ init: null, //初始化的选择值,
+ on: null, //select值发生变化
+ filter: function filter(id, inputVal, val, isDisabled) {
+ return val.name.indexOf(inputVal) == -1;
+ },
+ clearid: -1,
+ direction: 'auto',
+ height: null,
+ isEmpty: false,
+ btns: [quickBtns[0], quickBtns[1], quickBtns[2]]
+ };
+ this.select = null;
+ this.values = [];
+ $.extend(true, this.config, options);
+ };
+
+ //一些简单的处理方法
+ var Common = function Common() {
+ this.loadingCss();
+ this.appender();
+ this.init();
+ this.on();
+ this.initVal();
+ this.onreset();
+ this.listening();
+ };
+
+ Common.prototype.appender = function () {
+ //针对IE做的一些拓展
+ if (!Array.prototype.map) {
+ Array.prototype.map = function (callback, thisArg) {
+ var T,
+ A,
+ k,
+ O = Object(this),
+ len = O.length >>> 0;
+ if (thisArg) {
+ T = thisArg;
+ }
+ A = new Array(len);
+ k = 0;
+ while (k < len) {
+ var kValue, mappedValue;
+ if (k in O) {
+ kValue = O[k];
+ mappedValue = callback.call(T, kValue, k, O);
+ A[k] = mappedValue;
+ }
+ k++;
+ }
+ return A;
+ };
+ }
+ if (!Array.prototype.forEach) {
+ Array.prototype.forEach = function forEach(callback, thisArg) {
+ var T, k;
+ if (this == null) {
+ throw new TypeError("this is null or not defined");
+ }
+ var O = Object(this);
+ var len = O.length >>> 0;
+ if (typeof callback !== "function") {
+ throw new TypeError(callback + " is not a function");
+ }
+ if (arguments.length > 1) {
+ T = thisArg;
+ }
+ k = 0;
+ while (k < len) {
+ var kValue;
+ if (k in O) {
+
+ kValue = O[k];
+ callback.call(T, kValue, k, O);
+ }
+ k++;
+ }
+ };
+ }
+ };
+
+ Common.prototype.init = function (target) {
+ var _this2 = this;
+
+ //初始化页面上已有的select
+ $(target ? target : 'select[' + NAME + ']').each(function (index, select) {
+ var othis = $(select),
+ id = othis.attr(NAME),
+ hasRender = othis.next('.layui-form-select'),
+ disabled = select.disabled,
+ max = othis.attr(MAX) - 0,
+ isSearch = othis.attr(SEARCH) != undefined,
+ searchUrl = isSearch ? othis.attr(SEARCH) : null,
+ isCreate = othis.attr(CREATE) != undefined,
+ isRadio = othis.attr(RADIO) != undefined,
+ skin = othis.attr(SKIN),
+ direction = othis.attr(DIRECTION),
+ optionsFirst = select.options[0],
+ height = othis.attr(HEIGHT),
+ formname = othis.attr('name'),
+ layverify = othis.attr('lay-verify'),
+ placeholder = optionsFirst ? optionsFirst.value ? TIPS : optionsFirst.innerHTML || TIPS : TIPS,
+ value = othis.find('option[selected]').toArray().map(function (option) {
+ //获取已选中的数据
+ return {
+ name: option.innerHTML,
+ val: option.value
+ };
+ }),
+ fs = new FormSelects();
+ data[id] = fs;
+ //先取消layui对select的渲染
+ hasRender[0] && hasRender.remove();
+
+ //包裹一个div
+ othis.wrap('
');
+
+ //构造渲染div
+ var dinfo = _this2.renderSelect(id, placeholder, select);
+ var heightStyle = height ? 'style="height: ' + height + ';"' : '';
+ var inputHtml = height ? ['
', ' '] : ['', ' ', '
'];
+ var reElem = $('');
+ othis.after(reElem);
+ fs.select = othis.remove(); //去掉layui.form.render
+ fs.values = value;
+ fs.config.name = id;
+ fs.config.init = value.concat([]);
+ fs.config.direction = direction;
+ fs.config.height = height;
+ fs.config.radio = isRadio;
+
+ if (max) {
+ //有最大值
+ fs.config.max = max;
+ }
+
+ //如果可搜索, 加上事件
+ if (isSearch) {
+ reElem.find('.' + INPUT).on('input propertychange', function (e) {
+ var input = e.target,
+ inputValue = $.trim(input.value),
+ keyCode = e.keyCode;
+ if (keyCode === 9 || keyCode === 13 || keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
+ return false;
+ }
+
+ //过滤一下tips
+ _this2.changePlaceHolder($(input));
+
+ var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+ searchUrl = ajaxConfig.searchUrl || searchUrl;
+ //如果开启了远程搜索
+ if (searchUrl) {
+ if (ajaxConfig.searchVal) {
+ inputValue = ajaxConfig.searchVal;
+ ajaxConfig.searchVal = '';
+ }
+ if (!ajaxConfig.beforeSearch || ajaxConfig.beforeSearch && ajaxConfig.beforeSearch instanceof Function && ajaxConfig.beforeSearch(id, searchUrl, inputValue)) {
+ var delay = ajaxConfig.delay;
+ if (ajaxConfig.first) {
+ ajaxConfig.first = false;
+ delay = 10;
+ }
+ clearTimeout(fs.clearid);
+ fs.clearid = setTimeout(function () {
+ reElem.find('dl > *:not(.' + FORM_SELECT_TIPS + ')').remove();
+ reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('请求中');
+ _this2.ajax(id, searchUrl, inputValue, false, null, true);
+ }, delay);
+ }
+ } else {
+ reElem.find('dl .layui-hide').removeClass('layui-hide');
+ //遍历选项, 选择可以显示的值
+ reElem.find('dl dd:not(.' + FORM_SELECT_TIPS + ')').each(function (idx, item) {
+ var _item = $(item);
+ var searchFun = data[id].config.filter || events.filter[id];
+ if (searchFun && searchFun(id, inputValue, {
+ name: _item.find('span').text(),
+ val: _item.attr('lay-value')
+ }, _item.hasClass(DISABLED)) == true) {
+ _item.addClass('layui-hide');
+ }
+ });
+ //控制分组名称
+ reElem.find('dl dt').each(function (index, item) {
+ if (!$(item).nextUntil('dt', ':not(.layui-hide)').length) {
+ $(item).addClass('layui-hide');
+ }
+ });
+ //动态创建
+ _this2.create(id, isCreate, inputValue);
+ var shows = reElem.find('dl dd:not(.' + FORM_SELECT_TIPS + '):not(.layui-hide)');
+ if (!shows.length) {
+ reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('无匹配项');
+ } else {
+ reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
+ }
+ }
+ });
+ if (searchUrl) {
+ //触发第一次请求事件
+ _this2.triggerSearch(reElem, true);
+ }
+ }
+ });
+ };
+
+ Common.prototype.isArray = function (obj) {
+ return Object.prototype.toString.call(obj) == "[object Array]";
+ };
+
+ Common.prototype.triggerSearch = function (div, isCall) {
+ (div ? [div] : $('.' + FORM_SELECT).toArray()).forEach(function (reElem, index) {
+ reElem = $(reElem);
+ var id = reElem.find('dl').attr('xid');
+ if (id && data[id] && data[id].config.isEmpty || isCall) {
+ var obj_caller = reElem.find('.' + INPUT)[0];
+ if (document.createEventObject) {
+ obj_caller.fireEvent("onchange");
+ } else {
+ var evt = document.createEvent("HTMLEvents");
+ evt.initEvent("input", false, true);
+ obj_caller.dispatchEvent(evt);
+ }
+ }
+ });
+ };
+
+ Common.prototype.ajax = function (id, searchUrl, inputValue, isLinkage, linkageWidth, isSearch) {
+ var _this3 = this;
+
+ var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
+ if (!reElem[0] || !searchUrl) {
+ return;
+ }
+
+ var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+ var ajaxData = $.extend(true, {}, ajaxConfig.data);
+ ajaxData[ajaxConfig.searchName] = inputValue;
+ ajaxData['_'] = Date.now();
+ $.ajax({
+ type: ajaxConfig.type,
+ headers: ajaxConfig.header,
+ url: searchUrl,
+ data: ajaxConfig.dataType == 'json' ? JSON.stringify(ajaxData) : ajaxData,
+ success: function success(res) {
+ if (typeof res == 'string') {
+ res = JSON.parse(res);
+ }
+ ajaxConfig.beforeSuccess && ajaxConfig.beforeSuccess instanceof Function && (res = ajaxConfig.beforeSuccess(id, searchUrl, inputValue, res));
+ if (_this3.isArray(res)) {
+ res = {
+ code: 0,
+ msg: "",
+ data: res
+ };
+ }
+ if (res.code != 0) {
+ reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text(res.msg);
+ } else {
+ reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
+ //获得已选择的values
+ _this3.renderData(id, res.data, isLinkage, linkageWidth, isSearch);
+ data[id].config.isEmpty = res.data.length == 0;
+ }
+ ajaxConfig.success && ajaxConfig.success instanceof Function && ajaxConfig.success(id, searchUrl, inputValue, res);
+ },
+ error: function error(err) {
+ reElem.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + ')').remove();
+ reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('服务异常');
+ ajaxConfig.error && ajaxConfig.error instanceof Function && ajaxConfig.error(id, searchUrl, inputValue, err);
+ }
+ });
+ };
+
+ Common.prototype.renderData = function (id, dataArr, linkage, linkageWidth, isSearch) {
+ var _this4 = this;
+
+ if (linkage) {
+ var _ret = function () {
+ //渲染多级联动
+ var result = [],
+ index = 0,
+ temp = { "0": dataArr },
+ ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+
+ var _loop = function _loop() {
+ var group = result[index++] = [],
+ _temp = temp;
+ temp = {};
+ $.each(_temp, function (pid, arr) {
+ $.each(arr, function (idx, item) {
+ var val = {
+ pid: pid,
+ name: item[ajaxConfig.keyName],
+ val: item[ajaxConfig.keyVal]
+ };
+ group.push(val);
+ var children = item[ajaxConfig.keyChildren];
+ if (children && children.length) {
+ temp[val.val] = children;
+ }
+ });
+ });
+ };
+
+ do {
+ _loop();
+ } while (Object.getOwnPropertyNames(temp).length);
+
+ var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
+ var html = [''];
+
+ $.each(result, function (idx, arr) {
+ var groupDiv = ['
'];
+ $.each(arr, function (idx2, item) {
+ var span = '
' + item.name + ' ';
+ groupDiv.push(span);
+ });
+ groupDiv.push('');
+ html = html.concat(groupDiv);
+ });
+ //
123
+ html.push('
');
+ html.push('
');
+ reElem.find('dl').html(html.join(''));
+ reElem.find('.' + INPUT).css('display', 'none'); //联动暂时不支持搜索
+ return {
+ v: void 0
+ };
+ }();
+
+ if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
+ }
+
+ var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
+ var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+ var pcInput = reElem.find('.' + TDIV + ' input');
+
+ var values = [];
+ reElem.find('dl').html(this.renderSelect(id, pcInput.attr('placeholder') || pcInput.attr('back'), dataArr.map(function (item) {
+ if (item[ajaxConfig.keySel]) {
+ values.push({
+ name: item[ajaxConfig.keyName],
+ val: item[ajaxConfig.keyVal]
+ });
+ }
+ return {
+ innerHTML: item[ajaxConfig.keyName],
+ value: item[ajaxConfig.keyVal],
+ sel: item[ajaxConfig.keySel],
+ disabled: item[ajaxConfig.keyDis],
+ type: item.type,
+ name: item.name
+ };
+ })));
+
+ var label = reElem.find('.' + LABEL);
+ var dl = reElem.find('dl[xid]');
+ if (isSearch) {
+ //如果是远程搜索, 这里需要判重
+ var oldVal = data[id].values;
+ oldVal.forEach(function (item, index) {
+ dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
+ });
+ values.forEach(function (item, index) {
+ if (_this4.indexOf(oldVal, item) == -1) {
+ _this4.addLabel(id, label, item);
+ dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
+ oldVal.push(item);
+ }
+ });
+ } else {
+ values.forEach(function (item, index) {
+ _this4.addLabel(id, label, item);
+ dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
+ });
+ data[id].values = values;
+ }
+ this.commonHanler(id, label);
+ };
+
+ Common.prototype.create = function (id, isCreate, inputValue) {
+ if (isCreate && inputValue) {
+ var fs = data[id],
+ dl = $('[xid="' + id + '"]'),
+ tips = dl.find('dd.' + FORM_SELECT_TIPS + ':first'),
+ tdd = null,
+ temp = dl.find('dd.' + TEMP);
+ dl.find('dd:not(.' + FORM_SELECT_TIPS + '):not(.' + TEMP + ')').each(function (index, item) {
+ if (inputValue == $(item).find('span').text()) {
+ tdd = item;
+ }
+ });
+ if (!tdd) {
+ //如果不存在, 则创建
+ if (temp[0]) {
+ temp.attr('lay-value', inputValue);
+ temp.find('span').text(inputValue);
+ temp.removeClass('layui-hide');
+ } else {
+ tips.after($(this.createDD({
+ innerHTML: inputValue,
+ value: Date.now()
+ }, TEMP + ' ' + CREATE_LONG)));
+ }
+ }
+ } else {
+ $('[xid=' + id + '] dd.' + TEMP).remove();
+ }
+ };
+
+ Common.prototype.createDD = function (item, clz) {
+ return '\n\t\t\t\t\t\n\t\t\t\t\t\t' + $.trim(item.innerHTML) + ' \n\t\t\t\t\t\t \n\t\t\t\t\t
\n\t\t\t\t ';
+ };
+
+ Common.prototype.createQuickBtn = function (obj, right) {
+ return '' + obj.name + '
';
+ };
+
+ Common.prototype.renderBtns = function (id, show, right) {
+ var _this5 = this;
+
+ var quickBtn = [];
+ var dl = $('dl[xid="' + id + '"]');
+ quickBtn.push('');
+ $.each(data[id].config.btns, function (index, item) {
+ quickBtn.push(_this5.createQuickBtn(item, right));
+ });
+ quickBtn.push('
');
+ quickBtn.push(this.createQuickBtn({ icon: 'iconfont icon-caidan', name: '' }));
+ return quickBtn.join('');
+ };
+
+ Common.prototype.renderSelect = function (id, tips, select) {
+ var _this6 = this;
+
+ var arr = [];
+ if (data[id].config.btns.length) {
+ setTimeout(function () {
+ var dl = $('dl[xid="' + id + '"]');
+ dl.find('.' + CZ_GROUP).css('max-width', dl.prev().width() - 54 + 'px');
+ }, 10);
+ arr.push(['', this.renderBtns(id, null, '30px'), ' '].join(''));
+ } else {
+ arr.push('' + tips + ' ');
+ }
+ if (this.isArray(select)) {
+ $(select).each(function (index, item) {
+ if (item.type === 'optgroup') {
+ arr.push('' + item.name + ' ');
+ } else {
+ arr.push(_this6.createDD(item));
+ }
+ });
+ } else {
+ $(select).find('*').each(function (index, item) {
+ if (item.tagName.toLowerCase() == 'option' && index == 0 && !item.value) {
+ return;
+ }
+ if (item.tagName.toLowerCase() === 'optgroup') {
+ arr.push('' + item.label + ' ');
+ } else {
+ arr.push(_this6.createDD(item));
+ }
+ });
+ }
+ arr.push(' ');
+ arr.push('\u6CA1\u6709\u9009\u9879 ');
+ return arr.join('');
+ };
+
+ Common.prototype.on = function () {
+ var _this7 = this;
+
+ //事件绑定
+ this.one();
+
+ $(document).on('click', function (e) {
+ if (!$(e.target).parents('.' + FORM_TITLE)[0]) {
+ //清空input中的值
+ $('.' + INPUT).val('');
+ $('.' + PNAME + ' dl .layui-hide').removeClass('layui-hide');
+ $('.' + PNAME + ' dl dd.' + TEMP).remove();
+ _this7.triggerSearch();
+ }
+ $('.' + PNAME + ' .' + FORM_SELECTED).removeClass(FORM_SELECTED);
+ });
+ };
+
+ Common.prototype.one = function (target) {
+ var _this8 = this;
+
+ //一次性事件绑定
+ $(target ? target : document).find('.' + FORM_TITLE).off('click').on('click', function (e) {
+ var othis = $(e.target),
+ title = othis.is(FORM_TITLE) ? othis : othis.parents('.' + FORM_TITLE),
+ dl = title.next(),
+ id = dl.attr('xid');
+
+ //清空非本select的input val
+ $('dl[xid]').not(dl).prev().find('.' + INPUT).val('');
+ $('dl[xid]').not(dl).find('dd.layui-hide').removeClass('layui-hide');
+
+ //如果是disabled select
+ if (title.hasClass(DIS)) {
+ return false;
+ }
+ //如果点击的是右边的三角或者只读的input
+ if (othis.is('.' + SANJIAO) || othis.is('.' + INPUT + '[readonly]')) {
+ _this8.changeShow(title, !title.parents('.' + FORM_SELECT).hasClass(FORM_SELECTED));
+ return false;
+ }
+ //如果点击的是input的右边, focus一下
+ if (title.find('.' + INPUT + ':not(readonly)')[0]) {
+ var input = title.find('.' + INPUT),
+ epos = { x: e.pageX, y: e.pageY },
+ pos = _this8.getPosition(title[0]),
+ width = title.width();
+ while (epos.x > pos.x) {
+ if ($(document.elementFromPoint(epos.x, epos.y)).is(input)) {
+ input.focus();
+ _this8.changeShow(title, true);
+ return false;
+ }
+ epos.x -= 50;
+ }
+ }
+
+ //如果点击的是可搜索的input
+ if (othis.is('.' + INPUT)) {
+ _this8.changeShow(title, true);
+ return false;
+ }
+ //如果点击的是x按钮
+ if (othis.is('i[fsw="' + NAME + '"]')) {
+ var val = {
+ name: othis.prev().text(),
+ val: othis.parent().attr("value")
+ },
+ dd = dl.find('dd[lay-value=\'' + val.val + '\']');
+ if (dd.hasClass(DISABLED)) {
+ //如果是disabled状态, 不可选, 不可删
+ return false;
+ }
+ _this8.handlerLabel(id, dd, false, val);
+ return false;
+ }
+
+ _this8.changeShow(title, !title.parents('.' + FORM_SELECT).hasClass(FORM_SELECTED));
+ return false;
+ });
+ $(target ? target : document).find('dl.' + DL).off('click').on('click', function (e) {
+ var othis = $(e.target);
+ if (othis.is('.' + LINKAGE) || othis.parents('.' + LINKAGE)[0]) {
+ //linkage的处理
+ othis = othis.is('li') ? othis : othis.parents('li');
+ var _group = othis.parents('.xm-select-linkage-group'),
+ _id = othis.parents('dl').attr('xid');
+ //激活li
+ _group.find('.xm-select-active').removeClass('xm-select-active');
+ othis.addClass('xm-select-active');
+ //激活下一个group, 激活前显示对应数据
+ _group.nextAll('.xm-select-linkage-group').addClass('xm-select-linkage-hide');
+ var nextGroup = _group.next('.xm-select-linkage-group');
+ nextGroup.find('li').addClass('xm-select-linkage-hide');
+ nextGroup.find('li[pid="' + othis.attr('value') + '"]').removeClass('xm-select-linkage-hide');
+ //如果没有下一个group, 或没有对应的值
+ if (!nextGroup[0] || nextGroup.find('li:not(.xm-select-linkage-hide)').length == 0) {
+ var vals = [],
+ index = 0,
+ _isAdd = !othis.hasClass('xm-select-this');
+ if (data[_id].config.radio) {
+ othis.parents('.xm-select-linkage').find('.xm-select-this').removeClass('xm-select-this');
+ }
+ do {
+ vals[index++] = {
+ name: othis.find('span').text(),
+ val: othis.attr('value')
+ /*isAdd ? (
+ othis.addClass('xm-select-this')
+ ) : (
+ !othis.parent('.xm-select-linkage-group').next().find(`li[pid="${othis.attr('value')}"].xm-select-this`).length && othis.removeClass('xm-select-this')
+ );*/
+ };othis = othis.parents('.xm-select-linkage-group').prev().find('li[value="' + othis.attr('pid') + '"]');
+ } while (othis.length);
+ vals.reverse();
+ var val = {
+ name: vals.map(function (item) {
+ return item.name;
+ }).join('/'),
+ val: vals.map(function (item) {
+ return item.val;
+ }).join('/')
+ };
+ _this8.handlerLabel(_id, null, _isAdd, val);
+ } else {
+ nextGroup.removeClass('xm-select-linkage-hide');
+ }
+ return false;
+ } //xm-select-this xm-select-active
+
+ if (othis.is('dt') || othis.is('dl')) {
+ return false;
+ }
+ var dd = othis.is('dd') ? othis : othis.parents('dd');
+ var id = dd.parent('dl').attr('xid');
+ if (dd.hasClass(DISABLED)) {
+ //被禁用选项的处理
+ return false;
+ }
+ if (dd.hasClass(FORM_SELECT_TIPS)) {
+ //tips的处理
+ var btn = othis.is('.' + CZ) ? othis : othis.parents('.' + CZ);
+ if (!btn[0]) {
+ return false;
+ }
+ //TODO 快捷操作
+ var method = btn.attr('method');
+ var obj = data[id].config.btns.filter(function (bean) {
+ return bean.name == method;
+ })[0];
+ obj && obj.click && obj.click instanceof Function && obj.click(id, _this8);
+ return false;
+ }
+ var isAdd = !dd.hasClass(THIS);
+ _this8.handlerLabel(id, dd, isAdd);
+ return false;
+ });
+ };
+
+ Common.prototype.linkageAdd = function (id, val) {
+ var dl = $('dl[xid="' + id + '"]');
+ dl.find('.xm-select-active').removeClass('xm-select-active');
+ var vs = val.val.split('/');
+ var pid = void 0,
+ li = void 0,
+ index = 0;
+ var lis = [];
+ do {
+ pid = vs[index];
+ li = dl.find('.xm-select-linkage-group' + (index + 1) + ' li[value="' + pid + '"]');
+ li[0] && lis.push(li);
+ index++;
+ } while (li.length && pid != undefined);
+ if (lis.length == vs.length) {
+ $.each(lis, function (idx, item) {
+ item.addClass('xm-select-this');
+ });
+ }
+ };
+
+ Common.prototype.linkageDel = function (id, val) {
+ var dl = $('dl[xid="' + id + '"]');
+ var vs = val.val.split('/');
+ var pid = void 0,
+ li = void 0,
+ index = vs.length - 1;
+ do {
+ pid = vs[index];
+ li = dl.find('.xm-select-linkage-group' + (index + 1) + ' li[value="' + pid + '"]');
+ if (!li.parent().next().find('li[pid=' + pid + '].xm-select-this').length) {
+ li.removeClass('xm-select-this');
+ }
+ index--;
+ } while (li.length && pid != undefined);
+ };
+
+ Common.prototype.valToName = function (id, val) {
+ var dl = $('dl[xid="' + id + '"]');
+ var vs = (val + "").split('/');
+ var names = [];
+ $.each(vs, function (idx, item) {
+ var name = dl.find('.xm-select-linkage-group' + (idx + 1) + ' li[value="' + item + '"] span').text();
+ names.push(name);
+ });
+ return names.length == vs.length ? names.join('/') : null;
+ };
+
+ Common.prototype.commonHanler = function (key, label) {
+ //计算input的提示语
+ this.changePlaceHolder(label);
+ //计算高度
+ this.retop(label.parents('.' + FORM_SELECT));
+ this.checkHideSpan(label);
+ this.calcLeft(key, label);
+ //表单默认值
+ label.parents('.' + PNAME).find('.' + HIDE_INPUT).val(data[key].values.map(function (val) {
+ return val.val;
+ }).join(','));
+ //title值
+ label.parents('.' + FORM_TITLE + ' .' + NAME).attr('title', data[key].values.map(function (val) {
+ return val.name;
+ }).join(','));
+ };
+
+ Common.prototype.initVal = function (id) {
+ var _this9 = this;
+
+ var target = {};
+ if (id) {
+ target[id] = data[id];
+ } else {
+ target = data;
+ }
+ $.each(target, function (key, val) {
+ var values = val.values,
+ div = $('dl[xid="' + key + '"]').parent(),
+ label = div.find('.' + LABEL),
+ dl = div.find('dl');
+ dl.find('dd.' + THIS).removeClass(THIS);
+
+ var _vals = values.concat([]);
+ _vals.concat([]).forEach(function (item, index) {
+ _this9.addLabel(key, label, item);
+ dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
+ });
+ if (val.config.radio) {
+ _vals.length && values.push(_vals[_vals.length - 1]);
+ }
+ _this9.commonHanler(key, label);
+ });
+ };
+
+ Common.prototype.handlerLabel = function (id, dd, isAdd, oval, notOn) {
+ var div = $('[xid="' + id + '"]').prev().find('.' + LABEL),
+ val = dd && {
+ name: dd.find('span').text(),
+ val: dd.attr('lay-value')
+ },
+ vals = data[id].values,
+ on = data[id].config.on || events.on[id];
+ if (oval) {
+ val = oval;
+ }
+ var fs = data[id];
+ if (isAdd && fs.config.max && fs.values.length >= fs.config.max) {
+ var maxTipsFun = data[id].config.maxTips || events.maxTips[id];
+ maxTipsFun && maxTipsFun(id, vals.concat([]), val, fs.max);
+ return;
+ }
+ if (!notOn) {
+ if (on && on instanceof Function && on(id, vals.concat([]), val, isAdd, dd && dd.hasClass(DISABLED) == false)) {
+ return;
+ }
+ }
+ var dl = $('dl[xid="' + id + '"]');
+ isAdd ? (dd && dd[0] ? (dd.addClass(THIS), dd.removeClass(TEMP)) : dl.find('.xm-select-linkage')[0] && this.linkageAdd(id, val), this.addLabel(id, div, val), vals.push(val)) : (dd && dd[0] ? dd.removeClass(THIS) : dl.find('.xm-select-linkage')[0] && this.linkageDel(id, val), this.delLabel(id, div, val), this.remove(vals, val));
+ if (!div[0]) return;
+ //单选选完后直接关闭选择域
+ if (fs.config.radio) {
+ this.changeShow(div, false);
+ }
+ //移除表单验证的红色边框
+ div.parents('.' + FORM_TITLE).prev().removeClass('layui-form-danger');
+
+ //清空搜索值
+ fs.config.clearInput && div.parents('.' + PNAME).find('.' + INPUT).val('');
+
+ this.commonHanler(id, div);
+ };
+
+ Common.prototype.addLabel = function (id, div, val) {
+ if (!val) return;
+ var tips = 'fsw="' + NAME + '"';
+ var _ref = [$('' + val.name + ' '), $('\xD7 ')],
+ $label = _ref[0],
+ $close = _ref[1];
+
+ $label.append($close);
+ //如果是radio模式
+ var fs = data[id];
+ if (fs.config.radio) {
+ fs.values.length = 0;
+ $('dl[xid="' + id + '"]').find('dd.' + THIS + ':not([lay-value="' + val.val + '"])').removeClass(THIS);
+ div.find('span').remove();
+ }
+ //如果是固定高度
+ if (fs.config.height) {
+ div.append($label);
+ } else {
+ div.find('input').css('width', '50px');
+ div.find('input').before($label);
+ }
+ };
+
+ Common.prototype.delLabel = function (id, div, val) {
+ if (!val) return;
+ div.find('span[value="' + val.val + '"]:first').remove();
+ };
+
+ Common.prototype.calcLeft = function (id, div) {
+ if (data[id].config.height) {
+ var showLastSpan = div.find('span:not(.xm-span-hide):last')[0];
+ div.next().css('left', (showLastSpan ? this.getPosition(showLastSpan).x - this.getPosition(div[0]).x + showLastSpan.offsetWidth + 20 : 10) + 'px');
+ }
+ };
+
+ Common.prototype.checkHideSpan = function (div) {
+ var _this10 = this;
+
+ var parentHeight = div.parents('.' + NAME)[0].offsetHeight + 5;
+ div.find('span.xm-span-hide').removeClass('xm-span-hide');
+ div.find('span').each(function (index, item) {
+ if (item.offsetHeight + item.offsetTop > parentHeight || _this10.getPosition(item).y + item.offsetHeight > _this10.getPosition(div[0]).y + div[0].offsetHeight + 5) {
+ $(item).addClass('xm-span-hide');
+ }
+ });
+ };
+
+ Common.prototype.retop = function (div) {
+ //计算dl显示的位置
+ var dl = div.find('dl'),
+ top = div.offset().top + div.outerHeight() + 5 - $win.scrollTop(),
+ dlHeight = dl.outerHeight();
+ var up = div.hasClass('layui-form-selectup') || dl.css('top').indexOf('-') != -1 || top + dlHeight > $win.height() && top >= dlHeight;
+ div = div.find('.' + NAME);
+
+ var fs = data[dl.attr('xid')];
+ var base = dl.parents('.layui-form-pane')[0] && dl.prev()[0].clientHeight > 38 ? 14 : 10;
+ if (fs) {
+ if (fs.config.direction == 'up') {
+ dl.css({
+ top: 'auto',
+ bottom: '42px'
+ });
+ return;
+ }
+ if (fs.direction == 'down') {
+ dl.css({
+ top: div[0].offsetTop + div.height() + base + 'px',
+ bottom: 'auto'
+ });
+ return;
+ }
+ }
+
+ if (up) {
+ dl.css({
+ top: 'auto',
+ bottom: '42px'
+ });
+ } else {
+ dl.css({
+ top: div[0].offsetTop + div.height() + base + 'px',
+ bottom: 'auto'
+ });
+ }
+ };
+
+ Common.prototype.changeShow = function (children, isShow) {
+ //显示于隐藏
+ var top = children.parents('.' + FORM_SELECT);
+ $('.' + PNAME + ' .' + FORM_SELECT).not(top).removeClass(FORM_SELECTED);
+ if (isShow) {
+ this.retop(top);
+ top.addClass(FORM_SELECTED);
+ top.find('.' + INPUT).focus();
+ } else {
+ top.removeClass(FORM_SELECTED);
+ top.find('.' + INPUT).val('');
+ top.find('dl .layui-hide').removeClass('layui-hide');
+ top.find('dl dd.' + TEMP).remove();
+ //计算ajax数据是否为空, 然后重新请求数据
+ var id = top.find('dl').attr('xid');
+ if (id && data[id] && data[id].config.isEmpty) {
+ this.triggerSearch(top);
+ }
+ }
+ };
+
+ Common.prototype.changePlaceHolder = function (div) {
+ //显示于隐藏提示语
+ //调整pane模式下的高度
+ var title = div.parents('.' + FORM_TITLE);
+
+ var id = div.parents('.' + PNAME).find('dl[xid]').attr('xid');
+ if (data[id] && data[id].config.height) {//既然固定高度了, 那就看着办吧
+
+ } else {
+ var height = title.find('.' + NAME)[0].clientHeight;
+ title.css('height', (height > 34 ? height + 4 : height) + 'px');
+ //如果是layui pane模式, 处理label的高度
+ var label = title.parents('.' + PNAME).parent().prev();
+ if (label.is('.layui-form-label') && title.parents('.layui-form-pane')[0]) {
+ height = height > 36 ? height + 4 : height;
+ title.css('height', height + 'px');
+ label.css({
+ height: height + 2 + 'px',
+ lineHeight: height - 18 + 'px'
+ });
+ }
+ }
+
+ var input = title.find('.' + TDIV + ' input'),
+ isShow = !div.find('span:last')[0] && !title.find('.' + INPUT).val();
+ if (isShow) {
+ var ph = input.attr('back');
+ input.removeAttr('back');
+ input.attr('placeholder', ph);
+ } else {
+ var _ph = input.attr('placeholder');
+ input.removeAttr('placeholder');
+ input.attr('back', _ph);
+ }
+ };
+
+ Common.prototype.indexOf = function (arr, val) {
+ for (var i = 0; i < arr.length; i++) {
+ if (arr[i].val == val || arr[i].val == (val ? val.val : val) || arr[i] == val || JSON.stringify(arr[i]) == JSON.stringify(val)) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+ Common.prototype.remove = function (arr, val) {
+ var idx = this.indexOf(arr, val ? val.val : val);
+ if (idx > -1) {
+ arr.splice(idx, 1);
+ return true;
+ }
+ return false;
+ };
+
+ Common.prototype.selectAll = function (id, isOn, skipDis) {
+ var _this11 = this;
+
+ var dl = $('[xid="' + id + '"]');
+ if (dl.find('.xm-select-linkage')[0]) {
+ return;
+ }
+ dl.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + '):not(.' + THIS + ')' + (skipDis ? ':not(.' + DISABLED + ')' : '')).each(function (index, item) {
+ item = $(item);
+ var val = {
+ name: item.find('span').text(),
+ val: item.attr('lay-value')
+ };
+ _this11.handlerLabel(id, dl.find('dd[lay-value="' + val.val + '"]'), true, val, !isOn);
+ });
+ };
+
+ Common.prototype.removeAll = function (id, isOn, skipDis) {
+ var _this12 = this;
+
+ var dl = $('[xid="' + id + '"]');
+ if (dl.find('.xm-select-linkage')[0]) {
+ //针对多级联动的处理
+ data[id].values.concat([]).forEach(function (item, idx) {
+ var vs = item.val.split('/');
+ var pid = void 0,
+ li = void 0,
+ index = 0;
+ do {
+ pid = vs[index++];
+ li = dl.find('.xm-select-linkage-group' + index + ':not(.xm-select-linkage-hide) li[value="' + pid + '"]');
+ li.click();
+ } while (li.length && pid != undefined);
+ });
+ return;
+ }
+ data[id].values.concat([]).forEach(function (item, index) {
+ if (skipDis && dl.find('dd[lay-value="' + item.val + '"]').hasClass(DISABLED)) {} else {
+ _this12.handlerLabel(id, dl.find('dd[lay-value="' + item.val + '"]'), false, item, !isOn);
+ }
+ });
+ };
+
+ Common.prototype.reverse = function (id, isOn, skipDis) {
+ var _this13 = this;
+
+ var dl = $('[xid="' + id + '"]');
+ if (dl.find('.xm-select-linkage')[0]) {
+ return;
+ }
+ dl.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + ')' + (skipDis ? ':not(.' + DISABLED + ')' : '')).each(function (index, item) {
+ item = $(item);
+ var val = {
+ name: item.find('span').text(),
+ val: item.attr('lay-value')
+ };
+ _this13.handlerLabel(id, dl.find('dd[lay-value="' + val.val + '"]'), !item.hasClass(THIS), val, !isOn);
+ });
+ };
+
+ Common.prototype.skin = function (id) {
+ var skins = ['default', 'primary', 'normal', 'warm', 'danger'];
+ var skin = skins[Math.floor(Math.random() * skins.length)];
+ $('dl[xid="' + id + '"]').parents('.' + PNAME).find('.' + FORM_SELECT).attr('xm-select-skin', skin);
+ this.commonHanler(id, $('dl[xid="' + id + '"]').parents('.' + PNAME).find('.' + LABEL));
+ };
+
+ Common.prototype.getPosition = function (e) {
+ var x = 0,
+ y = 0;
+ while (e != null) {
+ x += e.offsetLeft;
+ y += e.offsetTop;
+ e = e.offsetParent;
+ }
+ return { x: x, y: y };
+ };
+
+ Common.prototype.onreset = function () {
+ //监听reset按钮, 然后重置多选
+ $(document).on('click', '[type=reset]', function (e) {
+ $(e.target).parents('form').find('.' + PNAME + ' dl[xid]').each(function (index, item) {
+ var id = item.getAttribute('xid'),
+ dl = $(item),
+ dd = void 0,
+ temp = {};
+ common.removeAll(id);
+ data[id].config.init.forEach(function (val, idx) {
+ if (val && (!temp[val] || data[id].config.repeat) && (dd = dl.find('dd[lay-value="' + val.val + '"]'))[0]) {
+ common.handlerLabel(id, dd, true);
+ temp[val] = 1;
+ }
+ });
+ });
+ });
+ };
+
+ Common.prototype.loadingCss = function () {
+ var cssStyle = $('' + ' ');
+ $('head link:last')[0] && $('head link:last').after(cssStyle) || $('head').append(cssStyle);
+ };
+
+ Common.prototype.listening = function () {
+ //TODO 用于监听dom结构变化, 如果出现新的为渲染select, 则自动进行渲染
+ var flag = false;
+ var index = 0;
+ $(document).on('DOMNodeInserted', function (e) {
+ if (flag) {
+ //避免递归渲染
+ return;
+ }
+ flag = true;
+ //渲染select
+ $('select[' + NAME + ']').each(function (index, select) {
+ var sid = select.getAttribute(NAME);
+ common.init(select);
+ common.one($('dl[xid="' + sid + '"]').parents('.' + PNAME));
+ common.initVal(sid);
+ });
+
+ flag = false;
+ });
+ };
+
+ var Select4 = function Select4() {
+ this.v = v;
+ };
+ var common = new Common();
+
+ Select4.prototype.value = function (id, type, isAppend) {
+ if (typeof id != 'string') {
+ return [];
+ }
+ var fs = data[id];
+ if (!fs) {
+ return [];
+ }
+ if (typeof type == 'string' || type == undefined) {
+ var arr = fs.values.concat([]) || [];
+ if (type == 'val') {
+ return arr.map(function (val) {
+ return val.val;
+ });
+ }
+ if (type == 'valStr') {
+ return arr.map(function (val) {
+ return val.val;
+ }).join(',');
+ }
+ if (type == 'name') {
+ return arr.map(function (val) {
+ return val.name;
+ });
+ }
+ if (type == 'nameStr') {
+ return arr.map(function (val) {
+ return val.name;
+ }).join(',');
+ }
+ return arr;
+ }
+ if (common.isArray(type)) {
+ var dl = $('[xid="' + id + '"]'),
+ temp = {},
+ dd = void 0,
+ isAdd = true;
+ if (isAppend == false) {
+ //删除传入的数组
+ isAdd = false;
+ } else if (isAppend == true) {
+ //追加模式
+ isAdd = true;
+ } else {
+ //删除原有的数据
+ common.removeAll(id);
+ }
+ if (isAdd) {
+ fs.values.forEach(function (val, index) {
+ temp[val.val] = 1;
+ });
+ }
+ type.forEach(function (val, index) {
+ if (val && (!temp[val] || fs.config.repeat)) {
+ if ((dd = dl.find('dd[lay-value="' + val + '"]'))[0]) {
+ common.handlerLabel(id, dd, isAdd, null, true);
+ temp[val] = 1;
+ } else {
+ var name = common.valToName(id, val);
+ if (name) {
+ common.handlerLabel(id, dd, isAdd, {
+ name: name,
+ val: val
+ }, true);
+ temp[val] = 1;
+ }
+ }
+ }
+ });
+ }
+ };
+
+ Common.prototype.bindEvent = function (name, id, fun) {
+ if (id && id instanceof Function) {
+ fun = id;
+ id = null;
+ }
+ if (fun && fun instanceof Function) {
+ if (!id) {
+ $.each(data, function (id, val) {
+ data[id] ? data[id].config[name] = fun : events[name][id] = fun;
+ });
+ } else {
+ data[id] ? data[id].config[name] = fun : events[name][id] = fun;
+ }
+ }
+ };
+
+ Select4.prototype.on = function (id, fun) {
+ common.bindEvent('on', id, fun);
+ return this;
+ };
+
+ Select4.prototype.filter = function (id, fun) {
+ common.bindEvent('filter', id, fun);
+ return this;
+ };
+
+ Select4.prototype.maxTips = function (id, fun) {
+ common.bindEvent('maxTips', id, fun);
+ return this;
+ };
+
+ Select4.prototype.config = function (id, config, isJson) {
+ if (id && (typeof id === 'undefined' ? 'undefined' : _typeof(id)) == 'object') {
+ isJson = config == true;
+ config = id;
+ id = null;
+ }
+ if (config && (typeof config === 'undefined' ? 'undefined' : _typeof(config)) == 'object') {
+ if (isJson) {
+ config.header || (config.header = {});
+ config.header['Content-Type'] = 'application/json; charset=UTF-8';
+ config.dataType = 'json';
+ }
+ id ? (ajaxs[id] = $.extend(true, {}, ajax, config), data[id] && (data[id].config.direction = config.direction), config.searchUrl && data[id] && common.triggerSearch($('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT), true)) : $.extend(true, ajax, config);
+ }
+ return this;
+ };
+
+ Select4.prototype.render = function (id) {
+ var _this14 = this;
+
+ var target = {};
+ id ? data[id] && (target[id] = data[id]) : data;
+
+ if (Object.getOwnPropertyNames(target).length) {
+ $.each(target, function (key, val) {
+ //恢复初始值
+ var dl = $('dl[xid="' + key + '"]'),
+ vals = [];
+ val.select.find('option[selected]').each(function (index, item) {
+ vals.push(item.value);
+ });
+ //移除创建元素
+ dl.find('.' + CREATE_LONG).remove();
+ //清空INPUT
+ dl.prev().find('.' + INPUT).val('');
+ //触发search
+ common.triggerSearch(dl.parents('.' + FORM_SELECT), true);
+ //移除hidn
+ dl.find('.layui-hide').removeClass('layui-hide');
+ //重新赋值
+ _this14.value(key, vals);
+ });
+ }
+ ($('select[' + NAME + '="' + id + '"]')[0] ? $('select[' + NAME + '="' + id + '"]') : $('select[' + NAME + ']')).each(function (index, select) {
+ var sid = select.getAttribute(NAME);
+ common.init(select);
+ common.one($('dl[xid="' + sid + '"]').parents('.' + PNAME));
+ common.initVal(sid);
+ });
+ return this;
+ };
+
+ Select4.prototype.disabled = function (id) {
+ var target = {};
+ id ? data[id] && (target[id] = data[id]) : target = data;
+
+ $.each(target, function (key, val) {
+ $('dl[xid="' + key + '"]').prev().addClass(DIS);
+ });
+ return this;
+ };
+
+ Select4.prototype.undisabled = function (id) {
+ var target = {};
+ id ? data[id] && (target[id] = data[id]) : target = data;
+
+ $.each(target, function (key, val) {
+ $('dl[xid="' + key + '"]').prev().removeClass(DIS);
+ });
+ return this;
+ };
+
+ Select4.prototype.data = function (id, type, config) {
+ if (!id || !type || !config) {
+ return this;
+ }
+ //检测该id是否尚未渲染
+ !data[id] && this.render(id).value(id, []);
+ this.config(id, config);
+ if (type == 'local') {
+ common.renderData(id, config.arr, config.linkage == true, config.linkageWidth ? config.linkageWidth : '100');
+ } else if (type == 'server') {
+ common.ajax(id, config.url, config.keyword, config.linkage == true, config.linkageWidth ? config.linkageWidth : '100');
+ }
+ return this;
+ };
+
+ Select4.prototype.btns = function (id, btns, config) {
+ if (!btns || !common.isArray(btns)) {
+ return this;
+ };
+ var target = {};
+ id ? data[id] && (target[id] = data[id]) : target = data;
+
+ btns = btns.map(function (obj) {
+ if (typeof obj == 'string') {
+ if (obj == 'select') {
+ return quickBtns[0];
+ }
+ if (obj == 'remove') {
+ return quickBtns[1];
+ }
+ if (obj == 'reverse') {
+ return quickBtns[2];
+ }
+ if (obj == 'skin') {
+ return quickBtns[3];
+ }
+ }
+ return obj;
+ });
+
+ $.each(target, function (key, val) {
+ val.config.btns = btns;
+ var dd = $('dl[xid="' + key + '"]').find('.' + FORM_SELECT_TIPS + ':first');
+ if (btns.length) {
+ var show = config && config.show && (config.show == 'name' || config.show == 'icon') ? config.show : '';
+ var html = common.renderBtns(key, show, config && config.space ? config.space : '30px');
+ dd.html(html);
+ } else {
+ var pcInput = dd.parents('.' + FORM_SELECT).find('.' + TDIV + ' input');
+ var _html = pcInput.attr('placeholder') || pcInput.attr('back');
+ dd.html(_html);
+ dd.removeAttr('style');
+ }
+ });
+
+ return this;
+ };
+
+ Select4.prototype.search = function (id, val) {
+ if (id && data[id]) {
+ ajaxs[id] = $.extend(true, {}, ajax, {
+ first: true,
+ searchVal: val
+ });
+ common.triggerSearch($('dl[xid="' + id + '"]').parents('.' + FORM_SELECT), true);
+ }
+ return this;
+ };
+
+ return new Select4();
});
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.css b/zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.css
similarity index 99%
rename from zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.css
rename to zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.css
index 5049b634..626a4d59 100644
--- a/zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.css
+++ b/zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.css
@@ -1,156 +1,156 @@
-/* formSelects多选css */
-.xm-select-parent * {margin: 0;padding: 0;font-family: "Helvetica Neue", Helvetica, "PingFang SC", 微软雅黑, Tahoma, Arial, sans-serif;}
-.xm-select-parent {text-align: left;}
-.xm-select-parent select {display: none;}
-.xm-select-parent .xm-select-title {position: relative;min-height: 36px;}
-.xm-select-parent .xm-input {cursor: pointer;border-radius: 2px;border-width: 1px;border-style: solid;border-color: #E6E6E6;display: block;width: 100%;box-sizing: border-box;background-color: #FFF;height: 36px;line-height: 1.3;padding-left: 10px;outline: 0}
-.xm-select-parent .xm-select-sj {display: inline-block;width: 0;height: 0;border-style: dashed;border-color: transparent;overflow: hidden;position: absolute;right: 10px;top: 50%;margin-top: -3px;cursor: pointer;border-width: 6px;border-top-color: #C2C2C2;border-top-style: solid;transition: all .3s;-webkit-transition: all .3s}
-.xm-select-parent .xm-form-selected .xm-select-sj {margin-top: -9px;transform: rotate(180deg)}
-.xm-select-parent .xm-form-select dl {display: none;position: absolute;left: 0;top: 42px;padding: 5px 0;z-index: 999;min-width: 100%;border: 1px solid #d2d2d2;max-height: 300px;overflow-y: auto;background-color: #fff;border-radius: 2px;box-shadow: 0 2px 4px rgba(0, 0, 0, .12);box-sizing: border-box;animation-fill-mode: both;-webkit-animation-name: layui-upbit;animation-name: layui-upbit;-webkit-animation-duration: .3s;animation-duration: .3s;-webkit-animation-fill-mode: both;animation-fill-mode: both}
-@-webkit-keyframes layui-upbit {
- from {-webkit-transform: translate3d(0, 30px, 0);opacity: .3}
- to {-webkit-transform: translate3d(0, 0, 0);opacity: 1}
-}
-@keyframes layui-upbit {
- from {transform: translate3d(0, 30px, 0);opacity: .3}
- to {transform: translate3d(0, 0, 0);opacity: 1}
-}
-.xm-select-parent .xm-form-selected dl {display: block}
-.xm-select-parent .xm-form-select dl dd,.xm-select-parent .xm-form-select dl dt {padding: 0 10px;line-height: 36px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis}
-.xm-select-parent .xm-form-select dl dd {cursor: pointer;height: 36px;}
-.xm-select-parent .xm-form-select dl dd:hover {background-color: #f2f2f2}
-.xm-select-parent .xm-form-select dl dt {font-size: 12px;color: #999}
-.layui-select-disabled .xm-dis-disabled {border-color: #eee!important}
-.xm-select-parent .xm-form-select dl .xm-select-tips {padding-left: 10px!important;color: #999;font-size: 14px}
-.xm-unselect {-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none}
-.xm-form-checkbox {position: relative;display: inline-block;vertical-align: middle;height: 30px;line-height: 30px;margin-right: 10px;padding-right: 30px;background-color: #fff;cursor: pointer;font-size: 0;-webkit-transition: .1s linear;transition: .1s linear;box-sizing: border-box}
-.xm-form-checkbox * {display: inline-block;vertical-align: middle}
-.xm-form-checkbox span {padding: 0 10px;height: 100%;font-size: 14px;border-radius: 2px 0 0 2px;background-color: #d2d2d2;color: #fff;overflow: hidden;white-space: nowrap;text-overflow: ellipsis}
-.xm-form-checkbox:hover span {background-color: #c2c2c2}
-.xm-form-checkbox i {position: absolute;right: 0;top: 0;width: 30px;height: 28px;border: 1px solid #d2d2d2;border-left: none;border-radius: 0 2px 2px 0;color: #fff;font-size: 20px;text-align: center}
-.xm-form-checkbox:hover i {border-color: #c2c2c2;color: #c2c2c2}
-.xm-form-checkbox[lay-skin=primary] {height: auto!important;line-height: normal!important;border: none!important;margin-right: 0;padding-right: 0;background: 0 0}
-.xm-form-checkbox[lay-skin=primary] span {float: right;padding-right: 15px;line-height: 18px;background: 0 0;color: #666}
-.xm-form-checkbox[lay-skin=primary] i {position: relative;top: 0;width: 16px;height: 16px;line-height: 16px;border: 1px solid #d2d2d2;font-size: 12px;border-radius: 2px;background-color: #fff;-webkit-transition: .1s linear;transition: .1s linear}
-.xm-form-checkbox[lay-skin=primary]:hover i {border-color: #5FB878;color: #fff}
-.xm-icon-yes {width: 30px;height: 30px;border-radius: 4px;background-color: #009688;position: relative}
-.xm-icon-yes:after {content: '';display: inline-block;border: 2px solid #fff;border-top-width: 0;border-right-width: 0;width: 9px;height: 5px;-webkit-transform: rotate(-50deg);transform: rotate(-50deg);position: absolute;top: 2px;left: 3px}
-.xm-dis-disabled,.xm-dis-disabled:hover {color: #d2d2d2!important;cursor: not-allowed!important}
-.xm-form-select dl dd.xm-dis-disabled {background-color: #fff!important}
-.xm-form-select dl dd.xm-dis-disabled span {color: #C2C2C2}
-.xm-form-select dl dd.xm-dis-disabled .xm-icon-yes {border-color: #C2C2C2}
-.xm-select-parent {position: relative;-moz-user-select: none;-ms-user-select: none;-webkit-user-select: none}
-.xm-select-parent .xm-select {line-height: normal;height: auto;padding: 4px 10px 1px 10px;overflow: hidden;min-height: 36px;left: 0;z-index: 99;position: absolute;background: 0 0;padding-right: 20px}
-.xm-select-parent .xm-select:hover {border-color: #C0C4CC}
-.xm-select-parent .xm-select .xm-select-label {display: inline-block;margin: 0;vertical-align: middle}
-.xm-select-parent .xm-select-title div.xm-select-label>span {position: relative;padding: 2px 5px;background-color: #009688;border-radius: 2px;color: #FFF;display: inline-block;line-height: 18px;height: 18px;margin: 2px 5px 2px 0;cursor: initial;user-select: none;font-size: 14px;padding-right: 25px;}
-.xm-select-parent .xm-select-title div.xm-select-label>span i {position: absolute;right: 5px;top: 2px;margin-left: 8px;border-radius: 20px;font-size: 18px;cursor: pointer;display: inline-block;height: 14px;line-height: 15px;width: 12px;vertical-align: top;margin-top: 2px;}
-.xm-select-parent .xm-select .xm-select-input {border: none;height: 28px;background-color: transparent;padding: 0;vertical-align: middle;display: inline-block;width: 50px}
-.xm-select-parent .xm-select--suffix input {border: none}
-.xm-select-parent dl dd.xm-dis-disabled.xm-select-this i {border-color: #C2C2C2;background-color: #C2C2C2;color: #FFF}
-.xm-select-parent dl dd.xm-select-this i {background-color: #009688;border-color: #009688}
-.xm-form-selected .xm-select,.xm-form-selected .xm-select:hover {border-color: #009688!important}
-.xm-select--suffix+div {position: absolute;top: 0;left: 0;bottom: 0;right: 0}
-.xm-select-dis .xm-select--suffix+div {z-index: 100;cursor: no-drop!important;opacity: .2;background-color: #FFF;}
-.xm-select-disabled,.xm-select-disabled:hover {color: #d2d2d2!important;cursor: not-allowed!important;background-color: #fff}
-.xm-select-none {display: none;margin: 5px 0;text-align: center;}
-.xm-select-none:hover {background-color: #FFF!important}
-.xm-select-empty {display: block}
-.xm-span-hide {display: none!important;}
-.xm-select-radio .xm-icon-yes {border-radius: 20px!important;}
-.xm-select-radio .xm-icon-yes:after {border-radius: 20px;background-color: #fff;width: 6px;height: 6px;border: none;top: 5px;left: 5px;}
-.layui-form-pane .xm-select,.layui-form-pane .xm-select:hover {border: none!important;top: 0px}
-.layui-form-pane .xm-select-title {border: 1px solid #e6e6e6!important}
-
-
-/* 颜色相关 */
-div[xm-select-skin] .xm-select-title div.xm-select-label>span {border: 1px solid #009688}
-div[xm-select-skin] .xm-select-title div.xm-select-label>span i:hover {opacity: .8;filter: alpha(opacity=80);cursor: pointer}
-div[xm-select-skin=default] .xm-select-title div.xm-select-label>span {background-color: #F0F2F5;color: #909399;border: 1px solid #F0F2F5}
-div[xm-select-skin=default] .xm-select-title div.xm-select-label>span i {background-color: #C0C4CC;color: #FFF}
-div[xm-select-skin=default] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #5FB878;border-color: #5FB878;color: #FFF}
-div[xm-select-skin=default].xm-form-selected .xm-select,div[xm-select-skin=default].xm-form-selected .xm-select:hover {border-color: #C0C4CC!important}
-div[xm-select-skin=primary] .xm-select-title div.xm-select-label>span {background-color: #009688;color: #FFF;border: 1px solid #009688}
-div[xm-select-skin=primary] .xm-select-title div.xm-select-label>span i {background-color: #009688;color: #FFF}
-div[xm-select-skin=primary] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #009688;border-color: #009688;color: #FFF}
-div[xm-select-skin=primary].xm-form-selected .xm-select,div[xm-select-skin=primary].xm-form-selected .xm-select:hover {border-color: #009688!important}
-div[xm-select-skin=normal] .xm-select-title div.xm-select-label>span {background-color: #1E9FFF;color: #FFF;border: 1px solid #1E9FFF}
-div[xm-select-skin=normal] .xm-select-title div.xm-select-label>span i {background-color: #1E9FFF;color: #FFF}
-div[xm-select-skin=normal] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #1E9FFF;border-color: #1E9FFF;color: #FFF}
-div[xm-select-skin=normal].xm-form-selected .xm-select,div[xm-select-skin=normal].xm-form-selected .xm-select:hover {border-color: #1E9FFF!important}
-div[xm-select-skin=warm] .xm-select-title div.xm-select-label>span {background-color: #FFB800;color: #FFF;border: 1px solid #FFB800}
-div[xm-select-skin=warm] .xm-select-title div.xm-select-label>span i {background-color: #FFB800;color: #FFF}
-div[xm-select-skin=warm] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #FFB800;border-color: #FFB800;color: #FFF}
-div[xm-select-skin=warm].xm-form-selected .xm-select,div[xm-select-skin=warm].xm-form-selected .xm-select:hover {border-color: #FFB800!important}
-div[xm-select-skin=danger] .xm-select-title div.xm-select-label>span {background-color: #FF5722;color: #FFF;border: 1px solid #FF5722}
-div[xm-select-skin=danger] .xm-select-title div.xm-select-label>span i {background-color: #FF5722;color: #FFF}
-div[xm-select-skin=danger] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #FF5722;border-color: #FF5722;color: #FFF}
-div[xm-select-skin=danger].xm-form-selected .xm-select,div[xm-select-skin=danger].xm-form-selected .xm-select:hover {border-color: #FF5722!important}
-
-
-/* 多选联动 */
-.xm-select-parent .layui-form-danger+.xm-select-title .xm-select {border-color: #FF5722 !important;}
-.xm-select-linkage li {padding: 10px 0px;cursor: pointer;}
-.xm-select-linkage li span {padding-left: 20px;padding-right: 30px;display: inline-block;height: 20px;overflow: hidden;text-overflow: ellipsis;}
-.xm-select-linkage li.xm-select-this span {border-left: 5px solid #009688;color: #009688;padding-left: 15px;}
-.xm-select-linkage-group {position: absolute;left: 0;top: 0;right: 0;bottom: 0;overflow-x: hidden;overflow-y: auto;}
-.xm-select-linkage-group li:hover {border-left: 1px solid #009688;}
-.xm-select-linkage-group li:hover span {padding-left: 19px;}
-.xm-select-linkage-group li.xm-select-this:hover span {padding-left: 15px;border-left-width: 4px;}
-.xm-select-linkage-group:nth-child(4n+1){background-color: #EFEFEF; left: 0;}
-.xm-select-linkage-group:nth-child(4n+1) li.xm-select-active{background-color: #F5F5F5;}
-.xm-select-linkage-group:nth-child(4n+2){background-color: #F5F5F5; left: 100px;}
-.xm-select-linkage-group:nth-child(4n+3) li.xm-select-active{background-color: #FAFAFA;}
-.xm-select-linkage-group:nth-child(4n+3){background-color: #FAFAFA; left: 200px;}
-.xm-select-linkage-group:nth-child(4n+3) li.xm-select-active{background-color: #FFFFFF;}
-.xm-select-linkage-group:nth-child(4n+4){background-color: #FFFFFF; left: 300px;}
-.xm-select-linkage-group:nth-child(4n+4) li.xm-select-active{background-color: #EFEFEF;}
-.xm-select-linkage li{list-style: none;}
-.xm-select-linkage-hide {display: none;}
-.xm-select-linkage-show {display: block;}
-
-div[xm-select-skin='default'] .xm-select-linkage li.xm-select-this span {border-left-color: #5FB878;color: #5FB878;}
-div[xm-select-skin='default'] .xm-select-linkage-group li:hover {border-left-color: #5FB878;}
-div[xm-select-skin='primary'] .xm-select-linkage li.xm-select-this span {border-left-color: #1E9FFF;color: #1E9FFF;}
-div[xm-select-skin='primary'] .xm-select-linkage-group li:hover {border-left-color: #1E9FFF;}
-div[xm-select-skin='normal'] .xm-select-linkage li.xm-select-this span {border-left-color: #1E9FFF;color: #1E9FFF;}
-div[xm-select-skin='normal'] .xm-select-linkage-group li:hover {border-left-color: #1E9FFF;}
-div[xm-select-skin='warm'] .xm-select-linkage li.xm-select-this span {border-left-color: #FFB800;color: #FFB800;}
-div[xm-select-skin='warm'] .xm-select-linkage-group li:hover {border-left-color: #FFB800;}
-div[xm-select-skin='danger'] .xm-select-linkage li.xm-select-this span {border-left-color: #FF5722;color: #FF5722;}
-div[xm-select-skin='danger'] .xm-select-linkage-group li:hover {border-left-color: #FF5722;}
-.xm-form-checkbox[lay-skin=primary] i {top: 9px}
-.xm-form-checkbox[lay-skin=primary] span {line-height: 36px;}
-
-
-/* 快捷操作 */
-.xm-select-tips[style]:hover{background-color: #FFF!important;}
-.xm-select-parent dd > .xm-cz{position: absolute; top: 5px; right: 10px;}
-.xm-select-parent dd > .xm-cz-group{margin-right: 30px; border-right: 2px solid #ddd; height: 16px; margin-top: 10px; line-height: 16px; overflow: hidden;}
-.xm-select-parent dd > .xm-cz-group .xm-cz{display: inline-block; margin-right: 30px;}
-.xm-select-parent dd > .xm-cz-group .xm-cz i{margin-right: 10px;}
-.xm-select-parent dd > .xm-cz-group[show='name'] .xm-cz i{display: none;}
-.xm-select-parent dd > .xm-cz-group[show='icon'] .xm-cz span{display: none;}
-.xm-select-parent dd .xm-cz:hover{color: #009688;}
-div[xm-select-skin='default'] dd .xm-cz:hover{color: #C0C4CC;}
-div[xm-select-skin='primary'] dd .xm-cz:hover{color: #009688;}
-div[xm-select-skin='normal'] dd .xm-cz:hover{color: #1E9FFF;}
-div[xm-select-skin='warm'] dd .xm-cz:hover{color: #FFB800;}
-div[xm-select-skin='danger'] dd .xm-cz:hover{color: #FF5722;}
-
-
-
-/* 阿里巴巴矢量图标库 */
-@font-face {
- font-family: "iconfont";
- src: url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAkUAAsAAAAADXQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZXMkouY21hcAAAAYAAAACEAAAB3mzwoL5nbHlmAAACBAAABNwAAAbEQLmyxWhlYWQAAAbgAAAAMQAAADYR3AzwaGhlYQAABxQAAAAgAAAAJAgBA6pobXR4AAAHNAAAABsAAAAcHA3//mxvY2EAAAdQAAAAEAAAABAFDAZgbWF4cAAAB2AAAAAfAAAAIAEXAM9uYW1lAAAHgAAAAUUAAAJtPlT+fXBvc3QAAAjIAAAASwAAAF/pDVOXeJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWKcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGBwYKl6YMzf8b2CIYW5mOAIUZgTJAQDaoQv3eJzFkcsJwzAQRN9GsgkhBBeiu2+uIoeU4BJ8zCmlLu7C2Y/BJA14xBPMIGnFLtABxWhGBfkguN6WSuSFW+SVp/kHVy70LDpo00nnddw2y//9IbE7x3Jf4oUu6vWcJjmv9K/usb925x1ZduyLOiQ+JW2J9Q+dEj+vc+LTXMeE+gUlrx+seJyNVE2IHEUUrlfVVdV/0z3939u70zs9vTudsMmumdndcaNu1h/wBw+RRJNcAlGDEdSDBwMacUGUCB4EDzEoKKIYUfDgwUuEmN1IvAgevIiEFQVzUC/iQXB7fdW7Sm461Lx6/V71V/V9/eoRTsjWD+wiS0lAdpF95C5ykBAQM9BzaAeKan6WzkBU8CgJHVaVVSHL3iy7DZKeCOPB4nw/EVK44EAOw2KwWM3SChbml+ktMIg7AGPj2SF/esJnr4GZVvlL9X30XYgmywl3eW99754D4aAb6Kdt3x/z/Vd1wblOqeY68GQSG9wwRf0ed7Po4uRuOgn2WJXdf6zVHfdPnJ1/qjOdGACrqxCMd50PDniZh+NMFgf+mGy39DRrlVMhnP7JSgO70/+R4E8g11s1wiaIRRJSkgVyNzmGbAvFoywUIygcCOOkWIb5Pmv8YZMFWfUxPwnxKD4AGOix/xGB7+FPP039WvpJQq1m8m8Ibfubt587amSBecput+0LRjBm/sczPZ5OpTjq7yAtU1CmfhkSFUvYQ+eOmPjKKZsx+wNzLKiff+OowjhlUWpdQJz6zLkjGDAet3ZWEFUDL2jAXiRtEpJpsoi6EEAyLjR0BopNJatRMo0iRd62QCNvFioPNYq8HBJUSQXK6dIB6W0XQ7OC/XolGsWXw3AtHkXrQfDH+vra5vv1RqcsO9DtlABlRz1BP4cw3w2wO4frG3kPYDaHqFMA9HL64ZUwVDBrYbgej8Lf19bWrnY79TW1rJcjTAGbG/hm/Uvehwa3R3dwd3ZR319Dnp+zNXYHibHS7ySHkKUi+S/THEaLDddRWeHRi20qyTBSBHcYc6+chQVvfnFU5DCp6gWLXxZKi2XFOk5YJFP9y2NoWrr+jPR1S2xIuXQQYP/M5tbMfjU/gH8K2/7m+YWsLDP4KkMx6tdn9tNXoJvWM2kXcIZv1fyJrl85qiNggohUo/KansqfD+9ZAljaU8PMEuz4sIX+yfo89DK4mil5siVY2vxtB+zrtChSpQXbqrc+0qbYIfIo+YJcJoTjBegr1v2Rh1e6X/XnaH8OMDALo+VGmGU4QBcT1CJWUik7aDKYw/hwoCLxdnISorhpCwrJkzg7MM2xJBZHC94IMRqsaqHZYQ76FV5Al+K+aqlQgSY8B6XsIc5OQuGrQXOqzpN4oTpGMqTfdOvzbt7SfS5AiHbVNuUgMg1bOpwJymNb558Jzx7r9yLhc8cAzdX9LBRGOuFQTdhB28h6U25gv2OYlsmly4E64jGzE3njJlDXdKv6OXjayHTOinHTDVydPWJQzZBmaL6NG7Vv1i2qcSvYNRE6wWRqZwaVwl5xpal/LLiUlk0BqGY6up4MueHwlh1NMcGEOXVY03nQimJ4gjEhLF3eFOuGLdqWiO1kwpT8U+FyQYFRQ7Ntyk1NapRyy2LYIW0OoNutt0zdMoX0HCHjXJy0U+Qt6md5K8HqGwLlmnEcHo4z09Acg52wUE88u2+9aQrAgwmE0tttrlHgJvdsaggNpH5BndxwDcq4bmAxJ/uE0Khw4qi+R0pJGTS9YxV76gp6FvGavkqC0iuiAoaNRX+h8dEmMpGqkWArWV2BlS18b6W+BOSvSzc+1df3nj37z6AEVjCFZvNSjcsIGvrgDQvI3936DLp4nGNgZGBgAGLtNU3b4/ltvjJwszCAwHXflFkw+v+//zYsKszNQC4HAxNIFABGAgv1AAAAeJxjYGRgYG7438AQw6L8/9///ywqDEARFMAOAKazBrJ4nGNhYGBgfsnAwAKkWRihtPL/fyAaACKnAyYAAAAAAAB2AQIBdgH8AyADYnicY2BkYGBgZzjMwMYAAkxAzAWEDAz/wXwGABycAecAeJxlj01OwzAQhV/6B6QSqqhgh+QFYgEo/RGrblhUavdddN+mTpsqiSPHrdQDcB6OwAk4AtyAO/BIJ5s2lsffvHljTwDc4Acejt8t95E9XDI7cg0XuBeuU38QbpBfhJto41W4Rf1N2MczpsJtdGF5g9e4YvaEd2EPHXwI13CNT+E69S/hBvlbuIk7/Aq30PHqwj7mXle4jUcv9sdWL5xeqeVBxaHJIpM5v4KZXu+Sha3S6pxrW8QmU4OgX0lTnWlb3VPs10PnIhVZk6oJqzpJjMqt2erQBRvn8lGvF4kehCblWGP+tsYCjnEFhSUOjDFCGGSIyujoO1Vm9K+xQ8Jee1Y9zed0WxTU/3OFAQL0z1xTurLSeTpPgT1fG1J1dCtuy56UNJFezUkSskJe1rZUQuoBNmVXjhF6XNGJPyhnSP8ACVpuyAAAAHicbcNRCoAgEAXAfWYqdRYPtWXJEqwJSR6/oN8Ghgx9JvrnYTDAYoSDRyD0UBtrf7uVJbHO9yaLcLkkRnvK3kIVzUfRTPQAg/cP1gA=') format('woff');
-}
-.iconfont {font-family:"iconfont" !important; font-size:16px; font-style:normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}
-.icon-quanxuan:before { content: "\e62c"; }
-.icon-caidan:before { content: "\e610"; }
-.icon-fanxuan:before { content: "\e837"; }
-.icon-pifu:before { content: "\e668"; }
-.icon-qingkong:before { content: "\e63e"; }
-
-
-
+/* formSelects多选css */
+.xm-select-parent * {margin: 0;padding: 0;font-family: "Helvetica Neue", Helvetica, "PingFang SC", 微软雅黑, Tahoma, Arial, sans-serif;}
+.xm-select-parent {text-align: left;}
+.xm-select-parent select {display: none;}
+.xm-select-parent .xm-select-title {position: relative;min-height: 36px;}
+.xm-select-parent .xm-input {cursor: pointer;border-radius: 2px;border-width: 1px;border-style: solid;border-color: #E6E6E6;display: block;width: 100%;box-sizing: border-box;background-color: #FFF;height: 36px;line-height: 1.3;padding-left: 10px;outline: 0}
+.xm-select-parent .xm-select-sj {display: inline-block;width: 0;height: 0;border-style: dashed;border-color: transparent;overflow: hidden;position: absolute;right: 10px;top: 50%;margin-top: -3px;cursor: pointer;border-width: 6px;border-top-color: #C2C2C2;border-top-style: solid;transition: all .3s;-webkit-transition: all .3s}
+.xm-select-parent .xm-form-selected .xm-select-sj {margin-top: -9px;transform: rotate(180deg)}
+.xm-select-parent .xm-form-select dl {display: none;position: absolute;left: 0;top: 42px;padding: 5px 0;z-index: 999;min-width: 100%;border: 1px solid #d2d2d2;max-height: 300px;overflow-y: auto;background-color: #fff;border-radius: 2px;box-shadow: 0 2px 4px rgba(0, 0, 0, .12);box-sizing: border-box;animation-fill-mode: both;-webkit-animation-name: layui-upbit;animation-name: layui-upbit;-webkit-animation-duration: .3s;animation-duration: .3s;-webkit-animation-fill-mode: both;animation-fill-mode: both}
+@-webkit-keyframes layui-upbit {
+ from {-webkit-transform: translate3d(0, 30px, 0);opacity: .3}
+ to {-webkit-transform: translate3d(0, 0, 0);opacity: 1}
+}
+@keyframes layui-upbit {
+ from {transform: translate3d(0, 30px, 0);opacity: .3}
+ to {transform: translate3d(0, 0, 0);opacity: 1}
+}
+.xm-select-parent .xm-form-selected dl {display: block}
+.xm-select-parent .xm-form-select dl dd,.xm-select-parent .xm-form-select dl dt {padding: 0 10px;line-height: 36px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis}
+.xm-select-parent .xm-form-select dl dd {cursor: pointer;height: 36px;}
+.xm-select-parent .xm-form-select dl dd:hover {background-color: #f2f2f2}
+.xm-select-parent .xm-form-select dl dt {font-size: 12px;color: #999}
+.layui-select-disabled .xm-dis-disabled {border-color: #eee!important}
+.xm-select-parent .xm-form-select dl .xm-select-tips {padding-left: 10px!important;color: #999;font-size: 14px}
+.xm-unselect {-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none}
+.xm-form-checkbox {position: relative;display: inline-block;vertical-align: middle;height: 30px;line-height: 30px;margin-right: 10px;padding-right: 30px;background-color: #fff;cursor: pointer;font-size: 0;-webkit-transition: .1s linear;transition: .1s linear;box-sizing: border-box}
+.xm-form-checkbox * {display: inline-block;vertical-align: middle}
+.xm-form-checkbox span {padding: 0 10px;height: 100%;font-size: 14px;border-radius: 2px 0 0 2px;background-color: #d2d2d2;color: #fff;overflow: hidden;white-space: nowrap;text-overflow: ellipsis}
+.xm-form-checkbox:hover span {background-color: #c2c2c2}
+.xm-form-checkbox i {position: absolute;right: 0;top: 0;width: 30px;height: 28px;border: 1px solid #d2d2d2;border-left: none;border-radius: 0 2px 2px 0;color: #fff;font-size: 20px;text-align: center}
+.xm-form-checkbox:hover i {border-color: #c2c2c2;color: #c2c2c2}
+.xm-form-checkbox[lay-skin=primary] {height: auto!important;line-height: normal!important;border: none!important;margin-right: 0;padding-right: 0;background: 0 0}
+.xm-form-checkbox[lay-skin=primary] span {float: right;padding-right: 15px;line-height: 18px;background: 0 0;color: #666}
+.xm-form-checkbox[lay-skin=primary] i {position: relative;top: 0;width: 16px;height: 16px;line-height: 16px;border: 1px solid #d2d2d2;font-size: 12px;border-radius: 2px;background-color: #fff;-webkit-transition: .1s linear;transition: .1s linear}
+.xm-form-checkbox[lay-skin=primary]:hover i {border-color: #5FB878;color: #fff}
+.xm-icon-yes {width: 30px;height: 30px;border-radius: 4px;background-color: #009688;position: relative}
+.xm-icon-yes:after {content: '';display: inline-block;border: 2px solid #fff;border-top-width: 0;border-right-width: 0;width: 9px;height: 5px;-webkit-transform: rotate(-50deg);transform: rotate(-50deg);position: absolute;top: 2px;left: 3px}
+.xm-dis-disabled,.xm-dis-disabled:hover {color: #d2d2d2!important;cursor: not-allowed!important}
+.xm-form-select dl dd.xm-dis-disabled {background-color: #fff!important}
+.xm-form-select dl dd.xm-dis-disabled span {color: #C2C2C2}
+.xm-form-select dl dd.xm-dis-disabled .xm-icon-yes {border-color: #C2C2C2}
+.xm-select-parent {position: relative;-moz-user-select: none;-ms-user-select: none;-webkit-user-select: none}
+.xm-select-parent .xm-select {line-height: normal;height: auto;padding: 4px 10px 1px 10px;overflow: hidden;min-height: 36px;left: 0;z-index: 99;position: absolute;background: 0 0;padding-right: 20px}
+.xm-select-parent .xm-select:hover {border-color: #C0C4CC}
+.xm-select-parent .xm-select .xm-select-label {display: inline-block;margin: 0;vertical-align: middle}
+.xm-select-parent .xm-select-title div.xm-select-label>span {position: relative;padding: 2px 5px;background-color: #009688;border-radius: 2px;color: #FFF;display: inline-block;line-height: 18px;height: 18px;margin: 2px 5px 2px 0;cursor: initial;user-select: none;font-size: 14px;padding-right: 25px;}
+.xm-select-parent .xm-select-title div.xm-select-label>span i {position: absolute;right: 5px;top: 2px;margin-left: 8px;border-radius: 20px;font-size: 18px;cursor: pointer;display: inline-block;height: 14px;line-height: 15px;width: 12px;vertical-align: top;margin-top: 2px;}
+.xm-select-parent .xm-select .xm-select-input {border: none;height: 28px;background-color: transparent;padding: 0;vertical-align: middle;display: inline-block;width: 50px}
+.xm-select-parent .xm-select--suffix input {border: none}
+.xm-select-parent dl dd.xm-dis-disabled.xm-select-this i {border-color: #C2C2C2;background-color: #C2C2C2;color: #FFF}
+.xm-select-parent dl dd.xm-select-this i {background-color: #009688;border-color: #009688}
+.xm-form-selected .xm-select,.xm-form-selected .xm-select:hover {border-color: #009688!important}
+.xm-select--suffix+div {position: absolute;top: 0;left: 0;bottom: 0;right: 0}
+.xm-select-dis .xm-select--suffix+div {z-index: 100;cursor: no-drop!important;opacity: .2;background-color: #FFF;}
+.xm-select-disabled,.xm-select-disabled:hover {color: #d2d2d2!important;cursor: not-allowed!important;background-color: #fff}
+.xm-select-none {display: none;margin: 5px 0;text-align: center;}
+.xm-select-none:hover {background-color: #FFF!important}
+.xm-select-empty {display: block}
+.xm-span-hide {display: none!important;}
+.xm-select-radio .xm-icon-yes {border-radius: 20px!important;}
+.xm-select-radio .xm-icon-yes:after {border-radius: 20px;background-color: #fff;width: 6px;height: 6px;border: none;top: 5px;left: 5px;}
+.layui-form-pane .xm-select,.layui-form-pane .xm-select:hover {border: none!important;top: 0px}
+.layui-form-pane .xm-select-title {border: 1px solid #e6e6e6!important}
+
+
+/* 颜色相关 */
+div[xm-select-skin] .xm-select-title div.xm-select-label>span {border: 1px solid #009688}
+div[xm-select-skin] .xm-select-title div.xm-select-label>span i:hover {opacity: .8;filter: alpha(opacity=80);cursor: pointer}
+div[xm-select-skin=default] .xm-select-title div.xm-select-label>span {background-color: #F0F2F5;color: #909399;border: 1px solid #F0F2F5}
+div[xm-select-skin=default] .xm-select-title div.xm-select-label>span i {background-color: #C0C4CC;color: #FFF}
+div[xm-select-skin=default] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #5FB878;border-color: #5FB878;color: #FFF}
+div[xm-select-skin=default].xm-form-selected .xm-select,div[xm-select-skin=default].xm-form-selected .xm-select:hover {border-color: #C0C4CC!important}
+div[xm-select-skin=primary] .xm-select-title div.xm-select-label>span {background-color: #009688;color: #FFF;border: 1px solid #009688}
+div[xm-select-skin=primary] .xm-select-title div.xm-select-label>span i {background-color: #009688;color: #FFF}
+div[xm-select-skin=primary] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #009688;border-color: #009688;color: #FFF}
+div[xm-select-skin=primary].xm-form-selected .xm-select,div[xm-select-skin=primary].xm-form-selected .xm-select:hover {border-color: #009688!important}
+div[xm-select-skin=normal] .xm-select-title div.xm-select-label>span {background-color: #1E9FFF;color: #FFF;border: 1px solid #1E9FFF}
+div[xm-select-skin=normal] .xm-select-title div.xm-select-label>span i {background-color: #1E9FFF;color: #FFF}
+div[xm-select-skin=normal] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #1E9FFF;border-color: #1E9FFF;color: #FFF}
+div[xm-select-skin=normal].xm-form-selected .xm-select,div[xm-select-skin=normal].xm-form-selected .xm-select:hover {border-color: #1E9FFF!important}
+div[xm-select-skin=warm] .xm-select-title div.xm-select-label>span {background-color: #FFB800;color: #FFF;border: 1px solid #FFB800}
+div[xm-select-skin=warm] .xm-select-title div.xm-select-label>span i {background-color: #FFB800;color: #FFF}
+div[xm-select-skin=warm] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #FFB800;border-color: #FFB800;color: #FFF}
+div[xm-select-skin=warm].xm-form-selected .xm-select,div[xm-select-skin=warm].xm-form-selected .xm-select:hover {border-color: #FFB800!important}
+div[xm-select-skin=danger] .xm-select-title div.xm-select-label>span {background-color: #FF5722;color: #FFF;border: 1px solid #FF5722}
+div[xm-select-skin=danger] .xm-select-title div.xm-select-label>span i {background-color: #FF5722;color: #FFF}
+div[xm-select-skin=danger] dl dd.xm-select-this:not(.xm-dis-disabled) i {background-color: #FF5722;border-color: #FF5722;color: #FFF}
+div[xm-select-skin=danger].xm-form-selected .xm-select,div[xm-select-skin=danger].xm-form-selected .xm-select:hover {border-color: #FF5722!important}
+
+
+/* 多选联动 */
+.xm-select-parent .layui-form-danger+.xm-select-title .xm-select {border-color: #FF5722 !important;}
+.xm-select-linkage li {padding: 10px 0px;cursor: pointer;}
+.xm-select-linkage li span {padding-left: 20px;padding-right: 30px;display: inline-block;height: 20px;overflow: hidden;text-overflow: ellipsis;}
+.xm-select-linkage li.xm-select-this span {border-left: 5px solid #009688;color: #009688;padding-left: 15px;}
+.xm-select-linkage-group {position: absolute;left: 0;top: 0;right: 0;bottom: 0;overflow-x: hidden;overflow-y: auto;}
+.xm-select-linkage-group li:hover {border-left: 1px solid #009688;}
+.xm-select-linkage-group li:hover span {padding-left: 19px;}
+.xm-select-linkage-group li.xm-select-this:hover span {padding-left: 15px;border-left-width: 4px;}
+.xm-select-linkage-group:nth-child(4n+1){background-color: #EFEFEF; left: 0;}
+.xm-select-linkage-group:nth-child(4n+1) li.xm-select-active{background-color: #F5F5F5;}
+.xm-select-linkage-group:nth-child(4n+2){background-color: #F5F5F5; left: 100px;}
+.xm-select-linkage-group:nth-child(4n+3) li.xm-select-active{background-color: #FAFAFA;}
+.xm-select-linkage-group:nth-child(4n+3){background-color: #FAFAFA; left: 200px;}
+.xm-select-linkage-group:nth-child(4n+3) li.xm-select-active{background-color: #FFFFFF;}
+.xm-select-linkage-group:nth-child(4n+4){background-color: #FFFFFF; left: 300px;}
+.xm-select-linkage-group:nth-child(4n+4) li.xm-select-active{background-color: #EFEFEF;}
+.xm-select-linkage li{list-style: none;}
+.xm-select-linkage-hide {display: none;}
+.xm-select-linkage-show {display: block;}
+
+div[xm-select-skin='default'] .xm-select-linkage li.xm-select-this span {border-left-color: #5FB878;color: #5FB878;}
+div[xm-select-skin='default'] .xm-select-linkage-group li:hover {border-left-color: #5FB878;}
+div[xm-select-skin='primary'] .xm-select-linkage li.xm-select-this span {border-left-color: #1E9FFF;color: #1E9FFF;}
+div[xm-select-skin='primary'] .xm-select-linkage-group li:hover {border-left-color: #1E9FFF;}
+div[xm-select-skin='normal'] .xm-select-linkage li.xm-select-this span {border-left-color: #1E9FFF;color: #1E9FFF;}
+div[xm-select-skin='normal'] .xm-select-linkage-group li:hover {border-left-color: #1E9FFF;}
+div[xm-select-skin='warm'] .xm-select-linkage li.xm-select-this span {border-left-color: #FFB800;color: #FFB800;}
+div[xm-select-skin='warm'] .xm-select-linkage-group li:hover {border-left-color: #FFB800;}
+div[xm-select-skin='danger'] .xm-select-linkage li.xm-select-this span {border-left-color: #FF5722;color: #FF5722;}
+div[xm-select-skin='danger'] .xm-select-linkage-group li:hover {border-left-color: #FF5722;}
+.xm-form-checkbox[lay-skin=primary] i {top: 9px}
+.xm-form-checkbox[lay-skin=primary] span {line-height: 36px;}
+
+
+/* 快捷操作 */
+.xm-select-tips[style]:hover{background-color: #FFF!important;}
+.xm-select-parent dd > .xm-cz{position: absolute; top: 5px; right: 10px;}
+.xm-select-parent dd > .xm-cz-group{margin-right: 30px; border-right: 2px solid #ddd; height: 16px; margin-top: 10px; line-height: 16px; overflow: hidden;}
+.xm-select-parent dd > .xm-cz-group .xm-cz{display: inline-block; margin-right: 30px;}
+.xm-select-parent dd > .xm-cz-group .xm-cz i{margin-right: 10px;}
+.xm-select-parent dd > .xm-cz-group[show='name'] .xm-cz i{display: none;}
+.xm-select-parent dd > .xm-cz-group[show='icon'] .xm-cz span{display: none;}
+.xm-select-parent dd .xm-cz:hover{color: #009688;}
+div[xm-select-skin='default'] dd .xm-cz:hover{color: #C0C4CC;}
+div[xm-select-skin='primary'] dd .xm-cz:hover{color: #009688;}
+div[xm-select-skin='normal'] dd .xm-cz:hover{color: #1E9FFF;}
+div[xm-select-skin='warm'] dd .xm-cz:hover{color: #FFB800;}
+div[xm-select-skin='danger'] dd .xm-cz:hover{color: #FF5722;}
+
+
+
+/* 阿里巴巴矢量图标库 */
+@font-face {
+ font-family: "iconfont";
+ src: url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAkUAAsAAAAADXQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZXMkouY21hcAAAAYAAAACEAAAB3mzwoL5nbHlmAAACBAAABNwAAAbEQLmyxWhlYWQAAAbgAAAAMQAAADYR3AzwaGhlYQAABxQAAAAgAAAAJAgBA6pobXR4AAAHNAAAABsAAAAcHA3//mxvY2EAAAdQAAAAEAAAABAFDAZgbWF4cAAAB2AAAAAfAAAAIAEXAM9uYW1lAAAHgAAAAUUAAAJtPlT+fXBvc3QAAAjIAAAASwAAAF/pDVOXeJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWKcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGBwYKl6YMzf8b2CIYW5mOAIUZgTJAQDaoQv3eJzFkcsJwzAQRN9GsgkhBBeiu2+uIoeU4BJ8zCmlLu7C2Y/BJA14xBPMIGnFLtABxWhGBfkguN6WSuSFW+SVp/kHVy70LDpo00nnddw2y//9IbE7x3Jf4oUu6vWcJjmv9K/usb925x1ZduyLOiQ+JW2J9Q+dEj+vc+LTXMeE+gUlrx+seJyNVE2IHEUUrlfVVdV/0z3939u70zs9vTudsMmumdndcaNu1h/wBw+RRJNcAlGDEdSDBwMacUGUCB4EDzEoKKIYUfDgwUuEmN1IvAgevIiEFQVzUC/iQXB7fdW7Sm461Lx6/V71V/V9/eoRTsjWD+wiS0lAdpF95C5ykBAQM9BzaAeKan6WzkBU8CgJHVaVVSHL3iy7DZKeCOPB4nw/EVK44EAOw2KwWM3SChbml+ktMIg7AGPj2SF/esJnr4GZVvlL9X30XYgmywl3eW99754D4aAb6Kdt3x/z/Vd1wblOqeY68GQSG9wwRf0ed7Po4uRuOgn2WJXdf6zVHfdPnJ1/qjOdGACrqxCMd50PDniZh+NMFgf+mGy39DRrlVMhnP7JSgO70/+R4E8g11s1wiaIRRJSkgVyNzmGbAvFoywUIygcCOOkWIb5Pmv8YZMFWfUxPwnxKD4AGOix/xGB7+FPP039WvpJQq1m8m8Ibfubt587amSBecput+0LRjBm/sczPZ5OpTjq7yAtU1CmfhkSFUvYQ+eOmPjKKZsx+wNzLKiff+OowjhlUWpdQJz6zLkjGDAet3ZWEFUDL2jAXiRtEpJpsoi6EEAyLjR0BopNJatRMo0iRd62QCNvFioPNYq8HBJUSQXK6dIB6W0XQ7OC/XolGsWXw3AtHkXrQfDH+vra5vv1RqcsO9DtlABlRz1BP4cw3w2wO4frG3kPYDaHqFMA9HL64ZUwVDBrYbgej8Lf19bWrnY79TW1rJcjTAGbG/hm/Uvehwa3R3dwd3ZR319Dnp+zNXYHibHS7ySHkKUi+S/THEaLDddRWeHRi20qyTBSBHcYc6+chQVvfnFU5DCp6gWLXxZKi2XFOk5YJFP9y2NoWrr+jPR1S2xIuXQQYP/M5tbMfjU/gH8K2/7m+YWsLDP4KkMx6tdn9tNXoJvWM2kXcIZv1fyJrl85qiNggohUo/KansqfD+9ZAljaU8PMEuz4sIX+yfo89DK4mil5siVY2vxtB+zrtChSpQXbqrc+0qbYIfIo+YJcJoTjBegr1v2Rh1e6X/XnaH8OMDALo+VGmGU4QBcT1CJWUik7aDKYw/hwoCLxdnISorhpCwrJkzg7MM2xJBZHC94IMRqsaqHZYQ76FV5Al+K+aqlQgSY8B6XsIc5OQuGrQXOqzpN4oTpGMqTfdOvzbt7SfS5AiHbVNuUgMg1bOpwJymNb558Jzx7r9yLhc8cAzdX9LBRGOuFQTdhB28h6U25gv2OYlsmly4E64jGzE3njJlDXdKv6OXjayHTOinHTDVydPWJQzZBmaL6NG7Vv1i2qcSvYNRE6wWRqZwaVwl5xpal/LLiUlk0BqGY6up4MueHwlh1NMcGEOXVY03nQimJ4gjEhLF3eFOuGLdqWiO1kwpT8U+FyQYFRQ7Ntyk1NapRyy2LYIW0OoNutt0zdMoX0HCHjXJy0U+Qt6md5K8HqGwLlmnEcHo4z09Acg52wUE88u2+9aQrAgwmE0tttrlHgJvdsaggNpH5BndxwDcq4bmAxJ/uE0Khw4qi+R0pJGTS9YxV76gp6FvGavkqC0iuiAoaNRX+h8dEmMpGqkWArWV2BlS18b6W+BOSvSzc+1df3nj37z6AEVjCFZvNSjcsIGvrgDQvI3936DLp4nGNgZGBgAGLtNU3b4/ltvjJwszCAwHXflFkw+v+//zYsKszNQC4HAxNIFABGAgv1AAAAeJxjYGRgYG7438AQw6L8/9///ywqDEARFMAOAKazBrJ4nGNhYGBgfsnAwAKkWRihtPL/fyAaACKnAyYAAAAAAAB2AQIBdgH8AyADYnicY2BkYGBgZzjMwMYAAkxAzAWEDAz/wXwGABycAecAeJxlj01OwzAQhV/6B6QSqqhgh+QFYgEo/RGrblhUavdddN+mTpsqiSPHrdQDcB6OwAk4AtyAO/BIJ5s2lsffvHljTwDc4Acejt8t95E9XDI7cg0XuBeuU38QbpBfhJto41W4Rf1N2MczpsJtdGF5g9e4YvaEd2EPHXwI13CNT+E69S/hBvlbuIk7/Aq30PHqwj7mXle4jUcv9sdWL5xeqeVBxaHJIpM5v4KZXu+Sha3S6pxrW8QmU4OgX0lTnWlb3VPs10PnIhVZk6oJqzpJjMqt2erQBRvn8lGvF4kehCblWGP+tsYCjnEFhSUOjDFCGGSIyujoO1Vm9K+xQ8Jee1Y9zed0WxTU/3OFAQL0z1xTurLSeTpPgT1fG1J1dCtuy56UNJFezUkSskJe1rZUQuoBNmVXjhF6XNGJPyhnSP8ACVpuyAAAAHicbcNRCoAgEAXAfWYqdRYPtWXJEqwJSR6/oN8Ghgx9JvrnYTDAYoSDRyD0UBtrf7uVJbHO9yaLcLkkRnvK3kIVzUfRTPQAg/cP1gA=') format('woff');
+}
+.iconfont {font-family:"iconfont" !important; font-size:16px; font-style:normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}
+.icon-quanxuan:before { content: "\e62c"; }
+.icon-caidan:before { content: "\e610"; }
+.icon-fanxuan:before { content: "\e837"; }
+.icon-pifu:before { content: "\e668"; }
+.icon-qingkong:before { content: "\e63e"; }
+
+
+
diff --git a/zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.js b/zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.js
similarity index 96%
rename from zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.js
rename to zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.js
index d55ed6c9..f613eeca 100644
--- a/zlt-web/back-web/src/main/resources/static/module/formSelects/formSelects-v4.js
+++ b/zlt-web/layui-web/src/main/resources/static/module/formSelects/formSelects-v4.js
@@ -1,1412 +1,1412 @@
-'use strict';
-
-var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
-
-/**
- * name: formSelects
- * 基于Layui Select多选
- * version: 4.0.0.formSelects
- * http://sun.faysunshine.com/layui/formSelects-v4/dist/formSelects-v4.js
- */
-(function (layui, window, factory) {
- if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
- // 支持 CommonJS
- module.exports = factory();
- } else if (typeof define === 'function' && define.amd) {
- // 支持 AMD
- define(factory);
- } else if (window.layui && layui.define) {
- //layui加载
- layui.define(['jquery'], function (exports) {
- exports('formSelects', factory());
- });
- } else {
- window.formSelects = factory();
- }
-})(typeof layui == 'undefined' ? null : layui, window, function () {
- var v = '4.0.0.formSelects',
- NAME = 'xm-select',
- PNAME = 'xm-select-parent',
- INPUT = 'xm-select-input',
- TDIV = 'xm-select--suffix',
- THIS = 'xm-select-this',
- LABEL = 'xm-select-label',
- SEARCH = 'xm-select-search',
- CREATE = 'xm-select-create',
- CREATE_LONG = 'xm-select-create-long',
- MAX = 'xm-select-max',
- SKIN = 'xm-select-skin',
- DIRECTION = "xm-select-direction",
- HEIGHT = 'xm-select-height',
- DISABLED = 'xm-dis-disabled',
- DIS = 'xm-select-dis',
- TEMP = 'xm-select-temp',
- RADIO = 'xm-select-radio',
- LINKAGE = 'xm-select-linkage',
- DL = 'xm-select-dl',
- HIDE_INPUT = 'xm-hide-input',
- SANJIAO = 'xm-select-sj',
- ICON_CLOSE = 'xm-icon-close',
- FORM_TITLE = 'xm-select-title',
- FORM_SELECT = 'xm-form-select',
- FORM_SELECTED = 'xm-form-selected',
- FORM_NONE = 'xm-select-none',
- FORM_EMPTY = 'xm-select-empty',
- FORM_INPUT = 'xm-input',
- FORM_SELECT_TIPS = 'xm-select-tips',
- CHECKBOX_YES = 'xm-icon-yes',
- CZ = 'xm-cz',
- CZ_GROUP = 'xm-cz-group',
- TIPS = '请选择',
- data = {},
- events = {
- on: {},
- filter: {},
- maxTips: {}
- },
- ajax = {
- type: 'get',
- header: {},
- first: true,
- data: {},
- searchUrl: '',
- searchName: 'keyword',
- searchVal: null,
- keyName: 'name',
- keyVal: 'value',
- keySel: 'selected',
- keyDis: 'disabled',
- keyChildren: 'children',
- dataType: '',
- delay: 500,
- beforeSuccess: null,
- success: null,
- error: null,
- beforeSearch: null,
- clearInput: false
- },
- quickBtns = [{ icon: 'iconfont icon-quanxuan', name: '全选', click: function click(id, cm) {
- cm.selectAll(id, true, true);
- } }, { icon: 'iconfont icon-qingkong', name: '清空', click: function click(id, cm) {
- cm.removeAll(id, true, true);
- } }, { icon: 'iconfont icon-fanxuan', name: '反选', click: function click(id, cm) {
- cm.reverse(id, true, true);
- } }, { icon: 'iconfont icon-pifu', name: '换肤', click: function click(id, cm) {
- cm.skin(id);
- } }],
- $ = window.$ || window.layui && window.layui.jquery,
- $win = $(window),
- ajaxs = {},
- FormSelects = function FormSelects(options) {
- var _this = this;
-
- this.config = {
- name: null, //xm-select="xxx"
- max: null,
- maxTips: function maxTips(vals, val, max) {
- var ipt = $('[xid="' + _this.config.name + '"]').prev().find('.' + NAME);
- if (ipt.parents('.layui-form-item[pane]').length) {
- ipt = ipt.parents('.layui-form-item[pane]');
- }
- ipt.attr('style', 'border-color: red !important');
- setTimeout(function () {
- ipt.removeAttr('style');
- }, 300);
- },
- init: null, //初始化的选择值,
- on: null, //select值发生变化
- filter: function filter(id, inputVal, val, isDisabled) {
- return val.name.indexOf(inputVal) == -1;
- },
- clearid: -1,
- direction: 'auto',
- height: null,
- isEmpty: false,
- btns: [quickBtns[0], quickBtns[1], quickBtns[2]]
- };
- this.select = null;
- this.values = [];
- $.extend(true, this.config, options);
- };
-
- //一些简单的处理方法
- var Common = function Common() {
- this.loadingCss();
- this.appender();
- this.init();
- this.on();
- this.initVal();
- this.onreset();
- this.listening();
- };
-
- Common.prototype.appender = function () {
- //针对IE做的一些拓展
- if (!Array.prototype.map) {
- Array.prototype.map = function (callback, thisArg) {
- var T,
- A,
- k,
- O = Object(this),
- len = O.length >>> 0;
- if (thisArg) {
- T = thisArg;
- }
- A = new Array(len);
- k = 0;
- while (k < len) {
- var kValue, mappedValue;
- if (k in O) {
- kValue = O[k];
- mappedValue = callback.call(T, kValue, k, O);
- A[k] = mappedValue;
- }
- k++;
- }
- return A;
- };
- }
- if (!Array.prototype.forEach) {
- Array.prototype.forEach = function forEach(callback, thisArg) {
- var T, k;
- if (this == null) {
- throw new TypeError("this is null or not defined");
- }
- var O = Object(this);
- var len = O.length >>> 0;
- if (typeof callback !== "function") {
- throw new TypeError(callback + " is not a function");
- }
- if (arguments.length > 1) {
- T = thisArg;
- }
- k = 0;
- while (k < len) {
- var kValue;
- if (k in O) {
-
- kValue = O[k];
- callback.call(T, kValue, k, O);
- }
- k++;
- }
- };
- }
- };
-
- Common.prototype.init = function (target) {
- var _this2 = this;
-
- //初始化页面上已有的select
- $(target ? target : 'select[' + NAME + ']').each(function (index, select) {
- var othis = $(select),
- id = othis.attr(NAME),
- hasRender = othis.next('.layui-form-select'),
- disabled = select.disabled,
- max = othis.attr(MAX) - 0,
- isSearch = othis.attr(SEARCH) != undefined,
- searchUrl = isSearch ? othis.attr(SEARCH) : null,
- isCreate = othis.attr(CREATE) != undefined,
- isRadio = othis.attr(RADIO) != undefined,
- skin = othis.attr(SKIN),
- direction = othis.attr(DIRECTION),
- optionsFirst = select.options[0],
- height = othis.attr(HEIGHT),
- formname = othis.attr('name'),
- layverify = othis.attr('lay-verify'),
- placeholder = optionsFirst ? optionsFirst.value ? TIPS : optionsFirst.innerHTML || TIPS : TIPS,
- value = othis.find('option[selected]').toArray().map(function (option) {
- //获取已选中的数据
- return {
- name: option.innerHTML,
- val: option.value
- };
- }),
- fs = new FormSelects();
- data[id] = fs;
- //先取消layui对select的渲染
- hasRender[0] && hasRender.remove();
-
- //包裹一个div
- othis.wrap('
');
-
- //构造渲染div
- var dinfo = _this2.renderSelect(id, placeholder, select);
- var heightStyle = height ? 'style="height: ' + height + ';"' : '';
- var inputHtml = height ? ['
', ' '] : ['', ' ', '
'];
- var reElem = $('');
- othis.after(reElem);
- fs.select = othis.remove(); //去掉layui.form.render
- fs.values = value;
- fs.config.name = id;
- fs.config.init = value.concat([]);
- fs.config.direction = direction;
- fs.config.height = height;
- fs.config.radio = isRadio;
-
- if (max) {
- //有最大值
- fs.config.max = max;
- }
-
- //如果可搜索, 加上事件
- if (isSearch) {
- reElem.find('.' + INPUT).on('input propertychange', function (e) {
- var input = e.target,
- inputValue = $.trim(input.value),
- keyCode = e.keyCode;
- if (keyCode === 9 || keyCode === 13 || keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
- return false;
- }
-
- //过滤一下tips
- _this2.changePlaceHolder($(input));
-
- var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
- searchUrl = ajaxConfig.searchUrl || searchUrl;
- //如果开启了远程搜索
- if (searchUrl) {
- if (ajaxConfig.searchVal) {
- inputValue = ajaxConfig.searchVal;
- ajaxConfig.searchVal = '';
- }
- if (!ajaxConfig.beforeSearch || ajaxConfig.beforeSearch && ajaxConfig.beforeSearch instanceof Function && ajaxConfig.beforeSearch(id, searchUrl, inputValue)) {
- var delay = ajaxConfig.delay;
- if (ajaxConfig.first) {
- ajaxConfig.first = false;
- delay = 10;
- }
- clearTimeout(fs.clearid);
- fs.clearid = setTimeout(function () {
- reElem.find('dl > *:not(.' + FORM_SELECT_TIPS + ')').remove();
- reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('请求中');
- _this2.ajax(id, searchUrl, inputValue, false, null, true);
- }, delay);
- }
- } else {
- reElem.find('dl .layui-hide').removeClass('layui-hide');
- //遍历选项, 选择可以显示的值
- reElem.find('dl dd:not(.' + FORM_SELECT_TIPS + ')').each(function (idx, item) {
- var _item = $(item);
- var searchFun = data[id].config.filter || events.filter[id];
- if (searchFun && searchFun(id, inputValue, {
- name: _item.find('span').text(),
- val: _item.attr('lay-value')
- }, _item.hasClass(DISABLED)) == true) {
- _item.addClass('layui-hide');
- }
- });
- //控制分组名称
- reElem.find('dl dt').each(function (index, item) {
- if (!$(item).nextUntil('dt', ':not(.layui-hide)').length) {
- $(item).addClass('layui-hide');
- }
- });
- //动态创建
- _this2.create(id, isCreate, inputValue);
- var shows = reElem.find('dl dd:not(.' + FORM_SELECT_TIPS + '):not(.layui-hide)');
- if (!shows.length) {
- reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('无匹配项');
- } else {
- reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
- }
- }
- });
- if (searchUrl) {
- //触发第一次请求事件
- _this2.triggerSearch(reElem, true);
- }
- }
- });
- };
-
- Common.prototype.isArray = function (obj) {
- return Object.prototype.toString.call(obj) == "[object Array]";
- };
-
- Common.prototype.triggerSearch = function (div, isCall) {
- (div ? [div] : $('.' + FORM_SELECT).toArray()).forEach(function (reElem, index) {
- reElem = $(reElem);
- var id = reElem.find('dl').attr('xid');
- if (id && data[id] && data[id].config.isEmpty || isCall) {
- var obj_caller = reElem.find('.' + INPUT)[0];
- if (document.createEventObject) {
- obj_caller.fireEvent("onchange");
- } else {
- var evt = document.createEvent("HTMLEvents");
- evt.initEvent("input", false, true);
- obj_caller.dispatchEvent(evt);
- }
- }
- });
- };
-
- Common.prototype.ajax = function (id, searchUrl, inputValue, isLinkage, linkageWidth, isSearch) {
- var _this3 = this;
-
- var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
- if (!reElem[0] || !searchUrl) {
- return;
- }
-
- var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
- var ajaxData = $.extend(true, {}, ajaxConfig.data);
- ajaxData[ajaxConfig.searchName] = inputValue;
- ajaxData['_'] = Date.now();
- $.ajax({
- type: ajaxConfig.type,
- headers: ajaxConfig.header,
- url: searchUrl,
- data: ajaxConfig.dataType == 'json' ? JSON.stringify(ajaxData) : ajaxData,
- success: function success(res) {
- if (typeof res == 'string') {
- res = JSON.parse(res);
- }
- ajaxConfig.beforeSuccess && ajaxConfig.beforeSuccess instanceof Function && (res = ajaxConfig.beforeSuccess(id, searchUrl, inputValue, res));
- if (_this3.isArray(res)) {
- res = {
- code: 0,
- msg: "",
- data: res
- };
- }
- if (res.code != 0) {
- reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text(res.msg);
- } else {
- reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
- //获得已选择的values
- _this3.renderData(id, res.data, isLinkage, linkageWidth, isSearch);
- data[id].config.isEmpty = res.data.length == 0;
- }
- ajaxConfig.success && ajaxConfig.success instanceof Function && ajaxConfig.success(id, searchUrl, inputValue, res);
- },
- error: function error(err) {
- reElem.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + ')').remove();
- reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('服务异常');
- ajaxConfig.error && ajaxConfig.error instanceof Function && ajaxConfig.error(id, searchUrl, inputValue, err);
- }
- });
- };
-
- Common.prototype.renderData = function (id, dataArr, linkage, linkageWidth, isSearch) {
- var _this4 = this;
-
- if (linkage) {
- var _ret = function () {
- //渲染多级联动
- var result = [],
- index = 0,
- temp = { "0": dataArr },
- ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
-
- var _loop = function _loop() {
- var group = result[index++] = [],
- _temp = temp;
- temp = {};
- $.each(_temp, function (pid, arr) {
- $.each(arr, function (idx, item) {
- var val = {
- pid: pid,
- name: item[ajaxConfig.keyName],
- val: item[ajaxConfig.keyVal]
- };
- group.push(val);
- var children = item[ajaxConfig.keyChildren];
- if (children && children.length) {
- temp[val.val] = children;
- }
- });
- });
- };
-
- do {
- _loop();
- } while (Object.getOwnPropertyNames(temp).length);
-
- var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
- var html = [''];
-
- $.each(result, function (idx, arr) {
- var groupDiv = ['
'];
- $.each(arr, function (idx2, item) {
- var span = '
' + item.name + ' ';
- groupDiv.push(span);
- });
- groupDiv.push('');
- html = html.concat(groupDiv);
- });
- //
123
- html.push('
');
- html.push('
');
- reElem.find('dl').html(html.join(''));
- reElem.find('.' + INPUT).css('display', 'none'); //联动暂时不支持搜索
- return {
- v: void 0
- };
- }();
-
- if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
- }
-
- var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
- var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
- var pcInput = reElem.find('.' + TDIV + ' input');
-
- var values = [];
- reElem.find('dl').html(this.renderSelect(id, pcInput.attr('placeholder') || pcInput.attr('back'), dataArr.map(function (item) {
- if (item[ajaxConfig.keySel]) {
- values.push({
- name: item[ajaxConfig.keyName],
- val: item[ajaxConfig.keyVal]
- });
- }
- return {
- innerHTML: item[ajaxConfig.keyName],
- value: item[ajaxConfig.keyVal],
- sel: item[ajaxConfig.keySel],
- disabled: item[ajaxConfig.keyDis],
- type: item.type,
- name: item.name
- };
- })));
-
- var label = reElem.find('.' + LABEL);
- var dl = reElem.find('dl[xid]');
- if (isSearch) {
- //如果是远程搜索, 这里需要判重
- var oldVal = data[id].values;
- oldVal.forEach(function (item, index) {
- dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
- });
- values.forEach(function (item, index) {
- if (_this4.indexOf(oldVal, item) == -1) {
- _this4.addLabel(id, label, item);
- dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
- oldVal.push(item);
- }
- });
- } else {
- values.forEach(function (item, index) {
- _this4.addLabel(id, label, item);
- dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
- });
- data[id].values = values;
- }
- this.commonHanler(id, label);
- };
-
- Common.prototype.create = function (id, isCreate, inputValue) {
- if (isCreate && inputValue) {
- var fs = data[id],
- dl = $('[xid="' + id + '"]'),
- tips = dl.find('dd.' + FORM_SELECT_TIPS + ':first'),
- tdd = null,
- temp = dl.find('dd.' + TEMP);
- dl.find('dd:not(.' + FORM_SELECT_TIPS + '):not(.' + TEMP + ')').each(function (index, item) {
- if (inputValue == $(item).find('span').text()) {
- tdd = item;
- }
- });
- if (!tdd) {
- //如果不存在, 则创建
- if (temp[0]) {
- temp.attr('lay-value', inputValue);
- temp.find('span').text(inputValue);
- temp.removeClass('layui-hide');
- } else {
- tips.after($(this.createDD({
- innerHTML: inputValue,
- value: Date.now()
- }, TEMP + ' ' + CREATE_LONG)));
- }
- }
- } else {
- $('[xid=' + id + '] dd.' + TEMP).remove();
- }
- };
-
- Common.prototype.createDD = function (item, clz) {
- return '\n\t\t\t\t\t\n\t\t\t\t\t\t' + $.trim(item.innerHTML) + ' \n\t\t\t\t\t\t \n\t\t\t\t\t
\n\t\t\t\t ';
- };
-
- Common.prototype.createQuickBtn = function (obj, right) {
- return '' + obj.name + '
';
- };
-
- Common.prototype.renderBtns = function (id, show, right) {
- var _this5 = this;
-
- var quickBtn = [];
- var dl = $('dl[xid="' + id + '"]');
- quickBtn.push('');
- $.each(data[id].config.btns, function (index, item) {
- quickBtn.push(_this5.createQuickBtn(item, right));
- });
- quickBtn.push('
');
- quickBtn.push(this.createQuickBtn({ icon: 'iconfont icon-caidan', name: '' }));
- return quickBtn.join('');
- };
-
- Common.prototype.renderSelect = function (id, tips, select) {
- var _this6 = this;
-
- var arr = [];
- if (data[id].config.btns.length) {
- setTimeout(function () {
- var dl = $('dl[xid="' + id + '"]');
- dl.find('.' + CZ_GROUP).css('max-width', dl.prev().width() - 54 + 'px');
- }, 10);
- arr.push(['', this.renderBtns(id, null, '30px'), ' '].join(''));
- } else {
- arr.push('' + tips + ' ');
- }
- if (this.isArray(select)) {
- $(select).each(function (index, item) {
- if (item.type === 'optgroup') {
- arr.push('' + item.name + ' ');
- } else {
- arr.push(_this6.createDD(item));
- }
- });
- } else {
- $(select).find('*').each(function (index, item) {
- if (item.tagName.toLowerCase() == 'option' && index == 0 && !item.value) {
- return;
- }
- if (item.tagName.toLowerCase() === 'optgroup') {
- arr.push('' + item.label + ' ');
- } else {
- arr.push(_this6.createDD(item));
- }
- });
- }
- arr.push(' ');
- arr.push('\u6CA1\u6709\u9009\u9879 ');
- return arr.join('');
- };
-
- Common.prototype.on = function () {
- var _this7 = this;
-
- //事件绑定
- this.one();
-
- $(document).on('click', function (e) {
- if (!$(e.target).parents('.' + FORM_TITLE)[0]) {
- //清空input中的值
- $('.' + INPUT).val('');
- $('.' + PNAME + ' dl .layui-hide').removeClass('layui-hide');
- $('.' + PNAME + ' dl dd.' + TEMP).remove();
- _this7.triggerSearch();
- }
- $('.' + PNAME + ' .' + FORM_SELECTED).removeClass(FORM_SELECTED);
- });
- };
-
- Common.prototype.one = function (target) {
- var _this8 = this;
-
- //一次性事件绑定
- $(target ? target : document).find('.' + FORM_TITLE).off('click').on('click', function (e) {
- var othis = $(e.target),
- title = othis.is(FORM_TITLE) ? othis : othis.parents('.' + FORM_TITLE),
- dl = title.next(),
- id = dl.attr('xid');
-
- //清空非本select的input val
- $('dl[xid]').not(dl).prev().find('.' + INPUT).val('');
- $('dl[xid]').not(dl).find('dd.layui-hide').removeClass('layui-hide');
-
- //如果是disabled select
- if (title.hasClass(DIS)) {
- return false;
- }
- //如果点击的是右边的三角或者只读的input
- if (othis.is('.' + SANJIAO) || othis.is('.' + INPUT + '[readonly]')) {
- _this8.changeShow(title, !title.parents('.' + FORM_SELECT).hasClass(FORM_SELECTED));
- return false;
- }
- //如果点击的是input的右边, focus一下
- if (title.find('.' + INPUT + ':not(readonly)')[0]) {
- var input = title.find('.' + INPUT),
- epos = { x: e.pageX, y: e.pageY },
- pos = _this8.getPosition(title[0]),
- width = title.width();
- while (epos.x > pos.x) {
- if ($(document.elementFromPoint(epos.x, epos.y)).is(input)) {
- input.focus();
- _this8.changeShow(title, true);
- return false;
- }
- epos.x -= 50;
- }
- }
-
- //如果点击的是可搜索的input
- if (othis.is('.' + INPUT)) {
- _this8.changeShow(title, true);
- return false;
- }
- //如果点击的是x按钮
- if (othis.is('i[fsw="' + NAME + '"]')) {
- var val = {
- name: othis.prev().text(),
- val: othis.parent().attr("value")
- },
- dd = dl.find('dd[lay-value=\'' + val.val + '\']');
- if (dd.hasClass(DISABLED)) {
- //如果是disabled状态, 不可选, 不可删
- return false;
- }
- _this8.handlerLabel(id, dd, false, val);
- return false;
- }
-
- _this8.changeShow(title, !title.parents('.' + FORM_SELECT).hasClass(FORM_SELECTED));
- return false;
- });
- $(target ? target : document).find('dl.' + DL).off('click').on('click', function (e) {
- var othis = $(e.target);
- if (othis.is('.' + LINKAGE) || othis.parents('.' + LINKAGE)[0]) {
- //linkage的处理
- othis = othis.is('li') ? othis : othis.parents('li');
- var _group = othis.parents('.xm-select-linkage-group'),
- _id = othis.parents('dl').attr('xid');
- //激活li
- _group.find('.xm-select-active').removeClass('xm-select-active');
- othis.addClass('xm-select-active');
- //激活下一个group, 激活前显示对应数据
- _group.nextAll('.xm-select-linkage-group').addClass('xm-select-linkage-hide');
- var nextGroup = _group.next('.xm-select-linkage-group');
- nextGroup.find('li').addClass('xm-select-linkage-hide');
- nextGroup.find('li[pid="' + othis.attr('value') + '"]').removeClass('xm-select-linkage-hide');
- //如果没有下一个group, 或没有对应的值
- if (!nextGroup[0] || nextGroup.find('li:not(.xm-select-linkage-hide)').length == 0) {
- var vals = [],
- index = 0,
- _isAdd = !othis.hasClass('xm-select-this');
- if (data[_id].config.radio) {
- othis.parents('.xm-select-linkage').find('.xm-select-this').removeClass('xm-select-this');
- }
- do {
- vals[index++] = {
- name: othis.find('span').text(),
- val: othis.attr('value')
- /*isAdd ? (
- othis.addClass('xm-select-this')
- ) : (
- !othis.parent('.xm-select-linkage-group').next().find(`li[pid="${othis.attr('value')}"].xm-select-this`).length && othis.removeClass('xm-select-this')
- );*/
- };othis = othis.parents('.xm-select-linkage-group').prev().find('li[value="' + othis.attr('pid') + '"]');
- } while (othis.length);
- vals.reverse();
- var val = {
- name: vals.map(function (item) {
- return item.name;
- }).join('/'),
- val: vals.map(function (item) {
- return item.val;
- }).join('/')
- };
- _this8.handlerLabel(_id, null, _isAdd, val);
- } else {
- nextGroup.removeClass('xm-select-linkage-hide');
- }
- return false;
- } //xm-select-this xm-select-active
-
- if (othis.is('dt') || othis.is('dl')) {
- return false;
- }
- var dd = othis.is('dd') ? othis : othis.parents('dd');
- var id = dd.parent('dl').attr('xid');
- if (dd.hasClass(DISABLED)) {
- //被禁用选项的处理
- return false;
- }
- if (dd.hasClass(FORM_SELECT_TIPS)) {
- //tips的处理
- var btn = othis.is('.' + CZ) ? othis : othis.parents('.' + CZ);
- if (!btn[0]) {
- return false;
- }
- //TODO 快捷操作
- var method = btn.attr('method');
- var obj = data[id].config.btns.filter(function (bean) {
- return bean.name == method;
- })[0];
- obj && obj.click && obj.click instanceof Function && obj.click(id, _this8);
- return false;
- }
- var isAdd = !dd.hasClass(THIS);
- _this8.handlerLabel(id, dd, isAdd);
- return false;
- });
- };
-
- Common.prototype.linkageAdd = function (id, val) {
- var dl = $('dl[xid="' + id + '"]');
- dl.find('.xm-select-active').removeClass('xm-select-active');
- var vs = val.val.split('/');
- var pid = void 0,
- li = void 0,
- index = 0;
- var lis = [];
- do {
- pid = vs[index];
- li = dl.find('.xm-select-linkage-group' + (index + 1) + ' li[value="' + pid + '"]');
- li[0] && lis.push(li);
- index++;
- } while (li.length && pid != undefined);
- if (lis.length == vs.length) {
- $.each(lis, function (idx, item) {
- item.addClass('xm-select-this');
- });
- }
- };
-
- Common.prototype.linkageDel = function (id, val) {
- var dl = $('dl[xid="' + id + '"]');
- var vs = val.val.split('/');
- var pid = void 0,
- li = void 0,
- index = vs.length - 1;
- do {
- pid = vs[index];
- li = dl.find('.xm-select-linkage-group' + (index + 1) + ' li[value="' + pid + '"]');
- if (!li.parent().next().find('li[pid=' + pid + '].xm-select-this').length) {
- li.removeClass('xm-select-this');
- }
- index--;
- } while (li.length && pid != undefined);
- };
-
- Common.prototype.valToName = function (id, val) {
- var dl = $('dl[xid="' + id + '"]');
- var vs = (val + "").split('/');
- var names = [];
- $.each(vs, function (idx, item) {
- var name = dl.find('.xm-select-linkage-group' + (idx + 1) + ' li[value="' + item + '"] span').text();
- names.push(name);
- });
- return names.length == vs.length ? names.join('/') : null;
- };
-
- Common.prototype.commonHanler = function (key, label) {
- //计算input的提示语
- this.changePlaceHolder(label);
- //计算高度
- this.retop(label.parents('.' + FORM_SELECT));
- this.checkHideSpan(label);
- this.calcLeft(key, label);
- //表单默认值
- label.parents('.' + PNAME).find('.' + HIDE_INPUT).val(data[key].values.map(function (val) {
- return val.val;
- }).join(','));
- //title值
- label.parents('.' + FORM_TITLE + ' .' + NAME).attr('title', data[key].values.map(function (val) {
- return val.name;
- }).join(','));
- };
-
- Common.prototype.initVal = function (id) {
- var _this9 = this;
-
- var target = {};
- if (id) {
- target[id] = data[id];
- } else {
- target = data;
- }
- $.each(target, function (key, val) {
- var values = val.values,
- div = $('dl[xid="' + key + '"]').parent(),
- label = div.find('.' + LABEL),
- dl = div.find('dl');
- dl.find('dd.' + THIS).removeClass(THIS);
-
- var _vals = values.concat([]);
- _vals.concat([]).forEach(function (item, index) {
- _this9.addLabel(key, label, item);
- dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
- });
- if (val.config.radio) {
- _vals.length && values.push(_vals[_vals.length - 1]);
- }
- _this9.commonHanler(key, label);
- });
- };
-
- Common.prototype.handlerLabel = function (id, dd, isAdd, oval, notOn) {
- var div = $('[xid="' + id + '"]').prev().find('.' + LABEL),
- val = dd && {
- name: dd.find('span').text(),
- val: dd.attr('lay-value')
- },
- vals = data[id].values,
- on = data[id].config.on || events.on[id];
- if (oval) {
- val = oval;
- }
- var fs = data[id];
- if (isAdd && fs.config.max && fs.values.length >= fs.config.max) {
- var maxTipsFun = data[id].config.maxTips || events.maxTips[id];
- maxTipsFun && maxTipsFun(id, vals.concat([]), val, fs.max);
- return;
- }
- if (!notOn) {
- if (on && on instanceof Function && on(id, vals.concat([]), val, isAdd, dd && dd.hasClass(DISABLED) == false)) {
- return;
- }
- }
- var dl = $('dl[xid="' + id + '"]');
- isAdd ? (dd && dd[0] ? (dd.addClass(THIS), dd.removeClass(TEMP)) : dl.find('.xm-select-linkage')[0] && this.linkageAdd(id, val), this.addLabel(id, div, val), vals.push(val)) : (dd && dd[0] ? dd.removeClass(THIS) : dl.find('.xm-select-linkage')[0] && this.linkageDel(id, val), this.delLabel(id, div, val), this.remove(vals, val));
- if (!div[0]) return;
- //单选选完后直接关闭选择域
- if (fs.config.radio) {
- this.changeShow(div, false);
- }
- //移除表单验证的红色边框
- div.parents('.' + FORM_TITLE).prev().removeClass('layui-form-danger');
-
- //清空搜索值
- fs.config.clearInput && div.parents('.' + PNAME).find('.' + INPUT).val('');
-
- this.commonHanler(id, div);
- };
-
- Common.prototype.addLabel = function (id, div, val) {
- if (!val) return;
- var tips = 'fsw="' + NAME + '"';
- var _ref = [$('' + val.name + ' '), $('\xD7 ')],
- $label = _ref[0],
- $close = _ref[1];
-
- $label.append($close);
- //如果是radio模式
- var fs = data[id];
- if (fs.config.radio) {
- fs.values.length = 0;
- $('dl[xid="' + id + '"]').find('dd.' + THIS + ':not([lay-value="' + val.val + '"])').removeClass(THIS);
- div.find('span').remove();
- }
- //如果是固定高度
- if (fs.config.height) {
- div.append($label);
- } else {
- div.find('input').css('width', '50px');
- div.find('input').before($label);
- }
- };
-
- Common.prototype.delLabel = function (id, div, val) {
- if (!val) return;
- div.find('span[value="' + val.val + '"]:first').remove();
- };
-
- Common.prototype.calcLeft = function (id, div) {
- if (data[id].config.height) {
- var showLastSpan = div.find('span:not(.xm-span-hide):last')[0];
- div.next().css('left', (showLastSpan ? this.getPosition(showLastSpan).x - this.getPosition(div[0]).x + showLastSpan.offsetWidth + 20 : 10) + 'px');
- }
- };
-
- Common.prototype.checkHideSpan = function (div) {
- var _this10 = this;
-
- var parentHeight = div.parents('.' + NAME)[0].offsetHeight + 5;
- div.find('span.xm-span-hide').removeClass('xm-span-hide');
- div.find('span').each(function (index, item) {
- if (item.offsetHeight + item.offsetTop > parentHeight || _this10.getPosition(item).y + item.offsetHeight > _this10.getPosition(div[0]).y + div[0].offsetHeight + 5) {
- $(item).addClass('xm-span-hide');
- }
- });
- };
-
- Common.prototype.retop = function (div) {
- //计算dl显示的位置
- var dl = div.find('dl'),
- top = div.offset().top + div.outerHeight() + 5 - $win.scrollTop(),
- dlHeight = dl.outerHeight();
- var up = div.hasClass('layui-form-selectup') || dl.css('top').indexOf('-') != -1 || top + dlHeight > $win.height() && top >= dlHeight;
- div = div.find('.' + NAME);
-
- var fs = data[dl.attr('xid')];
- var base = dl.parents('.layui-form-pane')[0] && dl.prev()[0].clientHeight > 38 ? 14 : 10;
- if (fs) {
- if (fs.config.direction == 'up') {
- dl.css({
- top: 'auto',
- bottom: '42px'
- });
- return;
- }
- if (fs.direction == 'down') {
- dl.css({
- top: div[0].offsetTop + div.height() + base + 'px',
- bottom: 'auto'
- });
- return;
- }
- }
-
- if (up) {
- dl.css({
- top: 'auto',
- bottom: '42px'
- });
- } else {
- dl.css({
- top: div[0].offsetTop + div.height() + base + 'px',
- bottom: 'auto'
- });
- }
- };
-
- Common.prototype.changeShow = function (children, isShow) {
- //显示于隐藏
- var top = children.parents('.' + FORM_SELECT);
- $('.' + PNAME + ' .' + FORM_SELECT).not(top).removeClass(FORM_SELECTED);
- if (isShow) {
- this.retop(top);
- top.addClass(FORM_SELECTED);
- top.find('.' + INPUT).focus();
- } else {
- top.removeClass(FORM_SELECTED);
- top.find('.' + INPUT).val('');
- top.find('dl .layui-hide').removeClass('layui-hide');
- top.find('dl dd.' + TEMP).remove();
- //计算ajax数据是否为空, 然后重新请求数据
- var id = top.find('dl').attr('xid');
- if (id && data[id] && data[id].config.isEmpty) {
- this.triggerSearch(top);
- }
- }
- };
-
- Common.prototype.changePlaceHolder = function (div) {
- //显示于隐藏提示语
- //调整pane模式下的高度
- var title = div.parents('.' + FORM_TITLE);
-
- var id = div.parents('.' + PNAME).find('dl[xid]').attr('xid');
- if (data[id] && data[id].config.height) {//既然固定高度了, 那就看着办吧
-
- } else {
- var height = title.find('.' + NAME)[0].clientHeight;
- title.css('height', (height > 34 ? height + 4 : height) + 'px');
- //如果是layui pane模式, 处理label的高度
- var label = title.parents('.' + PNAME).parent().prev();
- if (label.is('.layui-form-label') && title.parents('.layui-form-pane')[0]) {
- height = height > 36 ? height + 4 : height;
- title.css('height', height + 'px');
- label.css({
- height: height + 2 + 'px',
- lineHeight: height - 18 + 'px'
- });
- }
- }
-
- var input = title.find('.' + TDIV + ' input'),
- isShow = !div.find('span:last')[0] && !title.find('.' + INPUT).val();
- if (isShow) {
- var ph = input.attr('back');
- input.removeAttr('back');
- input.attr('placeholder', ph);
- } else {
- var _ph = input.attr('placeholder');
- input.removeAttr('placeholder');
- input.attr('back', _ph);
- }
- };
-
- Common.prototype.indexOf = function (arr, val) {
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].val == val || arr[i].val == (val ? val.val : val) || arr[i] == val || JSON.stringify(arr[i]) == JSON.stringify(val)) {
- return i;
- }
- }
- return -1;
- };
-
- Common.prototype.remove = function (arr, val) {
- var idx = this.indexOf(arr, val ? val.val : val);
- if (idx > -1) {
- arr.splice(idx, 1);
- return true;
- }
- return false;
- };
-
- Common.prototype.selectAll = function (id, isOn, skipDis) {
- var _this11 = this;
-
- var dl = $('[xid="' + id + '"]');
- if (dl.find('.xm-select-linkage')[0]) {
- return;
- }
- dl.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + '):not(.' + THIS + ')' + (skipDis ? ':not(.' + DISABLED + ')' : '')).each(function (index, item) {
- item = $(item);
- var val = {
- name: item.find('span').text(),
- val: item.attr('lay-value')
- };
- _this11.handlerLabel(id, dl.find('dd[lay-value="' + val.val + '"]'), true, val, !isOn);
- });
- };
-
- Common.prototype.removeAll = function (id, isOn, skipDis) {
- var _this12 = this;
-
- var dl = $('[xid="' + id + '"]');
- if (dl.find('.xm-select-linkage')[0]) {
- //针对多级联动的处理
- data[id].values.concat([]).forEach(function (item, idx) {
- var vs = item.val.split('/');
- var pid = void 0,
- li = void 0,
- index = 0;
- do {
- pid = vs[index++];
- li = dl.find('.xm-select-linkage-group' + index + ':not(.xm-select-linkage-hide) li[value="' + pid + '"]');
- li.click();
- } while (li.length && pid != undefined);
- });
- return;
- }
- data[id].values.concat([]).forEach(function (item, index) {
- if (skipDis && dl.find('dd[lay-value="' + item.val + '"]').hasClass(DISABLED)) {} else {
- _this12.handlerLabel(id, dl.find('dd[lay-value="' + item.val + '"]'), false, item, !isOn);
- }
- });
- };
-
- Common.prototype.reverse = function (id, isOn, skipDis) {
- var _this13 = this;
-
- var dl = $('[xid="' + id + '"]');
- if (dl.find('.xm-select-linkage')[0]) {
- return;
- }
- dl.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + ')' + (skipDis ? ':not(.' + DISABLED + ')' : '')).each(function (index, item) {
- item = $(item);
- var val = {
- name: item.find('span').text(),
- val: item.attr('lay-value')
- };
- _this13.handlerLabel(id, dl.find('dd[lay-value="' + val.val + '"]'), !item.hasClass(THIS), val, !isOn);
- });
- };
-
- Common.prototype.skin = function (id) {
- var skins = ['default', 'primary', 'normal', 'warm', 'danger'];
- var skin = skins[Math.floor(Math.random() * skins.length)];
- $('dl[xid="' + id + '"]').parents('.' + PNAME).find('.' + FORM_SELECT).attr('xm-select-skin', skin);
- this.commonHanler(id, $('dl[xid="' + id + '"]').parents('.' + PNAME).find('.' + LABEL));
- };
-
- Common.prototype.getPosition = function (e) {
- var x = 0,
- y = 0;
- while (e != null) {
- x += e.offsetLeft;
- y += e.offsetTop;
- e = e.offsetParent;
- }
- return { x: x, y: y };
- };
-
- Common.prototype.onreset = function () {
- //监听reset按钮, 然后重置多选
- $(document).on('click', '[type=reset]', function (e) {
- $(e.target).parents('form').find('.' + PNAME + ' dl[xid]').each(function (index, item) {
- var id = item.getAttribute('xid'),
- dl = $(item),
- dd = void 0,
- temp = {};
- common.removeAll(id);
- data[id].config.init.forEach(function (val, idx) {
- if (val && (!temp[val] || data[id].config.repeat) && (dd = dl.find('dd[lay-value="' + val.val + '"]'))[0]) {
- common.handlerLabel(id, dd, true);
- temp[val] = 1;
- }
- });
- });
- });
- };
-
- Common.prototype.loadingCss = function () {};
-
- Common.prototype.listening = function () {
- //TODO 用于监听dom结构变化, 如果出现新的为渲染select, 则自动进行渲染
- var flag = false;
- var index = 0;
- $(document).on('DOMNodeInserted', function (e) {
- if (flag) {
- //避免递归渲染
- return;
- }
- flag = true;
- //渲染select
- $('select[' + NAME + ']').each(function (index, select) {
- var sid = select.getAttribute(NAME);
- common.init(select);
- common.one($('dl[xid="' + sid + '"]').parents('.' + PNAME));
- common.initVal(sid);
- });
-
- flag = false;
- });
- };
-
- var Select4 = function Select4() {
- this.v = v;
- };
- var common = new Common();
-
- Select4.prototype.value = function (id, type, isAppend) {
- if (typeof id != 'string') {
- return [];
- }
- var fs = data[id];
- if (!fs) {
- return [];
- }
- if (typeof type == 'string' || type == undefined) {
- var arr = fs.values.concat([]) || [];
- if (type == 'val') {
- return arr.map(function (val) {
- return val.val;
- });
- }
- if (type == 'valStr') {
- return arr.map(function (val) {
- return val.val;
- }).join(',');
- }
- if (type == 'name') {
- return arr.map(function (val) {
- return val.name;
- });
- }
- if (type == 'nameStr') {
- return arr.map(function (val) {
- return val.name;
- }).join(',');
- }
- return arr;
- }
- if (common.isArray(type)) {
- var dl = $('[xid="' + id + '"]'),
- temp = {},
- dd = void 0,
- isAdd = true;
- if (isAppend == false) {
- //删除传入的数组
- isAdd = false;
- } else if (isAppend == true) {
- //追加模式
- isAdd = true;
- } else {
- //删除原有的数据
- common.removeAll(id);
- }
- if (isAdd) {
- fs.values.forEach(function (val, index) {
- temp[val.val] = 1;
- });
- }
- type.forEach(function (val, index) {
- if (val && (!temp[val] || fs.config.repeat)) {
- if ((dd = dl.find('dd[lay-value="' + val + '"]'))[0]) {
- common.handlerLabel(id, dd, isAdd, null, true);
- temp[val] = 1;
- } else {
- var name = common.valToName(id, val);
- if (name) {
- common.handlerLabel(id, dd, isAdd, {
- name: name,
- val: val
- }, true);
- temp[val] = 1;
- }
- }
- }
- });
- }
- };
-
- Common.prototype.bindEvent = function (name, id, fun) {
- if (id && id instanceof Function) {
- fun = id;
- id = null;
- }
- if (fun && fun instanceof Function) {
- if (!id) {
- $.each(data, function (id, val) {
- data[id] ? data[id].config[name] = fun : events[name][id] = fun;
- });
- } else {
- data[id] ? data[id].config[name] = fun : events[name][id] = fun;
- }
- }
- };
-
- Select4.prototype.on = function (id, fun) {
- common.bindEvent('on', id, fun);
- return this;
- };
-
- Select4.prototype.filter = function (id, fun) {
- common.bindEvent('filter', id, fun);
- return this;
- };
-
- Select4.prototype.maxTips = function (id, fun) {
- common.bindEvent('maxTips', id, fun);
- return this;
- };
-
- Select4.prototype.config = function (id, config, isJson) {
- if (id && (typeof id === 'undefined' ? 'undefined' : _typeof(id)) == 'object') {
- isJson = config == true;
- config = id;
- id = null;
- }
- if (config && (typeof config === 'undefined' ? 'undefined' : _typeof(config)) == 'object') {
- if (isJson) {
- config.header || (config.header = {});
- config.header['Content-Type'] = 'application/json; charset=UTF-8';
- config.dataType = 'json';
- }
- id ? (ajaxs[id] = $.extend(true, {}, ajax, config), data[id] && (data[id].config.direction = config.direction), config.searchUrl && data[id] && common.triggerSearch($('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT), true)) : $.extend(true, ajax, config);
- }
- return this;
- };
-
- Select4.prototype.render = function (id) {
- var _this14 = this;
-
- var target = {};
- id ? data[id] && (target[id] = data[id]) : data;
-
- if (Object.getOwnPropertyNames(target).length) {
- $.each(target, function (key, val) {
- //恢复初始值
- var dl = $('dl[xid="' + key + '"]'),
- vals = [];
- val.select.find('option[selected]').each(function (index, item) {
- vals.push(item.value);
- });
- //移除创建元素
- dl.find('.' + CREATE_LONG).remove();
- //清空INPUT
- dl.prev().find('.' + INPUT).val('');
- //触发search
- common.triggerSearch(dl.parents('.' + FORM_SELECT), true);
- //移除hidn
- dl.find('.layui-hide').removeClass('layui-hide');
- //重新赋值
- _this14.value(key, vals);
- });
- }
- ($('select[' + NAME + '="' + id + '"]')[0] ? $('select[' + NAME + '="' + id + '"]') : $('select[' + NAME + ']')).each(function (index, select) {
- var sid = select.getAttribute(NAME);
- common.init(select);
- common.one($('dl[xid="' + sid + '"]').parents('.' + PNAME));
- common.initVal(sid);
- });
- return this;
- };
-
- Select4.prototype.disabled = function (id) {
- var target = {};
- id ? data[id] && (target[id] = data[id]) : target = data;
-
- $.each(target, function (key, val) {
- $('dl[xid="' + key + '"]').prev().addClass(DIS);
- });
- return this;
- };
-
- Select4.prototype.undisabled = function (id) {
- var target = {};
- id ? data[id] && (target[id] = data[id]) : target = data;
-
- $.each(target, function (key, val) {
- $('dl[xid="' + key + '"]').prev().removeClass(DIS);
- });
- return this;
- };
-
- Select4.prototype.data = function (id, type, config) {
- if (!id || !type || !config) {
- return this;
- }
- //检测该id是否尚未渲染
- !data[id] && this.render(id).value(id, []);
- this.config(id, config);
- if (type == 'local') {
- common.renderData(id, config.arr, config.linkage == true, config.linkageWidth ? config.linkageWidth : '100');
- } else if (type == 'server') {
- common.ajax(id, config.url, config.keyword, config.linkage == true, config.linkageWidth ? config.linkageWidth : '100');
- }
- return this;
- };
-
- Select4.prototype.btns = function (id, btns, config) {
- if (!btns || !common.isArray(btns)) {
- return this;
- };
- var target = {};
- id ? data[id] && (target[id] = data[id]) : target = data;
-
- btns = btns.map(function (obj) {
- if (typeof obj == 'string') {
- if (obj == 'select') {
- return quickBtns[0];
- }
- if (obj == 'remove') {
- return quickBtns[1];
- }
- if (obj == 'reverse') {
- return quickBtns[2];
- }
- if (obj == 'skin') {
- return quickBtns[3];
- }
- }
- return obj;
- });
-
- $.each(target, function (key, val) {
- val.config.btns = btns;
- var dd = $('dl[xid="' + key + '"]').find('.' + FORM_SELECT_TIPS + ':first');
- if (btns.length) {
- var show = config && config.show && (config.show == 'name' || config.show == 'icon') ? config.show : '';
- var html = common.renderBtns(key, show, config && config.space ? config.space : '30px');
- dd.html(html);
- } else {
- var pcInput = dd.parents('.' + FORM_SELECT).find('.' + TDIV + ' input');
- var _html = pcInput.attr('placeholder') || pcInput.attr('back');
- dd.html(_html);
- dd.removeAttr('style');
- }
- });
-
- return this;
- };
-
- Select4.prototype.search = function (id, val) {
- if (id && data[id]) {
- ajaxs[id] = $.extend(true, {}, ajax, {
- first: true,
- searchVal: val
- });
- common.triggerSearch($('dl[xid="' + id + '"]').parents('.' + FORM_SELECT), true);
- }
- return this;
- };
-
- return new Select4();
+'use strict';
+
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+
+/**
+ * name: formSelects
+ * 基于Layui Select多选
+ * version: 4.0.0.formSelects
+ * http://sun.faysunshine.com/layui/formSelects-v4/dist/formSelects-v4.js
+ */
+(function (layui, window, factory) {
+ if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
+ // 支持 CommonJS
+ module.exports = factory();
+ } else if (typeof define === 'function' && define.amd) {
+ // 支持 AMD
+ define(factory);
+ } else if (window.layui && layui.define) {
+ //layui加载
+ layui.define(['jquery'], function (exports) {
+ exports('formSelects', factory());
+ });
+ } else {
+ window.formSelects = factory();
+ }
+})(typeof layui == 'undefined' ? null : layui, window, function () {
+ var v = '4.0.0.formSelects',
+ NAME = 'xm-select',
+ PNAME = 'xm-select-parent',
+ INPUT = 'xm-select-input',
+ TDIV = 'xm-select--suffix',
+ THIS = 'xm-select-this',
+ LABEL = 'xm-select-label',
+ SEARCH = 'xm-select-search',
+ CREATE = 'xm-select-create',
+ CREATE_LONG = 'xm-select-create-long',
+ MAX = 'xm-select-max',
+ SKIN = 'xm-select-skin',
+ DIRECTION = "xm-select-direction",
+ HEIGHT = 'xm-select-height',
+ DISABLED = 'xm-dis-disabled',
+ DIS = 'xm-select-dis',
+ TEMP = 'xm-select-temp',
+ RADIO = 'xm-select-radio',
+ LINKAGE = 'xm-select-linkage',
+ DL = 'xm-select-dl',
+ HIDE_INPUT = 'xm-hide-input',
+ SANJIAO = 'xm-select-sj',
+ ICON_CLOSE = 'xm-icon-close',
+ FORM_TITLE = 'xm-select-title',
+ FORM_SELECT = 'xm-form-select',
+ FORM_SELECTED = 'xm-form-selected',
+ FORM_NONE = 'xm-select-none',
+ FORM_EMPTY = 'xm-select-empty',
+ FORM_INPUT = 'xm-input',
+ FORM_SELECT_TIPS = 'xm-select-tips',
+ CHECKBOX_YES = 'xm-icon-yes',
+ CZ = 'xm-cz',
+ CZ_GROUP = 'xm-cz-group',
+ TIPS = '请选择',
+ data = {},
+ events = {
+ on: {},
+ filter: {},
+ maxTips: {}
+ },
+ ajax = {
+ type: 'get',
+ header: {},
+ first: true,
+ data: {},
+ searchUrl: '',
+ searchName: 'keyword',
+ searchVal: null,
+ keyName: 'name',
+ keyVal: 'value',
+ keySel: 'selected',
+ keyDis: 'disabled',
+ keyChildren: 'children',
+ dataType: '',
+ delay: 500,
+ beforeSuccess: null,
+ success: null,
+ error: null,
+ beforeSearch: null,
+ clearInput: false
+ },
+ quickBtns = [{ icon: 'iconfont icon-quanxuan', name: '全选', click: function click(id, cm) {
+ cm.selectAll(id, true, true);
+ } }, { icon: 'iconfont icon-qingkong', name: '清空', click: function click(id, cm) {
+ cm.removeAll(id, true, true);
+ } }, { icon: 'iconfont icon-fanxuan', name: '反选', click: function click(id, cm) {
+ cm.reverse(id, true, true);
+ } }, { icon: 'iconfont icon-pifu', name: '换肤', click: function click(id, cm) {
+ cm.skin(id);
+ } }],
+ $ = window.$ || window.layui && window.layui.jquery,
+ $win = $(window),
+ ajaxs = {},
+ FormSelects = function FormSelects(options) {
+ var _this = this;
+
+ this.config = {
+ name: null, //xm-select="xxx"
+ max: null,
+ maxTips: function maxTips(vals, val, max) {
+ var ipt = $('[xid="' + _this.config.name + '"]').prev().find('.' + NAME);
+ if (ipt.parents('.layui-form-item[pane]').length) {
+ ipt = ipt.parents('.layui-form-item[pane]');
+ }
+ ipt.attr('style', 'border-color: red !important');
+ setTimeout(function () {
+ ipt.removeAttr('style');
+ }, 300);
+ },
+ init: null, //初始化的选择值,
+ on: null, //select值发生变化
+ filter: function filter(id, inputVal, val, isDisabled) {
+ return val.name.indexOf(inputVal) == -1;
+ },
+ clearid: -1,
+ direction: 'auto',
+ height: null,
+ isEmpty: false,
+ btns: [quickBtns[0], quickBtns[1], quickBtns[2]]
+ };
+ this.select = null;
+ this.values = [];
+ $.extend(true, this.config, options);
+ };
+
+ //一些简单的处理方法
+ var Common = function Common() {
+ this.loadingCss();
+ this.appender();
+ this.init();
+ this.on();
+ this.initVal();
+ this.onreset();
+ this.listening();
+ };
+
+ Common.prototype.appender = function () {
+ //针对IE做的一些拓展
+ if (!Array.prototype.map) {
+ Array.prototype.map = function (callback, thisArg) {
+ var T,
+ A,
+ k,
+ O = Object(this),
+ len = O.length >>> 0;
+ if (thisArg) {
+ T = thisArg;
+ }
+ A = new Array(len);
+ k = 0;
+ while (k < len) {
+ var kValue, mappedValue;
+ if (k in O) {
+ kValue = O[k];
+ mappedValue = callback.call(T, kValue, k, O);
+ A[k] = mappedValue;
+ }
+ k++;
+ }
+ return A;
+ };
+ }
+ if (!Array.prototype.forEach) {
+ Array.prototype.forEach = function forEach(callback, thisArg) {
+ var T, k;
+ if (this == null) {
+ throw new TypeError("this is null or not defined");
+ }
+ var O = Object(this);
+ var len = O.length >>> 0;
+ if (typeof callback !== "function") {
+ throw new TypeError(callback + " is not a function");
+ }
+ if (arguments.length > 1) {
+ T = thisArg;
+ }
+ k = 0;
+ while (k < len) {
+ var kValue;
+ if (k in O) {
+
+ kValue = O[k];
+ callback.call(T, kValue, k, O);
+ }
+ k++;
+ }
+ };
+ }
+ };
+
+ Common.prototype.init = function (target) {
+ var _this2 = this;
+
+ //初始化页面上已有的select
+ $(target ? target : 'select[' + NAME + ']').each(function (index, select) {
+ var othis = $(select),
+ id = othis.attr(NAME),
+ hasRender = othis.next('.layui-form-select'),
+ disabled = select.disabled,
+ max = othis.attr(MAX) - 0,
+ isSearch = othis.attr(SEARCH) != undefined,
+ searchUrl = isSearch ? othis.attr(SEARCH) : null,
+ isCreate = othis.attr(CREATE) != undefined,
+ isRadio = othis.attr(RADIO) != undefined,
+ skin = othis.attr(SKIN),
+ direction = othis.attr(DIRECTION),
+ optionsFirst = select.options[0],
+ height = othis.attr(HEIGHT),
+ formname = othis.attr('name'),
+ layverify = othis.attr('lay-verify'),
+ placeholder = optionsFirst ? optionsFirst.value ? TIPS : optionsFirst.innerHTML || TIPS : TIPS,
+ value = othis.find('option[selected]').toArray().map(function (option) {
+ //获取已选中的数据
+ return {
+ name: option.innerHTML,
+ val: option.value
+ };
+ }),
+ fs = new FormSelects();
+ data[id] = fs;
+ //先取消layui对select的渲染
+ hasRender[0] && hasRender.remove();
+
+ //包裹一个div
+ othis.wrap('
');
+
+ //构造渲染div
+ var dinfo = _this2.renderSelect(id, placeholder, select);
+ var heightStyle = height ? 'style="height: ' + height + ';"' : '';
+ var inputHtml = height ? ['
', ' '] : ['', ' ', '
'];
+ var reElem = $('');
+ othis.after(reElem);
+ fs.select = othis.remove(); //去掉layui.form.render
+ fs.values = value;
+ fs.config.name = id;
+ fs.config.init = value.concat([]);
+ fs.config.direction = direction;
+ fs.config.height = height;
+ fs.config.radio = isRadio;
+
+ if (max) {
+ //有最大值
+ fs.config.max = max;
+ }
+
+ //如果可搜索, 加上事件
+ if (isSearch) {
+ reElem.find('.' + INPUT).on('input propertychange', function (e) {
+ var input = e.target,
+ inputValue = $.trim(input.value),
+ keyCode = e.keyCode;
+ if (keyCode === 9 || keyCode === 13 || keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
+ return false;
+ }
+
+ //过滤一下tips
+ _this2.changePlaceHolder($(input));
+
+ var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+ searchUrl = ajaxConfig.searchUrl || searchUrl;
+ //如果开启了远程搜索
+ if (searchUrl) {
+ if (ajaxConfig.searchVal) {
+ inputValue = ajaxConfig.searchVal;
+ ajaxConfig.searchVal = '';
+ }
+ if (!ajaxConfig.beforeSearch || ajaxConfig.beforeSearch && ajaxConfig.beforeSearch instanceof Function && ajaxConfig.beforeSearch(id, searchUrl, inputValue)) {
+ var delay = ajaxConfig.delay;
+ if (ajaxConfig.first) {
+ ajaxConfig.first = false;
+ delay = 10;
+ }
+ clearTimeout(fs.clearid);
+ fs.clearid = setTimeout(function () {
+ reElem.find('dl > *:not(.' + FORM_SELECT_TIPS + ')').remove();
+ reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('请求中');
+ _this2.ajax(id, searchUrl, inputValue, false, null, true);
+ }, delay);
+ }
+ } else {
+ reElem.find('dl .layui-hide').removeClass('layui-hide');
+ //遍历选项, 选择可以显示的值
+ reElem.find('dl dd:not(.' + FORM_SELECT_TIPS + ')').each(function (idx, item) {
+ var _item = $(item);
+ var searchFun = data[id].config.filter || events.filter[id];
+ if (searchFun && searchFun(id, inputValue, {
+ name: _item.find('span').text(),
+ val: _item.attr('lay-value')
+ }, _item.hasClass(DISABLED)) == true) {
+ _item.addClass('layui-hide');
+ }
+ });
+ //控制分组名称
+ reElem.find('dl dt').each(function (index, item) {
+ if (!$(item).nextUntil('dt', ':not(.layui-hide)').length) {
+ $(item).addClass('layui-hide');
+ }
+ });
+ //动态创建
+ _this2.create(id, isCreate, inputValue);
+ var shows = reElem.find('dl dd:not(.' + FORM_SELECT_TIPS + '):not(.layui-hide)');
+ if (!shows.length) {
+ reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('无匹配项');
+ } else {
+ reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
+ }
+ }
+ });
+ if (searchUrl) {
+ //触发第一次请求事件
+ _this2.triggerSearch(reElem, true);
+ }
+ }
+ });
+ };
+
+ Common.prototype.isArray = function (obj) {
+ return Object.prototype.toString.call(obj) == "[object Array]";
+ };
+
+ Common.prototype.triggerSearch = function (div, isCall) {
+ (div ? [div] : $('.' + FORM_SELECT).toArray()).forEach(function (reElem, index) {
+ reElem = $(reElem);
+ var id = reElem.find('dl').attr('xid');
+ if (id && data[id] && data[id].config.isEmpty || isCall) {
+ var obj_caller = reElem.find('.' + INPUT)[0];
+ if (document.createEventObject) {
+ obj_caller.fireEvent("onchange");
+ } else {
+ var evt = document.createEvent("HTMLEvents");
+ evt.initEvent("input", false, true);
+ obj_caller.dispatchEvent(evt);
+ }
+ }
+ });
+ };
+
+ Common.prototype.ajax = function (id, searchUrl, inputValue, isLinkage, linkageWidth, isSearch) {
+ var _this3 = this;
+
+ var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
+ if (!reElem[0] || !searchUrl) {
+ return;
+ }
+
+ var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+ var ajaxData = $.extend(true, {}, ajaxConfig.data);
+ ajaxData[ajaxConfig.searchName] = inputValue;
+ ajaxData['_'] = Date.now();
+ $.ajax({
+ type: ajaxConfig.type,
+ headers: ajaxConfig.header,
+ url: searchUrl,
+ data: ajaxConfig.dataType == 'json' ? JSON.stringify(ajaxData) : ajaxData,
+ success: function success(res) {
+ if (typeof res == 'string') {
+ res = JSON.parse(res);
+ }
+ ajaxConfig.beforeSuccess && ajaxConfig.beforeSuccess instanceof Function && (res = ajaxConfig.beforeSuccess(id, searchUrl, inputValue, res));
+ if (_this3.isArray(res)) {
+ res = {
+ code: 0,
+ msg: "",
+ data: res
+ };
+ }
+ if (res.code != 0) {
+ reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text(res.msg);
+ } else {
+ reElem.find('dd.' + FORM_NONE).removeClass(FORM_EMPTY);
+ //获得已选择的values
+ _this3.renderData(id, res.data, isLinkage, linkageWidth, isSearch);
+ data[id].config.isEmpty = res.data.length == 0;
+ }
+ ajaxConfig.success && ajaxConfig.success instanceof Function && ajaxConfig.success(id, searchUrl, inputValue, res);
+ },
+ error: function error(err) {
+ reElem.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + ')').remove();
+ reElem.find('dd.' + FORM_NONE).addClass(FORM_EMPTY).text('服务异常');
+ ajaxConfig.error && ajaxConfig.error instanceof Function && ajaxConfig.error(id, searchUrl, inputValue, err);
+ }
+ });
+ };
+
+ Common.prototype.renderData = function (id, dataArr, linkage, linkageWidth, isSearch) {
+ var _this4 = this;
+
+ if (linkage) {
+ var _ret = function () {
+ //渲染多级联动
+ var result = [],
+ index = 0,
+ temp = { "0": dataArr },
+ ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+
+ var _loop = function _loop() {
+ var group = result[index++] = [],
+ _temp = temp;
+ temp = {};
+ $.each(_temp, function (pid, arr) {
+ $.each(arr, function (idx, item) {
+ var val = {
+ pid: pid,
+ name: item[ajaxConfig.keyName],
+ val: item[ajaxConfig.keyVal]
+ };
+ group.push(val);
+ var children = item[ajaxConfig.keyChildren];
+ if (children && children.length) {
+ temp[val.val] = children;
+ }
+ });
+ });
+ };
+
+ do {
+ _loop();
+ } while (Object.getOwnPropertyNames(temp).length);
+
+ var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
+ var html = [''];
+
+ $.each(result, function (idx, arr) {
+ var groupDiv = ['
'];
+ $.each(arr, function (idx2, item) {
+ var span = '
' + item.name + ' ';
+ groupDiv.push(span);
+ });
+ groupDiv.push('');
+ html = html.concat(groupDiv);
+ });
+ //
123
+ html.push('
');
+ html.push('
');
+ reElem.find('dl').html(html.join(''));
+ reElem.find('.' + INPUT).css('display', 'none'); //联动暂时不支持搜索
+ return {
+ v: void 0
+ };
+ }();
+
+ if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
+ }
+
+ var reElem = $('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT);
+ var ajaxConfig = ajaxs[id] ? ajaxs[id] : ajax;
+ var pcInput = reElem.find('.' + TDIV + ' input');
+
+ var values = [];
+ reElem.find('dl').html(this.renderSelect(id, pcInput.attr('placeholder') || pcInput.attr('back'), dataArr.map(function (item) {
+ if (item[ajaxConfig.keySel]) {
+ values.push({
+ name: item[ajaxConfig.keyName],
+ val: item[ajaxConfig.keyVal]
+ });
+ }
+ return {
+ innerHTML: item[ajaxConfig.keyName],
+ value: item[ajaxConfig.keyVal],
+ sel: item[ajaxConfig.keySel],
+ disabled: item[ajaxConfig.keyDis],
+ type: item.type,
+ name: item.name
+ };
+ })));
+
+ var label = reElem.find('.' + LABEL);
+ var dl = reElem.find('dl[xid]');
+ if (isSearch) {
+ //如果是远程搜索, 这里需要判重
+ var oldVal = data[id].values;
+ oldVal.forEach(function (item, index) {
+ dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
+ });
+ values.forEach(function (item, index) {
+ if (_this4.indexOf(oldVal, item) == -1) {
+ _this4.addLabel(id, label, item);
+ dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
+ oldVal.push(item);
+ }
+ });
+ } else {
+ values.forEach(function (item, index) {
+ _this4.addLabel(id, label, item);
+ dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
+ });
+ data[id].values = values;
+ }
+ this.commonHanler(id, label);
+ };
+
+ Common.prototype.create = function (id, isCreate, inputValue) {
+ if (isCreate && inputValue) {
+ var fs = data[id],
+ dl = $('[xid="' + id + '"]'),
+ tips = dl.find('dd.' + FORM_SELECT_TIPS + ':first'),
+ tdd = null,
+ temp = dl.find('dd.' + TEMP);
+ dl.find('dd:not(.' + FORM_SELECT_TIPS + '):not(.' + TEMP + ')').each(function (index, item) {
+ if (inputValue == $(item).find('span').text()) {
+ tdd = item;
+ }
+ });
+ if (!tdd) {
+ //如果不存在, 则创建
+ if (temp[0]) {
+ temp.attr('lay-value', inputValue);
+ temp.find('span').text(inputValue);
+ temp.removeClass('layui-hide');
+ } else {
+ tips.after($(this.createDD({
+ innerHTML: inputValue,
+ value: Date.now()
+ }, TEMP + ' ' + CREATE_LONG)));
+ }
+ }
+ } else {
+ $('[xid=' + id + '] dd.' + TEMP).remove();
+ }
+ };
+
+ Common.prototype.createDD = function (item, clz) {
+ return '\n\t\t\t\t\t\n\t\t\t\t\t\t' + $.trim(item.innerHTML) + ' \n\t\t\t\t\t\t \n\t\t\t\t\t
\n\t\t\t\t ';
+ };
+
+ Common.prototype.createQuickBtn = function (obj, right) {
+ return '' + obj.name + '
';
+ };
+
+ Common.prototype.renderBtns = function (id, show, right) {
+ var _this5 = this;
+
+ var quickBtn = [];
+ var dl = $('dl[xid="' + id + '"]');
+ quickBtn.push('');
+ $.each(data[id].config.btns, function (index, item) {
+ quickBtn.push(_this5.createQuickBtn(item, right));
+ });
+ quickBtn.push('
');
+ quickBtn.push(this.createQuickBtn({ icon: 'iconfont icon-caidan', name: '' }));
+ return quickBtn.join('');
+ };
+
+ Common.prototype.renderSelect = function (id, tips, select) {
+ var _this6 = this;
+
+ var arr = [];
+ if (data[id].config.btns.length) {
+ setTimeout(function () {
+ var dl = $('dl[xid="' + id + '"]');
+ dl.find('.' + CZ_GROUP).css('max-width', dl.prev().width() - 54 + 'px');
+ }, 10);
+ arr.push(['', this.renderBtns(id, null, '30px'), ' '].join(''));
+ } else {
+ arr.push('' + tips + ' ');
+ }
+ if (this.isArray(select)) {
+ $(select).each(function (index, item) {
+ if (item.type === 'optgroup') {
+ arr.push('' + item.name + ' ');
+ } else {
+ arr.push(_this6.createDD(item));
+ }
+ });
+ } else {
+ $(select).find('*').each(function (index, item) {
+ if (item.tagName.toLowerCase() == 'option' && index == 0 && !item.value) {
+ return;
+ }
+ if (item.tagName.toLowerCase() === 'optgroup') {
+ arr.push('' + item.label + ' ');
+ } else {
+ arr.push(_this6.createDD(item));
+ }
+ });
+ }
+ arr.push(' ');
+ arr.push('\u6CA1\u6709\u9009\u9879 ');
+ return arr.join('');
+ };
+
+ Common.prototype.on = function () {
+ var _this7 = this;
+
+ //事件绑定
+ this.one();
+
+ $(document).on('click', function (e) {
+ if (!$(e.target).parents('.' + FORM_TITLE)[0]) {
+ //清空input中的值
+ $('.' + INPUT).val('');
+ $('.' + PNAME + ' dl .layui-hide').removeClass('layui-hide');
+ $('.' + PNAME + ' dl dd.' + TEMP).remove();
+ _this7.triggerSearch();
+ }
+ $('.' + PNAME + ' .' + FORM_SELECTED).removeClass(FORM_SELECTED);
+ });
+ };
+
+ Common.prototype.one = function (target) {
+ var _this8 = this;
+
+ //一次性事件绑定
+ $(target ? target : document).find('.' + FORM_TITLE).off('click').on('click', function (e) {
+ var othis = $(e.target),
+ title = othis.is(FORM_TITLE) ? othis : othis.parents('.' + FORM_TITLE),
+ dl = title.next(),
+ id = dl.attr('xid');
+
+ //清空非本select的input val
+ $('dl[xid]').not(dl).prev().find('.' + INPUT).val('');
+ $('dl[xid]').not(dl).find('dd.layui-hide').removeClass('layui-hide');
+
+ //如果是disabled select
+ if (title.hasClass(DIS)) {
+ return false;
+ }
+ //如果点击的是右边的三角或者只读的input
+ if (othis.is('.' + SANJIAO) || othis.is('.' + INPUT + '[readonly]')) {
+ _this8.changeShow(title, !title.parents('.' + FORM_SELECT).hasClass(FORM_SELECTED));
+ return false;
+ }
+ //如果点击的是input的右边, focus一下
+ if (title.find('.' + INPUT + ':not(readonly)')[0]) {
+ var input = title.find('.' + INPUT),
+ epos = { x: e.pageX, y: e.pageY },
+ pos = _this8.getPosition(title[0]),
+ width = title.width();
+ while (epos.x > pos.x) {
+ if ($(document.elementFromPoint(epos.x, epos.y)).is(input)) {
+ input.focus();
+ _this8.changeShow(title, true);
+ return false;
+ }
+ epos.x -= 50;
+ }
+ }
+
+ //如果点击的是可搜索的input
+ if (othis.is('.' + INPUT)) {
+ _this8.changeShow(title, true);
+ return false;
+ }
+ //如果点击的是x按钮
+ if (othis.is('i[fsw="' + NAME + '"]')) {
+ var val = {
+ name: othis.prev().text(),
+ val: othis.parent().attr("value")
+ },
+ dd = dl.find('dd[lay-value=\'' + val.val + '\']');
+ if (dd.hasClass(DISABLED)) {
+ //如果是disabled状态, 不可选, 不可删
+ return false;
+ }
+ _this8.handlerLabel(id, dd, false, val);
+ return false;
+ }
+
+ _this8.changeShow(title, !title.parents('.' + FORM_SELECT).hasClass(FORM_SELECTED));
+ return false;
+ });
+ $(target ? target : document).find('dl.' + DL).off('click').on('click', function (e) {
+ var othis = $(e.target);
+ if (othis.is('.' + LINKAGE) || othis.parents('.' + LINKAGE)[0]) {
+ //linkage的处理
+ othis = othis.is('li') ? othis : othis.parents('li');
+ var _group = othis.parents('.xm-select-linkage-group'),
+ _id = othis.parents('dl').attr('xid');
+ //激活li
+ _group.find('.xm-select-active').removeClass('xm-select-active');
+ othis.addClass('xm-select-active');
+ //激活下一个group, 激活前显示对应数据
+ _group.nextAll('.xm-select-linkage-group').addClass('xm-select-linkage-hide');
+ var nextGroup = _group.next('.xm-select-linkage-group');
+ nextGroup.find('li').addClass('xm-select-linkage-hide');
+ nextGroup.find('li[pid="' + othis.attr('value') + '"]').removeClass('xm-select-linkage-hide');
+ //如果没有下一个group, 或没有对应的值
+ if (!nextGroup[0] || nextGroup.find('li:not(.xm-select-linkage-hide)').length == 0) {
+ var vals = [],
+ index = 0,
+ _isAdd = !othis.hasClass('xm-select-this');
+ if (data[_id].config.radio) {
+ othis.parents('.xm-select-linkage').find('.xm-select-this').removeClass('xm-select-this');
+ }
+ do {
+ vals[index++] = {
+ name: othis.find('span').text(),
+ val: othis.attr('value')
+ /*isAdd ? (
+ othis.addClass('xm-select-this')
+ ) : (
+ !othis.parent('.xm-select-linkage-group').next().find(`li[pid="${othis.attr('value')}"].xm-select-this`).length && othis.removeClass('xm-select-this')
+ );*/
+ };othis = othis.parents('.xm-select-linkage-group').prev().find('li[value="' + othis.attr('pid') + '"]');
+ } while (othis.length);
+ vals.reverse();
+ var val = {
+ name: vals.map(function (item) {
+ return item.name;
+ }).join('/'),
+ val: vals.map(function (item) {
+ return item.val;
+ }).join('/')
+ };
+ _this8.handlerLabel(_id, null, _isAdd, val);
+ } else {
+ nextGroup.removeClass('xm-select-linkage-hide');
+ }
+ return false;
+ } //xm-select-this xm-select-active
+
+ if (othis.is('dt') || othis.is('dl')) {
+ return false;
+ }
+ var dd = othis.is('dd') ? othis : othis.parents('dd');
+ var id = dd.parent('dl').attr('xid');
+ if (dd.hasClass(DISABLED)) {
+ //被禁用选项的处理
+ return false;
+ }
+ if (dd.hasClass(FORM_SELECT_TIPS)) {
+ //tips的处理
+ var btn = othis.is('.' + CZ) ? othis : othis.parents('.' + CZ);
+ if (!btn[0]) {
+ return false;
+ }
+ //TODO 快捷操作
+ var method = btn.attr('method');
+ var obj = data[id].config.btns.filter(function (bean) {
+ return bean.name == method;
+ })[0];
+ obj && obj.click && obj.click instanceof Function && obj.click(id, _this8);
+ return false;
+ }
+ var isAdd = !dd.hasClass(THIS);
+ _this8.handlerLabel(id, dd, isAdd);
+ return false;
+ });
+ };
+
+ Common.prototype.linkageAdd = function (id, val) {
+ var dl = $('dl[xid="' + id + '"]');
+ dl.find('.xm-select-active').removeClass('xm-select-active');
+ var vs = val.val.split('/');
+ var pid = void 0,
+ li = void 0,
+ index = 0;
+ var lis = [];
+ do {
+ pid = vs[index];
+ li = dl.find('.xm-select-linkage-group' + (index + 1) + ' li[value="' + pid + '"]');
+ li[0] && lis.push(li);
+ index++;
+ } while (li.length && pid != undefined);
+ if (lis.length == vs.length) {
+ $.each(lis, function (idx, item) {
+ item.addClass('xm-select-this');
+ });
+ }
+ };
+
+ Common.prototype.linkageDel = function (id, val) {
+ var dl = $('dl[xid="' + id + '"]');
+ var vs = val.val.split('/');
+ var pid = void 0,
+ li = void 0,
+ index = vs.length - 1;
+ do {
+ pid = vs[index];
+ li = dl.find('.xm-select-linkage-group' + (index + 1) + ' li[value="' + pid + '"]');
+ if (!li.parent().next().find('li[pid=' + pid + '].xm-select-this').length) {
+ li.removeClass('xm-select-this');
+ }
+ index--;
+ } while (li.length && pid != undefined);
+ };
+
+ Common.prototype.valToName = function (id, val) {
+ var dl = $('dl[xid="' + id + '"]');
+ var vs = (val + "").split('/');
+ var names = [];
+ $.each(vs, function (idx, item) {
+ var name = dl.find('.xm-select-linkage-group' + (idx + 1) + ' li[value="' + item + '"] span').text();
+ names.push(name);
+ });
+ return names.length == vs.length ? names.join('/') : null;
+ };
+
+ Common.prototype.commonHanler = function (key, label) {
+ //计算input的提示语
+ this.changePlaceHolder(label);
+ //计算高度
+ this.retop(label.parents('.' + FORM_SELECT));
+ this.checkHideSpan(label);
+ this.calcLeft(key, label);
+ //表单默认值
+ label.parents('.' + PNAME).find('.' + HIDE_INPUT).val(data[key].values.map(function (val) {
+ return val.val;
+ }).join(','));
+ //title值
+ label.parents('.' + FORM_TITLE + ' .' + NAME).attr('title', data[key].values.map(function (val) {
+ return val.name;
+ }).join(','));
+ };
+
+ Common.prototype.initVal = function (id) {
+ var _this9 = this;
+
+ var target = {};
+ if (id) {
+ target[id] = data[id];
+ } else {
+ target = data;
+ }
+ $.each(target, function (key, val) {
+ var values = val.values,
+ div = $('dl[xid="' + key + '"]').parent(),
+ label = div.find('.' + LABEL),
+ dl = div.find('dl');
+ dl.find('dd.' + THIS).removeClass(THIS);
+
+ var _vals = values.concat([]);
+ _vals.concat([]).forEach(function (item, index) {
+ _this9.addLabel(key, label, item);
+ dl.find('dd[lay-value="' + item.val + '"]').addClass(THIS);
+ });
+ if (val.config.radio) {
+ _vals.length && values.push(_vals[_vals.length - 1]);
+ }
+ _this9.commonHanler(key, label);
+ });
+ };
+
+ Common.prototype.handlerLabel = function (id, dd, isAdd, oval, notOn) {
+ var div = $('[xid="' + id + '"]').prev().find('.' + LABEL),
+ val = dd && {
+ name: dd.find('span').text(),
+ val: dd.attr('lay-value')
+ },
+ vals = data[id].values,
+ on = data[id].config.on || events.on[id];
+ if (oval) {
+ val = oval;
+ }
+ var fs = data[id];
+ if (isAdd && fs.config.max && fs.values.length >= fs.config.max) {
+ var maxTipsFun = data[id].config.maxTips || events.maxTips[id];
+ maxTipsFun && maxTipsFun(id, vals.concat([]), val, fs.max);
+ return;
+ }
+ if (!notOn) {
+ if (on && on instanceof Function && on(id, vals.concat([]), val, isAdd, dd && dd.hasClass(DISABLED) == false)) {
+ return;
+ }
+ }
+ var dl = $('dl[xid="' + id + '"]');
+ isAdd ? (dd && dd[0] ? (dd.addClass(THIS), dd.removeClass(TEMP)) : dl.find('.xm-select-linkage')[0] && this.linkageAdd(id, val), this.addLabel(id, div, val), vals.push(val)) : (dd && dd[0] ? dd.removeClass(THIS) : dl.find('.xm-select-linkage')[0] && this.linkageDel(id, val), this.delLabel(id, div, val), this.remove(vals, val));
+ if (!div[0]) return;
+ //单选选完后直接关闭选择域
+ if (fs.config.radio) {
+ this.changeShow(div, false);
+ }
+ //移除表单验证的红色边框
+ div.parents('.' + FORM_TITLE).prev().removeClass('layui-form-danger');
+
+ //清空搜索值
+ fs.config.clearInput && div.parents('.' + PNAME).find('.' + INPUT).val('');
+
+ this.commonHanler(id, div);
+ };
+
+ Common.prototype.addLabel = function (id, div, val) {
+ if (!val) return;
+ var tips = 'fsw="' + NAME + '"';
+ var _ref = [$('' + val.name + ' '), $('\xD7 ')],
+ $label = _ref[0],
+ $close = _ref[1];
+
+ $label.append($close);
+ //如果是radio模式
+ var fs = data[id];
+ if (fs.config.radio) {
+ fs.values.length = 0;
+ $('dl[xid="' + id + '"]').find('dd.' + THIS + ':not([lay-value="' + val.val + '"])').removeClass(THIS);
+ div.find('span').remove();
+ }
+ //如果是固定高度
+ if (fs.config.height) {
+ div.append($label);
+ } else {
+ div.find('input').css('width', '50px');
+ div.find('input').before($label);
+ }
+ };
+
+ Common.prototype.delLabel = function (id, div, val) {
+ if (!val) return;
+ div.find('span[value="' + val.val + '"]:first').remove();
+ };
+
+ Common.prototype.calcLeft = function (id, div) {
+ if (data[id].config.height) {
+ var showLastSpan = div.find('span:not(.xm-span-hide):last')[0];
+ div.next().css('left', (showLastSpan ? this.getPosition(showLastSpan).x - this.getPosition(div[0]).x + showLastSpan.offsetWidth + 20 : 10) + 'px');
+ }
+ };
+
+ Common.prototype.checkHideSpan = function (div) {
+ var _this10 = this;
+
+ var parentHeight = div.parents('.' + NAME)[0].offsetHeight + 5;
+ div.find('span.xm-span-hide').removeClass('xm-span-hide');
+ div.find('span').each(function (index, item) {
+ if (item.offsetHeight + item.offsetTop > parentHeight || _this10.getPosition(item).y + item.offsetHeight > _this10.getPosition(div[0]).y + div[0].offsetHeight + 5) {
+ $(item).addClass('xm-span-hide');
+ }
+ });
+ };
+
+ Common.prototype.retop = function (div) {
+ //计算dl显示的位置
+ var dl = div.find('dl'),
+ top = div.offset().top + div.outerHeight() + 5 - $win.scrollTop(),
+ dlHeight = dl.outerHeight();
+ var up = div.hasClass('layui-form-selectup') || dl.css('top').indexOf('-') != -1 || top + dlHeight > $win.height() && top >= dlHeight;
+ div = div.find('.' + NAME);
+
+ var fs = data[dl.attr('xid')];
+ var base = dl.parents('.layui-form-pane')[0] && dl.prev()[0].clientHeight > 38 ? 14 : 10;
+ if (fs) {
+ if (fs.config.direction == 'up') {
+ dl.css({
+ top: 'auto',
+ bottom: '42px'
+ });
+ return;
+ }
+ if (fs.direction == 'down') {
+ dl.css({
+ top: div[0].offsetTop + div.height() + base + 'px',
+ bottom: 'auto'
+ });
+ return;
+ }
+ }
+
+ if (up) {
+ dl.css({
+ top: 'auto',
+ bottom: '42px'
+ });
+ } else {
+ dl.css({
+ top: div[0].offsetTop + div.height() + base + 'px',
+ bottom: 'auto'
+ });
+ }
+ };
+
+ Common.prototype.changeShow = function (children, isShow) {
+ //显示于隐藏
+ var top = children.parents('.' + FORM_SELECT);
+ $('.' + PNAME + ' .' + FORM_SELECT).not(top).removeClass(FORM_SELECTED);
+ if (isShow) {
+ this.retop(top);
+ top.addClass(FORM_SELECTED);
+ top.find('.' + INPUT).focus();
+ } else {
+ top.removeClass(FORM_SELECTED);
+ top.find('.' + INPUT).val('');
+ top.find('dl .layui-hide').removeClass('layui-hide');
+ top.find('dl dd.' + TEMP).remove();
+ //计算ajax数据是否为空, 然后重新请求数据
+ var id = top.find('dl').attr('xid');
+ if (id && data[id] && data[id].config.isEmpty) {
+ this.triggerSearch(top);
+ }
+ }
+ };
+
+ Common.prototype.changePlaceHolder = function (div) {
+ //显示于隐藏提示语
+ //调整pane模式下的高度
+ var title = div.parents('.' + FORM_TITLE);
+
+ var id = div.parents('.' + PNAME).find('dl[xid]').attr('xid');
+ if (data[id] && data[id].config.height) {//既然固定高度了, 那就看着办吧
+
+ } else {
+ var height = title.find('.' + NAME)[0].clientHeight;
+ title.css('height', (height > 34 ? height + 4 : height) + 'px');
+ //如果是layui pane模式, 处理label的高度
+ var label = title.parents('.' + PNAME).parent().prev();
+ if (label.is('.layui-form-label') && title.parents('.layui-form-pane')[0]) {
+ height = height > 36 ? height + 4 : height;
+ title.css('height', height + 'px');
+ label.css({
+ height: height + 2 + 'px',
+ lineHeight: height - 18 + 'px'
+ });
+ }
+ }
+
+ var input = title.find('.' + TDIV + ' input'),
+ isShow = !div.find('span:last')[0] && !title.find('.' + INPUT).val();
+ if (isShow) {
+ var ph = input.attr('back');
+ input.removeAttr('back');
+ input.attr('placeholder', ph);
+ } else {
+ var _ph = input.attr('placeholder');
+ input.removeAttr('placeholder');
+ input.attr('back', _ph);
+ }
+ };
+
+ Common.prototype.indexOf = function (arr, val) {
+ for (var i = 0; i < arr.length; i++) {
+ if (arr[i].val == val || arr[i].val == (val ? val.val : val) || arr[i] == val || JSON.stringify(arr[i]) == JSON.stringify(val)) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+ Common.prototype.remove = function (arr, val) {
+ var idx = this.indexOf(arr, val ? val.val : val);
+ if (idx > -1) {
+ arr.splice(idx, 1);
+ return true;
+ }
+ return false;
+ };
+
+ Common.prototype.selectAll = function (id, isOn, skipDis) {
+ var _this11 = this;
+
+ var dl = $('[xid="' + id + '"]');
+ if (dl.find('.xm-select-linkage')[0]) {
+ return;
+ }
+ dl.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + '):not(.' + THIS + ')' + (skipDis ? ':not(.' + DISABLED + ')' : '')).each(function (index, item) {
+ item = $(item);
+ var val = {
+ name: item.find('span').text(),
+ val: item.attr('lay-value')
+ };
+ _this11.handlerLabel(id, dl.find('dd[lay-value="' + val.val + '"]'), true, val, !isOn);
+ });
+ };
+
+ Common.prototype.removeAll = function (id, isOn, skipDis) {
+ var _this12 = this;
+
+ var dl = $('[xid="' + id + '"]');
+ if (dl.find('.xm-select-linkage')[0]) {
+ //针对多级联动的处理
+ data[id].values.concat([]).forEach(function (item, idx) {
+ var vs = item.val.split('/');
+ var pid = void 0,
+ li = void 0,
+ index = 0;
+ do {
+ pid = vs[index++];
+ li = dl.find('.xm-select-linkage-group' + index + ':not(.xm-select-linkage-hide) li[value="' + pid + '"]');
+ li.click();
+ } while (li.length && pid != undefined);
+ });
+ return;
+ }
+ data[id].values.concat([]).forEach(function (item, index) {
+ if (skipDis && dl.find('dd[lay-value="' + item.val + '"]').hasClass(DISABLED)) {} else {
+ _this12.handlerLabel(id, dl.find('dd[lay-value="' + item.val + '"]'), false, item, !isOn);
+ }
+ });
+ };
+
+ Common.prototype.reverse = function (id, isOn, skipDis) {
+ var _this13 = this;
+
+ var dl = $('[xid="' + id + '"]');
+ if (dl.find('.xm-select-linkage')[0]) {
+ return;
+ }
+ dl.find('dd[lay-value]:not(.' + FORM_SELECT_TIPS + ')' + (skipDis ? ':not(.' + DISABLED + ')' : '')).each(function (index, item) {
+ item = $(item);
+ var val = {
+ name: item.find('span').text(),
+ val: item.attr('lay-value')
+ };
+ _this13.handlerLabel(id, dl.find('dd[lay-value="' + val.val + '"]'), !item.hasClass(THIS), val, !isOn);
+ });
+ };
+
+ Common.prototype.skin = function (id) {
+ var skins = ['default', 'primary', 'normal', 'warm', 'danger'];
+ var skin = skins[Math.floor(Math.random() * skins.length)];
+ $('dl[xid="' + id + '"]').parents('.' + PNAME).find('.' + FORM_SELECT).attr('xm-select-skin', skin);
+ this.commonHanler(id, $('dl[xid="' + id + '"]').parents('.' + PNAME).find('.' + LABEL));
+ };
+
+ Common.prototype.getPosition = function (e) {
+ var x = 0,
+ y = 0;
+ while (e != null) {
+ x += e.offsetLeft;
+ y += e.offsetTop;
+ e = e.offsetParent;
+ }
+ return { x: x, y: y };
+ };
+
+ Common.prototype.onreset = function () {
+ //监听reset按钮, 然后重置多选
+ $(document).on('click', '[type=reset]', function (e) {
+ $(e.target).parents('form').find('.' + PNAME + ' dl[xid]').each(function (index, item) {
+ var id = item.getAttribute('xid'),
+ dl = $(item),
+ dd = void 0,
+ temp = {};
+ common.removeAll(id);
+ data[id].config.init.forEach(function (val, idx) {
+ if (val && (!temp[val] || data[id].config.repeat) && (dd = dl.find('dd[lay-value="' + val.val + '"]'))[0]) {
+ common.handlerLabel(id, dd, true);
+ temp[val] = 1;
+ }
+ });
+ });
+ });
+ };
+
+ Common.prototype.loadingCss = function () {};
+
+ Common.prototype.listening = function () {
+ //TODO 用于监听dom结构变化, 如果出现新的为渲染select, 则自动进行渲染
+ var flag = false;
+ var index = 0;
+ $(document).on('DOMNodeInserted', function (e) {
+ if (flag) {
+ //避免递归渲染
+ return;
+ }
+ flag = true;
+ //渲染select
+ $('select[' + NAME + ']').each(function (index, select) {
+ var sid = select.getAttribute(NAME);
+ common.init(select);
+ common.one($('dl[xid="' + sid + '"]').parents('.' + PNAME));
+ common.initVal(sid);
+ });
+
+ flag = false;
+ });
+ };
+
+ var Select4 = function Select4() {
+ this.v = v;
+ };
+ var common = new Common();
+
+ Select4.prototype.value = function (id, type, isAppend) {
+ if (typeof id != 'string') {
+ return [];
+ }
+ var fs = data[id];
+ if (!fs) {
+ return [];
+ }
+ if (typeof type == 'string' || type == undefined) {
+ var arr = fs.values.concat([]) || [];
+ if (type == 'val') {
+ return arr.map(function (val) {
+ return val.val;
+ });
+ }
+ if (type == 'valStr') {
+ return arr.map(function (val) {
+ return val.val;
+ }).join(',');
+ }
+ if (type == 'name') {
+ return arr.map(function (val) {
+ return val.name;
+ });
+ }
+ if (type == 'nameStr') {
+ return arr.map(function (val) {
+ return val.name;
+ }).join(',');
+ }
+ return arr;
+ }
+ if (common.isArray(type)) {
+ var dl = $('[xid="' + id + '"]'),
+ temp = {},
+ dd = void 0,
+ isAdd = true;
+ if (isAppend == false) {
+ //删除传入的数组
+ isAdd = false;
+ } else if (isAppend == true) {
+ //追加模式
+ isAdd = true;
+ } else {
+ //删除原有的数据
+ common.removeAll(id);
+ }
+ if (isAdd) {
+ fs.values.forEach(function (val, index) {
+ temp[val.val] = 1;
+ });
+ }
+ type.forEach(function (val, index) {
+ if (val && (!temp[val] || fs.config.repeat)) {
+ if ((dd = dl.find('dd[lay-value="' + val + '"]'))[0]) {
+ common.handlerLabel(id, dd, isAdd, null, true);
+ temp[val] = 1;
+ } else {
+ var name = common.valToName(id, val);
+ if (name) {
+ common.handlerLabel(id, dd, isAdd, {
+ name: name,
+ val: val
+ }, true);
+ temp[val] = 1;
+ }
+ }
+ }
+ });
+ }
+ };
+
+ Common.prototype.bindEvent = function (name, id, fun) {
+ if (id && id instanceof Function) {
+ fun = id;
+ id = null;
+ }
+ if (fun && fun instanceof Function) {
+ if (!id) {
+ $.each(data, function (id, val) {
+ data[id] ? data[id].config[name] = fun : events[name][id] = fun;
+ });
+ } else {
+ data[id] ? data[id].config[name] = fun : events[name][id] = fun;
+ }
+ }
+ };
+
+ Select4.prototype.on = function (id, fun) {
+ common.bindEvent('on', id, fun);
+ return this;
+ };
+
+ Select4.prototype.filter = function (id, fun) {
+ common.bindEvent('filter', id, fun);
+ return this;
+ };
+
+ Select4.prototype.maxTips = function (id, fun) {
+ common.bindEvent('maxTips', id, fun);
+ return this;
+ };
+
+ Select4.prototype.config = function (id, config, isJson) {
+ if (id && (typeof id === 'undefined' ? 'undefined' : _typeof(id)) == 'object') {
+ isJson = config == true;
+ config = id;
+ id = null;
+ }
+ if (config && (typeof config === 'undefined' ? 'undefined' : _typeof(config)) == 'object') {
+ if (isJson) {
+ config.header || (config.header = {});
+ config.header['Content-Type'] = 'application/json; charset=UTF-8';
+ config.dataType = 'json';
+ }
+ id ? (ajaxs[id] = $.extend(true, {}, ajax, config), data[id] && (data[id].config.direction = config.direction), config.searchUrl && data[id] && common.triggerSearch($('.' + PNAME + ' dl[xid="' + id + '"]').parents('.' + FORM_SELECT), true)) : $.extend(true, ajax, config);
+ }
+ return this;
+ };
+
+ Select4.prototype.render = function (id) {
+ var _this14 = this;
+
+ var target = {};
+ id ? data[id] && (target[id] = data[id]) : data;
+
+ if (Object.getOwnPropertyNames(target).length) {
+ $.each(target, function (key, val) {
+ //恢复初始值
+ var dl = $('dl[xid="' + key + '"]'),
+ vals = [];
+ val.select.find('option[selected]').each(function (index, item) {
+ vals.push(item.value);
+ });
+ //移除创建元素
+ dl.find('.' + CREATE_LONG).remove();
+ //清空INPUT
+ dl.prev().find('.' + INPUT).val('');
+ //触发search
+ common.triggerSearch(dl.parents('.' + FORM_SELECT), true);
+ //移除hidn
+ dl.find('.layui-hide').removeClass('layui-hide');
+ //重新赋值
+ _this14.value(key, vals);
+ });
+ }
+ ($('select[' + NAME + '="' + id + '"]')[0] ? $('select[' + NAME + '="' + id + '"]') : $('select[' + NAME + ']')).each(function (index, select) {
+ var sid = select.getAttribute(NAME);
+ common.init(select);
+ common.one($('dl[xid="' + sid + '"]').parents('.' + PNAME));
+ common.initVal(sid);
+ });
+ return this;
+ };
+
+ Select4.prototype.disabled = function (id) {
+ var target = {};
+ id ? data[id] && (target[id] = data[id]) : target = data;
+
+ $.each(target, function (key, val) {
+ $('dl[xid="' + key + '"]').prev().addClass(DIS);
+ });
+ return this;
+ };
+
+ Select4.prototype.undisabled = function (id) {
+ var target = {};
+ id ? data[id] && (target[id] = data[id]) : target = data;
+
+ $.each(target, function (key, val) {
+ $('dl[xid="' + key + '"]').prev().removeClass(DIS);
+ });
+ return this;
+ };
+
+ Select4.prototype.data = function (id, type, config) {
+ if (!id || !type || !config) {
+ return this;
+ }
+ //检测该id是否尚未渲染
+ !data[id] && this.render(id).value(id, []);
+ this.config(id, config);
+ if (type == 'local') {
+ common.renderData(id, config.arr, config.linkage == true, config.linkageWidth ? config.linkageWidth : '100');
+ } else if (type == 'server') {
+ common.ajax(id, config.url, config.keyword, config.linkage == true, config.linkageWidth ? config.linkageWidth : '100');
+ }
+ return this;
+ };
+
+ Select4.prototype.btns = function (id, btns, config) {
+ if (!btns || !common.isArray(btns)) {
+ return this;
+ };
+ var target = {};
+ id ? data[id] && (target[id] = data[id]) : target = data;
+
+ btns = btns.map(function (obj) {
+ if (typeof obj == 'string') {
+ if (obj == 'select') {
+ return quickBtns[0];
+ }
+ if (obj == 'remove') {
+ return quickBtns[1];
+ }
+ if (obj == 'reverse') {
+ return quickBtns[2];
+ }
+ if (obj == 'skin') {
+ return quickBtns[3];
+ }
+ }
+ return obj;
+ });
+
+ $.each(target, function (key, val) {
+ val.config.btns = btns;
+ var dd = $('dl[xid="' + key + '"]').find('.' + FORM_SELECT_TIPS + ':first');
+ if (btns.length) {
+ var show = config && config.show && (config.show == 'name' || config.show == 'icon') ? config.show : '';
+ var html = common.renderBtns(key, show, config && config.space ? config.space : '30px');
+ dd.html(html);
+ } else {
+ var pcInput = dd.parents('.' + FORM_SELECT).find('.' + TDIV + ' input');
+ var _html = pcInput.attr('placeholder') || pcInput.attr('back');
+ dd.html(_html);
+ dd.removeAttr('style');
+ }
+ });
+
+ return this;
+ };
+
+ Select4.prototype.search = function (id, val) {
+ if (id && data[id]) {
+ ajaxs[id] = $.extend(true, {}, ajax, {
+ first: true,
+ searchVal: val
+ });
+ common.triggerSearch($('dl[xid="' + id + '"]').parents('.' + FORM_SELECT), true);
+ }
+ return this;
+ };
+
+ return new Select4();
});
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/module/index.js b/zlt-web/layui-web/src/main/resources/static/module/index.js
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/module/index.js
rename to zlt-web/layui-web/src/main/resources/static/module/index.js
index 183a5f3c..7bb9e6fa 100644
--- a/zlt-web/back-web/src/main/resources/static/module/index.js
+++ b/zlt-web/layui-web/src/main/resources/static/module/index.js
@@ -1,291 +1,291 @@
-//add by owen 修复 path 无法引用http://页面的问题 begin
-String.prototype.startWith = function(str) {
- if (str == null || str == "" || this.length == 0
- || str.length > this.length)
- return false;
- if (this.substr(0, str.length) == str)
- return true;
- else
- return false;
- return true;
-}
-
-
-function initIFrame() {
- var $parent = $(".admin-iframe").parent();
- if ($parent.hasClass('layui-body')) {
- $parent.addClass('admin-iframe-body');
- return;
- }
- if ($parent.hasClass('layui-tab-item')) {
- $parent.css({'padding': '0', 'overflow-y': 'hidden'});
- } else {
- $parent.css({'width': '100%', 'height': '100%'});
- }
-}
-//add by owen 修复 path 无法引用http://页面的问题 end
-
-layui.define(['config', 'admin', 'layer', 'laytpl', 'element', 'form'], function (exports) {
- var $ = layui.$;
- var config = layui.config;
- var admin = layui.admin;
- var layer = layui.layer;
- var laytpl = layui.laytpl;
- var element = layui.element;
- var form = layui.form;
-
- var index = {
- // 渲染左侧菜单栏
- initLeftNav: function () {
- admin.req('api-user/menus/current', {}, function (data) {
- //data = data[1];
- admin.putTempData("menus",data);
- var menus = data;
- // 判断权限
- for (var i = menus.length - 1; i >= 0; i--) {
- var tempMenu = menus[i];
- if (tempMenu.auth && !admin.hasPerm(tempMenu.auth)) {
- menus.splice(i, 1);
- continue;
- }
- if (!tempMenu.subMenus) {
- continue;
- }
- for (var j = tempMenu.subMenus.length - 1; j >= 0; j--) {
- var jMenus = tempMenu.subMenus[j];
- if (jMenus.auth && !admin.hasPerm(jMenus.auth)) {
- tempMenu.subMenus.splice(j, 1);
- continue;
- }
- if (!jMenus.subMenus) {
- continue;
- }
- for (var k = jMenus.subMenus.length - 1; k >= 0; k--) {
- if (jMenus.subMenus[k].auth && !admin.hasPerm(jMenus.subMenus[k].auth)) {
- jMenus.subMenus.splice(k, 1);
- continue;
- }
- }
- }
- }
- // 去除空的目录
- for (var i = menus.length - 1; i >= 0; i--) {
- var tempMenu = menus[i];
- if (tempMenu.subMenus && tempMenu.subMenus.length <= 0) {
- menus.splice(i, 1);
- continue;
- }
- if (!tempMenu.subMenus) {
- continue;
- }
- for (var j = tempMenu.subMenus.length - 1; j >= 0; j--) {
- var jMenus = tempMenu.subMenus[j];
- if (jMenus.subMenus && jMenus.subMenus.length <= 0) {
- tempMenu.splice(j, 1);
- continue;
- }
- }
- }
- // 渲染
- $('.layui-layout-admin .layui-side').load('pages/side.html', function () {
- laytpl(sideNav.innerHTML).render(menus, function (html) {
- $('#sideNav').after(html);
- });
- element.render('nav');
- admin.activeNav(Q.lash);
- });
-
-
- }, 'GET');
- },
- // 路由注册
- initRouter: function () {
-
- index.regRouter(admin.getTempData("menus"));
- // index.regRouter(config.menus);
- Q.reg('console', function () {
- var menuPath = 'pages/console.html'
- index.loadView('console', menuPath, '主页');
- });
-
- Q.init({
- index: 'console'
- });
- },
- // 使用递归循环注册
- regRouter: function (menus) {
- $.each(menus, function (i, data) {
- if (data.url && data.url.indexOf('#!') == 0) {
- Q.reg(data.url.substring(2), function () {
- if (data.path.startWith("http://")) {
- window.open(data.path);
- } else {
- //临时保存url
- data.path.startWith("http://") ? admin.putTempData("params",data.path) : null ;
-
- var menuId = data.url.substring(2);
- //add by owen 修复 path 无法引用http://页面的问题
- var menuPath = data.path.startWith("http://") ? 'pages/tpl/iframe.html' : 'pages/' + data.path
- index.loadView(menuId, menuPath, data.name);
- }
- });
- }
- if (data.subMenus) {
- index.regRouter(data.subMenus);
- }
- });
- },
- // 路由加载组件
- loadView: function (menuId, menuPath, menuName) {
- var contentDom = '.layui-layout-admin .layui-body';
- admin.showLoading('.layui-layout-admin .layui-body');
- var flag; // 选项卡是否添加
- flag = menuPath.startWith("http://") ? false : flag ;
- // 判断是否开启了选项卡功能
- if (config.pageTabs) {
- $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title>li').each(function (index) {
- if ($(this).attr('lay-id') === menuId) {
- flag = true;
- }
- });
- if (!flag) {
- element.tabAdd('admin-pagetabs', {
- title: menuName,
- //add by owen 修复 path 无法引用http://页面的问题
- content: menuPath.startWith("http://") ? '
' : '' ,
- id: menuId
- });
- }
- contentDom = '#' + menuId;
- element.tabChange('admin-pagetabs', menuId);
- admin.rollPage('auto');
- // 切换tab关闭表格内浮窗
- $('.layui-table-tips-c').trigger('click');
- // 解决切换tab滚动条时而消失的问题
- var $iframe = $('.layui-layout-admin .layui-body .layui-tab-content .layui-tab-item.layui-show .admin-iframe')[0];
- if ($iframe) {
- $iframe.style.height = "99%";
- $iframe.scrollWidth;
- $iframe.style.height = "100%";
- }
- }
- if (!flag || admin.isRefresh) {
- $(contentDom).load(menuPath, function () {
- admin.isRefresh = false;
- element.render('breadcrumb');
- form.render('select');
- admin.removeLoading('.layui-layout-admin .layui-body');
- });
- } else {
- admin.removeLoading('.layui-layout-admin .layui-body');
- }
- admin.activeNav(Q.lash);
- // 移动设备切换页面隐藏侧导航
- if (document.body.clientWidth <= 750) {
- admin.flexible(true);
- }
- },
- // 从服务器获取登录用户的信息
- getUser: function (success) {
- layer.load(2);
- admin.req('api-user/users/current', {}, function (data) {
- layer.closeAll('loading');
- if (data && data.resp_code === 0) {
- let user = data.datas;
- config.putUser(user);
- admin.putTempData("permissions",user.permissions);
- success(user);
- } else {
- layer.msg('获取用户失败', {icon: 2});
- config.removeToken();
- location.replace('login.html');
- }
- }, 'GET');
- },
- //获取菜单
- getMenus: function () {
- admin.req('api-user/menus/current', {}, function (data) {
- admin.putTempData("menus",data);
- }, 'GET');
- },
- // 页面元素绑定事件监听
- bindEvent: function () {
- // 退出登录
- $('#btnLogout').click(function () {
- layer.confirm('确定退出登录?', function () {
- let token = config.getToken();
- let isExistsToken = false;
- if (token) {
- let accessToken = token.access_token;
- config.removeToken();
-
- if (accessToken) {
- isExistsToken = true;
- admin.req('api-uaa/oauth/check_token?token='+accessToken, {}, function (data) {
- if (data.active) {
- let loginPageUrl = window.location.protocol + '//' + window.location.host + '/login.html';
- window.location = config.base_server + 'api-uaa/oauth/remove/token?redirect_uri='+loginPageUrl+'&access_token='+accessToken;
- } else {
- location.replace('login.html');
- }
- }, 'POST');
- }
- }
- if (!isExistsToken) {
- location.replace('login.html');
- }
- });
- });
- // 修改密码
- $('#setPsw').click(function () {
- admin.popupRight('pages/tpl/password.html');
- });
- // 个人信息
- $('#setInfo').click(function () {
- Q.go('myInfo');
- });
- // 消息
- $('#btnMessage').click(function () {
- admin.popupRight('pages/tpl/message.html');
- });
- },
- // 检查多标签功能是否开启
- checkPageTabs: function () {
- // 加载主页
- if (config.pageTabs) {
- $('.layui-layout-admin').addClass('open-tab');
- element.tabAdd('admin-pagetabs', {
- title: ' ',
- content: '
',
- id: 'console'
- });
- $('#console').load('pages/console.html', function () {
- });
- } else {
- $('.layui-layout-admin').removeClass('open-tab');
- }
- },
- // 打开新页面
- openNewTab: function (param) {
- var url = param.url;
- var title = param.title;
- var menuId = param.menuId;
- if (!menuId) {
- menuId = url.replace(/[?:=&/]/g, '_');
- }
- index.loadView(menuId, url, title);
- },
- // 关闭选项卡
- closeTab: function (menuId) {
- element.tabDelete('admin-pagetabs', menuId);
- }
- };
-
- // tab选项卡切换监听
- element.on('tab(admin-pagetabs)', function (data) {
- var layId = $(this).attr('lay-id');
- Q.go(layId);
- });
-
- exports('index', index);
-});
+//add by owen 修复 path 无法引用http://页面的问题 begin
+String.prototype.startWith = function(str) {
+ if (str == null || str == "" || this.length == 0
+ || str.length > this.length)
+ return false;
+ if (this.substr(0, str.length) == str)
+ return true;
+ else
+ return false;
+ return true;
+}
+
+
+function initIFrame() {
+ var $parent = $(".admin-iframe").parent();
+ if ($parent.hasClass('layui-body')) {
+ $parent.addClass('admin-iframe-body');
+ return;
+ }
+ if ($parent.hasClass('layui-tab-item')) {
+ $parent.css({'padding': '0', 'overflow-y': 'hidden'});
+ } else {
+ $parent.css({'width': '100%', 'height': '100%'});
+ }
+}
+//add by owen 修复 path 无法引用http://页面的问题 end
+
+layui.define(['config', 'admin', 'layer', 'laytpl', 'element', 'form'], function (exports) {
+ var $ = layui.$;
+ var config = layui.config;
+ var admin = layui.admin;
+ var layer = layui.layer;
+ var laytpl = layui.laytpl;
+ var element = layui.element;
+ var form = layui.form;
+
+ var index = {
+ // 渲染左侧菜单栏
+ initLeftNav: function () {
+ admin.req('api-user/menus/current', {}, function (data) {
+ //data = data[1];
+ admin.putTempData("menus",data);
+ var menus = data;
+ // 判断权限
+ for (var i = menus.length - 1; i >= 0; i--) {
+ var tempMenu = menus[i];
+ if (tempMenu.auth && !admin.hasPerm(tempMenu.auth)) {
+ menus.splice(i, 1);
+ continue;
+ }
+ if (!tempMenu.subMenus) {
+ continue;
+ }
+ for (var j = tempMenu.subMenus.length - 1; j >= 0; j--) {
+ var jMenus = tempMenu.subMenus[j];
+ if (jMenus.auth && !admin.hasPerm(jMenus.auth)) {
+ tempMenu.subMenus.splice(j, 1);
+ continue;
+ }
+ if (!jMenus.subMenus) {
+ continue;
+ }
+ for (var k = jMenus.subMenus.length - 1; k >= 0; k--) {
+ if (jMenus.subMenus[k].auth && !admin.hasPerm(jMenus.subMenus[k].auth)) {
+ jMenus.subMenus.splice(k, 1);
+ continue;
+ }
+ }
+ }
+ }
+ // 去除空的目录
+ for (var i = menus.length - 1; i >= 0; i--) {
+ var tempMenu = menus[i];
+ if (tempMenu.subMenus && tempMenu.subMenus.length <= 0) {
+ menus.splice(i, 1);
+ continue;
+ }
+ if (!tempMenu.subMenus) {
+ continue;
+ }
+ for (var j = tempMenu.subMenus.length - 1; j >= 0; j--) {
+ var jMenus = tempMenu.subMenus[j];
+ if (jMenus.subMenus && jMenus.subMenus.length <= 0) {
+ tempMenu.splice(j, 1);
+ continue;
+ }
+ }
+ }
+ // 渲染
+ $('.layui-layout-admin .layui-side').load('pages/side.html', function () {
+ laytpl(sideNav.innerHTML).render(menus, function (html) {
+ $('#sideNav').after(html);
+ });
+ element.render('nav');
+ admin.activeNav(Q.lash);
+ });
+
+
+ }, 'GET');
+ },
+ // 路由注册
+ initRouter: function () {
+
+ index.regRouter(admin.getTempData("menus"));
+ // index.regRouter(config.menus);
+ Q.reg('console', function () {
+ var menuPath = 'pages/console.html'
+ index.loadView('console', menuPath, '主页');
+ });
+
+ Q.init({
+ index: 'console'
+ });
+ },
+ // 使用递归循环注册
+ regRouter: function (menus) {
+ $.each(menus, function (i, data) {
+ if (data.url && data.url.indexOf('#!') == 0) {
+ Q.reg(data.url.substring(2), function () {
+ if (data.path.startWith("http://")) {
+ window.open(data.path);
+ } else {
+ //临时保存url
+ data.path.startWith("http://") ? admin.putTempData("params",data.path) : null ;
+
+ var menuId = data.url.substring(2);
+ //add by owen 修复 path 无法引用http://页面的问题
+ var menuPath = data.path.startWith("http://") ? 'pages/tpl/iframe.html' : 'pages/' + data.path
+ index.loadView(menuId, menuPath, data.name);
+ }
+ });
+ }
+ if (data.subMenus) {
+ index.regRouter(data.subMenus);
+ }
+ });
+ },
+ // 路由加载组件
+ loadView: function (menuId, menuPath, menuName) {
+ var contentDom = '.layui-layout-admin .layui-body';
+ admin.showLoading('.layui-layout-admin .layui-body');
+ var flag; // 选项卡是否添加
+ flag = menuPath.startWith("http://") ? false : flag ;
+ // 判断是否开启了选项卡功能
+ if (config.pageTabs) {
+ $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title>li').each(function (index) {
+ if ($(this).attr('lay-id') === menuId) {
+ flag = true;
+ }
+ });
+ if (!flag) {
+ element.tabAdd('admin-pagetabs', {
+ title: menuName,
+ //add by owen 修复 path 无法引用http://页面的问题
+ content: menuPath.startWith("http://") ? '
' : '' ,
+ id: menuId
+ });
+ }
+ contentDom = '#' + menuId;
+ element.tabChange('admin-pagetabs', menuId);
+ admin.rollPage('auto');
+ // 切换tab关闭表格内浮窗
+ $('.layui-table-tips-c').trigger('click');
+ // 解决切换tab滚动条时而消失的问题
+ var $iframe = $('.layui-layout-admin .layui-body .layui-tab-content .layui-tab-item.layui-show .admin-iframe')[0];
+ if ($iframe) {
+ $iframe.style.height = "99%";
+ $iframe.scrollWidth;
+ $iframe.style.height = "100%";
+ }
+ }
+ if (!flag || admin.isRefresh) {
+ $(contentDom).load(menuPath, function () {
+ admin.isRefresh = false;
+ element.render('breadcrumb');
+ form.render('select');
+ admin.removeLoading('.layui-layout-admin .layui-body');
+ });
+ } else {
+ admin.removeLoading('.layui-layout-admin .layui-body');
+ }
+ admin.activeNav(Q.lash);
+ // 移动设备切换页面隐藏侧导航
+ if (document.body.clientWidth <= 750) {
+ admin.flexible(true);
+ }
+ },
+ // 从服务器获取登录用户的信息
+ getUser: function (success) {
+ layer.load(2);
+ admin.req('api-user/users/current', {}, function (data) {
+ layer.closeAll('loading');
+ if (data && data.resp_code === 0) {
+ let user = data.datas;
+ config.putUser(user);
+ admin.putTempData("permissions",user.permissions);
+ success(user);
+ } else {
+ layer.msg('获取用户失败', {icon: 2});
+ config.removeToken();
+ location.replace('login.html');
+ }
+ }, 'GET');
+ },
+ //获取菜单
+ getMenus: function () {
+ admin.req('api-user/menus/current', {}, function (data) {
+ admin.putTempData("menus",data);
+ }, 'GET');
+ },
+ // 页面元素绑定事件监听
+ bindEvent: function () {
+ // 退出登录
+ $('#btnLogout').click(function () {
+ layer.confirm('确定退出登录?', function () {
+ let token = config.getToken();
+ let isExistsToken = false;
+ if (token) {
+ let accessToken = token.access_token;
+ config.removeToken();
+
+ if (accessToken) {
+ isExistsToken = true;
+ admin.req('api-uaa/oauth/check_token?token='+accessToken, {}, function (data) {
+ if (data.active) {
+ let loginPageUrl = window.location.protocol + '//' + window.location.host + '/login.html';
+ window.location = config.base_server + 'api-uaa/oauth/remove/token?redirect_uri='+loginPageUrl+'&access_token='+accessToken;
+ } else {
+ location.replace('login.html');
+ }
+ }, 'POST');
+ }
+ }
+ if (!isExistsToken) {
+ location.replace('login.html');
+ }
+ });
+ });
+ // 修改密码
+ $('#setPsw').click(function () {
+ admin.popupRight('pages/tpl/password.html');
+ });
+ // 个人信息
+ $('#setInfo').click(function () {
+ Q.go('myInfo');
+ });
+ // 消息
+ $('#btnMessage').click(function () {
+ admin.popupRight('pages/tpl/message.html');
+ });
+ },
+ // 检查多标签功能是否开启
+ checkPageTabs: function () {
+ // 加载主页
+ if (config.pageTabs) {
+ $('.layui-layout-admin').addClass('open-tab');
+ element.tabAdd('admin-pagetabs', {
+ title: ' ',
+ content: '
',
+ id: 'console'
+ });
+ $('#console').load('pages/console.html', function () {
+ });
+ } else {
+ $('.layui-layout-admin').removeClass('open-tab');
+ }
+ },
+ // 打开新页面
+ openNewTab: function (param) {
+ var url = param.url;
+ var title = param.title;
+ var menuId = param.menuId;
+ if (!menuId) {
+ menuId = url.replace(/[?:=&/]/g, '_');
+ }
+ index.loadView(menuId, url, title);
+ },
+ // 关闭选项卡
+ closeTab: function (menuId) {
+ element.tabDelete('admin-pagetabs', menuId);
+ }
+ };
+
+ // tab选项卡切换监听
+ element.on('tab(admin-pagetabs)', function (data) {
+ var layId = $(this).attr('lay-id');
+ Q.go(layId);
+ });
+
+ exports('index', index);
+});
diff --git a/zlt-web/back-web/src/main/resources/static/module/treetable-lay/treetable.css b/zlt-web/layui-web/src/main/resources/static/module/treetable-lay/treetable.css
similarity index 94%
rename from zlt-web/back-web/src/main/resources/static/module/treetable-lay/treetable.css
rename to zlt-web/layui-web/src/main/resources/static/module/treetable-lay/treetable.css
index a5eb1dd7..584b2f8c 100644
--- a/zlt-web/back-web/src/main/resources/static/module/treetable-lay/treetable.css
+++ b/zlt-web/layui-web/src/main/resources/static/module/treetable-lay/treetable.css
@@ -1,18 +1,18 @@
-.treeTable-empty {
- width: 20px;
- display: inline-block;
-}
-
-.treeTable-icon {
- cursor: pointer;
-}
-
-.treeTable-icon .layui-icon-triangle-d:before {
- content: "\e623";
-}
-
-.treeTable-icon.open .layui-icon-triangle-d:before {
- content: "\e625";
- background-color: transparent;
-}
-
+.treeTable-empty {
+ width: 20px;
+ display: inline-block;
+}
+
+.treeTable-icon {
+ cursor: pointer;
+}
+
+.treeTable-icon .layui-icon-triangle-d:before {
+ content: "\e623";
+}
+
+.treeTable-icon.open .layui-icon-triangle-d:before {
+ content: "\e625";
+ background-color: transparent;
+}
+
diff --git a/zlt-web/back-web/src/main/resources/static/module/treetable-lay/treetable.js b/zlt-web/layui-web/src/main/resources/static/module/treetable-lay/treetable.js
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/module/treetable-lay/treetable.js
rename to zlt-web/layui-web/src/main/resources/static/module/treetable-lay/treetable.js
index efb897af..35efdcf2 100644
--- a/zlt-web/back-web/src/main/resources/static/module/treetable-lay/treetable.js
+++ b/zlt-web/layui-web/src/main/resources/static/module/treetable-lay/treetable.js
@@ -1,198 +1,198 @@
-layui.define(['layer', 'table'], function (exports) {
- var $ = layui.jquery;
- var layer = layui.layer;
- var table = layui.table;
-
- var treetable = {
- // 渲染树形表格
- render: function (param) {
- // 检查参数
- if (!treetable.checkParam(param)) {
- return;
- }
- var doneCallback = param.done;
- // 获取数据
- var mData = [];
- $.getJSON(param.url, param.where, function (res) {
- var tNodes = res.data;
- // 补上id和pid字段
- for (var i = 0; i < tNodes.length; i++) {
- var tt = tNodes[i];
- if (!tt.id) {
- if (!param.treeIdName) {
- layer.msg('参数treeIdName不能为空', {icon: 5});
- return;
- }
- tt.id = tt[param.treeIdName];
- }
- if (!tt.pid) {
- if (!param.treePidName) {
- layer.msg('参数treePidName不能为空', {icon: 5});
- return;
- }
- tt.pid = tt[param.treePidName];
- }
- }
-
- // 对数据进行排序
- var sort = function (s_pid, data) {
- for (var i = 0; i < data.length; i++) {
- if (data[i].pid == s_pid) {
- var len = mData.length;
- if (len > 0 && mData[len - 1].id == s_pid) {
- mData[len - 1].isParent = true;
- }
- mData.push(data[i]);
- sort(data[i].id, data);
- }
- }
- };
- sort(param.treeSpid, tNodes);
-
- // 重写参数
- param.url = undefined;
- param.data = mData;
- param.page = {
- count: param.data.length,
- limit: param.data.length
- };
- param.cols[0][param.treeColIndex].templet = function (d) {
- var mId = d.id;
- var mPid = d.pid;
- var isDir = d.isParent;
- var emptyNum = treetable.getEmptyNum(mPid, mData);
- var iconHtml = '';
- for (var i = 0; i < emptyNum; i++) {
- iconHtml += ' ';
- }
- if (isDir) {
- iconHtml += ' ';
- } else {
- iconHtml += ' ';
- }
- iconHtml += ' ';
- var ttype = isDir ? 'dir' : 'file';
- var vg = '';
- return vg + iconHtml + d[param.cols[0][param.treeColIndex].field] + ' '
- };
-
- param.done = function (res, curr, count) {
- $(param.elem).next().addClass('treeTable');
- $('.treeTable .layui-table-page').css('display', 'none');
- $(param.elem).next().attr('treeLinkage', param.treeLinkage);
- // 绑定事件换成对body绑定
- /*$('.treeTable .treeTable-icon').click(function () {
- treetable.toggleRows($(this), param.treeLinkage);
- });*/
- if (param.treeDefaultClose) {
- treetable.foldAll(param.elem);
- }
- if (doneCallback) {
- doneCallback(res, curr, count);
- }
- };
-
- // 渲染表格
- table.render(param);
- });
- },
- // 计算缩进的数量
- getEmptyNum: function (pid, data) {
- var num = 0;
- if (!pid) {
- return num;
- }
- var tPid;
- for (var i = 0; i < data.length; i++) {
- if (pid == data[i].id) {
- num += 1;
- tPid = data[i].pid;
- break;
- }
- }
- return num + treetable.getEmptyNum(tPid, data);
- },
- // 展开/折叠行
- toggleRows: function ($dom, linkage) {
- var type = $dom.attr('lay-ttype');
- if ('file' == type) {
- return;
- }
- var mId = $dom.attr('lay-tid');
- var isOpen = $dom.hasClass('open');
- if (isOpen) {
- $dom.removeClass('open');
- } else {
- $dom.addClass('open');
- }
- $dom.closest('tbody').find('tr').each(function () {
- var $ti = $(this).find('.treeTable-icon');
- var pid = $ti.attr('lay-tpid');
- var ttype = $ti.attr('lay-ttype');
- var tOpen = $ti.hasClass('open');
- if (mId == pid) {
- if (isOpen) {
- $(this).hide();
- if ('dir' == ttype && tOpen == isOpen) {
- $ti.trigger('click');
- }
- } else {
- $(this).show();
- if (linkage && 'dir' == ttype && tOpen == isOpen) {
- $ti.trigger('click');
- }
- }
- }
- });
- },
- // 检查参数
- checkParam: function (param) {
- if (!param.treeSpid && param.treeSpid != 0) {
- layer.msg('参数treeSpid不能为空', {icon: 5});
- return false;
- }
-
- if (!param.treeColIndex && param.treeColIndex != 0) {
- layer.msg('参数treeColIndex不能为空', {icon: 5});
- return false;
- }
- return true;
- },
- // 展开所有
- expandAll: function (dom) {
- $(dom).next('.treeTable').find('.layui-table-body tbody tr').each(function () {
- var $ti = $(this).find('.treeTable-icon');
- var ttype = $ti.attr('lay-ttype');
- var tOpen = $ti.hasClass('open');
- if ('dir' == ttype && !tOpen) {
- $ti.trigger('click');
- }
- });
- },
- // 折叠所有
- foldAll: function (dom) {
- $(dom).next('.treeTable').find('.layui-table-body tbody tr').each(function () {
- var $ti = $(this).find('.treeTable-icon');
- var ttype = $ti.attr('lay-ttype');
- var tOpen = $ti.hasClass('open');
- if ('dir' == ttype && tOpen) {
- $ti.trigger('click');
- }
- });
- }
- };
-
- layui.link(layui.cache.base + 'treetable-lay/treetable.css');
-
- // 给图标列绑定事件
- $('body').on('click', '.treeTable .treeTable-icon', function () {
- var treeLinkage = $(this).parents('.treeTable').attr('treeLinkage');
- if ('true' == treeLinkage) {
- treetable.toggleRows($(this), true);
- } else {
- treetable.toggleRows($(this), false);
- }
- });
-
- exports('treetable', treetable);
-});
+layui.define(['layer', 'table'], function (exports) {
+ var $ = layui.jquery;
+ var layer = layui.layer;
+ var table = layui.table;
+
+ var treetable = {
+ // 渲染树形表格
+ render: function (param) {
+ // 检查参数
+ if (!treetable.checkParam(param)) {
+ return;
+ }
+ var doneCallback = param.done;
+ // 获取数据
+ var mData = [];
+ $.getJSON(param.url, param.where, function (res) {
+ var tNodes = res.data;
+ // 补上id和pid字段
+ for (var i = 0; i < tNodes.length; i++) {
+ var tt = tNodes[i];
+ if (!tt.id) {
+ if (!param.treeIdName) {
+ layer.msg('参数treeIdName不能为空', {icon: 5});
+ return;
+ }
+ tt.id = tt[param.treeIdName];
+ }
+ if (!tt.pid) {
+ if (!param.treePidName) {
+ layer.msg('参数treePidName不能为空', {icon: 5});
+ return;
+ }
+ tt.pid = tt[param.treePidName];
+ }
+ }
+
+ // 对数据进行排序
+ var sort = function (s_pid, data) {
+ for (var i = 0; i < data.length; i++) {
+ if (data[i].pid == s_pid) {
+ var len = mData.length;
+ if (len > 0 && mData[len - 1].id == s_pid) {
+ mData[len - 1].isParent = true;
+ }
+ mData.push(data[i]);
+ sort(data[i].id, data);
+ }
+ }
+ };
+ sort(param.treeSpid, tNodes);
+
+ // 重写参数
+ param.url = undefined;
+ param.data = mData;
+ param.page = {
+ count: param.data.length,
+ limit: param.data.length
+ };
+ param.cols[0][param.treeColIndex].templet = function (d) {
+ var mId = d.id;
+ var mPid = d.pid;
+ var isDir = d.isParent;
+ var emptyNum = treetable.getEmptyNum(mPid, mData);
+ var iconHtml = '';
+ for (var i = 0; i < emptyNum; i++) {
+ iconHtml += ' ';
+ }
+ if (isDir) {
+ iconHtml += ' ';
+ } else {
+ iconHtml += ' ';
+ }
+ iconHtml += ' ';
+ var ttype = isDir ? 'dir' : 'file';
+ var vg = '';
+ return vg + iconHtml + d[param.cols[0][param.treeColIndex].field] + ' '
+ };
+
+ param.done = function (res, curr, count) {
+ $(param.elem).next().addClass('treeTable');
+ $('.treeTable .layui-table-page').css('display', 'none');
+ $(param.elem).next().attr('treeLinkage', param.treeLinkage);
+ // 绑定事件换成对body绑定
+ /*$('.treeTable .treeTable-icon').click(function () {
+ treetable.toggleRows($(this), param.treeLinkage);
+ });*/
+ if (param.treeDefaultClose) {
+ treetable.foldAll(param.elem);
+ }
+ if (doneCallback) {
+ doneCallback(res, curr, count);
+ }
+ };
+
+ // 渲染表格
+ table.render(param);
+ });
+ },
+ // 计算缩进的数量
+ getEmptyNum: function (pid, data) {
+ var num = 0;
+ if (!pid) {
+ return num;
+ }
+ var tPid;
+ for (var i = 0; i < data.length; i++) {
+ if (pid == data[i].id) {
+ num += 1;
+ tPid = data[i].pid;
+ break;
+ }
+ }
+ return num + treetable.getEmptyNum(tPid, data);
+ },
+ // 展开/折叠行
+ toggleRows: function ($dom, linkage) {
+ var type = $dom.attr('lay-ttype');
+ if ('file' == type) {
+ return;
+ }
+ var mId = $dom.attr('lay-tid');
+ var isOpen = $dom.hasClass('open');
+ if (isOpen) {
+ $dom.removeClass('open');
+ } else {
+ $dom.addClass('open');
+ }
+ $dom.closest('tbody').find('tr').each(function () {
+ var $ti = $(this).find('.treeTable-icon');
+ var pid = $ti.attr('lay-tpid');
+ var ttype = $ti.attr('lay-ttype');
+ var tOpen = $ti.hasClass('open');
+ if (mId == pid) {
+ if (isOpen) {
+ $(this).hide();
+ if ('dir' == ttype && tOpen == isOpen) {
+ $ti.trigger('click');
+ }
+ } else {
+ $(this).show();
+ if (linkage && 'dir' == ttype && tOpen == isOpen) {
+ $ti.trigger('click');
+ }
+ }
+ }
+ });
+ },
+ // 检查参数
+ checkParam: function (param) {
+ if (!param.treeSpid && param.treeSpid != 0) {
+ layer.msg('参数treeSpid不能为空', {icon: 5});
+ return false;
+ }
+
+ if (!param.treeColIndex && param.treeColIndex != 0) {
+ layer.msg('参数treeColIndex不能为空', {icon: 5});
+ return false;
+ }
+ return true;
+ },
+ // 展开所有
+ expandAll: function (dom) {
+ $(dom).next('.treeTable').find('.layui-table-body tbody tr').each(function () {
+ var $ti = $(this).find('.treeTable-icon');
+ var ttype = $ti.attr('lay-ttype');
+ var tOpen = $ti.hasClass('open');
+ if ('dir' == ttype && !tOpen) {
+ $ti.trigger('click');
+ }
+ });
+ },
+ // 折叠所有
+ foldAll: function (dom) {
+ $(dom).next('.treeTable').find('.layui-table-body tbody tr').each(function () {
+ var $ti = $(this).find('.treeTable-icon');
+ var ttype = $ti.attr('lay-ttype');
+ var tOpen = $ti.hasClass('open');
+ if ('dir' == ttype && tOpen) {
+ $ti.trigger('click');
+ }
+ });
+ }
+ };
+
+ layui.link(layui.cache.base + 'treetable-lay/treetable.css');
+
+ // 给图标列绑定事件
+ $('body').on('click', '.treeTable .treeTable-icon', function () {
+ var treeLinkage = $(this).parents('.treeTable').attr('treeLinkage');
+ if ('true' == treeLinkage) {
+ treetable.toggleRows($(this), true);
+ } else {
+ treetable.toggleRows($(this), false);
+ }
+ });
+
+ exports('treetable', treetable);
+});
diff --git a/zlt-web/back-web/src/main/resources/static/pages/attestation/app.html b/zlt-web/layui-web/src/main/resources/static/pages/attestation/app.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/attestation/app.html
rename to zlt-web/layui-web/src/main/resources/static/pages/attestation/app.html
index b87fd0d8..d0a1978b 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/attestation/app.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/attestation/app.html
@@ -1,237 +1,237 @@
-
-
-
-
- 搜索:
- 搜索
- 添加
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/console.html b/zlt-web/layui-web/src/main/resources/static/pages/console.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/console.html
rename to zlt-web/layui-web/src/main/resources/static/pages/console.html
index 6a676246..9ae86c4b 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/console.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/console.html
@@ -1,308 +1,308 @@
-
-
-
-
- 首页
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ 首页
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/console_old.html b/zlt-web/layui-web/src/main/resources/static/pages/console_old.html
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/pages/console_old.html
rename to zlt-web/layui-web/src/main/resources/static/pages/console_old.html
diff --git a/zlt-web/back-web/src/main/resources/static/pages/files/files.html b/zlt-web/layui-web/src/main/resources/static/pages/files/files.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/files/files.html
rename to zlt-web/layui-web/src/main/resources/static/pages/files/files.html
index 756ae6bd..a2946033 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/files/files.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/files/files.html
@@ -1,108 +1,108 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/zlt-web/back-web/src/main/resources/static/pages/generator/list.html b/zlt-web/layui-web/src/main/resources/static/pages/generator/list.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/generator/list.html
rename to zlt-web/layui-web/src/main/resources/static/pages/generator/list.html
index 2bb5e915..cc69233e 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/generator/list.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/generator/list.html
@@ -1,78 +1,78 @@
-
-
-
-
-
- 搜索:
- 搜索
-
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/header.html b/zlt-web/layui-web/src/main/resources/static/pages/header.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/header.html
rename to zlt-web/layui-web/src/main/resources/static/pages/header.html
index 54d9e588..dbba1250 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/header.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/header.html
@@ -1,45 +1,45 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{nickname}}
-
-
-
- 个人信息
-
-
- 修改密码
-
-
-
- 退出
-
-
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/log/auditLog.html b/zlt-web/layui-web/src/main/resources/static/pages/log/auditLog.html
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/pages/log/auditLog.html
rename to zlt-web/layui-web/src/main/resources/static/pages/log/auditLog.html
diff --git a/zlt-web/back-web/src/main/resources/static/pages/log/slowQueryLog.html b/zlt-web/layui-web/src/main/resources/static/pages/log/slowQueryLog.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/log/slowQueryLog.html
rename to zlt-web/layui-web/src/main/resources/static/pages/log/slowQueryLog.html
index f319fdda..896ae109 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/log/slowQueryLog.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/log/slowQueryLog.html
@@ -1,61 +1,61 @@
-
-
-
-
- 搜索:
-
- 全文搜索
- 查询语句
-
-
- 搜索
-
-
-
-
-
-
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/log/sysLog.html b/zlt-web/layui-web/src/main/resources/static/pages/log/sysLog.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/log/sysLog.html
rename to zlt-web/layui-web/src/main/resources/static/pages/log/sysLog.html
index 204ae7e7..bf6f3ddc 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/log/sysLog.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/log/sysLog.html
@@ -1,106 +1,106 @@
-
-
-
-
- 搜索:
-
- 全文搜索
- 日志信息
- 日志级别
- 应用名
- 类名
- 链路追踪id
-
-
- 搜索
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/log/traceLog.html b/zlt-web/layui-web/src/main/resources/static/pages/log/traceLog.html
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/pages/log/traceLog.html
rename to zlt-web/layui-web/src/main/resources/static/pages/log/traceLog.html
diff --git a/zlt-web/back-web/src/main/resources/static/pages/search/index_manager.html b/zlt-web/layui-web/src/main/resources/static/pages/search/index_manager.html
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/pages/search/index_manager.html
rename to zlt-web/layui-web/src/main/resources/static/pages/search/index_manager.html
diff --git a/zlt-web/back-web/src/main/resources/static/pages/search/index_manager_form.html b/zlt-web/layui-web/src/main/resources/static/pages/search/index_manager_form.html
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/pages/search/index_manager_form.html
rename to zlt-web/layui-web/src/main/resources/static/pages/search/index_manager_form.html
diff --git a/zlt-web/back-web/src/main/resources/static/pages/search/index_manager_view.html b/zlt-web/layui-web/src/main/resources/static/pages/search/index_manager_view.html
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/pages/search/index_manager_view.html
rename to zlt-web/layui-web/src/main/resources/static/pages/search/index_manager_view.html
diff --git a/zlt-web/back-web/src/main/resources/static/pages/search/user_search.html b/zlt-web/layui-web/src/main/resources/static/pages/search/user_search.html
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/pages/search/user_search.html
rename to zlt-web/layui-web/src/main/resources/static/pages/search/user_search.html
diff --git a/zlt-web/back-web/src/main/resources/static/pages/side.html b/zlt-web/layui-web/src/main/resources/static/pages/side.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/side.html
rename to zlt-web/layui-web/src/main/resources/static/pages/side.html
index c538a139..1a9860aa 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/side.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/side.html
@@ -1,38 +1,38 @@
-
+
diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/menus.html b/zlt-web/layui-web/src/main/resources/static/pages/system/menus.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/system/menus.html
rename to zlt-web/layui-web/src/main/resources/static/pages/system/menus.html
index 23d3861e..2eea260c 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/system/menus.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/system/menus.html
@@ -1,188 +1,188 @@
-
-
-
-
- 所属应用:
- 搜索:
-
-
- 全部展开
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/menus_form.html b/zlt-web/layui-web/src/main/resources/static/pages/system/menus_form.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/system/menus_form.html
rename to zlt-web/layui-web/src/main/resources/static/pages/system/menus_form.html
index 7b8431c2..c440c269 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/system/menus_form.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/system/menus_form.html
@@ -1,140 +1,140 @@
-
-
-
-
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/myInfo.html b/zlt-web/layui-web/src/main/resources/static/pages/system/myInfo.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/system/myInfo.html
rename to zlt-web/layui-web/src/main/resources/static/pages/system/myInfo.html
index 94e4ec49..97d8ca64 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/system/myInfo.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/system/myInfo.html
@@ -1,112 +1,112 @@
-
-
-
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/role.html b/zlt-web/layui-web/src/main/resources/static/pages/system/role.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/system/role.html
rename to zlt-web/layui-web/src/main/resources/static/pages/system/role.html
index 80f2d681..ba0f7084 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/system/role.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/system/role.html
@@ -1,253 +1,253 @@
-
-
-
-
-
-
- 所属应用:
- 搜索:
-
- -请选择-
- 角色名称
-
-
- 搜索
- 添加
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ 所属应用:
+ 搜索:
+
+ -请选择-
+ 角色名称
+
+
+ 搜索
+ 添加
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/tokens.html b/zlt-web/layui-web/src/main/resources/static/pages/system/tokens.html
similarity index 100%
rename from zlt-web/back-web/src/main/resources/static/pages/system/tokens.html
rename to zlt-web/layui-web/src/main/resources/static/pages/system/tokens.html
diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/user.html b/zlt-web/layui-web/src/main/resources/static/pages/system/user.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/system/user.html
rename to zlt-web/layui-web/src/main/resources/static/pages/system/user.html
index 644db720..684b4ecc 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/system/user.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/system/user.html
@@ -1,221 +1,221 @@
-
-
-
-
- 搜索:
-
- -请选择-
- ID
- 账号
- 用户名
- 手机号
-
-
- 搜索
- 添加
- 导出
-
- 导入
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/system/user_form.html b/zlt-web/layui-web/src/main/resources/static/pages/system/user_form.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/system/user_form.html
rename to zlt-web/layui-web/src/main/resources/static/pages/system/user_form.html
index 4b2efb15..c2729323 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/system/user_form.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/system/user_form.html
@@ -1,99 +1,99 @@
-
-
-
-
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/tpl/iframe.html b/zlt-web/layui-web/src/main/resources/static/pages/tpl/iframe.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/tpl/iframe.html
rename to zlt-web/layui-web/src/main/resources/static/pages/tpl/iframe.html
index a03de8c0..8d6c2649 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/tpl/iframe.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/tpl/iframe.html
@@ -1,32 +1,32 @@
-
-
-
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/tpl/message.html b/zlt-web/layui-web/src/main/resources/static/pages/tpl/message.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/tpl/message.html
rename to zlt-web/layui-web/src/main/resources/static/pages/tpl/message.html
index 230b0c72..f1d21b1b 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/tpl/message.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/tpl/message.html
@@ -1,78 +1,78 @@
-
-
- 通知({{notices.length}})
- 私信({{messages.length}})
- 待办({{schedules.length}})
-
-
-
-
-
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/tpl/password.html b/zlt-web/layui-web/src/main/resources/static/pages/tpl/password.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/tpl/password.html
rename to zlt-web/layui-web/src/main/resources/static/pages/tpl/password.html
index 5fac9aa1..d3b9087e 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/tpl/password.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/tpl/password.html
@@ -1,63 +1,63 @@
-
-
-
-
\ No newline at end of file
diff --git a/zlt-web/back-web/src/main/resources/static/pages/tpl/theme.html b/zlt-web/layui-web/src/main/resources/static/pages/tpl/theme.html
similarity index 97%
rename from zlt-web/back-web/src/main/resources/static/pages/tpl/theme.html
rename to zlt-web/layui-web/src/main/resources/static/pages/tpl/theme.html
index 8a7b324b..21ba9a8c 100644
--- a/zlt-web/back-web/src/main/resources/static/pages/tpl/theme.html
+++ b/zlt-web/layui-web/src/main/resources/static/pages/tpl/theme.html
@@ -1,55 +1,55 @@
-
-
-
-
\ No newline at end of file
diff --git a/zlt-web/pom.xml b/zlt-web/pom.xml
index 1d27732f..edddbdd7 100644
--- a/zlt-web/pom.xml
+++ b/zlt-web/pom.xml
@@ -1,126 +1,56 @@
-
- 4.0.0
- pom
-
- react-web
-
-
-
+ 4.0.0
com.zlt
- central-platform
+ zlt-web
5.4.0
-
- zlt-web
- 前端
+ 前端
+ pom
-
- v16.13.2
- v1.22.19
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
-
-
- com.github.eirslett
- frontend-maven-plugin
- 1.12.1
-
-
- install node and yarn
-
- install-node-and-yarn
-
-
- ${node.version}
- ${yarn.version}
- src/main/frontend
-
-
-
- yarn install
- generate-resources
-
- yarn
-
-
- install
- src/main/frontend
-
-
-
- yarn run build
- compile
-
- yarn
-
-
- run build
- src/main/frontend
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 3.3.0
-
- true
-
-
-
- copy
- compile
-
- resources
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
- repackage
-
-
-
-
-
-
-
- src/main/resources
-
-
- src/main/frontend/dist
- META-INF/central-platform-ui
- false
-
-
-
-
-
- noNode
-
-
-
- com.github.eirslett
- frontend-maven-plugin
-
- true
-
-
-
-
-
-
+
+ 1.8
+ 1.8
+ UTF-8
+ 8
+ 2.5.14
+ 1.2.2
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot-dependencies.version}
+ pom
+ import
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring-boot-dependencies.version}
+
+
+ com.spotify
+ docker-maven-plugin
+ ${docker-maven-plugin.version}
+
+
+
+
+
+
+
+ layui-web
+
+ react-web
+
diff --git a/zlt-web/react-web/pom.xml b/zlt-web/react-web/pom.xml
index 6861d4de..e71c856c 100644
--- a/zlt-web/react-web/pom.xml
+++ b/zlt-web/react-web/pom.xml
@@ -10,7 +10,7 @@
4.0.0
react-web
- React前端
+ React开发的前端(Ant Design)
v16.13.2
@@ -84,6 +84,7 @@
org.springframework.boot
spring-boot-maven-plugin
+ ${spring-boot-dependencies.version}
diff --git a/zlt-web/src/main/frontend/build.bat b/zlt-web/react-web/src/main/frontend/build.bat
similarity index 100%
rename from zlt-web/src/main/frontend/build.bat
rename to zlt-web/react-web/src/main/frontend/build.bat
diff --git a/zlt-web/react-web/src/main/frontend/package.json b/zlt-web/react-web/src/main/frontend/package.json
index 307d8eea..bf5d20ca 100644
--- a/zlt-web/react-web/src/main/frontend/package.json
+++ b/zlt-web/react-web/src/main/frontend/package.json
@@ -21,7 +21,7 @@
"playwright": "playwright install && playwright test",
"prettier": "prettier -c --write \"src/**/*\"",
"serve": "umi-serve",
- "start": "cross-env UMI_ENV=dev umi dev",
+ "start": "cross-env UMI_ENV=dev umi dev --port=8066",
"start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev",
"start:no-mock": "cross-env MOCK=none UMI_ENV=dev umi dev",
"start:no-ui": "cross-env UMI_UI=none UMI_ENV=dev umi dev",
diff --git a/zlt-web/src/main/frontend/start.bat b/zlt-web/react-web/src/main/frontend/start.bat
similarity index 100%
rename from zlt-web/src/main/frontend/start.bat
rename to zlt-web/react-web/src/main/frontend/start.bat