From cbcb839cb9f3c70e5dd96befb700f871d2b9e586 Mon Sep 17 00:00:00 2001 From: augushong Date: Tue, 12 Nov 2024 13:57:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=A4=9A=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/admin/css/public.css | 12 ++ public/static/common/css/theme/index.css | 3 - .../static/plugs/ulthon-admin/ulthon-admin.js | 131 +++++++++++++++--- 3 files changed, 121 insertions(+), 25 deletions(-) diff --git a/public/static/admin/css/public.css b/public/static/admin/css/public.css index b20384f..0f5d315 100644 --- a/public/static/admin/css/public.css +++ b/public/static/admin/css/public.css @@ -585,6 +585,18 @@ table样式 .layuimini-form.multiple-columns .layui-form-item.full-line { width: calc(100% - 0px); } + + .layui-table-tool-temp{ + padding-right: unset; + padding-bottom: 40px; + + } + + .layuimini-container .layui-table-tool-self{ + right: 0; + bottom: 10px; + top: unset; + } } .w-e-text-container, diff --git a/public/static/common/css/theme/index.css b/public/static/common/css/theme/index.css index a04da56..012cc78 100644 --- a/public/static/common/css/theme/index.css +++ b/public/static/common/css/theme/index.css @@ -517,9 +517,6 @@ background-color: rgb(126, 252, 246); color: rgb(2, 17, 20); } -.elem-style-sicfi .layui-layout-admin .layui-header .layuimini-tool i { - color: rgb(126, 252, 246); -} .elem-style-sicfi .color-red { color: rgb(255, 0, 0) !important; } diff --git a/public/static/plugs/ulthon-admin/ulthon-admin.js b/public/static/plugs/ulthon-admin/ulthon-admin.js index 30650a1..59f3e35 100644 --- a/public/static/plugs/ulthon-admin/ulthon-admin.js +++ b/public/static/plugs/ulthon-admin/ulthon-admin.js @@ -12,7 +12,7 @@ }; window.onInitElemStyle(); - + const { createEditor, createToolbar } = window.wangEditor; var lastTableWhere = {}; @@ -41,11 +41,8 @@ var table; - if (tools.checkMobile()) { - table = window.uaTable; - } else { - table = layui.table; - } + table = layui.table; + var extGroup = { // 图片扩展名数组 @@ -174,11 +171,11 @@ }, error: function (xhr, textstatus, thrown) { var errorMsg = ''; - if(xhr.responseJSON.message){ + if (xhr.responseJSON.message) { errorMsg = xhr.responseJSON.message; } loading.hide(); - admin.msg.error('Status:' + xhr.status + ',' + xhr.statusText + ',请稍后再试!
'+errorMsg, function () { + admin.msg.error('Status:' + xhr.status + ',' + xhr.statusText + ',请稍后再试!
' + errorMsg, function () { ex(this); }); return false; @@ -275,6 +272,33 @@ options.headers = admin.headers(); options.page = admin.parame(options.page, true); options.search = admin.parame(options.search, true); + options.layout = admin.parame(options.layout, true); + options.layoutList = admin.parame(options.layoutList, + [ + 'table', + 'card', + { + name: 'usercard', + // 优先级1 + tplFunction() { + + }, + // 优先级3 + tplVue() { + + }, + // 优先级2 + tplLay() { + + }, + // 优先级4 + tplLayId: '', + // 优先级5 + tplVueId: '' + } + ] + ); + options.layoutDefault = admin.parame(options.layoutDefault, true); options.skin = options.skin || 'line'; options.autoSort = options.autoSort || false; options.limit = options.limit || 15; @@ -282,6 +306,14 @@ options.cols = options.cols || []; var defaultToolbar = ['filter', 'print']; + if (options.layout === true) { + defaultToolbar.push({ + title: '视图', + layEvent: 'TABLE_LAYOUT', + icon: 'layui-icon-template-1', + extend: 'data-table-id="' + options.id + '"' + }); + } if (options.search) { defaultToolbar.push({ @@ -304,6 +336,7 @@ } options.done = function (res, curr, count) { optionDone(res, curr, count); + console.log(res, curr, count); // 监听表格内的复制组件 admin.api.copyText('[lay-id=' + options.id + ']'); @@ -315,21 +348,8 @@ selectConfirmCallback = admin.getQueryVariable('select_confirm_callback', 'onTableDataConfirm'); - // 判断是否为移动端 - if (admin.checkMobile()) { - options.defaultToolbar = !options.search ? ['filter'] : ['filter', { - title: '搜索', - layEvent: 'TABLE_SEARCH', - icon: 'layui-icon-search', - extend: 'data-table-id="' + options.id + '"' - }]; - options.page = { - layout: ['first', 'prev', 'page', 'next', 'last', 'count'] - }; - } - if (selectMode == 'checkbox') { if (options.cols[0][0].type == 'radio') { @@ -362,6 +382,12 @@ options = admin.table.renderSearch(options.cols, options.elem, options.id, options); } + // 初始化模板切换 + if (options.layout === true) { + + options = admin.table.renderLayout(options); + } + // 初始化表格左上方工具栏 options.toolbar = options.toolbar || ['refresh', 'add', 'delete', 'export']; @@ -685,6 +711,58 @@ return options; }, + renderLayout: function (options) { + + if (!options.layoutList) { + return options; + } + + var tableId = options.id; + var elem = options.elem; + console.log(tableId); + + + // 初始化参数 + options.labelList = options.layoutList.map((item) => { + if (item == 'table') { + return { + name: 'table', + title: '默认表格', + + }; + } + if (item == 'card') { + return { + name: 'card', + title: '默认卡片', + 'tplFunction': function (data) { + return ''; + } + }; + } + return item; + }); + + var optionDone = options.done; + options.done = function (res, curr, count) { + optionDone(res, curr, count); + + + }; + // 生成html + var layoutElemId = 'layout-list-option-' + tableId; + // 构建下拉选择 + var layoutHtml = '
'; + + layoutHtml += '
'; + + $(elem).before(layoutHtml); + + + return options; + + }, + renderSwitch: function (cols, tableInit, tableId, modifyReload) { tableInit.modifyUrl = tableInit.modifyUrl || false; cols = cols[0] || {}; @@ -1347,6 +1425,15 @@ _that.addClass('layui-hide'); } break; + case 'TABLE_LAYOUT': + var searchFieldsetId = 'searchFieldset_' + tableId; + var _that = $("#" + searchFieldsetId); + if (_that.hasClass("layui-hide")) { + _that.removeClass('layui-hide'); + } else { + _that.addClass('layui-hide'); + } + break; } }); }, @@ -2477,7 +2564,7 @@ var targetElemName = $(v).data('paste-target'); $(v).on('click', function () { - if(!navigator.clipboard){ + if (!navigator.clipboard) { admin.msg.error('您的当前不支持粘贴操作'); return; }