php管理和接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

114 lines
4.9 KiB

define(["jquery", "easy-admin", "tableSelect"], function ($, ea) {
let tableSelect = layui.tableSelect;
let init = {
table_elem: '#currentTable',
table_render_id: 'currentTableRenderId',
index_url: 'user.ipuser/index',
add_url: 'user.ipuser/add',
delete_url: 'user.ipuser/delete',
modify_url: 'user.ipuser/modify',
user_list_url: 'user.api/getUserPageList',
ip_list_url: 'user.api/getIpPageList',
};
let Controller = {
index: function () {
ea.table.render({
init: init,
toolbar: [
'refresh',
'add',
'delete'
],
cols: [[
{type: "checkbox"},
{field: 'id', width: 80, title: '编号'},
{field: 'username', minWidth: 80, title: '用户昵称'},
{field: 'avatar', minWidth: 80, title: '头像', search: false, templet: ea.table.image},
{field: 'ip', minWidth: 80, title: 'IP'},
{field: 'count', minWidth: 80, title: '使用次数'},
{field: 'status', title: '状态', width: 100, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
{field: 'ip_status', title: 'IP状态', width: 80, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: function (d) {
let html = '';
if (d.ip_status == 1) {
html = '<button type="button" class="layui-btn layui-bg-blue layui-btn-xs">启用</button>'
} else {
html = '<button type="button" class="layui-btn layui-bg-red layui-btn-xs">禁用</button>'
}
return html
}},
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
{
width: 250,
title: '操作',
templet: ea.table.tool,
operat: [
'delete'
]
}
]],
});
ea.listen();
},
add: function () {
tableSelect.render({
elem: '#nick_name', //定义输入框input对象
checkedKey: 'uid', //表格的唯一建值,非常重要,影响到选中状态 必填
searchKey: 'keyword', //搜索输入框的name值 默认keyword
searchPlaceholder: '关键词搜索', //搜索输入框的提示文字 默认关键词搜索
table: { //定义表格参数,与LAYUI的TABLE模块一致,只是无需再定义表格elem
url: ea.url(init.user_list_url),
cols: [[
{ type: 'radio' },
{ field: 'uid', title: 'ID' },
{ field: 'nick_name', title: '姓名' }
]]
},
done: function (elem, data) {
let uidArr = []
let nameArr = []
layui.each(data.data, function (index, item) {
uidArr.push(item.uid)
nameArr.push(item.nick_name)
})
$("#uid").val(uidArr.join(','))
$("#nick_name").val(nameArr.join(','))
}
})
tableSelect.render({
elem: '#ip', //定义输入框input对象
checkedKey: 'id', //表格的唯一建值,非常重要,影响到选中状态 必填
searchKey: 'keyword', //搜索输入框的name值 默认keyword
searchPlaceholder: '关键词搜索', //搜索输入框的提示文字 默认关键词搜索
table: { //定义表格参数,与LAYUI的TABLE模块一致,只是无需再定义表格elem
url: ea.url(init.ip_list_url),
cols: [[
{ type: 'radio' },
{ field: 'id', title: 'ID' },
{ field: 'ip', title: 'IP' }
]]
},
done: function (elem, data) {
let ipArr = []
let ipIdArr = []
layui.each(data.data, function (index, item) {
ipArr.push(item.ip)
ipIdArr.push(item.id)
})
$("#ip").val(ipArr.join(','))
$("#ip_id").val(ipIdArr.join(','))
}
})
ea.listen();
},
edit: function () {
ea.listen();
},
};
return Controller;
});