save
This commit is contained in:
parent
6e20a09b86
commit
3ef5204166
@ -107,68 +107,69 @@
|
|||||||
const UPDATE_URL = "/app/admin/admin/update";
|
const UPDATE_URL = "/app/admin/admin/update";
|
||||||
|
|
||||||
// 字段 创建时间 created_at
|
// 字段 创建时间 created_at
|
||||||
layui.use(['laydate'], function() {
|
layui.use(["laydate"], function() {
|
||||||
layui.laydate.render({
|
layui.laydate.render({
|
||||||
elem: '#created_at',
|
elem: "#created_at",
|
||||||
range: ['#created_at-date-start', '#created_at-date-end'],
|
range: ["#created_at-date-start", "#created_at-date-end"],
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
// 表格渲染
|
// 表格渲染
|
||||||
layui.use(['table', 'form', 'jquery', 'common', 'popup'], function() {
|
layui.use(['table', 'form', 'jquery', 'common', 'popup', 'util'], function() {
|
||||||
let table = layui.table;
|
let table = layui.table;
|
||||||
let form = layui.form;
|
let form = layui.form;
|
||||||
let $ = layui.jquery;
|
let $ = layui.jquery;
|
||||||
let common = layui.common;
|
let common = layui.common;
|
||||||
|
let util = layui.util;
|
||||||
|
|
||||||
// 表头参数
|
// 表头参数
|
||||||
let cols = [
|
let cols = [
|
||||||
{
|
{
|
||||||
type: 'checkbox'
|
type: "checkbox"
|
||||||
},{
|
},{
|
||||||
title: 'ID',
|
title: "ID",
|
||||||
field: 'id',
|
field: "id",
|
||||||
},{
|
},{
|
||||||
title: '用户名',
|
title: "用户名",
|
||||||
field: 'username',
|
field: "username",
|
||||||
},{
|
},{
|
||||||
title: '昵称',
|
title: "昵称",
|
||||||
field: 'nickname',
|
field: "nickname",
|
||||||
},{
|
},{
|
||||||
title: '密码',
|
title: "密码",
|
||||||
field: 'password',
|
field: "password",
|
||||||
hide: true,
|
hide: true,
|
||||||
},{
|
},{
|
||||||
title: '头像',
|
title: "头像",
|
||||||
field: 'avatar',
|
field: "avatar",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
return '<img src="'+d.avatar+'" style="max-width:32px;max-height:32px;" alt="" />';
|
return '<img src="'+encodeURI(d['avatar'])+'" style="max-width:32px;max-height:32px;" alt="" />'
|
||||||
}
|
}
|
||||||
},{
|
},{
|
||||||
title: '邮箱',
|
title: "邮箱",
|
||||||
field: 'email',
|
field: "email",
|
||||||
},{
|
},{
|
||||||
title: '手机',
|
title: "手机",
|
||||||
field: 'mobile',
|
field: "mobile",
|
||||||
},{
|
},{
|
||||||
title: '创建时间',
|
title: "创建时间",
|
||||||
field: 'created_at',
|
field: "created_at",
|
||||||
hide: true,
|
hide: true,
|
||||||
},{
|
},{
|
||||||
title: '更新时间',
|
title: "更新时间",
|
||||||
field: 'updated_at',
|
field: "updated_at",
|
||||||
hide: true,
|
hide: true,
|
||||||
},{
|
},{
|
||||||
title: '角色',
|
title: "角色",
|
||||||
field: 'roles',
|
field: "roles",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
let field = 'roles';
|
let field = "roles";
|
||||||
if (typeof d[field] == "undefined") return '';
|
if (typeof d[field] == "undefined") return "";
|
||||||
let items = [];
|
let items = [];
|
||||||
layui.each((d[field] + '').split(','), function (k , v) {
|
layui.each((d[field] + "").split(","), function (k , v) {
|
||||||
items.push(apiResults[field][v] || v);
|
items.push(apiResults[field][v] || v);
|
||||||
});
|
});
|
||||||
return items.join(',');
|
return util.escape(items.join(","));
|
||||||
}
|
}
|
||||||
},{
|
},{
|
||||||
title: "操作",
|
title: "操作",
|
||||||
@ -182,19 +183,19 @@
|
|||||||
function render()
|
function render()
|
||||||
{
|
{
|
||||||
table.render({
|
table.render({
|
||||||
elem: '#data-table',
|
elem: "#data-table",
|
||||||
url: SELECT_API,
|
url: SELECT_API,
|
||||||
page: true,
|
page: true,
|
||||||
cols: [cols],
|
cols: [cols],
|
||||||
skin: 'line',
|
skin: "line",
|
||||||
size: 'lg',
|
size: "lg",
|
||||||
toolbar: '#table-toolbar',
|
toolbar: "#table-toolbar",
|
||||||
autoSort: false,
|
autoSort: false,
|
||||||
defaultToolbar: [{
|
defaultToolbar: [{
|
||||||
title: '刷新',
|
title: "刷新",
|
||||||
layEvent: 'refresh',
|
layEvent: "refresh",
|
||||||
icon: 'layui-icon-refresh',
|
icon: "layui-icon-refresh",
|
||||||
}, 'filter', 'print', 'exports']
|
}, "filter", "print", "exports"]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +209,7 @@
|
|||||||
let [field, url] = item;
|
let [field, url] = item;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
dateType: 'json',
|
dateType: "json",
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
function travel(items) {
|
function travel(items) {
|
||||||
for (let k in items) {
|
for (let k in items) {
|
||||||
|
@ -91,36 +91,37 @@
|
|||||||
const INSERT_API = "/app/admin/admin/insert";
|
const INSERT_API = "/app/admin/admin/insert";
|
||||||
|
|
||||||
// 字段 头像 avatar
|
// 字段 头像 avatar
|
||||||
layui.use(['upload', 'layer', 'jquery'], function() {
|
layui.use(["upload", "layer", "jquery"], function() {
|
||||||
let input = layui.jquery('#avatar').prev();
|
let input = layui.jquery("#avatar").prev();
|
||||||
input.prev().attr('src', input.val());
|
input.prev().attr("src", input.val());
|
||||||
layui.upload.render({
|
layui.upload.render({
|
||||||
elem: '#avatar',
|
elem: "#avatar",
|
||||||
url: '/app/admin/upload/avatar',
|
url: '/app/admin/upload/avatar',
|
||||||
value: '/app/admin/avatar.png',
|
value: '/app/admin/avatar.png',
|
||||||
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
||||||
|
field: '__file__',
|
||||||
done: function (res) {
|
done: function (res) {
|
||||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||||
this.item.prev().val(res.data.path).prev().attr('src', res.data.path);
|
this.item.prev().val(res.data.path).prev().attr("src", res.data.path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 字段 角色 roles
|
// 字段 角色 roles
|
||||||
layui.use(['jquery', 'xmSelect'], function() {
|
layui.use(["jquery", "xmSelect"], function() {
|
||||||
layui.jquery.ajax({
|
layui.jquery.ajax({
|
||||||
url: '/app/admin/admin-role/select?format=select',
|
url: "/app/admin/admin-role/select?format=select",
|
||||||
dataType: 'json',
|
dataType: "json",
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
let value = layui.jquery('#roles').attr('value');
|
let value = layui.jquery("#roles").attr("value");
|
||||||
let initValue = value ? value.split(',') : [];
|
let initValue = value ? value.split(",") : [];
|
||||||
layui.xmSelect.render({
|
layui.xmSelect.render({
|
||||||
el: '#roles',
|
el: "#roles",
|
||||||
name: 'roles',
|
name: "roles",
|
||||||
initValue: initValue,
|
initValue: initValue,
|
||||||
data: e.data,
|
data: e.data,
|
||||||
tree: {show: true},
|
tree: {"show":true},
|
||||||
toolbar: {show: true,"list":["ALL","CLEAR","REVERSE"]},
|
toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -108,42 +108,43 @@
|
|||||||
}
|
}
|
||||||
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
if (typeof obj[0] === 'undefined' || !obj[0].nodeName) return;
|
||||||
if (obj[0].nodeName.toLowerCase() === 'textarea') {
|
if (obj[0].nodeName.toLowerCase() === 'textarea') {
|
||||||
obj.html(layui.util.escape(value));
|
obj.val(layui.util.escape(value));
|
||||||
} else {
|
} else {
|
||||||
obj.attr('value', value);
|
obj.attr('value', value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 字段 头像 avatar
|
// 字段 头像 avatar
|
||||||
layui.use(['upload', 'layer', 'jquery'], function() {
|
layui.use(["upload", "layer", "jquery"], function() {
|
||||||
let input = layui.jquery('#avatar').prev();
|
let input = layui.jquery("#avatar").prev();
|
||||||
input.prev().attr('src', input.val());
|
input.prev().attr("src", input.val());
|
||||||
layui.upload.render({
|
layui.upload.render({
|
||||||
elem: '#avatar',
|
elem: "#avatar",
|
||||||
url: '/app/admin/upload/avatar',
|
url: '/app/admin/upload/avatar',
|
||||||
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
acceptMime: 'image/gif,image/jpeg,image/jpg,image/png',
|
||||||
|
field: '__file__',
|
||||||
done: function (res) {
|
done: function (res) {
|
||||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||||
this.item.prev().val(res.data.path).prev().attr('src', res.data.path);
|
this.item.prev().val(res.data.path).prev().attr("src", res.data.path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 字段 角色 roles
|
// 字段 角色 roles
|
||||||
layui.use(['jquery', 'xmSelect'], function() {
|
layui.use(["jquery", "xmSelect"], function() {
|
||||||
layui.jquery.ajax({
|
layui.jquery.ajax({
|
||||||
url: '/app/admin/admin-role/select?format=select',
|
url: "/app/admin/admin-role/select?format=select",
|
||||||
dataType: 'json',
|
dataType: "json",
|
||||||
success: function (e) {
|
success: function (e) {
|
||||||
let value = layui.jquery('#roles').attr('value');
|
let value = layui.jquery("#roles").attr("value");
|
||||||
let initValue = value ? value.split(',') : [];
|
let initValue = value ? value.split(",") : [];
|
||||||
layui.xmSelect.render({
|
layui.xmSelect.render({
|
||||||
el: '#roles',
|
el: "#roles",
|
||||||
name: 'roles',
|
name: "roles",
|
||||||
initValue: initValue,
|
initValue: initValue,
|
||||||
data: e.data,
|
data: e.data,
|
||||||
tree: {show: true},
|
tree: {"show":true},
|
||||||
toolbar: {show: true,"list":["ALL","CLEAR","REVERSE"]},
|
toolbar: {"show":true,"list":["ALL","CLEAR","REVERSE"]},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user