提交 fd908ba8 编写于 作者: lakernote's avatar lakernote

(新增)[后端](增加登录验证码校验)

上级 47704d77
......@@ -101,17 +101,17 @@ spring:
**二、纯静态模式**
> 测试中
纯静态的,可直接在浏览器运行,修改配置`web/admin/componet/pear/pear.js`
纯静态的,可直接在浏览器运行,修改配置`web/admin/config/pear.config.yml`
```javascript
const EasyAdminContext = {
url: "http://localhost:8080"
};
## 配置服务端地址
admin:
server: http://localhost:8080
```
直接在浏览器访问`web/admin/index.html`
直接在浏览器访问`index.html`,如下图直接就可以访问了
![输入图片说明](https://images.gitee.com/uploads/images/2021/0816/001751_ef56d4c9_709188.png "屏幕截图.png")
#### 项目截图
......@@ -176,7 +176,7 @@ nohup java -jar easy-admin.jar &
##### 前端
**按照相对位置放即可**
**按照相对位置放即可**(或者自己弄个nginx丢进去)
```
easy-admin.jar
......@@ -191,4 +191,5 @@ web
----login.html
```
浏览器访问`http://ip:port/admin`
\ No newline at end of file
浏览器访问`http://ip:port/admin`
......@@ -32,6 +32,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
.excludePathPatterns("/admin/**",
"/admin/login.html",
"/error",
"/swagger-resources/**",
"/api/v1/login",
"/captcha");
}
......
layui.define(['jquery', 'element', 'table', 'yaml', 'common'], function (exports) {
"use strict";
var MOD_NAME = 'easyAdmin';
var $ = layui.jquery;
var table = layui.table;
var element = layui.element;
var common = layui.common;
var easyAdmin = new function () {
this.GetAdminServerUrl = function () {
return layui.data('easyAdmin').serverUrl;
}
this.GetTokenQueryString = function () {
var user = layui.data('user');
// 用于判断未登录跳转到登录页
if (JSON.stringify(user) == "{}") {
console.log("当前浏览器存储中没有用户信息,讲跳转到login.html")
location.href = "login.html";
}
return user.token.name + "=" + user.token.value;
}
/**
* 通用 http请求 参数同 ajax 有部分扩展
* sendToken:是否发送token默认发送
* @param options
*/
this.http = function (options) {
var defaults = {
type: 'get',
headers: {},
data: {},
dataType: null,
async: true,
cache: false,
// 是否发送token默认发送
sendToken: true,
beforeSend: null,
success: null,
complete: null
};
var o = $.extend({}, defaults, options);
// 配置服务端地址
var adminServerUrl = layui.data('easyAdmin').serverUrl;
$.ajax({
url: adminServerUrl + o.url,
type: o.type,
headers: {
'Content-Type': o.contentType,
// 'access_token': o.token
},
data: o.data,
dataType: o.dataType,
async: o.async,
beforeSend: function (request) {
if (o.sendToken) {
o.beforeSend && o.beforeSend();
var user = layui.data('user');
// 用于判断未登录跳转到登录页
if (JSON.stringify(user) == "{}") {
console.log("当前浏览器存储中没有用户信息,讲跳转到login.html")
location.href = "login.html";
}
request.setRequestHeader(user.token.name, user.token.value);
}
},
success: function (res) {
o.success && o.success(res);
},
complete: function () {
o.complete && o.complete();
},
error: function () {
o.error && o.error();
}
});
};
/**
*
* @param uri 地址
* @param success 成功回调
* @param sendToken 是否发送token
* @param async 是否异步
*/
this.httpGet = function (uri, success, sendToken, async) {
this.http({
url: uri,
success: success,
sendToken: sendToken,
async: async
})
};
/**
* 表格渲染
* @param options
*/
this.tableRender = function (options) {
var defaults = {
sendToken: true
};
var o = $.extend({}, defaults, options);
// 配置服务端地址
var adminServerUrl = layui.data('easyAdmin').serverUrl;
var user;
if (o.sendToken) {
user = layui.data('user');
// 用于判断未登录跳转到登录页
if (JSON.stringify(user) == "{}") {
console.log("当前浏览器存储中没有用户信息,讲跳转到login.html")
location.href = "login.html";
}
}
var tokenName = user.token.name;
var tokenValue = user.token.value;
var headers = {};
headers[tokenName] = tokenValue;
table.render({
elem: o.elem, // 对应table的id
headers: headers,
url: adminServerUrl + o.url,
page: o.page, // 分页参数可以自定义
cols: o.cols, // 列表示
skin: o.skin, // 表格样式
toolbar: o.toolbar, // 表格头部工具栏 可定义左上角和右上角工具栏,一般用于左上角配置
// 自由配置头部工具栏右侧的图标按钮
defaultToolbar: o.defaultToolbar
});
}
/**
* tableId : 'user-table'
*/
this.tableRefresh = function (tableId) {
table.reload(tableId);
}
/**
* 跳转到add页面
*/
this.JumpAdd = function (path) {
layer.open({
type: 2,
title: '新增',
shade: 0.1,
area: [common.isModile() ? '100%' : '500px', common.isModile() ? '100%' : '500px'],
content: path + 'add.html'
});
}
/**
* 跳转到edit页面
*/
this.JumpEdit = function (MODULE_PATH, id) {
layer.open({
type: 2,
title: '修改',
shade: 0.1,
area: ['500px', '500px'],
content: [MODULE_PATH + 'edit.html?id=' + id, 'no']
});
}
/**
* 获取url中的 参数
* @param name 参数名称
* @returns {string}
*/
this.getQueryString = function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r !== null)
return unescape(r[2]);
return "";
}
/**
* 获取当前表格选中字段
* @param obj 表格回调参数
* @param field 要获取的字段
* */
this.checkField = function (obj, field) {
let data = table.checkStatus(obj.config.id).data;
if (data.length === 0) {
return "";
}
let ids = "";
for (let i = 0; i < data.length; i++) {
ids += data[i][field] + ",";
}
ids = ids.substr(0, ids.length - 1);
return ids;
}
/**
* 当前是否为与移动端
* */
this.isModile = function () {
if ($(window).width() <= 768) {
return true;
}
return false;
}
/**
* <p>
* 新增 button lay-filter="save"
* <button type="submit" lay-submit lay-filter="save"
* 其父 main页面 id="table"
* <table id="table"
* </p>
*
*/
this.FormAddSave = function (url) {
form.on('submit(save)', function (data) {
easyAdmin.http({
url: url,
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
type: 'post',
success: function (result) {
if (result.success) {
layer.msg(result.msg,
{
icon: 1,
time: 1000,
area: ['100px', '80px'],
content: "新增成功"
}
, function () {
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
parent.layui.table.reload("table");
});
} else {
layer.msg(result.msg,
{icon: 2, time: 1000, area: ['100px', '80px']}
);
}
}
})
return false;
});
}
/**
* 提交 json 数据
* @param data 提交数据
* @param href 提交接口
* @param table 刷新父级表
*
* */
this.submit = function (data, href, table, callback) {
$.ajax({
url: href,
data: JSON.stringify(data),
dataType: 'json',
contentType: 'application/json',
type: 'post',
success: callback != null ? callback(result) : function (result) {
if (result.success) {
layer.msg(result.msg, {icon: 1, time: 1000}, function () {
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
parent.layui.table.reload(table);
});
} else {
layer.msg(result.msg, {icon: 2, time: 1000});
}
}
})
}
}
exports(MOD_NAME, easyAdmin);
});
......@@ -2,17 +2,6 @@ window.rootPath = (function (src) {
src = document.scripts[document.scripts.length - 1].src;
return src.substring(0, src.lastIndexOf("/") + 1);
})();
const EasyAdminContext = {
url: "",
getQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r !== null)
return unescape(r[2]);
return "";
}
};
layui.config({
base: rootPath + "module/",
version: "3.8.10"
......@@ -48,6 +37,7 @@ layui.config({
http: "http", // ajax请求组件
theme: "theme", // 主题转换
message: "message", // 通知组件
easyAdmin: "easyAdmin", // 自定义公共组件
}).use(['layer', 'theme'], function () {
layui.theme.changeTheme(window, false);
});
\ No newline at end of file
......@@ -189,7 +189,7 @@
$.ajax({
type: 'GET',
url: designer.config.ctxPath + "/flow/task/tip",
data: "orderId=" + designer.config.orderId + "&taskName=" + name,//_o.props['name'].value,
data: "orderId=" + designer.config.orderId + "&taskName=" + name + "&" + designer.config.token,//_o.props['name'].value,
async: false,
error: function () {
alert('数据处理错误!');
......@@ -202,9 +202,9 @@
"<a href='javascript:void(0)' onclick='document.body.removeChild(document.getElementById(\"tipDIV\"))' class='btnDel'></a>" +
"</div>" +
"<div style='width:180px; height:60px;border: 1px solid #d2dde2;'>" +
"<div id='currentActorDIV' style='width:180px; height:20px;'>参与者:" + data.data.actors + "</div>" +
"<div id='arrivalDIV' style='width:180px; height:20px;'>抵达时间:" + data.data.createTime + "</div>" +
"<div id='finishDIV' style='width:180px; height:20px;'>完成时间:" + data.data.finishTime + "</div>" +
"<div id='currentActorDIV' style='width:180px; height:20px;'>参与者:" + data.data.actors + "</div>" +
"<div id='arrivalDIV' style='width:180px; height:20px;'>抵达时间:" + data.data.createTime + "</div>" +
"<div id='finishDIV' style='width:180px; height:20px;'>完成时间:" + data.data.finishTime + "</div>" +
"</div>";
document.body.appendChild(tipDIV);
}
......
{
"logo": {
"title": "Pear Admin",
"image": "admin/images/logo.png"
},
"menu": {
"data": "admin/data/menu.json",
"collaspe": true,
"accordion": true,
"method": "GET",
"control": false,
"select": "0"
},
"tab": {
"muiltTab": true,
"keepState": true,
"tabMax": 30,
"index": {
"id": "0",
"href": "view/console/console1.html",
"title": "首页"
}
},
"theme": {
"defaultColor": "2",
"defaultMenu": "dark-theme",
"allowCustom": true
},
"colors": [{
"id": "1",
"color": "#2d8cf0"
},{
"id": "2",
"color": "#5FB878"
},{
"id": "3",
"color": "#1E9FFF"
}, {
"id": "4",
"color": "#FFB800"
}, {
"id": "5",
"color": "darkgray"
}
],
"links": [{
"icon": "layui-icon layui-icon-auz",
"title": "官方网站",
"href": "http://www.pearadmin.com"
},{
"icon": "layui-icon layui-icon-auz",
"title": "开发文档",
"href": "http://www.pearadmin.com"
},{
"icon": "layui-icon layui-icon-auz",
"title": "开源地址",
"href": "https://gitee.com/Jmysy/Pear-Admin-Layui"
}
],
"other": {
"keepLoad": 1200,
"autoHead": false
},
"header": {
"message": "admin/data/message.json"
}
}
---
## 配置服务端地址
admin:
server: http://localhost:8080
## 网站配置
logo:
## 网站名称
......@@ -22,7 +25,7 @@ menu:
## 默认选中的菜单项
select: "10"
## 是否开启异步菜单,true 时 data 属性设置为菜单数据,false 时为 json 文件或后端接口
async: true
async: false
## 视图内容配置
tab:
## 是否开启多选项卡
......
......@@ -81,22 +81,24 @@
<script src="component/pear/pear.js"></script>
<!-- 框 架 初 始 化 -->
<script>
layui.use(['admin', 'jquery', 'convert', 'popup'], function () {
layui.use(['admin', 'jquery', 'convert', 'popup', 'easyAdmin'], function () {
var admin = layui.admin;
var $ = layui.jquery;
var convert = layui.convert;
var popup = layui.popup;
var easyAdmin = layui.easyAdmin;
// 在登录的时候塞入的值
var user = layui.data('user');
// 用于判断未登录跳转到登录页
if (JSON.stringify(user) == "{}") {
console.log("当前浏览器存储中没有用户信息,讲跳转到login.html")
location.href = "login.html";
}
// 获取用户信息,用户名、昵称、头像等
$.ajax({
url: EasyAdminContext.url + "/api/v1/tokenInfo",
easyAdmin.http({
url: "/api/v1/tokenInfo",
dataType: 'json',
success: function (data) {
admin.setAvatar("admin/images/avatar.jpg", data.data.loginId);
......@@ -104,6 +106,7 @@
error: function () {
// 用于验证前端信息 对应到不对的会话情况
// 清空本地存储
console.log("当前浏览器存储中没有用户信息,清空本地存储,讲跳转到login.html")
layui.data('user', null);
location.href = "login.html";
}
......@@ -114,15 +117,17 @@
admin.setConfigPath("config/pear.config.yml");
// 动态设置配置文件中菜单树接口地址
let readConfig = admin.readConfig();
const menuUrl = EasyAdminContext.url + "/sys/menu/tree";
readConfig.menu.data = menuUrl;
// 动态加载菜单树
easyAdmin.httpGet("/sys/menu/tree", function (data) {
readConfig.menu.data = data;
}, true, false);
// 渲染
admin.render(readConfig);
// 登出逻辑
admin.logout(function () {
$.get(EasyAdminContext.url + "/api/v1/loginOut");
easyAdmin.httpGet("/api/v1/loginOut");
popup.success("注销成功", function () {
......
......@@ -42,19 +42,29 @@
<script src="component/layui/layui.js"></script>
<script src="component/pear/pear.js"></script>
<script>
layui.use(['form', 'button', 'popup', 'jquery'], function () {
layui.use(['form', 'button', 'popup', 'jquery', 'easyAdmin', 'yaml'], function () {
var form = layui.form;
var button = layui.button;
var popup = layui.popup;
let $ = layui.jquery;
var yaml = layui.yaml;
// 配置服务端地址,先获取adminServerUrl,否则第一次easyAdmin为空
let adminServerUrl = yaml.load("config/pear.config.yml").admin.server;
layui.data('easyAdmin', {
key: 'serverUrl'
, value: adminServerUrl
});
console.log('服务端地址:' + adminServerUrl);
let easyAdmin = layui.easyAdmin;
var uid;
captcha();
// 登 录 提 交
form.on('submit(login)', function (data) {
/// 登录
data.field.uid = uid;
$.ajax({
url: EasyAdminContext.url + '/api/v1/login',
easyAdmin.http({
url: '/api/v1/login',
sendToken: false,
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......@@ -63,9 +73,14 @@
if (result.success) {
layui.data('user', {
key: result.data.tokenName
, value: result.data.tokenValue
key: 'token'
, value: {
name: result.data.tokenName,
value: result.data.tokenValue
}
});
// 动画
button.load({
elem: '.login',
......@@ -91,10 +106,10 @@
function captcha() {
// 获取验证码
$.get(EasyAdminContext.url + '/captcha', function (res) {
easyAdmin.httpGet('/captcha', function (res) {
uid = res.data.uid;
$('#captcha').attr('src', res.data.image);
}, 'json');
}, false);
}
$("#captcha").click(function () {
......
......@@ -69,65 +69,64 @@
<script src="../../component/snaker/snaker.model.js" charset="utf-8" type="text/javascript"></script>
<script src="../../component/snaker/snaker.editors.js" type="text/javascript"></script>
<script>
var json = "";
$.ajaxSettings.async = false;
id = getQueryString("processId");
$.get(EasyAdminContext.url + "/flow/process/modelJson?processId=" + id, function (data, status) {
json = data;
});
$.ajaxSettings.async = true;
layui.use(['table', 'form', 'jquery', 'common', 'easyAdmin'], function () {
let easyAdmin = layui.easyAdmin;
id = getQueryString("processId");
easyAdmin.httpGet("/flow/process/modelJson?processId=" + id, function (data) {
var model = "";
if (data) {
model = eval("(" + data + ")");
}
$('#snakerflow').snakerflow({
basePath: "../../component/snaker/",
ctxPath: "/",
restore: model,
formPath: "forms/",
tools: {
save: {
onclick: function (data) {
// alert(data);
saveModel(data);
}
}
}
});
});
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r !== null)
return unescape(r[2]);
return "";
}
var model = "";
if (json) {
model = eval("(" + json + ")");
}
$('#snakerflow').snakerflow({
basePath: "../../component/snaker/",
ctxPath: "/",
restore: model,
formPath: "forms/",
tools: {
save: {
onclick: function (data) {
// alert(data);
saveModel(data);
}
}
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r !== null)
return unescape(r[2]);
return "";
}
});
window.saveModel = function (data) {
// alert(data);
$.ajax({
type: 'POST',
url: EasyAdminContext.url + "/flow/process/deployXml",
data: "model=" + data + "&id=" + id,
async: false,
globle: false,
error: function () {
alert('数据处理错误!');
return false;
},
success: function (data) {
if (data == true) {
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
parent.layui.table.reload("user-table");
} else {
window.saveModel = function (data) {
// alert(data);
easyAdmin.http({
type: 'POST',
url: "/flow/process/deployXml",
data: "model=" + data + "&id=" + id,
async: false,
globle: false,
error: function () {
alert('数据处理错误!');
return false;
},
success: function (data) {
if (data == true) {
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
parent.layui.table.reload("user-table");
} else {
alert('数据处理错误!');
}
}
}
});
});
}
}
})
</script>
</body>
</html>
......@@ -29,45 +29,48 @@
<script src="../../component/snaker/snaker.model.js" charset="utf-8" type="text/javascript"></script>
<script src="../../component/snaker/snaker.editors.js" type="text/javascript"></script>
<script>
layui.use(['table', 'form', 'jquery', 'common', 'easyAdmin'], function () {
let easyAdmin = layui.easyAdmin;
const orderId = getQueryString("orderId");
const processId = getQueryString("processId");
const orderId = getQueryString("orderId");
const processId = getQueryString("processId");
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r !== null)
return unescape(r[2]);
return "";
}
$.ajax({
type: 'GET',
url: EasyAdminContext.url + "/flow/process/json",
data: "processId=" + processId + "&orderId=" + orderId,
async: false,
globle: false,
error: function () {
alert('数据处理错误!');
return false;
},
success: function (data) {
display(data.process, data.state);
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r !== null)
return unescape(r[2]);
return "";
}
});
function display(process, state) {
/** view*/
$('#snakerflow').snakerflow($.extend(true, {
basePath: "../../component/snaker/",
ctxPath: EasyAdminContext.url,
orderId: orderId,
restore: eval("(" + process + ")"),
editable: false
}, eval("(" + state + ")")
));
easyAdmin.http({
type: 'GET',
url: "/flow/process/json",
data: "processId=" + processId + "&orderId=" + orderId,
async: false,
globle: false,
error: function () {
alert('数据处理错误!');
return false;
},
success: function (data) {
display(data.process, data.state);
}
});
}
function display(process, state) {
/** view*/
$('#snakerflow').snakerflow($.extend(true, {
basePath: "../../component/snaker/",
ctxPath: easyAdmin.GetAdminServerUrl(),
token: easyAdmin.GetTokenQueryString(),
orderId: orderId,
restore: eval("(" + process + ")"),
editable: false
}, eval("(" + state + ")")
));
}
})
</script>
</body>
</html>
......@@ -70,12 +70,12 @@
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'common'], function () {
layui.use(['table', 'form', 'jquery', 'common', 'easyAdmin'], function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let common = layui.common;
let easyAdmin = layui.easyAdmin;
let cols = [
[{
type: 'checkbox'
......@@ -116,9 +116,9 @@
]
]
table.render({
easyAdmin.tableRender({
elem: '#user-table',
url: EasyAdminContext.url + '/flow/order/list',
url: '/flow/order/list',
page: true,
cols: cols,
skin: 'line',
......@@ -184,8 +184,8 @@
}, function (index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: EasyAdminContext.url + "/flow/process/delete/" + obj.data['id'],
easyAdmin.http({
url: "/flow/process/delete/" + obj.data['id'],
dataType: 'json',
type: 'get',
success: function (result) {
......
......@@ -20,7 +20,8 @@
<div class="layui-form-item">
<label class="layui-form-label">请求理由</label>
<div class="layui-input-block">
<input type="text" name="leaveReason" lay-verify="title" autocomplete="off" placeholder="请输入请假理由"
<input type="text" name="leaveReason" lay-verify="title" autocomplete="off"
placeholder="请输入请假理由"
class="layui-textarea">
</div>
</div>
......@@ -43,13 +44,13 @@
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['form', 'jquery'], function () {
layui.use(['form', 'jquery', 'easyAdmin'], function () {
let form = layui.form;
let $ = layui.jquery;
let easyAdmin = layui.easyAdmin;
form.on('submit(user-save)', function (data) {
$.ajax({
url: EasyAdminContext.url + '/flow/startAndExecute?name=leave&version=2',
easyAdmin.http({
url: '/flow/startAndExecute?name=leave&version=2',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......
......@@ -70,12 +70,12 @@
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'common'], function () {
layui.use(['table', 'form', 'jquery', 'common', 'easyAdmin'], function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let common = layui.common;
let easyAdmin = layui.easyAdmin;
let cols = [
[{
type: 'checkbox'
......@@ -117,9 +117,9 @@
]
]
table.render({
easyAdmin.tableRender({
elem: '#user-table',
url: EasyAdminContext.url + '/flow/process/list',
url: '/flow/process/list',
page: true,
cols: cols,
skin: 'line',
......@@ -185,8 +185,8 @@
}, function (index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: EasyAdminContext.url + "/flow/process/delete/" + obj.data['id'],
easyAdmin.http({
url: "/flow/process/delete/" + obj.data['id'],
dataType: 'json',
type: 'get',
success: function (result) {
......
......@@ -43,12 +43,13 @@
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'element', 'popup'], function () {
layui.use(['table', 'form', 'jquery', 'element', 'popup', 'easyAdmin'], function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let element = layui.element;
var popup = layui.popup;
var easyAdmin = layui.easyAdmin;
let todoCols = [
[
{title: '流程名称', field: 'processName', align: 'center'},
......@@ -73,18 +74,18 @@
]
]
table.render({
easyAdmin.tableRender({
elem: '#todo-list-table',
url: EasyAdminContext.url + '/flow/task/todoList',
url: '/flow/task/todoList',
page: true,
cols: todoCols,
skin: 'line',
toolbar: false
});
table.render({
easyAdmin.tableRender({
elem: '#done-list-table',
url: EasyAdminContext.url + '/flow/task/doneList',
url: '/flow/task/doneList',
page: true,
cols: doneCols,
skin: 'line',
......@@ -134,8 +135,8 @@
});
window.agree = function (obj) {
$.ajax({
url: EasyAdminContext.url + "/flow/task/approval?taskId=" + obj.data['id'],
easyAdmin.http({
url: "/flow/task/approval?taskId=" + obj.data['id'],
dataType: 'json',
type: 'get',
success: function () {
......@@ -145,8 +146,8 @@
}
window.refuse = function (obj) {
$.ajax({
url: EasyAdminContext.url + "/flow/task/reject?taskId=" + obj.data['id'],
easyAdmin.http({
url: "/flow/task/reject?taskId=" + obj.data['id'],
dataType: 'json',
type: 'get',
success: function () {
......
......@@ -49,7 +49,7 @@
</div>
<div class="bottom">
<div class="button-container">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="dept-save">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
<i class="layui-icon layui-icon-ok"></i>
提交
</button>
......@@ -63,24 +63,27 @@
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['form', 'jquery', 'dtree'], function () {
layui.use(['form', 'jquery', 'dtree', 'easyAdmin'], function () {
let form = layui.form;
let $ = layui.jquery;
let dtree = layui.dtree;
let easyAdmin = layui.easyAdmin;
easyAdmin.httpGet("/sys/dept/tree", function (result) {
dtree.renderSelect({
elem: "#selectParent",
data: result.data,
method: 'get',
selectInputName: {nodeId: "pid", context: "deptName"},
dataFormat: "list",
response: {treeId: "deptId", parentId: "pid", title: "deptName"},
selectInitVal: "1"
});
})
dtree.renderSelect({
elem: "#selectParent",
url: EasyAdminContext.url + "/sys/dept/tree",
method: 'get',
selectInputName: {nodeId: "pid", context: "deptName"},
dataFormat: "list",
response: {treeId: "deptId", parentId: "pid", title: "deptName"},
selectInitVal: "1"
});
form.on('submit(dept-save)', function (data) {
$.ajax({
url: EasyAdminContext.url + '/sys/dept',
form.on('submit(save)', function (data) {
easyAdmin.http({
url: '/sys/dept',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......
......@@ -50,7 +50,7 @@
</div>
<div class="bottom">
<div class="button-container">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="dept-save">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
<i class="layui-icon layui-icon-ok"></i>
提交
</button>
......@@ -64,13 +64,14 @@
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['form', 'jquery'], function () {
layui.use(['form', 'jquery', 'easyAdmin'], function () {
let form = layui.form;
let $ = layui.jquery;
let easyAdmin = layui.easyAdmin;
// 根据menuId获取详情,用于数据回显
var deptId = EasyAdminContext.getQueryString("deptId");
$.ajax({
url: EasyAdminContext.url + '/sys/dept/' + deptId,
var deptId = easyAdmin.getQueryString("deptId");
easyAdmin.http({
url: '/sys/dept/' + deptId,
dataType: 'json',
contentType: 'application/json',
type: 'get',
......@@ -84,9 +85,9 @@
}
});
form.on('submit(dept-save)', function (data) {
$.ajax({
url: EasyAdminContext.url + '/sys/dept',
form.on('submit(save)', function (data) {
easyAdmin.http({
url: '/sys/dept',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......
......@@ -30,7 +30,7 @@
<div class="layui-card">
<div class="layui-card-body">
<table id="dept-table" lay-filter="dept-table"></table>
<table id="table" lay-filter="dept-table"></table>
</div>
</div>
......@@ -60,41 +60,46 @@
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'treetable', 'popup'], function () {
layui.use(['table', 'form', 'jquery', 'treetable', 'popup', 'easyAdmin'], function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let treetable = layui.treetable;
let popup = layui.popup;
let easyAdmin = layui.easyAdmin;
let MODULE_PATH = "dept/";
window.render = function () {
treetable.render({
treeColIndex: 1,
treeSpid: 0,
treeIdName: 'deptId',
treePidName: 'pid',
skin: 'line',
method: 'get',
treeDefaultClose: true,
toolbar: '#dept-toolbar',
elem: '#dept-table',
url: EasyAdminContext.url + '/sys/dept/data',
page: false,
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'],
cols: [
[
{type: 'checkbox'},
{field: 'deptName', minWidth: 200, title: '部门名称'},
{field: 'address', title: '详细地址'},
{field: 'status', title: '状态', templet: '#dept-status'},
{field: 'sort', title: '排序', width: 100},
{title: '操作', templet: '#dept-bar', width: 120, align: 'center'}
easyAdmin.httpGet('/sys/dept/data', function (result) {
treetable.render({
data: result.data,
treeColIndex: 1,
treeSpid: 0,
treeIdName: 'deptId',
treePidName: 'pid',
skin: 'line',
method: 'get',
treeDefaultClose: true,
toolbar: '#dept-toolbar',
elem: '#table',
page: false,
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'],
cols: [
[
{type: 'checkbox'},
{field: 'deptName', minWidth: 200, title: '部门名称'},
{field: 'address', title: '详细地址'},
{field: 'status', title: '状态', templet: '#dept-status'},
{field: 'sort', title: '排序', width: 100},
{title: '操作', templet: '#dept-bar', width: 120, align: 'center'}
]
]
]
});
});
})
}
render();
form.on('submit(dept-query)', function (data) {
var keyword = data.field.deptName;
var $tds = $('#dept-table').next('.treeTable').find('.layui-table-body tbody tr td');
......
此差异已折叠。
......@@ -60,40 +60,44 @@
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'treetable', 'popup'], function () {
layui.use(['table', 'form', 'jquery', 'treetable', 'popup', 'easyAdmin'], function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let treetable = layui.treetable;
let popup = layui.popup;
let easyAdmin = layui.easyAdmin;
let MODULE_PATH = "power/";
window.render = function () {
treetable.render({
treeColIndex: 1,
treeSpid: 0,
treeIdName: 'menuId',
treePidName: 'pid',
skin: 'line',
treeDefaultClose: true,
toolbar: '#power-toolbar',
elem: '#power-table',
url: EasyAdminContext.url + '/sys/menu/list',
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'],
page: false,
cols: [
[
{type: 'checkbox'},
{field: 'title', minWidth: 200, title: '权限名称'},
{field: 'icon', title: '图标', templet: '#icon'},
{field: 'type', title: '权限类型', templet: '#power-type'},
{field: 'enable', title: '是否可用', templet: '#power-enable'},
{field: 'sort', title: '排序'},
{title: '操作', templet: '#power-bar', width: 150, align: 'center'}
easyAdmin.httpGet('/sys/menu/list', function (result) {
treetable.render({
treeColIndex: 1,
treeSpid: 0,
treeIdName: 'menuId',
treePidName: 'pid',
skin: 'line',
treeDefaultClose: true,
toolbar: '#power-toolbar',
elem: '#power-table',
data: result.data,
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'],
page: false,
cols: [
[
{type: 'checkbox'},
{field: 'title', minWidth: 200, title: '权限名称'},
{field: 'icon', title: '图标', templet: '#icon'},
{field: 'type', title: '权限类型', templet: '#power-type'},
{field: 'enable', title: '是否可用', templet: '#power-enable'},
{field: 'sort', title: '排序'},
{title: '操作', templet: '#power-bar', width: 150, align: 'center'}
]
]
]
});
});
})
}
render();
......@@ -123,8 +127,8 @@
form.on('switch(power-enable)', function (obj) {
let loading = layer.load();
$.ajax({
url: EasyAdminContext.url + '/sys/menu',
easyAdmin.http({
url: '/sys/menu',
data: JSON.stringify({menuId: this.value, enable: obj.elem.checked}),
dataType: 'json',
contentType: 'application/json',
......
......@@ -87,23 +87,26 @@
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['form', 'jquery', 'iconPicker', 'dtree'], function () {
layui.use(['form', 'jquery', 'iconPicker', 'dtree', 'easyAdmin'], function () {
let form = layui.form;
let $ = layui.jquery;
let iconPicker = layui.iconPicker;
let dtree = layui.dtree;
let easyAdmin = layui.easyAdmin;
easyAdmin.httpGet("/sys/menu/selectTree", function (result) {
dtree.renderSelect({
elem: "#selectParent",
data: result.data,
method: 'get',
selectInputName: {nodeId: "pid", context: "title"},
// skin: "layui", // 换皮肤
line: true, // 显示树线
dataStyle: "layuiStyle",
response: {parentId: "pid", title: "title", message: "msg", statusCode: 0}, //修改json response中返回数据的定义
selectInitVal: "0"
});
})
dtree.renderSelect({
elem: "#selectParent",
url: EasyAdminContext.url + "/sys/menu/selectTree",
method: 'get',
selectInputName: {nodeId: "pid", context: "title"},
// skin: "layui", // 换皮肤
line: true, // 显示树线
dataStyle: "layuiStyle",
response: {parentId: "pid", title: "title", message: "msg", statusCode: 0}, //修改json response中返回数据的定义
selectInitVal: "0"
});
form.on("radio(powerType)", function () {
if (this.value == '0') {
......@@ -129,8 +132,8 @@
form.on('submit(power-save)', function (data) {
data.field.icon = "layui-icon " + data.field.icon;
$.ajax({
url: EasyAdminContext.url + '/sys/menu',
easyAdmin.http({
url: '/sys/menu',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......
......@@ -87,18 +87,19 @@
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['form', 'jquery', 'dtree', 'iconPicker'], function () {
layui.use(['form', 'jquery', 'dtree', 'iconPicker', 'easyAdmin'], function () {
let form = layui.form;
let $ = layui.jquery;
let dtree = layui.dtree;
let iconPicker = layui.iconPicker;
let easyAdmin = layui.easyAdmin;
let menuId;
form.on('submit(power-save)', function (data) {
data.field.icon = "layui-icon " + data.field.icon;
data.field.menuId = menuId;
$.ajax({
url: EasyAdminContext.url + '/sys/menu',
easyAdmin.http({
url: '/sys/menu',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......@@ -118,9 +119,9 @@
});
// 根据menuId获取详情,用于数据回显
menuId = EasyAdminContext.getQueryString("menuId");
$.ajax({
url: EasyAdminContext.url + '/sys/menu/' + menuId,
menuId = easyAdmin.getQueryString("menuId");
easyAdmin.http({
url: '/sys/menu/' + menuId,
dataType: 'json',
contentType: 'application/json',
type: 'get',
......@@ -129,17 +130,20 @@
// 表单数据回显
form.val("edit", result.data);
// 树形选择框回显
dtree.renderSelect({
elem: "#selectParent",
url: EasyAdminContext.url + "/sys/menu/selectTree",
method: 'get',
selectInputName: {nodeId: "pid", context: "title"},
// skin: "layui", // 换皮肤
line: true, // 显示树线
dataStyle: "layuiStyle",
response: {parentId: "pid", title: "title", message: "msg", statusCode: 0}, //修改json response中返回数据的定义
selectInitVal: result.data.pid + ''
});
easyAdmin.httpGet("/sys/menu/selectTree", function (result) {
dtree.renderSelect({
elem: "#selectParent",
method: 'get',
data: result.data,
selectInputName: {nodeId: "pid", context: "title"},
// skin: "layui", // 换皮肤
line: true, // 显示树线
dataStyle: "layuiStyle",
response: {parentId: "pid", title: "title", message: "msg", statusCode: 0}, //修改json response中返回数据的定义
selectInitVal: result.data.pid + ''
});
})
iconPicker.checkIcon("icon", result.data.icon);
......
......@@ -42,13 +42,13 @@
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'popup', 'common'], function () {
layui.use(['table', 'form', 'jquery', 'popup', 'common', 'easyAdmin'], function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let popup = layui.popup;
let common = layui.common;
let easyAdmin = layui.easyAdmin;
let MODULE_PATH = "role/";
let cols = [
......@@ -62,9 +62,9 @@
]
]
table.render({
easyAdmin.tableRender({
elem: '#role-table',
url: EasyAdminContext.url + '/sys/role',
url: '/sys/role',
page: true,
cols: cols,
skin: 'line',
......@@ -108,12 +108,12 @@
operate = "disable";
}
let loading = layer.load()
$.ajax({
easyAdmin.http({
url: '/system/role/' + operate,
data: JSON.stringify({roleId: this.value}),
dataType: 'json',
contentType: 'application/json',
type: 'put',
type: 'post',
success: function (result) {
layer.close(loading);
if (result.success) {
......@@ -159,8 +159,8 @@
layer.confirm('确定要删除该角色', {icon: 3, title: '提示'}, function (index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: EasyAdminContext.url + "/sys/role/" + obj.data['roleId'],
easyAdmin.http({
url: "/sys/role/" + obj.data['roleId'],
dataType: 'json',
type: 'delete',
success: function (result) {
......
......@@ -56,13 +56,13 @@
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['form', 'jquery'], function () {
layui.use(['form', 'jquery','easyAdmin'], function () {
let form = layui.form;
let $ = layui.jquery;
let easyAdmin = layui.easyAdmin;
form.on('submit(role-save)', function (data) {
$.ajax({
url: EasyAdminContext.url + '/sys/role',
easyAdmin.http({
url: '/sys/role',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......
......@@ -63,14 +63,14 @@
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['form', 'jquery'], function () {
layui.use(['form', 'jquery', 'easyAdmin'], function () {
let form = layui.form;
let $ = layui.jquery;
let easyAdmin = layui.easyAdmin;
form.on('submit(role-update)', function (data) {
$.ajax({
url: EasyAdminContext.url + '/sys/role',
easyAdmin.http({
url: '/sys/role',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......@@ -91,9 +91,9 @@
// 根据menuId获取详情,用于数据回显
var roleId = EasyAdminContext.getQueryString("roleId");
$.ajax({
url: EasyAdminContext.url + '/sys/role/' + roleId,
var roleId = easyAdmin.getQueryString("roleId");
easyAdmin.http({
url: '/sys/role/' + roleId,
dataType: 'json',
contentType: 'application/json',
type: 'get',
......
......@@ -30,23 +30,27 @@
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
layui.use(['dtree', 'form', 'jquery'], function () {
layui.use(['dtree', 'form', 'jquery', 'easyAdmin'], function () {
let dtree = layui.dtree;
let form = layui.form;
let $ = layui.jquery;
let easyAdmin = layui.easyAdmin;
// 根据menuId获取详情,用于数据回显
var roleId = EasyAdminContext.getQueryString("roleId");
dtree.render({
elem: "#role-power",
method: "get",
url: EasyAdminContext.url + "/sys/role/getRolePower?roleId=" + roleId,
dataFormat: "list",
checkbar: true,
// skin: "layui",
initLevel: "1",
checkbarType: "self",
response: {treeId: "menuId", parentId: "pid", title: "title"},
});
var roleId = easyAdmin.getQueryString("roleId");
easyAdmin.httpGet("/sys/role/getRolePower?roleId=" + roleId, function (result) {
dtree.render({
elem: "#role-power",
method: "get",
data: result.data,
dataFormat: "list",
checkbar: true,
// skin: "layui",
initLevel: "1",
checkbarType: "self",
response: {treeId: "menuId", parentId: "pid", title: "title"},
});
})
form.on('submit(power-save)', function (data) {
let param = dtree.getCheckbarNodesParam("role-power");
......@@ -59,8 +63,8 @@
data.field.roleId = roleId;
data.field.powerIds = ids;
$.ajax({
url: EasyAdminContext.url + '/sys/role/saveRolePower',
easyAdmin.http({
url: '/sys/role/saveRolePower',
data: data.field,
dataType: 'json',
type: 'put',
......
......@@ -94,12 +94,12 @@
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'common', 'dtree'], function () {
layui.use(['table', 'form', 'common', 'dtree', 'easyAdmin'], function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let common = layui.common;
let dtree = layui.dtree;
let easyAdmin = layui.easyAdmin;
let MODULE_PATH = "user/";
let cols = [
......@@ -149,20 +149,21 @@
]
]
dtree.renderSelect({
elem: "#selectParent",
url: EasyAdminContext.url + "/sys/dept/tree",
method: 'get',
selectInputName: {nodeId: "deptId", context: "deptName"},
// skin: "layui",
dataFormat: "list",
response: {treeId: "deptId", parentId: "pid", title: "deptName"},
selectInitVal: "1"
});
easyAdmin.httpGet("/sys/dept/tree", function (data) {
dtree.renderSelect({
elem: "#selectParent",
data: data.data,
selectInputName: {nodeId: "deptId", context: "deptName"},
// skin: "layui",
dataFormat: "list",
response: {treeId: "deptId", parentId: "pid", title: "deptName"},
selectInitVal: "1"
});
})
table.render({
easyAdmin.tableRender({
elem: '#user-table', // 对应table的id
url: EasyAdminContext.url + '/sys/user', // 异步请求url
url: "/sys/user",
page: true, // 分页参数可以自定义
cols: cols, // 列表示
skin: 'line', // 表格样式
......@@ -173,6 +174,7 @@
icon: 'layui-icon-refresh',
}, 'filter', 'print', 'exports']
});
// 触发行中工具条点击事件 (操作列)
// table.on('event(filter)', callback); filter为容器lay-filter设定的值
// cols: [[{fixed: 'right', width:150, align:'center', toolbar: '#barDemo'}
......@@ -182,7 +184,7 @@
window.remove(obj);
break;
case 'edit':
window.edit(obj);
easyAdmin.JumpEdit(MODULE_PATH, obj.data.userId)
break;
}
});
......@@ -191,10 +193,10 @@
table.on('toolbar(user-filter)', function (obj) {
switch (obj.event) {
case 'add':
window.add();
easyAdmin.JumpAdd(MODULE_PATH);
break;
case 'refresh':
window.refresh();
easyAdmin.tableRefresh('user-table');
break;
case 'batchRemove':
window.batchRemove(obj);
......@@ -219,8 +221,8 @@
// 触发switch开关 开关被点击时触发
form.on('switch(user-enable)', function (obj) {
layer.tips(this.value + ' ' + this.name + '' + obj.elem.checked, obj.othis);
$.ajax({
url: EasyAdminContext.url + '/sys/user',
easyAdmin.http({
url: '/sys/user',
data: JSON.stringify({
userId: this.value,
enable: obj.elem.checked ? 1 : 0
......@@ -241,26 +243,6 @@
})
});
window.add = function () {
layer.open({
type: 2,
title: '新增',
shade: 0.1,
area: [common.isModile() ? '100%' : '500px', common.isModile() ? '100%' : '500px'],
content: MODULE_PATH + 'add.html'
});
}
window.edit = function (obj) {
var data = obj.data;
layer.open({
type: 2,
title: '修改',
shade: 0.1,
area: ['500px', '500px'],
content: [MODULE_PATH + 'edit.html?userId=' + data.userId, 'no']
});
}
window.remove = function (obj) {
layer.confirm('确定要删除该用户', {
......@@ -269,8 +251,8 @@
}, function (index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: EasyAdminContext.url + "/sys/user/" + obj.data['userId'],
easyAdmin.http({
url: "/sys/user/" + obj.data['userId'],
dataType: 'json',
type: 'delete',
success: function (result) {
......@@ -315,7 +297,7 @@
}, function (index) {
layer.close(index);
let loading = layer.load();
$.ajax({
easyAdmin.http({
url: MODULE_PATH + "batchRemove/" + ids,
dataType: 'json',
type: 'delete',
......@@ -338,10 +320,6 @@
})
});
}
window.refresh = function (param) {
table.reload('user-table');
}
})
</script>
</body>
......
......@@ -79,7 +79,7 @@
</div>
<div class="bottom">
<div class="button-container">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="save">
<i class="layui-icon layui-icon-ok"></i>
提交
</button>
......@@ -102,13 +102,14 @@
<script>
layui.use(['form', 'jquery', 'laytpl', 'dtree'], function () {
layui.use(['form', 'jquery', 'laytpl', 'dtree', 'easyAdmin'], function () {
let form = layui.form;
let $ = layui.jquery;
let dtree = layui.dtree;
var laytpl = layui.laytpl;
var easyAdmin = layui.easyAdmin;
$.get(EasyAdminContext.url + "/sys/user/getRoles", function (result) {
easyAdmin.httpGet("/sys/user/getRoles", function (result) {
var getTpl = demo.innerHTML;
var view = document.getElementById('view11');
laytpl(getTpl).render(result, function (html) {
......@@ -118,17 +119,18 @@
form.render();
});
easyAdmin.httpGet("/sys/dept/tree", function (treeData) {
dtree.renderSelect({
elem: "#selectParent",
data: treeData.data,
selectInputName: {nodeId: "deptId", context: "deptName"},
// skin: "layui",
dataFormat: "list",
response: {treeId: "deptId", parentId: "pid", title: "deptName"},
selectInitVal: "1"
});
})
dtree.renderSelect({
elem: "#selectParent",
url: EasyAdminContext.url + "/sys/dept/tree",
method: 'get',
selectInputName: {nodeId: "deptId", context: "deptName"},
// skin: "layui",
dataFormat: "list",
response: {treeId: "deptId", parentId: "pid", title: "deptName"},
selectInitVal: "1"
});
form.on('submit(user-save)', function (data) {
let roleIds = "";
......@@ -137,10 +139,8 @@
});
roleIds = roleIds.substr(0, roleIds.length - 1);
data.field.roleIds = roleIds;
alert(roleIds)
console.log(data);
$.ajax({
url: EasyAdminContext.url + '/sys/user',
easyAdmin.http({
url: '/sys/user',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......
......@@ -92,13 +92,13 @@
</script>
<script>
layui.use(['form', 'jquery', 'dtree'], function () {
layui.use(['form', 'jquery', 'dtree', 'easyAdmin', 'popup'], function () {
let form = layui.form;
let $ = layui.jquery;
var id;
var popup = layui.popup;
let dtree = layui.dtree;
let easyAdmin = layui.easyAdmin;
var id;
form.on('submit(user-save)', function (data) {
let roleIds = "";
......@@ -109,8 +109,8 @@
data.field.roleIds = roleIds;
data.field.userId = id;
$.ajax({
url: EasyAdminContext.url + '/sys/user',
easyAdmin.http({
url: '/sys/user',
data: JSON.stringify(data.field),
dataType: 'json',
contentType: 'application/json',
......@@ -129,22 +129,10 @@
return false;
});
//说明:获取url参数
//参数obj:访问路径
//返回值:参数
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r !== null)
return unescape(r[2]);
return null;
}
id = getQueryString("userId");
$.ajax({
url: EasyAdminContext.url + '/sys/user/' + id,
id = easyAdmin.getQueryString("id");
easyAdmin.http({
url: '/sys/user/' + id,
dataType: 'json',
contentType: 'application/json',
type: 'get',
......@@ -152,16 +140,19 @@
if (result.success) {
//表单数据回显
form.val("edit", result.data);
dtree.renderSelect({
elem: "#selectParent",
url: EasyAdminContext.url + "/sys/dept/tree",
method: 'get',
selectInputName: {nodeId: "deptId", context: "deptName"},
// skin: "layui",
dataFormat: "list",
response: {treeId: "deptId", parentId: "pid", title: "deptName"},
selectInitVal: result.data.deptId + ''
});
easyAdmin.httpGet("/sys/dept/tree", function (treeData) {
dtree.renderSelect({
elem: "#selectParent",
data: treeData.data,
method: 'get',
selectInputName: {nodeId: "deptId", context: "deptName"},
// skin: "layui",
dataFormat: "list",
response: {treeId: "deptId", parentId: "pid", title: "deptName"},
selectInitVal: result.data.deptId + ''
});
})
} else {
layer.msg(result.msg, {icon: 2, time: 1000});
}
......@@ -170,7 +161,7 @@
var laytpl = layui.laytpl;
$.get(EasyAdminContext.url + "/sys/user/getRoles?userId=" + id, function (result) {
easyAdmin.httpGet("/sys/user/getRoles?userId=" + id, function (result) {
var getTpl = demo.innerHTML;
var view = document.getElementById('view11');
laytpl(getTpl).render(result, function (html) {
......
......@@ -20,7 +20,7 @@
autocomplete="off"
class="layui-input">
</div>
<button type="button" class="layui-btn" onclick="getLogFile()">查看
<button id="query" type="button" class="layui-btn">查看
</button>
</div>
</div>
......@@ -40,7 +40,7 @@
<option value="ERROR">ERROR</option>
</select>
<button type="button" class="layui-btn" onclick="updateLogLevel() ">
<button id="update" type="button" class="layui-btn">
更改
</button>
......@@ -55,45 +55,61 @@
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
var $; // 使用jQuery
var baseApi = EasyAdminContext.url + "/sys/weblog/file";
var layer;
layui.use(['jquery', 'layer'], function () { // 加载jQuery组件
$ = layui.$; //使用jQuery 重点处
layer = layui.layer;
$("#log-frame").attr("src", baseApi)
});
function getLogFile() {
var url = $('#url').val();
$("#log-frame").attr("src", baseApi + "?filePath=" + url);
}
function updateLogLevel() {
var packgeName = $('#packgeName').val();
var level = $('#level').val();
$.get(EasyAdminContext.url + "/sys/weblog/level", {name: packgeName, configuredLevel: level},
function (data) {
if (data !== "ok") {
layer.msg(data, {
icon: 0,
time: 3000 //2秒关闭(如果不配置,默认是3秒)
});
return;
}
layer.msg('日志级别设置成功!', {
icon: 1,
time: 3000 //2秒关闭(如果不配置,默认是3秒)
},
function () {
//do something
});
getLogFile();
})
;
}
layui.use(['table', 'form', 'common', 'dtree', 'easyAdmin'], function () {
var baseApi = "/sys/weblog/file";
var $ = layui.$; //使用jQuery 重点处
var layer = layui.layer;
var easyAdmin = layui.easyAdmin;
getLogFile();
function getLogFile() {
var url = $('#url').val();
// 配置服务端地址
var adminServerUrl = layui.data('easyAdmin').serverUrl;
var user = layui.data('user');
// 用于判断未登录跳转到登录页
if (JSON.stringify(user) == "{}") {
console.log("当前浏览器存储中没有用户信息,讲跳转到login.html")
location.href = "login.html";
}
$("#log-frame").attr("src", adminServerUrl + baseApi + "?filePath=" + url + "&" + user.token.name + "=" + user.token.value);
}
$("#query").click(function () {
getLogFile();
})
$("#update").click(function () {
updateLogLevel();
})
function updateLogLevel() {
var packgeName = $('#packgeName').val();
var level = $('#level').val();
easyAdmin.httpGet("/sys/weblog/level?name=" + packgeName + "&configuredLevel=" + level,
function (data) {
if (data !== "ok") {
layer.msg(data, {
icon: 0,
time: 3000 //2秒关闭(如果不配置,默认是3秒)
});
return;
}
layer.msg('日志级别设置成功!', {
icon: 1,
time: 3000 //2秒关闭(如果不配置,默认是3秒)
},
function () {
//do something
});
getLogFile();
})
;
}
})
</script>
</body>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册