ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ /** * 后台JS主入口 */ var layer = layui.layer, element = layui.element, laydate = layui.laydate, form = layui.form; /** * AJAX全局设置 */ $.ajaxSetup({ type: "post", dataType: "json" }); /** * 后台侧边菜单选中状态 */ $('.layui-nav-item').find('a').removeClass('layui-this'); $('.layui-nav-tree').find('a[href*="' + GV.current_controller + '"]').parent().addClass('layui-this').parents('.layui-nav-item').addClass('layui-nav-itemed'); /** * 通用单图上传 */ layui.use('upload', function(){ var upload = layui.upload; //执行实例 var uploadInst = upload.render({ elem: '#test1' //绑定元素 ,url: '/index.php/api/upload/upload' //上传接口 ,done: function(data){ //上传完毕回调 if (data.error === 0) { layer.msg('上传成功'); window.location.reload(); //document.getElementById('thumb').value = data.url; } else { layer.msg(data.message); } } ,error: function(){ //请求异常回调 } }); }); /** * 通用日期时间选择 */ $('.datetime').on('click', function () { laydate({ elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss' }) }); /** * 通用表单提交(AJAX方式) */ form.on('submit(*)', function (data) { $.ajax({ url: data.form.action, type: data.form.method, data: $(data.form).serialize(), success: function (info) { if (info.code === 1) { setTimeout(function () { location.href = info.url; }, 1000); } layer.msg(info.msg); } }); return false; }); /** * 通用批量处理(审核、取消审核、删除) */ $('.ajax-action').on('click', function () { var _action = $(this).data('action'); layer.open({ shade: false, content: '确定执行此操作?', btn: ['确定', '取消'], yes: function (index) { $.ajax({ url: _action, data: $('.ajax-form').serialize(), success: function (info) { if (info.code === 1) { setTimeout(function () { location.href = info.url; }, 1000); } layer.msg(info.msg); } }); layer.close(index); } }); return false; }); /** * 通用全选 */ $('.check-all').on('click', function () { $(this).parents('table').find('input[type="checkbox"]').prop('checked', $(this).prop('checked')); }); /** * 通用删除 */ $('.ajax-delete').on('click', function () { var _href = $(this).attr('href'); layer.open({ shade: false, content: '确定删除?', btn: ['确定', '取消'], yes: function (index) { $.ajax({ url: _href, type: "get", success: function (info) { if (info.code === 1) { setTimeout(function () { location.href = info.url; }, 1000); } layer.msg(info.msg); } }); layer.close(index); } }); return false; }); /** * 清除缓存 */ $('#clear-cache').on('click', function () { var _url = $(this).data('url'); if (_url !== 'undefined') { $.ajax({ url: _url, success: function (data) { if (data.code === 1) { setTimeout(function () { location.href = location.pathname; }, 1000); } layer.msg(data.msg); } }); } return false; }); /*小张书写start*/ /*弹出层start*/ function xadmin_show(title,url,w,h){ if (title == null || title == '') { title=false; }; if (url == null || url == '') { url="404.html"; }; if (w == null || w == '') { w=800; }; if (h == null || h == '') { h=($(window).height() - 50); }; layer.open({ type: 2, area: [w+'px', h +'px'], fix: false, //不固定 maxmin: true, shadeClose: true, shade:0.4, title: title, content: url }); } //弹出层1 function xadmin_show(title,url,w,h,ids){ if (title == null || title == '') { title=false; }; if (url == null || url == '') { url="404.html"; }; if (w == null || w == '') { w=800; }; if (h == null || h == '') { h=($(window).height() - 50); }; layer.open({ type: 2, area: [w+'px', h +'px'], fix: false, //不固定 maxmin: true, shadeClose: true, shade:0.4, title: title, content: url+"ids/"+ids+'.html' }); } /*关闭弹出框口*/ function xadmin_close(){ var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); } /*弹出层end*/ // 全选 $('.all').click(function() { if($(this).is(':checked')) { $(':checkbox').prop("checked", true); } else { $(':checkbox').prop("checked", false); } }); //选择图片-单 function img_simple(title,url,w,h){ ximg_show(title,url,w,h); } //选择图片-多 function img_more(title,url,w,h){ ximg_show(title,url,w,h); } //弹出层2 function ximg_show(title,url,w,h){ if (title == null || title == '') { title=false; }; if (url == null || url == '') { url="404.html"; }; if (w == null || w == '') { w=800; }; if (h == null || h == '') { h=($(window).height() - 50); }; layer.open({ type: 2, area: [w+'px', h +'px'], fix: false, //不固定 maxmin: true, shadeClose: true, shade:0.4, title: title, content: url }); } /*******end*******/ /*小张书写end*/ ~~~