edit 填充参数

v1.0
bobi 2019-05-21 11:30:43 +08:00
parent af683291d3
commit e3385ca165
8 changed files with 62 additions and 35 deletions

View File

@ -6,121 +6,132 @@
{
"id": "001",
"username": "zhangsan",
"name": "张三",
"reallyName": "张三",
"password": "111111",
"status": 0,
"role": 0,
"email": "zhangsan@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "002",
"username": "lisi",
"name": "李四",
"reallyName": "李四",
"password": "111111",
"status": 0,
"role": 0,
"email": "lisi@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "003",
"username": "wangwu",
"name": "王五",
"reallyName": "王五",
"password": "111111",
"status": 1,
"role": 1,
"email": "wangwu@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "004",
"username": "zhaoliu",
"name": "赵六",
"reallyName": "赵六",
"password": "111111",
"status": 1,
"role": 1,
"email": "zhaoliu@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "005",
"username": "sunqi",
"name": "孙七",
"reallyName": "孙七",
"password": "111111",
"status": 1,
"role": 1,
"email": "sunqi@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "006",
"username": "zhouba",
"name": "周八",
"reallyName": "周八",
"password": "111111",
"status": 1,
"role": 1,
"email": "zhouba@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "007",
"username": "wujiu",
"name": "吴九",
"reallyName": "吴九",
"password": "111111",
"status": 1,
"role": 1,
"email": "wujiu@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "008",
"username": "zhengshi",
"name": "郑十",
"reallyName": "郑十",
"password": "111111",
"status": 1,
"role": 1,
"email": "zhengshi@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "009",
"username": "liubei",
"name": "刘备",
"reallyName": "刘备",
"password": "111111",
"status": 1,
"role": 1,
"email": "liubei@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "010",
"username": "zhangfei",
"name": "张飞",
"reallyName": "张飞",
"password": "111111",
"status": 1,
"role": 1,
"email": "zhangfei@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
},
{
"id": "011",
"username": "guanyu",
"name": "关羽",
"reallyName": "关羽",
"password": "111111",
"status": 1,
"role": 1,
"email": "guanyu@qq.com",
"phone": "13222222222",
"createTime": "2018-05-06 18:15:28",
"logins": 24
}

View File

