From 685c5724a482cb106d1760e718aff1303fdd6088 Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 10 Sep 2026 17:26:23 +0000 Subject: [PATCH] =?UTF-8?q?feat(table):=20=E7=A7=BB=E9=99=A4=E5=AF=84?= =?UTF-8?q?=E7=94=9F=E5=A4=9A=E6=A8=A1=E6=9D=BF=E5=AE=9E=E7=8E=B0=EF=BC=8C?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E6=90=9C=E7=B4=A2=E4=B8=8E=E6=A0=B8=E5=BF=83?= =?UTF-8?q?=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/plugs/ulthon-admin/admin-table.js | 310 ------------------ 1 file changed, 310 deletions(-) diff --git a/public/static/plugs/ulthon-admin/admin-table.js b/public/static/plugs/ulthon-admin/admin-table.js index ec432fe..e555531 100644 --- a/public/static/plugs/ulthon-admin/admin-table.js +++ b/public/static/plugs/ulthon-admin/admin-table.js @@ -22,33 +22,6 @@ options.headers = ua.headers(); options.page = ua.parame(options.page, true); options.search = ua.parame(options.search, true); - options.layout = ua.parame(options.layout, true); - options.layoutList = ua.parame(options.layoutList, - [ - 'table', - 'card', - { - name: 'usercard', - // 优先级1 - tplFunction() { - - }, - // 优先级3 - tplVue() { - - }, - // 优先级2 - tplLay() { - - }, - // 优先级4 - tplLayId: '', - // 优先级5 - tplVueId: '' - } - ] - ); - options.layoutDefault = ua.parame(options.layoutDefault, true); options.skin = options.skin || 'line'; options.autoSort = options.autoSort || false; options.limit = options.limit || 15; @@ -57,27 +30,6 @@ options.rowDisableCallback = options.rowDisableCallback || null; 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.layoutDefault === true) { - // 自动判断,手机端默认card,电脑端默认table - if (ua.checkMobile()) { - options.layoutDefault = 'card'; - } else { - options.layoutDefault = 'table'; - } - } - - options.layoutDefault = ua.trySetPageSetting('table-layout-default', options.layoutDefault); - - - } if (options.search) { defaultToolbar.push({ @@ -154,12 +106,6 @@ options = ua.table.renderSearch(options.cols, options.elem, options.id, options); } - // 初始化模板切换 - if (options.layout === true) { - - options = ua.table.renderLayout(options); - } - // 初始化表格左上方工具栏 options.toolbar = options.toolbar || ['refresh', 'add', 'delete', 'export']; @@ -557,202 +503,6 @@ return options; }, - renderLayout: function (options) { - - if (!options.layoutList) { - return options; - } - - var tableId = options.id; - - var layuiTableElemName = '[lay-table-id="' + tableId + '"]'; - var elem = options.elem; - - // 初始化参数 - options.layoutList = options.layoutList.map((item) => { - if (item == 'table') { - return { - name: 'table', - icon: 'layui-icon layui-icon-table', - title: '默认表格', - - }; - } else if (item == 'card') { - return { - name: 'card', - title: '默认卡片', - icon: 'layui-icon layui-icon-form', - tplFunction: function (options, res, container) { - console.log('card func'); - - console.log(options); - console.log(res); - console.log(container); - - var baseItem = ` -
-
-
- # - -
-
- -
-
-
-
- - -
-
- -
`; - var baseDataItem = ` -
-
- -
-
- -
-
`; - - res.data.forEach(row => { - - var rowItem = $.extend(true, {}, row); - - var baseElem = $(baseItem).appendTo(container); - - if (options.cols[0][0].type == 'checkbox' || options.cols[0[0]].type == 'radio') { - $('') - .appendTo(baseElem.find('.header').find('.plus')); - - } - - rowItem.LAY_COL = $.extend(true, {}, options.cols[0][1]); - baseElem.find('.header').find('.main').find('span').html( - options.cols[0][1].templet(rowItem) - ); - - options.cols[0].forEach(LAY_COL => { - var dataItem = $.extend(true, {}, row); - dataItem.LAY_COL = $.extend(true, {}, LAY_COL); - if (LAY_COL.type == 'checkbox' || LAY_COL.type == 'radio') { - return; - } - - if (LAY_COL.templet == ua.table.tool) { - // 暂时隐藏按钮 - // baseElem.find('.footer .plus').html(dataItem.LAY_COL.templet(dataItem)); - return; - } - - if (LAY_COL.field == 'create_time') { - baseElem.find('.footer .main').html(dataItem.LAY_COL.templet(dataItem)); - return; - } - - var baseDataItemElem = $(baseDataItem).appendTo(baseElem.find('.body .main')); - baseDataItemElem.find('.item-title').html( - dataItem.LAY_COL.title + ':' - ); - baseDataItemElem.find('.item-value').html( - dataItem.LAY_COL.templet(dataItem) - ); - }); - - }); - - return ''; - } - }; - } else { - if (item.icon == undefined) { - item.icon = 'layui-icon layui-icon-component'; - } - if (item.title == undefined) { - item.title = item.name; - } - } - return item; - }); - - var optionBefore = options.before; - options.before = function (res, curr, count) { - optionBefore(res, curr, count); - console.log('layout before fun'); - - var currentLayout = ua.getPageSetting('table-layout-default', 'table'); - // 隐藏所有数据体内容 - var layuiTableElem = $(layuiTableElemName); - - options.layoutList.forEach((item) => { - if (item.name == 'table') { - layuiTableElem.find('.layui-table-box').hide(); - } else { - layuiTableElem.find('.layui-table-custom.layui-table-custom-' + item.name).hide(); - } - }); - - if (currentLayout == 'table') { - layuiTableElem.find('.layui-table-box').show(); - } else { - var className = '.layui-table-custom.layui-table-custom-' + currentLayout; - // 如果不存在则创建 - if (!layuiTableElem.find(className).length) { - layuiTableElem.find('.layui-table-box').before('
'); - } - layuiTableElem.find(className).show(); - loading.show(); - } - }; - - var optionDone = options.done; - options.done = function (res, curr, count) { - optionDone(res, curr, count); - console.log('layout done fun'); - - var currentLayout = ua.getPageSetting('table-layout-default', 'table'); - // 隐藏所有数据体内容 - var layuiTableElem = $(layuiTableElemName); - - options.layoutList.forEach((item) => { - if (currentLayout == 'table') { - // 如果是table,则不用生成数据,显示出来就行,before已经显示过了 - return; - } - - if (currentLayout != item.name) { - // 如果不是,则不进行任何操作 - return; - } - - var className = '.layui-table-custom.layui-table-custom-' + item.name; - - // 清空里面的数据 - layuiTableElem.find(className).html(''); - loading.hide(); - - item.tplFunction(options, res, layuiTableElem.find(className)); - - - - - }); - - }; - - return options; - - }, - renderSwitch: function (cols, tableInit, tableId, modifyReload) { tableInit.modifyUrl = tableInit.modifyUrl || false; cols = cols[0] || {}; @@ -1431,66 +1181,6 @@ _that.addClass('layui-hide'); } break; - case 'TABLE_LAYOUT': - var layoutElemId = 'layout-list-option-' + tableId; - var layoutElemIdName = '#' + layoutElemId; - - var currentLayout = ua.getPageSetting('table-layout-default', 'table'); - - // 构建下拉选择 - var layoutHtml = '
'; - - options.layoutList.forEach(item => { - var currentClassName = ''; - if (item.name == currentLayout) { - currentClassName = 'current'; - } - layoutHtml += ` -
-
-
${item.title}
-
`; - }); - - layoutHtml += '
'; - - var toolbarLayoutElem = $('[lay-table-id="' + tableId + '"]').find('[lay-event="TABLE_LAYOUT"]'); - if (toolbarLayoutElem.find(layoutElemIdName).length > 0) { - // If it is, remove the HTML - $(layoutElemIdName).remove(); - } - layoulElem = $(layoutHtml); - layoulElem.appendTo(toolbarLayoutElem); - - - layoulElem.on('click', function (event) { - - var item = $(event.target).closest('.item'); - if (item.length > 0) { - // 点击操作 - item.addClass('current').siblings().removeClass('current'); - - var layoutName = item.data('name'); - ua.setPageSetting('table-layout-default', layoutName); - - table.reloadData(tableId, {}, true); - } else { - // 其他区域操作 - } - - // 不要冒泡 - event.stopPropagation(); - }); - - // Remove any existing click event listeners to avoid duplicates - $(document).off('click.table-layout').on('click.table-layout', function (event) { - - if (!$(event.target).closest(toolbarLayoutElem).length) { - // If it is, remove the HTML - $(layoutElemIdName).remove(); - } - }); - break; } }); },