1
This commit is contained in:
51
public/static/admin/js/article/article.js
Normal file
51
public/static/admin/js/article/article.js
Normal file
@ -0,0 +1,51 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
let init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'article.article/index',
|
||||
add_url: 'article.article/add',
|
||||
edit_url: 'article.article/edit',
|
||||
delete_url: 'article.article/delete',
|
||||
export_url: 'article.article/export',
|
||||
modify_url: 'article.article/modify',
|
||||
};
|
||||
|
||||
let Controller = {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID'},
|
||||
{field: 'title', minWidth: 200, title: '文章标题'},
|
||||
{field: 'cate_name', width: 120, title: '分类'},
|
||||
{field: 'author', width: 100, title: '作者'},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
{field: 'create_time', minWidth: 150, title: '创建时间'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: ['edit', 'delete']
|
||||
}
|
||||
]],
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
|
||||
add: function () {
|
||||
ea.listen();
|
||||
},
|
||||
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
return Controller;
|
||||
});
|
||||
49
public/static/admin/js/article/cate.js
Normal file
49
public/static/admin/js/article/cate.js
Normal file
@ -0,0 +1,49 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
let init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'article.cate/index',
|
||||
add_url: 'article.cate/add',
|
||||
edit_url: 'article.cate/edit',
|
||||
delete_url: 'article.cate/delete',
|
||||
export_url: 'article.cate/export',
|
||||
modify_url: 'article.cate/modify',
|
||||
};
|
||||
|
||||
return {
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID'},
|
||||
{field: 'title', minWidth: 150, title: '分类名称'},
|
||||
{field: 'sort', width: 100, title: '排序', edit: 'text'},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
width: 85,
|
||||
selectList: {0: '禁用', 1: '启用'},
|
||||
templet: ea.table.switch
|
||||
},
|
||||
{field: 'create_time', minWidth: 150, title: '创建时间'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: ['edit', 'delete']
|
||||
}
|
||||
]],
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
});
|
||||
222
public/static/admin/js/index.js
Normal file
222
public/static/admin/js/index.js
Normal file
@ -0,0 +1,222 @@
|
||||
define(["jquery", "easy-admin", "echarts", "echarts-theme", "miniAdmin", "miniTheme", "miniTab", "swiper"], function ($, ea, echarts, undefined, miniAdmin, miniTheme, miniTab) {
|
||||
|
||||
return {
|
||||
index: function () {
|
||||
var options = {
|
||||
iniUrl: ea.url('ajax/initAdmin'), // 初始化接口
|
||||
clearUrl: ea.url("ajax/clearCache"), // 缓存清理接口
|
||||
urlHashLocation: true, // 是否打开hash定位
|
||||
bgColorDefault: false, // 主题默认配置
|
||||
multiModule: true, // 是否开启多模块
|
||||
menuChildOpen: false, // 是否默认展开菜单
|
||||
loadingTime: 0, // 初始化加载时间
|
||||
pageAnim: true, // iframe窗口动画
|
||||
maxTabNum: 20, // 最大的tab打开数量
|
||||
};
|
||||
miniAdmin.render(options);
|
||||
|
||||
$('.login-out').on("click", function () {
|
||||
ea.request.get({
|
||||
url: 'login/out',
|
||||
prefix: true,
|
||||
}, function (res) {
|
||||
ea.msg.success(res.msg, function () {
|
||||
window.location = ea.url('login/index');
|
||||
})
|
||||
});
|
||||
});
|
||||
},
|
||||
welcome: function () {
|
||||
miniTab.listen();
|
||||
|
||||
new Swiper('.mySwiper', {
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true,
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* 查看公告信息
|
||||
**/
|
||||
$('body').on('click', '.layuimini-notice', function () {
|
||||
var title = $(this).children('.layuimini-notice-title').text(),
|
||||
noticeTime = $(this).children('.layuimini-notice-extra').text(),
|
||||
content = $(this).children('.layuimini-notice-content').html();
|
||||
var html = '<div style="padding:15px 20px; text-align:justify; line-height: 22px;border-bottom:1px solid #e2e2e2;background-color: #2f4056;color: #ffffff">\n' +
|
||||
'<div style="text-align: center;margin-bottom: 20px;font-weight: bold;border-bottom:1px solid #718fb5;padding-bottom: 5px"><h4 class="text-danger">' + title + '</h4></div>\n' +
|
||||
'<div style="font-size: 12px">' + content + '</div>\n' +
|
||||
'</div>\n';
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '系统公告' + '<span style="float: right;right: 1px;font-size: 12px;color: #b1b3b9;margin-top: 1px">' + noticeTime + '</span>',
|
||||
area: '300px;',
|
||||
shade: 0.8,
|
||||
id: 'layuimini-notice',
|
||||
btn: ['查看', '取消'],
|
||||
btnAlign: 'c',
|
||||
moveType: 1,
|
||||
content: html,
|
||||
success: function (layero) {
|
||||
var btn = layero.find('.layui-layer-btn');
|
||||
btn.find('.layui-layer-btn0').attr({
|
||||
href: 'https://gitee.com/zhongshaofa/layuimini',
|
||||
target: '_blank'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 报表功能
|
||||
*/
|
||||
$(function () {
|
||||
$('#layui-version').text('v' + layui.v);
|
||||
let echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');
|
||||
let optionRecords = {
|
||||
title: {
|
||||
text: '访问统计'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎']
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
saveAsImage: {}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '邮件营销',
|
||||
type: 'line',
|
||||
stack: '总量',
|
||||
data: [120, 132, 101, 134, 90, 230, 210]
|
||||
},
|
||||
{
|
||||
name: '联盟广告',
|
||||
type: 'line',
|
||||
stack: '总量',
|
||||
data: [220, 182, 191, 234, 290, 330, 310]
|
||||
},
|
||||
{
|
||||
name: '视频广告',
|
||||
type: 'line',
|
||||
stack: '总量',
|
||||
data: [150, 232, 201, 154, 190, 330, 410]
|
||||
},
|
||||
{
|
||||
name: '直接访问',
|
||||
type: 'line',
|
||||
stack: '总量',
|
||||
data: [320, 332, 301, 334, 390, 330, 320]
|
||||
},
|
||||
{
|
||||
name: '搜索引擎',
|
||||
type: 'line',
|
||||
stack: '总量',
|
||||
data: [820, 932, 901, 934, 1290, 1330, 1320]
|
||||
}
|
||||
]
|
||||
};
|
||||
echartsRecords.setOption(optionRecords);
|
||||
window.addEventListener("resize", function () {
|
||||
echartsRecords.resize();
|
||||
});
|
||||
})
|
||||
|
||||
let util = layui.util;
|
||||
util.on({
|
||||
showComposerInfo: function () {
|
||||
// <div style="padding: 25px;">12313</div>
|
||||
let html = ``
|
||||
ea.request.get({
|
||||
url: ea.url('ajax/composerInfo'),
|
||||
}, function (success) {
|
||||
let data = success.data
|
||||
data.forEach(function (item) {
|
||||
html += `${item.name} ${item.version}\r\n`
|
||||
})
|
||||
html = `<pre class="layui-code code-demo">${html}</pre>`
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: 'composer 信息',
|
||||
area: ['50%', '90%'],
|
||||
shade: 0.8,
|
||||
shadeClose: true,
|
||||
scrollbar: false,
|
||||
content: html,
|
||||
success: function () {
|
||||
layui.code({elem: '.code-demo', theme: 'dark', lang: 'php'});
|
||||
}
|
||||
})
|
||||
}, function (error) {
|
||||
console.error(error)
|
||||
return false;
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* ✅ 定时检查未分配订单 + 播放提示音
|
||||
*/
|
||||
setInterval(function () {
|
||||
ea.request.get({
|
||||
url: ea.url('index/get_order'),
|
||||
}, function (res) {
|
||||
// 假设接口返回格式:{code:1, data:{count:2}}
|
||||
let audio;
|
||||
if (res.code === 1 && res.data > 0) {
|
||||
// 若不存在则动态创建
|
||||
audio = document.createElement('audio');
|
||||
audio.id = 'order-audio';
|
||||
audio.src = '/1.mp3'; // ✅ 修改为你的提示音路径
|
||||
audio.autoplay = true;
|
||||
audio.volume = 1.0;
|
||||
document.body.appendChild(audio);
|
||||
audio.play().then(r => {});
|
||||
layui.table.reload(init.table_render_id);
|
||||
}
|
||||
}, function (err) {
|
||||
console.error('检查未分配订单失败', err);
|
||||
});
|
||||
}, 10000); // 每60秒执行一次
|
||||
|
||||
},
|
||||
editAdmin: function () {
|
||||
let form = layui.form
|
||||
form.on('radio(loginType-filter)', function (data) {
|
||||
let elem = data.elem
|
||||
let value = elem.value
|
||||
if (value === '2') {
|
||||
let width = screen.width < 768 ? '85%' : '60%'
|
||||
ea.open('绑定谷歌验证码', ea.url('index/set2fa'), width, '75%')
|
||||
}
|
||||
});
|
||||
ea.listen();
|
||||
},
|
||||
editPassword: function () {
|
||||
ea.listen();
|
||||
},
|
||||
set2fa: function () {
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
});
|
||||
61
public/static/admin/js/login.js
Normal file
61
public/static/admin/js/login.js
Normal file
@ -0,0 +1,61 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
return {
|
||||
index: function () {
|
||||
if (top.location !== self.location) {
|
||||
top.location = self.location;
|
||||
}
|
||||
$(function () {
|
||||
if (backgroundUrl) {
|
||||
$('body').css('background', 'url(' + backgroundUrl + ') 0% 0% / cover no-repeat')
|
||||
}
|
||||
$('.bind-password').on('click', function () {
|
||||
if ($(this).hasClass('icon-5')) {
|
||||
$(this).removeClass('icon-5');
|
||||
$("input[name='password']").attr('type', 'password');
|
||||
} else {
|
||||
$(this).addClass('icon-5');
|
||||
$("input[name='password']").attr('type', 'text');
|
||||
}
|
||||
});
|
||||
|
||||
$('.icon-nocheck').on('click', function () {
|
||||
if ($(this).hasClass('icon-check')) {
|
||||
$(this).removeClass('icon-check');
|
||||
} else {
|
||||
$(this).addClass('icon-check');
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Enter' || event.keyCode === 13) {
|
||||
$('.login-btn').trigger('click')
|
||||
}
|
||||
});
|
||||
|
||||
$('.login-tip').on('click', function () {
|
||||
$('.icon-nocheck').click();
|
||||
});
|
||||
|
||||
ea.listen(function (data) {
|
||||
data['keep_login'] = $('.icon-nocheck').hasClass('icon-check') ? 1 : 0;
|
||||
return data;
|
||||
}, function (res) {
|
||||
ea.msg.success(res.msg, function () {
|
||||
window.location = ea.url('index');
|
||||
})
|
||||
}, function (res) {
|
||||
let data = res.data
|
||||
if (data?.is_ga_code || false) {
|
||||
let elem = $('#gaCode')
|
||||
elem.removeClass('layui-hide');
|
||||
elem.find('input').focus()
|
||||
}
|
||||
ea.msg.error(res.msg, function () {
|
||||
$('#refreshCaptcha').trigger("click");
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
208
public/static/admin/js/mall/blackip.js
Normal file
208
public/static/admin/js/mall/blackip.js
Normal file
@ -0,0 +1,208 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'mall.blackip/index',
|
||||
add_url: 'mall.blackip/add',
|
||||
edit_url: 'mall.blackip/edit',
|
||||
delete_url: 'mall.blackip/delete',
|
||||
export_url: 'mall.blackip/export',
|
||||
modify_url: 'mall.blackip/modify',
|
||||
recycle_url: 'mall.blackip/recycle',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
text: '添加',
|
||||
url: init.add_url,
|
||||
method: 'open',
|
||||
auth: 'add',
|
||||
class: 'layui-btn layui-btn-normal layui-btn-sm',
|
||||
icon: 'fa fa-plus ',
|
||||
extend: 'data-width="90%" data-height="95%"',
|
||||
}],
|
||||
'delete', 'export', 'recycle'],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'ip', width: 100, title: 'IP'},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
['delete']
|
||||
]
|
||||
}
|
||||
]],
|
||||
done: (res) => {
|
||||
// 状态为1的商品背景高亮 展示写法 可根据自己项目自定义
|
||||
$.each(res.data, function (idx, item) {
|
||||
if (item.status === 1) {
|
||||
$(`tr[data-index="${idx}"]`).css({
|
||||
'background': 'linear-gradient(to left, #77eb7c, #bbffbe, #ffffff, transparent)',
|
||||
'bblackip': 'none',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
layui.util.on({
|
||||
AiOptimization: function (data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
$(data).attr('lay-on', layOn + 'Loading')
|
||||
aiOptimization(data)
|
||||
},
|
||||
})
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#demo1',
|
||||
name: 'xxx', // form表单提交的name
|
||||
theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'},
|
||||
data: [
|
||||
{name: 'Make', value: 1},
|
||||
{name: 'PHP', value: 2},
|
||||
{name: 'Great Again', value: 3},
|
||||
]
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
layui.util.on({
|
||||
AiOptimization: function (data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
$(data).attr('lay-on', layOn + 'Loading')
|
||||
aiOptimization(data)
|
||||
},
|
||||
})
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#demo1',
|
||||
name: 'xxx', // form表单提交的name
|
||||
theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'},
|
||||
data: [
|
||||
{name: 'Make', value: 1},
|
||||
{name: 'PHP', value: 2, selected: true,},
|
||||
{name: 'Great Again', value: 3, selected: true,},
|
||||
]
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
stock: function () {
|
||||
ea.listen();
|
||||
},
|
||||
recycle: function () {
|
||||
init.index_url = init.recycle_url;
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
class: 'layui-btn layui-btn-sm',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
icon: 'fa fa-refresh',
|
||||
text: '全部恢复',
|
||||
title: '确定恢复?',
|
||||
auth: 'recycle',
|
||||
url: init.recycle_url + '?type=restore',
|
||||
checkbox: true
|
||||
}, {
|
||||
class: 'layui-btn layui-btn-danger layui-btn-sm',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
icon: 'fa fa-delete',
|
||||
text: '彻底删除',
|
||||
title: '确定彻底删除?',
|
||||
auth: 'recycle',
|
||||
url: init.recycle_url + '?type=delete',
|
||||
checkbox: true
|
||||
}], 'export',
|
||||
],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'cate_id', minWidth: 80, title: '商品分类', search: 'select', selectList: cateSelects, laySearch: true},
|
||||
{field: 'title', minWidth: 80, title: '商品名称'},
|
||||
{field: 'logo', minWidth: 80, title: '分类图片', search: false, templet: ea.table.image},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '禁用', 1: '启用'}},
|
||||
// 演示多选,实际数据库并无 status2 字段,搜索后会报错
|
||||
{
|
||||
field: 'status2', title: '演示多选', width: 105, search: 'xmSelect', selectList: {1: '模拟选项1', 2: '模拟选项2', 3: '模拟选项3', 4: '模拟选项4', 5: '模拟选项5'}, hide: true,
|
||||
searchOp: 'in', templet: function (res) {
|
||||
// 根据自己实际项目进行输出
|
||||
return res?.status2 || '模拟数据'
|
||||
}
|
||||
},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{field: 'delete_time', minWidth: 80, title: '删除时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
title: '确认恢复?',
|
||||
text: '恢复数据',
|
||||
filed: 'id',
|
||||
url: init.recycle_url + '?type=restore',
|
||||
method: 'get',
|
||||
auth: 'recycle',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-success',
|
||||
}, {
|
||||
title: '想好了吗?',
|
||||
text: '彻底删除',
|
||||
filed: 'id',
|
||||
method: 'get',
|
||||
url: init.recycle_url + '?type=delete',
|
||||
auth: 'recycle',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-normal layui-bg-red',
|
||||
}]]
|
||||
}
|
||||
]],
|
||||
});
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
|
||||
function aiOptimization(data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
let title = $('input[name="title"]').val()
|
||||
|
||||
// 告诉AI 你需要做什么
|
||||
let message = `优化这个标题 ${title}`
|
||||
|
||||
if ($.trim(title) === '') {
|
||||
ea.msg.error('标题不能为空', function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
return false
|
||||
}
|
||||
let url = ea.url('mall.blackip/aiOptimization')
|
||||
ea.request.post({url: url, data: {message: message}}, function (res) {
|
||||
let content = res.data?.choices[0]?.message?.content
|
||||
// stream 为true 时,AI 内容会逐字输出
|
||||
let stream = true
|
||||
ea.ai.chat(content, {stream: stream}, function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
}, function (error) {
|
||||
ea.msg.error(error.msg, function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
41
public/static/admin/js/mall/cate.js
Normal file
41
public/static/admin/js/mall/cate.js
Normal file
@ -0,0 +1,41 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'mall.cate/index',
|
||||
add_url: 'mall.cate/add',
|
||||
edit_url: 'mall.cate/edit',
|
||||
delete_url: 'mall.cate/delete',
|
||||
export_url: 'mall.cate/export',
|
||||
modify_url: 'mall.cate/modify',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'title', minWidth: 80, title: '分类名称'},
|
||||
{field: 'image', minWidth: 80, title: '分类图片', search: false, templet: ea.table.image},
|
||||
{field: 'remark', minWidth: 80, title: '备注信息'},
|
||||
{field: 'status', title: '状态', width: 85, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{width: 250, title: '操作', templet: ea.table.tool}
|
||||
]],
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
});
|
||||
247
public/static/admin/js/mall/goods.js
Normal file
247
public/static/admin/js/mall/goods.js
Normal file
@ -0,0 +1,247 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'mall.goods/index',
|
||||
add_url: 'mall.goods/add',
|
||||
edit_url: 'mall.goods/edit',
|
||||
delete_url: 'mall.goods/delete',
|
||||
export_url: 'mall.goods/export',
|
||||
modify_url: 'mall.goods/modify',
|
||||
stock_url: 'mall.goods/stock',
|
||||
recycle_url: 'mall.goods/recycle',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
text: '添加',
|
||||
url: init.add_url,
|
||||
method: 'open',
|
||||
auth: 'add',
|
||||
class: 'layui-btn layui-btn-normal layui-btn-sm',
|
||||
icon: 'fa fa-plus ',
|
||||
extend: 'data-width="90%" data-height="95%"',
|
||||
}],
|
||||
'delete', 'export', 'recycle'],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'cate_id', width: 100, title: '商品分类', search: 'select', selectList: cateSelects, laySearch: true},
|
||||
{field: 'title', width: 100, title: '商品名称'},
|
||||
{field: 'logo', width: 100, title: '分类图片', search: false, templet: ea.table.image},
|
||||
{field: 'market_price', width: 100, title: '市场价', templet: ea.table.price},
|
||||
{field: 'discount_price', width: 100, title: '折扣价', templet: ea.table.price},
|
||||
{field: 'total_stock', width: 100, title: '库存统计'},
|
||||
{field: 'stock', width: 100, title: '剩余库存'},
|
||||
{field: 'virtual_sales', width: 100, title: '虚拟销量'},
|
||||
{field: 'sales', width: 80, title: '销量'},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
// 演示多选,实际数据库并无 status2 字段,搜索后会报错
|
||||
{
|
||||
field: 'status2', title: '演示多选', width: 105, search: 'xmSelect', selectList: {1: '模拟选项1', 2: '模拟选项2', 3: '模拟选项3', 4: '模拟选项4', 5: '模拟选项5'}, hide: true,
|
||||
searchOp: 'in', templet: function (res) {
|
||||
// 根据自己实际项目进行输出
|
||||
return res?.status2 || '模拟数据'
|
||||
}
|
||||
},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
templet: function (d) {
|
||||
return `<button type="button" class="layui-btn layui-btn-xs">自定义 ${d.id}</button>`
|
||||
}
|
||||
}, {
|
||||
text: '编辑',
|
||||
url: init.edit_url,
|
||||
method: 'open',
|
||||
auth: 'edit',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-success',
|
||||
extend: 'data-width="90%" data-height="95%"',
|
||||
}, {
|
||||
text: '入库',
|
||||
url: init.stock_url,
|
||||
method: 'open',
|
||||
auth: 'stock',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-normal',
|
||||
visible: function (row) {
|
||||
return row.status === 1;
|
||||
},
|
||||
}],
|
||||
'delete']
|
||||
}
|
||||
]],
|
||||
done: (res) => {
|
||||
// 状态为1的商品背景高亮 展示写法 可根据自己项目自定义
|
||||
$.each(res.data, function (idx, item) {
|
||||
if (item.status === 1) {
|
||||
$(`tr[data-index="${idx}"]`).css({
|
||||
'background': 'linear-gradient(to left, #77eb7c, #bbffbe, #ffffff, transparent)',
|
||||
'border': 'none',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
layui.util.on({
|
||||
AiOptimization: function (data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
$(data).attr('lay-on', layOn + 'Loading')
|
||||
aiOptimization(data)
|
||||
},
|
||||
})
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#demo1',
|
||||
name: 'xxx', // form表单提交的name
|
||||
theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'},
|
||||
data: [
|
||||
{name: 'Make', value: 1},
|
||||
{name: 'PHP', value: 2},
|
||||
{name: 'Great Again', value: 3},
|
||||
]
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
layui.util.on({
|
||||
AiOptimization: function (data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
$(data).attr('lay-on', layOn + 'Loading')
|
||||
aiOptimization(data)
|
||||
},
|
||||
})
|
||||
|
||||
var demo1 = xmSelect.render({
|
||||
el: '#demo1',
|
||||
name: 'xxx', // form表单提交的name
|
||||
theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'},
|
||||
data: [
|
||||
{name: 'Make', value: 1},
|
||||
{name: 'PHP', value: 2, selected: true,},
|
||||
{name: 'Great Again', value: 3, selected: true,},
|
||||
]
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
stock: function () {
|
||||
ea.listen();
|
||||
},
|
||||
recycle: function () {
|
||||
init.index_url = init.recycle_url;
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
class: 'layui-btn layui-btn-sm',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
icon: 'fa fa-refresh',
|
||||
text: '全部恢复',
|
||||
title: '确定恢复?',
|
||||
auth: 'recycle',
|
||||
url: init.recycle_url + '?type=restore',
|
||||
checkbox: true
|
||||
}, {
|
||||
class: 'layui-btn layui-btn-danger layui-btn-sm',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
icon: 'fa fa-delete',
|
||||
text: '彻底删除',
|
||||
title: '确定彻底删除?',
|
||||
auth: 'recycle',
|
||||
url: init.recycle_url + '?type=delete',
|
||||
checkbox: true
|
||||
}], 'export',
|
||||
],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'cate_id', minWidth: 80, title: '商品分类', search: 'select', selectList: cateSelects, laySearch: true},
|
||||
{field: 'title', minWidth: 80, title: '商品名称'},
|
||||
{field: 'logo', minWidth: 80, title: '分类图片', search: false, templet: ea.table.image},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '禁用', 1: '启用'}},
|
||||
// 演示多选,实际数据库并无 status2 字段,搜索后会报错
|
||||
{
|
||||
field: 'status2', title: '演示多选', width: 105, search: 'xmSelect', selectList: {1: '模拟选项1', 2: '模拟选项2', 3: '模拟选项3', 4: '模拟选项4', 5: '模拟选项5'}, hide: true,
|
||||
searchOp: 'in', templet: function (res) {
|
||||
// 根据自己实际项目进行输出
|
||||
return res?.status2 || '模拟数据'
|
||||
}
|
||||
},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{field: 'delete_time', minWidth: 80, title: '删除时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
title: '确认恢复?',
|
||||
text: '恢复数据',
|
||||
filed: 'id',
|
||||
url: init.recycle_url + '?type=restore',
|
||||
method: 'get',
|
||||
auth: 'recycle',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-success',
|
||||
}, {
|
||||
title: '想好了吗?',
|
||||
text: '彻底删除',
|
||||
filed: 'id',
|
||||
method: 'get',
|
||||
url: init.recycle_url + '?type=delete',
|
||||
auth: 'recycle',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-normal layui-bg-red',
|
||||
}]]
|
||||
}
|
||||
]],
|
||||
});
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
|
||||
function aiOptimization(data) {
|
||||
let layOn = $(data).attr('lay-on')
|
||||
let title = $('input[name="title"]').val()
|
||||
|
||||
// 告诉AI 你需要做什么
|
||||
let message = `优化这个标题 ${title}`
|
||||
|
||||
if ($.trim(title) === '') {
|
||||
ea.msg.error('标题不能为空', function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
return false
|
||||
}
|
||||
let url = ea.url('mall.goods/aiOptimization')
|
||||
ea.request.post({url: url, data: {message: message}}, function (res) {
|
||||
let content = res.data?.choices[0]?.message?.content
|
||||
// stream 为true 时,AI 内容会逐字输出
|
||||
let stream = true
|
||||
ea.ai.chat(content, {stream: stream}, function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
}, function (error) {
|
||||
ea.msg.error(error.msg, function () {
|
||||
$(data).attr('lay-on', layOn.split('Loading')[0])
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
114
public/static/admin/js/mall/order.js
Normal file
114
public/static/admin/js/mall/order.js
Normal file
@ -0,0 +1,114 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'mall.order/index',
|
||||
add_url: 'mall.order/add',
|
||||
edit_url: 'mall.order/edit',
|
||||
delete_url: 'mall.order/delete',
|
||||
export_url: 'mall.order/export',
|
||||
modify_url: 'mall.order/modify',
|
||||
recharge_url: 'mall.order/recharge',
|
||||
blockip_url: 'mall.order/blockip',
|
||||
recycle_url: 'mall.order/recycle',
|
||||
};
|
||||
|
||||
let checkTimer = null; // 定时器对象
|
||||
let autoCheckEnabled = true; // 默认启用
|
||||
let autoCheckId = 1; // 默认启用
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
toolbar: [
|
||||
'refresh', 'delete', 'export', 'recycle'
|
||||
],
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'rid', width: 100, title: '订单号'},
|
||||
{field: 'money', width: 100, title: '金额'},
|
||||
{field: 'ip', width: 100, title: 'IP'},
|
||||
{field: 'url', width: 100, title: '支付链接', edit: true},
|
||||
{field: 'status', title: '状态', width: 85, selectList: {0: '未分配', 1: '已分配', 2: '已支付'}},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{
|
||||
width: 500,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
class: 'layui-btn layui-btn-success layui-btn-xs',
|
||||
method: 'open',
|
||||
field: 'id',
|
||||
text: '编辑支付链接',
|
||||
url: init.edit_url,
|
||||
extend: 'data-width="90%" data-height="95%"',
|
||||
}],
|
||||
[{
|
||||
class: 'layui-btn layui-btn-danger layui-btn-xs',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
text: '确认支付',
|
||||
url: init.recharge_url,
|
||||
}],
|
||||
[{
|
||||
class: 'layui-btn layui-btn-danger layui-btn-xs',
|
||||
method: 'get',
|
||||
field: 'id',
|
||||
text: 'IP拉黑',
|
||||
url: init.blockip_url,
|
||||
}],
|
||||
'delete'
|
||||
]
|
||||
}
|
||||
]],
|
||||
done: (res) => {
|
||||
$.each(res.data, function (idx, item) {
|
||||
if (item.status === 1) {
|
||||
$(`tr[data-index="${idx}"]`).css({
|
||||
'background': 'linear-gradient(to left, #77eb7c, #bbffbe, #ffffff, transparent)',
|
||||
'border': 'none',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// 🔁 定时检测逻辑
|
||||
checkTimer = setInterval(function () {
|
||||
ea.request.get({
|
||||
url: ea.url('index/get_order'),
|
||||
}, function (res) {
|
||||
if (res.code === 1 && res.data.count > 0) {
|
||||
let audio = document.getElementById('order-audio');
|
||||
if (!audio) {
|
||||
audio = document.createElement('audio');
|
||||
audio.id = 'order-audio';
|
||||
audio.src = '/1.mp3'; // 你的提示音路径
|
||||
audio.autoplay = true;
|
||||
audio.volume = 1.0;
|
||||
document.body.appendChild(audio);
|
||||
}
|
||||
if (autoCheckId !== res.data.rid) {
|
||||
autoCheckId = res.data.rid;
|
||||
layui.table.reload(init.table_render_id);
|
||||
}
|
||||
audio.play().catch(err => console.warn('播放失败', err));
|
||||
}
|
||||
}, function (err) {
|
||||
console.error('检查未分配订单失败', err);
|
||||
});
|
||||
}, 5000); // 每10秒执行一次
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
|
||||
});
|
||||
92
public/static/admin/js/system/admin.js
Normal file
92
public/static/admin/js/system/admin.js
Normal file
@ -0,0 +1,92 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'system.admin/index',
|
||||
add_url: 'system.admin/add',
|
||||
edit_url: 'system.admin/edit',
|
||||
delete_url: 'system.admin/delete',
|
||||
modify_url: 'system.admin/modify',
|
||||
export_url: 'system.admin/export',
|
||||
password_url: 'system.admin/password',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
|
||||
let _table = ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'username', minWidth: 80, title: '登录账户'},
|
||||
{field: 'head_img', minWidth: 80, title: '头像', search: false, templet: ea.table.image},
|
||||
{field: 'phone', minWidth: 80, title: '手机'},
|
||||
{field: 'login_num', minWidth: 80, title: '登录次数'},
|
||||
{
|
||||
field: 'role', minWidth: 80, title: '角色权限', align: 'left', search: 'none', templet: function (d) {
|
||||
let auth_ids = d.auth_ids || []
|
||||
let html = ``
|
||||
$.each(auth_ids, (idx, item) =>
|
||||
html += `<span class="layui-badge">${auth_list[item] || '-'}</span> `
|
||||
)
|
||||
return html
|
||||
}
|
||||
},
|
||||
{field: 'remark', minWidth: 80, title: '备注信息'},
|
||||
{field: 'status', title: '状态', width: 85, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
'edit',
|
||||
[{
|
||||
text: '设置密码',
|
||||
url: init.password_url,
|
||||
method: 'open',
|
||||
auth: 'password',
|
||||
class: 'layui-btn layui-btn-normal layui-btn-xs',
|
||||
}],
|
||||
'delete'
|
||||
]
|
||||
}
|
||||
]],
|
||||
});
|
||||
|
||||
$('body').on('click', '[data-table-reset]', function () {
|
||||
$('.layui-menu li').removeClass('layui-menu-item-checked').animate(
|
||||
{}, 0, () => $('.layui-menu li:eq(0)').addClass('layui-menu-item-checked')
|
||||
)
|
||||
})
|
||||
layui.util.on({
|
||||
authSearch: function (e) {
|
||||
let auth_id = $(this).data('auth_id')
|
||||
$('.layui-menu li').removeClass('layui-menu-item-checked').animate(
|
||||
{}, 0, () => $(this).parents('li').addClass('layui-menu-item-checked')
|
||||
)
|
||||
let _where = auth_id ? {
|
||||
filter: JSON.stringify({auth_ids: auth_id}),
|
||||
op: JSON.stringify({auth_ids: 'find_in_set'})
|
||||
} : {}
|
||||
_table.reload({where: _where})
|
||||
},
|
||||
})
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
password: function () {
|
||||
ea.listen();
|
||||
}
|
||||
};
|
||||
});
|
||||
107
public/static/admin/js/system/auth.js
Normal file
107
public/static/admin/js/system/auth.js
Normal file
@ -0,0 +1,107 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'system.auth/index',
|
||||
add_url: 'system.auth/add',
|
||||
edit_url: 'system.auth/edit',
|
||||
delete_url: 'system.auth/delete',
|
||||
export_url: 'system.auth/export',
|
||||
modify_url: 'system.auth/modify',
|
||||
authorize_url: 'system.auth/authorize',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'title', minWidth: 80, title: '权限名称'},
|
||||
{field: 'remark', minWidth: 80, title: '备注信息'},
|
||||
{field: 'status', title: '状态', width: 85, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{
|
||||
width: 250,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
'edit',
|
||||
[{
|
||||
text: '授权',
|
||||
url: init.authorize_url,
|
||||
method: 'open',
|
||||
auth: 'authorize',
|
||||
class: 'layui-btn layui-btn-normal layui-btn-xs',
|
||||
}],
|
||||
'delete'
|
||||
]
|
||||
}
|
||||
]],
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
authorize: function () {
|
||||
|
||||
let setting = {
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "checkbox",
|
||||
},
|
||||
view: {
|
||||
showIcon: true,
|
||||
showLine: true,
|
||||
selectedMulti: false,
|
||||
dblClickExpand: false
|
||||
}, callback: {
|
||||
onClick: function (e, treeId, treeNode, clickFlag) {
|
||||
treeObj.checkNode(treeNode, !treeNode.checked, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
let treeObj
|
||||
let treeData = []
|
||||
ea.request.get({url: window.location.href}, function (res) {
|
||||
res.data = res.data || [];
|
||||
$.each(res.data, function (index, value) {
|
||||
treeData[index] = []
|
||||
treeData[index].id = value.id
|
||||
treeData[index].name = value.title
|
||||
treeData[index].pId = 0
|
||||
treeData[index].open = true
|
||||
let children = value.children
|
||||
treeData[index]['children'] = []
|
||||
$.each(children, function (idx, val) {
|
||||
treeData[index]['children'].push({id: val.id, name: val.title, checked: val.checked, pId: value.id})
|
||||
})
|
||||
})
|
||||
$.fn.zTree.init($("#tree"), setting, treeData);
|
||||
treeObj = $.fn.zTree.getZTreeObj("tree");
|
||||
}
|
||||
);
|
||||
|
||||
ea.listen(function (data) {
|
||||
let checkedData = treeObj.getCheckedNodes();
|
||||
let ids = []
|
||||
for (var i = 0; i < checkedData.length; i++) {
|
||||
ids.push(checkedData[i].id)
|
||||
}
|
||||
data.node = JSON.stringify(ids);
|
||||
return data;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
34
public/static/admin/js/system/config.js
Normal file
34
public/static/admin/js/system/config.js
Normal file
@ -0,0 +1,34 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var form = layui.form;
|
||||
|
||||
return {
|
||||
index: function () {
|
||||
var _group = 'site'
|
||||
let tabs = layui.tabs
|
||||
var TABS_ID = 'docDemoTabBrief';
|
||||
tabs.on(`afterChange(${TABS_ID})`, function (data) {
|
||||
_group = $(this).data('group')
|
||||
})
|
||||
let _upload_type = upload_type || 'local'
|
||||
$('.upload_type').addClass('layui-hide')
|
||||
$('.' + _upload_type).removeClass('layui-hide')
|
||||
|
||||
form.on("radio(upload_type)", function (data) {
|
||||
_upload_type = this.value;
|
||||
$('.upload_type').addClass('layui-hide')
|
||||
$('.' + _upload_type).removeClass('layui-hide')
|
||||
});
|
||||
|
||||
form.on("submit", function (data) {
|
||||
data.field['group'] = _group
|
||||
});
|
||||
|
||||
ea.listen('', function (res) {
|
||||
ea.msg.success(res.msg);
|
||||
}, function (err) {
|
||||
ea.msg.error(err.msg);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
208
public/static/admin/js/system/curd_generate.js
Normal file
208
public/static/admin/js/system/curd_generate.js
Normal file
@ -0,0 +1,208 @@
|
||||
define(["jquery", "easy-admin", "miniTab"], function ($, ea, miniTab) {
|
||||
|
||||
var form = layui.form;
|
||||
var table = layui.table;
|
||||
|
||||
var init = {
|
||||
save_url: 'system.curd_generate/save',
|
||||
};
|
||||
|
||||
return {
|
||||
index: function () {
|
||||
|
||||
let element = layui.element;
|
||||
element.on('tab(curd-hash)', function (obj) {
|
||||
let id = obj.id
|
||||
let _html = `
|
||||
<div style="padding: 50px 25px;">
|
||||
<fieldset class="layui-elem-field">
|
||||
<legend>提示</legend>
|
||||
<div class="layui-field-box">
|
||||
<p><a class="layui-font-blue" target="_blank" rel="nofollow" href="https://edocs.easyadmin8.top/#/md/curd/command">命令可查询文档</a></p>
|
||||
</div>
|
||||
</fieldset>
|
||||
<form class="layui-form layui-form-pane" action="">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-group" style="width: 100%;">
|
||||
<div class="layui-input-split layui-input-prefix" style="width: 100px;">
|
||||
php think curd
|
||||
</div>
|
||||
<input type="text" class="layui-input" name="command" placeholder="在这里输入命令参数" lay-verify="required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn layui-btn-fluid layui-bg-cyan" type="button" lay-submit="system.CurdGenerate/save?type=console" lay-filter="curd-console-submit">一键执行</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
`
|
||||
if (id == '2') {
|
||||
layer.open({
|
||||
title: '命令行一键生成 CRUD/CRUD',
|
||||
type: 1,
|
||||
shade: 0.3,
|
||||
shadeClose: false,
|
||||
area: ['42%', 'auto'],
|
||||
content: _html,
|
||||
success: function () {
|
||||
form.on('submit(curd-console-submit)', function (data) {
|
||||
let field = data.field
|
||||
let url = $(this).attr('lay-submit')
|
||||
let options = {url: ea.url(url), data: field}
|
||||
ea.msg.confirm('确认执行该操作?<br>如果命令行中存在强制覆盖或者删除将会马上执行!', function () {
|
||||
ea.request.post(options, function (rs) {
|
||||
let msg = rs.msg || '未知~'
|
||||
layer.msg(msg.replace(/\n/g, '<br>'), {shade: 0.3, shadeClose: true})
|
||||
let code = rs?.code || '-1'
|
||||
if (code != '1') return
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
end: function () {
|
||||
element.tabChange('curd-hash', '1');
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
miniTab.listen();
|
||||
let createStatus = false
|
||||
let tb_prefix
|
||||
let tb_name
|
||||
form.on('submit(search)', function (data) {
|
||||
let field = data.field
|
||||
tb_prefix = field.tb_prefix
|
||||
tb_name = field.tb_name
|
||||
ea.request.get({url: $(this).attr('lay-submit'), prefix: true, data: field}, function (res) {
|
||||
createStatus = true
|
||||
$('.tableShow').removeClass('layui-hide')
|
||||
$('.table-text').text(field.tb_prefix + field.tb_name)
|
||||
let _data = res.data
|
||||
|
||||
let fieldsHtml = ``
|
||||
$.each(_data.list, function (i, v) {
|
||||
if (v.Key != 'PRI') fieldsHtml += `
|
||||
<div class="input_tag">
|
||||
<input lay-skin="tag" class="checkbox_${v.Field}" type="checkbox"
|
||||
title="${v.Field} (${v.Type})" value="${v.Field}" lay-filter="checkbox-filter" />
|
||||
</div>
|
||||
`
|
||||
})
|
||||
$('.table_fields').html(fieldsHtml)
|
||||
form.render('checkbox')
|
||||
|
||||
form.on('checkbox(checkbox-filter)', function (data) {
|
||||
let _checked = data.elem.checked
|
||||
$.each($(`.checkbox_${data.value}`), function (i, v) {
|
||||
if (i > 0) $(this).prop('checked', false);
|
||||
})
|
||||
$(data.elem).prop('checked', _checked);
|
||||
});
|
||||
|
||||
table.render({
|
||||
elem: '#currentTable', cols: [
|
||||
[
|
||||
{field: 'name', title: '字段', minWidth: 80},
|
||||
{field: 'type', title: '类型', minWidth: 80},
|
||||
{field: 'key', title: '键', minWidth: 80},
|
||||
{field: 'extra', title: '是否自增', minWidth: 80},
|
||||
{field: 'null', title: '是否为空', minWidth: 80},
|
||||
{field: 'desc', title: '描述', minWidth: 80},
|
||||
]
|
||||
], data: _data.data, page: false,
|
||||
});
|
||||
}, function (error) {
|
||||
createStatus = false
|
||||
ea.msg.error(error.msg)
|
||||
$('.tableShow').addClass('layui-hide')
|
||||
return
|
||||
})
|
||||
form.on('submit(add)', function (data) {
|
||||
let table = $('.table-text').text()
|
||||
if (!table || !createStatus) {
|
||||
ea.msg.error('请先查询数据')
|
||||
return
|
||||
}
|
||||
let url = $(this).attr('lay-submit')
|
||||
let fields = {}
|
||||
$.each($('.table_fields'), function (i, v) {
|
||||
let _name = $(this).data('name')
|
||||
let _inputs = {}
|
||||
$.each($(v).find('.input_tag'), function (i, v) {
|
||||
let checkedVal = $(this).find('input:checked').val()
|
||||
if (checkedVal) {
|
||||
_inputs[i] = checkedVal
|
||||
}
|
||||
})
|
||||
fields[_name] = _inputs
|
||||
})
|
||||
let options = {url: url, prefix: true, data: {tb_prefix: tb_prefix, tb_name: tb_name, tb_fields: fields}}
|
||||
layer.confirm('确定要自动生成【' + table + '】对应的CURD?', function (index) {
|
||||
ea.request.post(options, function (res) {
|
||||
createStatus = true
|
||||
ea.msg.success(res.msg)
|
||||
appendHtml(res['data']['result'], res['data']['link'])
|
||||
}, function (error) {
|
||||
createStatus = false
|
||||
let code = error.code
|
||||
if (code != '1') {
|
||||
if (code < 0) {
|
||||
createStatus = true
|
||||
layer.confirm(error.msg, {
|
||||
btn: ['确定强制覆盖生成', '取消'], title: '提示', icon: 0,
|
||||
yes: function () {
|
||||
options.prefix = false
|
||||
options.data.force = 1
|
||||
ea.request.post(options, function (rs) {
|
||||
createStatus = true
|
||||
ea.msg.success(rs.msg)
|
||||
appendHtml(rs['data']['result'], rs['data']['link'])
|
||||
})
|
||||
}
|
||||
});
|
||||
return
|
||||
}
|
||||
ea.msg.error(error.msg)
|
||||
return
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
form.on('submit(delete)', function (data) {
|
||||
let table = $('.table-text').text()
|
||||
if (!table || !createStatus) {
|
||||
ea.msg.error('请先查询数据')
|
||||
return
|
||||
}
|
||||
let url = $(this).attr('lay-submit')
|
||||
let options = {url: url, prefix: true, data: {tb_prefix: tb_prefix, tb_name: tb_name}}
|
||||
layer.confirm('确定要删除【' + table + '】对应CURD的文件?<br>确定清楚自己在做什么!', function (index) {
|
||||
ea.request.post(options, function (res) {
|
||||
ea.msg.success(res.msg)
|
||||
$('.table-text').text('')
|
||||
$('.file-list').empty()
|
||||
$('.table_fields').empty()
|
||||
$('.tableShow').addClass('layui-hide')
|
||||
createStatus = false
|
||||
})
|
||||
})
|
||||
})
|
||||
return
|
||||
})
|
||||
|
||||
function appendHtml(array, link) {
|
||||
$('.file-list').empty()
|
||||
let html = ''
|
||||
$.each(array, function (idx, item) {
|
||||
html += '<li class="layui-form-item">' + item + '</li>'
|
||||
})
|
||||
html += '<a layuimini-content-href="' + link + '" data-title="页面预览">' +
|
||||
'<button class="layui-btn"><i class="layui-icon layui-icon-link"></i> 自动生成页面预览</button>' +
|
||||
'</a>'
|
||||
$('.file-list').html(html)
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
92
public/static/admin/js/system/log.js
Normal file
92
public/static/admin/js/system/log.js
Normal file
@ -0,0 +1,92 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'system.log/index',
|
||||
export_url: 'system.log/export',
|
||||
deleteMonthLog_url: 'system.log/deleteMonthLog',
|
||||
};
|
||||
|
||||
return {
|
||||
index: function () {
|
||||
var util = layui.util;
|
||||
ea.table.render({
|
||||
init: init,
|
||||
lineStyle: 'height: auto;word-break: break-all;',
|
||||
toolbar: ['refresh', 'export',
|
||||
[{
|
||||
text: '框架日志',
|
||||
url: 'system.log/record',
|
||||
method: 'open',
|
||||
auth: 'record',
|
||||
class: 'layui-btn layui-btn-sm',
|
||||
icon: 'fa fa-book',
|
||||
extend: 'data-width="95%" data-height="95%"'
|
||||
}, {
|
||||
text: '删除部分日志',
|
||||
url: 'system.log/deleteMonthLog',
|
||||
method: 'open',
|
||||
auth: 'deleteMonthLog',
|
||||
class: 'layui-btn layui-btn-sm layui-btn-danger',
|
||||
icon: 'fa fa-remove',
|
||||
extend: 'data-width="35%" data-height="42%"'
|
||||
},]
|
||||
],
|
||||
cols: [[
|
||||
{field: 'id', width: 80, title: 'ID', search: false},
|
||||
{field: 'month', width: 80, title: '日志月份', hide: true, search: 'time', timeType: 'month', searchValue: util.toDateString(new Date(), 'yyyy-MM')},
|
||||
{
|
||||
field: 'admin.username', width: 100, title: '后台用户', search: false, templet: function (res) {
|
||||
let admin = res.admin
|
||||
return admin ? admin.username : '-'
|
||||
}
|
||||
},
|
||||
{field: 'method', width: 100, title: '请求方法'},
|
||||
{field: 'title', minWidth: 180, title: '请求标题'},
|
||||
{field: 'ip', width: 150, title: 'IP地址'},
|
||||
{field: 'url', minWidth: 150, title: '路由地址', align: "left"},
|
||||
{
|
||||
field: 'content', minWidth: 200, title: '请求数据', align: "left", templet: function (res) {
|
||||
let html = '<div class="layui-colla-item">' +
|
||||
'<div class="layui-colla-title">点击预览</div>' +
|
||||
'<div class="layui-colla-content">' + prettyFormat(JSON.stringify(res.content)) + '</div>' +
|
||||
'</div>'
|
||||
return '<div class="layui-collapse" lay-accordion>' + html + '</div>'
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'response', minWidth: 200, title: '回调数据', align: "left", templet: function (res) {
|
||||
let html = '<div class="layui-colla-item">' +
|
||||
'<div class="layui-colla-title">点击预览</div>' +
|
||||
'<div class="layui-colla-content">' + prettyFormat(JSON.stringify(res.response)) + '</div>' +
|
||||
'</div>'
|
||||
return '<div class="layui-collapse" lay-accordion>' + html + '</div>'
|
||||
}
|
||||
},
|
||||
{field: 'create_time', minWidth: 100, title: '创建时间', search: 'range'},
|
||||
]],
|
||||
done: function () {
|
||||
layui.element.render('collapse')
|
||||
}
|
||||
});
|
||||
ea.listen();
|
||||
},
|
||||
deleteMonthLog: function () {
|
||||
layui.form.on('submit(submit)', function (data) {
|
||||
let field = data.field
|
||||
let options = {
|
||||
url: ea.url(init.deleteMonthLog_url),
|
||||
data: field,
|
||||
}
|
||||
ea.msg.confirm('确认执行该操作?重要数据请先做好相关备份!', function () {
|
||||
ea.request.post(options, function (rs) {
|
||||
let msg = rs.msg || '未知~'
|
||||
layer.msg(msg.replace(/\n/g, '<br>'), {shade: 0.3, shadeClose: true, time: 2000})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
};
|
||||
});
|
||||
213
public/static/admin/js/system/menu.js
Normal file
213
public/static/admin/js/system/menu.js
Normal file
@ -0,0 +1,213 @@
|
||||
define(["jquery", "easy-admin", "treetable", "iconPickerFa", "autocomplete"], function ($, ea) {
|
||||
|
||||
var table = layui.table,
|
||||
treetable = layui.treetable,
|
||||
iconPickerFa = layui.iconPickerFa,
|
||||
autocomplete = layui.autocomplete;
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'system.menu/index',
|
||||
add_url: 'system.menu/add',
|
||||
delete_url: 'system.menu/delete',
|
||||
edit_url: 'system.menu/edit',
|
||||
modify_url: 'system.menu/modify',
|
||||
};
|
||||
|
||||
return {
|
||||
index: function () {
|
||||
|
||||
var renderTable = function () {
|
||||
layer.load(2);
|
||||
treetable.render({
|
||||
where: {limit: 9999},
|
||||
treeColIndex: 1,
|
||||
treeSpid: 0,
|
||||
homdPid: 99999999,
|
||||
treeIdName: 'id',
|
||||
treePidName: 'pid',
|
||||
url: ea.url(init.index_url),
|
||||
elem: init.table_elem,
|
||||
id: init.table_render_id,
|
||||
toolbar: '#toolbar',
|
||||
page: false,
|
||||
skin: 'line',
|
||||
|
||||
// @todo 不直接使用ea.table.render(); 进行表格初始化, 需要使用 ea.table.formatCols(); 方法格式化`cols`列数据
|
||||
cols: ea.table.formatCols([[
|
||||
{type: 'checkbox'},
|
||||
{field: 'title', width: 250, title: '菜单名称', align: 'left'},
|
||||
{field: 'icon', width: 80, title: '图标', templet: ea.table.icon},
|
||||
{field: 'href', minWidth: 120, title: '菜单链接'},
|
||||
{
|
||||
field: 'is_home',
|
||||
width: 80,
|
||||
title: '类型',
|
||||
templet: function (d) {
|
||||
if (d.pid === 99999999) {
|
||||
return '<span class="layui-badge layui-bg-blue">首页</span>';
|
||||
}
|
||||
if (d.pid === 0) {
|
||||
return '<span class="layui-badge layui-bg-gray">模块</span>';
|
||||
} else {
|
||||
return '<span class="layui-badge-rim">菜单</span>';
|
||||
}
|
||||
}
|
||||
},
|
||||
{field: 'status', title: '状态', width: 85, templet: ea.table.switch},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{
|
||||
width: 230,
|
||||
title: '操作',
|
||||
templet: ea.table.tool,
|
||||
operat: [
|
||||
[{
|
||||
text: '添加下级',
|
||||
url: init.add_url,
|
||||
method: 'open',
|
||||
auth: 'add',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-normal',
|
||||
}, {
|
||||
text: '编辑',
|
||||
url: init.edit_url,
|
||||
method: 'open',
|
||||
auth: 'edit',
|
||||
class: 'layui-btn layui-btn-xs layui-btn-success',
|
||||
}],
|
||||
'delete'
|
||||
]
|
||||
}
|
||||
]], init),
|
||||
done: function () {
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
renderTable();
|
||||
|
||||
$('body').on('click', '[data-treetable-refresh]', function () {
|
||||
renderTable();
|
||||
});
|
||||
|
||||
$('body').on('click', '[data-treetable-delete]', function () {
|
||||
var tableId = $(this).attr('data-treetable-delete'),
|
||||
url = $(this).attr('data-url');
|
||||
tableId = tableId || init.table_render_id;
|
||||
url = url != undefined ? ea.url(url) : window.location.href;
|
||||
var checkStatus = table.checkStatus(tableId),
|
||||
data = checkStatus.data;
|
||||
if (data.length <= 0) {
|
||||
ea.msg.error('请勾选需要删除的数据');
|
||||
return false;
|
||||
}
|
||||
var ids = [];
|
||||
$.each(data, function (i, v) {
|
||||
ids.push(v.id);
|
||||
});
|
||||
ea.msg.confirm('确定删除?', function () {
|
||||
ea.request.post({
|
||||
url: url,
|
||||
data: {
|
||||
id: ids
|
||||
},
|
||||
}, function (res) {
|
||||
ea.msg.success(res.msg, function () {
|
||||
renderTable();
|
||||
});
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('body').on('click', '[data-treetable-arrow]', function () {
|
||||
const $icon = $(this).find('i');
|
||||
const $textNode = $icon[0].nextSibling;
|
||||
if ($icon.hasClass('fa-arrow-up')) {
|
||||
treetable.foldAll(init.table_elem);
|
||||
$icon.removeClass('fa-arrow-up').addClass('fa-arrow-down');
|
||||
$textNode.textContent = ' 一键展开';
|
||||
$(this).attr('data-arrow', 'down');
|
||||
} else {
|
||||
treetable.expandAll(init.table_elem);
|
||||
$icon.removeClass('fa-arrow-down').addClass('fa-arrow-up');
|
||||
$textNode.textContent = ' 一键折叠';
|
||||
$(this).attr('data-arrow', 'up');
|
||||
}
|
||||
})
|
||||
|
||||
ea.table.listenSwitch({filter: 'status', url: init.modify_url});
|
||||
|
||||
ea.table.listenEdit(init, 'currentTable', init.table_render_id, true);
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
$(function () {
|
||||
iconPickerFa.render({
|
||||
elem: '#icon',
|
||||
url: PATH_CONFIG.iconLess,
|
||||
limit: 12,
|
||||
click: function (data) {
|
||||
$('#icon').val('fa ' + data.icon);
|
||||
},
|
||||
success: function (d) {
|
||||
console.log(d);
|
||||
}
|
||||
});
|
||||
})
|
||||
autocomplete.render({
|
||||
elem: $('#href')[0],
|
||||
url: ea.url('system.menu/getMenuTips'),
|
||||
template_val: '{{d.node}}',
|
||||
template_txt: '{{d.node}} <span class=\'layui-badge layui-bg-gray\'>{{d.title}}</span>',
|
||||
onselect: function (resp) {
|
||||
}
|
||||
});
|
||||
|
||||
ea.listen(function (data) {
|
||||
return data;
|
||||
}, function (res) {
|
||||
ea.msg.success(res.msg, function () {
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
parent.$('[data-treetable-refresh]').trigger("click");
|
||||
});
|
||||
});
|
||||
},
|
||||
edit: function () {
|
||||
$(function () {
|
||||
iconPickerFa.render({
|
||||
elem: '#icon',
|
||||
url: PATH_CONFIG.iconLess,
|
||||
limit: 12,
|
||||
click: function (data) {
|
||||
$('#icon').val('fa ' + data.icon);
|
||||
},
|
||||
success: function (d) {
|
||||
console.log(d);
|
||||
}
|
||||
});
|
||||
})
|
||||
autocomplete.render({
|
||||
elem: $('#href')[0],
|
||||
url: ea.url('system.menu/getMenuTips'),
|
||||
template_val: '{{d.node}}',
|
||||
template_txt: '{{d.node}} <span class=\'layui-badge layui-bg-gray\'>{{d.title}}</span>',
|
||||
onselect: function (resp) {
|
||||
}
|
||||
});
|
||||
|
||||
ea.listen(function (data) {
|
||||
return data;
|
||||
}, function (res) {
|
||||
ea.msg.success(res.msg, function () {
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
parent.$('[data-treetable-refresh]').trigger("click");
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
83
public/static/admin/js/system/node.js
Normal file
83
public/static/admin/js/system/node.js
Normal file
@ -0,0 +1,83 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'system.node/index',
|
||||
add_url: 'system.node/add',
|
||||
edit_url: 'system.node/edit',
|
||||
delete_url: 'system.node/delete',
|
||||
modify_url: 'system.node/modify',
|
||||
menu_url: 'system.node/refreshMenu',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
search: false,
|
||||
page: false,
|
||||
toolbar: ['refresh',
|
||||
[{
|
||||
text: '更新节点',
|
||||
title: '确定更新新节点?',
|
||||
url: 'system.node/refreshNode?force=0',
|
||||
method: 'request',
|
||||
auth: 'refresh',
|
||||
class: 'layui-btn layui-btn-success layui-btn-sm',
|
||||
icon: 'fa fa-hourglass',
|
||||
extend: 'data-table="' + init.table_render_id + '"',
|
||||
}, {
|
||||
text: '强制更新节点',
|
||||
title: '该操作会覆盖已存在的节点信息。<br>确定强制更新节点?',
|
||||
url: 'system.node/refreshNode?force=1',
|
||||
method: 'request',
|
||||
auth: 'refresh',
|
||||
class: 'layui-btn layui-btn-sm layui-btn-normal',
|
||||
icon: 'fa fa-hourglass',
|
||||
extend: 'data-table="' + init.table_render_id + '"',
|
||||
}, {
|
||||
|
||||
text: '清除失效节点',
|
||||
title: '确定清除失效节点?',
|
||||
url: 'system.node/clearNode',
|
||||
method: 'request',
|
||||
auth: 'clear',
|
||||
class: 'layui-btn layui-btn-sm layui-btn-danger',
|
||||
icon: 'fa fa-trash-o',
|
||||
extend: 'data-table="' + init.table_render_id + '"',
|
||||
},{
|
||||
|
||||
text: '刷新目录菜单',
|
||||
title: '确定刷新菜单?',
|
||||
url: 'system.node/refreshMenu',
|
||||
method: 'request',
|
||||
auth: 'menu',
|
||||
class: 'layui-btn layui-btn-sm layui-btn-info',
|
||||
icon: 'fa fa-list',
|
||||
extend: 'data-table="' + init.table_render_id + '"',
|
||||
}
|
||||
]],
|
||||
cols: [[
|
||||
{
|
||||
field: 'node', minWidth: 200, align: 'left', title: '系统节点', templet: function (d) {
|
||||
return `<span>${d.node}</span>`;
|
||||
}
|
||||
},
|
||||
{field: 'title', minWidth: 80, title: '节点名称 <i class="table-edit-tips color-red">*</i>', edit: 'text'},
|
||||
{field: 'update_time', minWidth: 80, title: '更新时间', search: 'range'},
|
||||
{field: 'is_auth', title: '节点控制', width: 85, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
]],
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
}
|
||||
};
|
||||
});
|
||||
89
public/static/admin/js/system/quick.js
Normal file
89
public/static/admin/js/system/quick.js
Normal file
@ -0,0 +1,89 @@
|
||||
define(["jquery", "easy-admin", "iconPickerFa", "autocomplete"], function ($, ea) {
|
||||
|
||||
var iconPickerFa = layui.iconPickerFa,
|
||||
autocomplete = layui.autocomplete;
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'system.quick/index',
|
||||
add_url: 'system.quick/add',
|
||||
edit_url: 'system.quick/edit',
|
||||
delete_url: 'system.quick/delete',
|
||||
export_url: 'system.quick/export',
|
||||
modify_url: 'system.quick/modify',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'sort', width: 80, title: '排序', edit: 'text'},
|
||||
{field: 'title', minWidth: 80, title: '权限名称'},
|
||||
{field: 'icon', width: 80, title: '图标', templet: ea.table.icon},
|
||||
{field: 'href', minWidth: 120, title: '快捷链接'},
|
||||
{field: 'remark', minWidth: 80, title: '备注信息'},
|
||||
{field: 'status', title: '状态', width: 85, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{width: 250, title: '操作', templet: ea.table.tool, operat: ['edit', 'delete']}
|
||||
]],
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
$(function () {
|
||||
iconPickerFa.render({
|
||||
elem: '#icon',
|
||||
url: PATH_CONFIG.iconLess,
|
||||
limit: 12,
|
||||
click: function (data) {
|
||||
$('#icon').val('fa ' + data.icon);
|
||||
},
|
||||
success: function (d) {
|
||||
console.log(d);
|
||||
}
|
||||
});
|
||||
})
|
||||
autocomplete.render({
|
||||
elem: $('#href')[0],
|
||||
url: ea.url('system.menu/getMenuTips'),
|
||||
template_val: '{{d.node}}',
|
||||
template_txt: '{{d.node}} <span class="layui-badge">{{d.title}}</span>',
|
||||
onselect: function (resp) {
|
||||
}
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
$(function () {
|
||||
iconPickerFa.render({
|
||||
elem: '#icon',
|
||||
url: PATH_CONFIG.iconLess,
|
||||
limit: 12,
|
||||
click: function (data) {
|
||||
$('#icon').val('fa ' + data.icon);
|
||||
},
|
||||
success: function (d) {
|
||||
console.log(d);
|
||||
}
|
||||
});
|
||||
})
|
||||
autocomplete.render({
|
||||
elem: $('#href')[0],
|
||||
url: ea.url('system.menu/getMenuTips'),
|
||||
template_val: '{{d.node}}',
|
||||
template_txt: '{{d.node}} <span class="layui-badge">{{d.title}}</span>',
|
||||
onselect: function (resp) {
|
||||
}
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
};
|
||||
});
|
||||
45
public/static/admin/js/system/uploadfile.js
Normal file
45
public/static/admin/js/system/uploadfile.js
Normal file
@ -0,0 +1,45 @@
|
||||
define(["jquery", "easy-admin"], function ($, ea) {
|
||||
|
||||
var init = {
|
||||
table_elem: '#currentTable',
|
||||
table_render_id: 'currentTableRenderId',
|
||||
index_url: 'system.uploadfile/index',
|
||||
add_url: 'system.uploadfile/add',
|
||||
edit_url: 'system.uploadfile/edit',
|
||||
delete_url: 'system.uploadfile/delete',
|
||||
modify_url: 'system.uploadfile/modify',
|
||||
export_url: 'system.uploadfile/export',
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
index: function () {
|
||||
ea.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: "checkbox"},
|
||||
{field: 'id', width: 80, title: 'ID', searchOp: '='},
|
||||
{field: 'upload_type', minWidth: 80, title: '存储位置', search: 'select', selectList: upload_types},
|
||||
{field: 'url', minWidth: 80, search: false, title: '图片信息', templet: ea.table.image},
|
||||
{field: 'url', minWidth: 120, title: '保存地址', templet: ea.table.url},
|
||||
{field: 'original_name', minWidth: 80, title: '文件原名'},
|
||||
{field: 'mime_type', minWidth: 80, title: 'mime类型'},
|
||||
{field: 'file_ext', minWidth: 80, title: '文件后缀'},
|
||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
||||
{width: 250, title: '操作', templet: ea.table.tool, operat: ['delete']}
|
||||
]],
|
||||
});
|
||||
|
||||
ea.listen();
|
||||
},
|
||||
add: function () {
|
||||
ea.listen();
|
||||
},
|
||||
edit: function () {
|
||||
ea.listen();
|
||||
},
|
||||
password: function () {
|
||||
ea.listen();
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user