@ -16,9 +16,10 @@ layui.define(["layer"], function (exports) {
* @param content
* @param width
* @param height
* @param isRefreshTable
* @param successFunction
* @param endFunction
*/
open: function (title, content, width, height, callbackFunction) {
open: function (title, content, width, height, successFunction, endFunction) {
layer.open({
title: title,
type: 2,
@ -29,7 +30,8 @@ layui.define(["layer"], function (exports) {
content: content,
zIndex: layer.zIndex,
skin: okLayer.skinChoose(),
end: callbackFunction
success: successFunction,
end: endFunction
});
},
/**

View File

@ -158,13 +158,13 @@
}
function add () {
okLayer.open("添加文章", "article-add.html", "90%", "90%", function () {
okLayer.open("添加文章", "article-add.html", "90%", "90%", null, function () {
articleTable.reload();
})
}
function edit (id) {
okLayer.open("编辑文章", "article-edit.html?id=" + id, "90%", "90%", function () {
okLayer.open("编辑文章", "article-edit.html?id=" + id, "90%", "90%", null, function () {
articleTable.reload();
})
}

View File

@ -103,7 +103,7 @@
});
function add () {
okLayer.open("添加角色", "role-add.html", "90%", "90%", function () {
okLayer.open("添加角色", "role-add.html", "90%", "90%", null, function () {
roleTable.reload();
})
}
@ -124,7 +124,7 @@
}
function edit (id) {
okLayer.open("编辑角色", "role-edit.html?id=" + id, "90%", "90%", function () {
okLayer.open("编辑角色", "role-edit.html?id=" + id, "90%", "90%", null, function () {
roleTable.reload();
})
}

View File

@ -64,9 +64,10 @@ okLayer.confirm("确定要批量删除吗?", function (index) {
* @param content 内容url
* @param width 弹窗宽度
* @param height 弹窗高度
* @param function 回调函数
* @param successFunction 弹出后回调函数
* @param endFunction 销毁后回调函数
*/
okLayer.open("添加用户", "user-add.html", "90%", "90%", function() {})
okLayer.open("添加用户", "user-add.html", "90%", "90%", function(layero, index) {}, function() {})
</pre>
</div>
<!--js逻辑-->

View File

@ -30,8 +30,7 @@
<i class="iconfont icon-ai-new"></i> XX管理
</a>
<dl class="layui-nav-child">
// tab-id不可和其它菜单重复
<dd><a href="javascript:;" path="xx.html" tab-id="xx-1"><i class="iconfont icon-xx"></i> xx列表</a></dd>
<dd><a href="javascript:;" path="xx.html"><i class="iconfont icon-xx"></i> xx列表</a></dd>
</dl>
</li>
</pre>
@ -43,9 +42,9 @@
<pre class="layui-code" lay-title="HTML" lay-encode="true">
<dl class="layui-nav-child">
<dd><a href="javascript:;" path="user-center.html" tab-id="0-1">个人中心<span class="layui-badge-dot"></span></a></dd>
<dd><a href="javascript:;" path="user-info.html" tab-id="0-2">基本资料</a></dd>
<dd><a href="javascript:;" path="user-security.html" tab-id="0-3">安全设置</a></dd>
<dd><a href="javascript:;" path="user-center.html">个人中心<span class="layui-badge-dot"></span></a></dd>
<dd><a href="javascript:;" path="user-info.html">基本资料</a></dd>
<dd><a href="javascript:;" path="user-security.html">安全设置</a></dd>
<dd><a href="javascript:;" id="lock">锁定账户</a></dd>
</dl>
</pre>

View File

@ -21,7 +21,7 @@
</a>
</div>
<!--form表单-->
<form class="layui-form ok-form">
<form class="layui-form ok-form" lay-filter="filter">
<div class="layui-form-item">
<label class="layui-form-label">用户名</label>
<div class="layui-input-block">
@ -105,6 +105,13 @@
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
var initData;
function initForm(data) {
var jsonString = JSON.stringify(data)
initData = JSON.parse(jsonString);
}
layui.config({
base: "../../lib/okPlugins/"
}).extend({
@ -115,7 +122,9 @@
var laydate = layui.laydate;
var okLayer = layui.okLayer;
var okUtils = layui.okUtils;
form.val("filter", initData);
laydate.render({elem: "#birthday", type: "datetime"});
form.verify({

View File

@ -64,14 +64,15 @@
{type: "checkbox"},
{field: "id", title: "ID", width: 80, sort: true},
{field: "username", title: "用户名", width: 100},
{field: "name", title: "姓名", width: 100},
{field: "reallyName", title: "姓名", width: 100},
{field: "password", title: "密码", width: 100},
{field: "status", title: "状态", width: 85, templet: "#statusTpl"},
{field: "role", title: "角色", width: 100, templet: "#roleTpl"},
{field: "email", title: "邮箱", width: 200},
{field: "email", title: "邮箱", width: 200},
{field: "phone", title: "电话号码", width: 200},
{field: "createTime", title: "创建时间", width: 200},
{field: "status", title: "状态", width: 100, templet: "#statusTpl"},
{field: "logins", title: "登陆次数", width: 100},
{title: "操作", width: 200, align: 'center', templet: "#operationTpl"}
{title: "操作", width: 100, align: 'center', templet: "#operationTpl", fixed: "right"}
]],
done: function (res, curr, count) {
console.log(res, curr, count)
@ -105,9 +106,10 @@
table.on("tool(tableFilter)", function (obj) {
var data = obj.data;
console.log(data);
switch (obj.event) {
case "edit":
edit(data.id);
edit(data);
break;
case "del":
del(data.id);
@ -161,13 +163,16 @@
}
function add () {
okLayer.open("添加用户", "user-add.html", "90%", "90%", function () {
okLayer.open("添加用户", "user-add.html", "90%", "90%", null, function () {
userTable.reload();
})
}
function edit (id) {
okLayer.open("编辑用户", "user-edit.html?id=" + id, "90%", "90%", function () {
function edit (data) {
okLayer.open("编辑用户", "user-edit.html", "90%", "90%", function (layero) {
var iframeWin = window[layero.find("iframe")[0]["name"]];
iframeWin.initForm(data);
}, function () {
userTable.reload();
})
}