From 95ccd4071b83076c75021b5335ab59dc8354dfbb Mon Sep 17 00:00:00 2001 From: wolfcode <37436228+wolf-leo@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:03:26 +0800 Subject: [PATCH] feat(easy-admin): add support for custom template functions in operat column-Implement the ability to use custom template functions in the operat column of easy-admin tables - Add a new button in the goods list page to demonstrate the usage of custom templates --- public/static/admin/js/mall/goods.js | 4 ++++ public/static/plugs/easy-admin/easy-admin.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/public/static/admin/js/mall/goods.js b/public/static/admin/js/mall/goods.js index 0c7b909..bc6e6f9 100644 --- a/public/static/admin/js/mall/goods.js +++ b/public/static/admin/js/mall/goods.js @@ -57,6 +57,10 @@ define(["jquery", "easy-admin"], function ($, ea) { templet: ea.table.tool, operat: [ [{ + templet: function (d) { + return `` + } + }, { text: '编辑', url: init.edit_url, method: 'open', diff --git a/public/static/plugs/easy-admin/easy-admin.js b/public/static/plugs/easy-admin/easy-admin.js index d65d72c..bf32e6c 100644 --- a/public/static/plugs/easy-admin/easy-admin.js +++ b/public/static/plugs/easy-admin/easy-admin.js @@ -672,6 +672,12 @@ define(["jquery", "tableSelect"], function ($, tableSelect) { $.each(item, function (i, operat) { if (typeof operat !== 'object') return + + if ('function' === typeof operat.templet) { + html += operat.templet(data); + return true; + } + operat.class = operat.class || ''; operat.icon = operat.icon || ''; operat.auth = operat.auth || '';