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
This commit is contained in:
wolfcode
2024-12-02 11:03:26 +08:00
parent 09f3ea7e54
commit 95ccd4071b
2 changed files with 10 additions and 0 deletions

View File

@@ -57,6 +57,10 @@ define(["jquery", "easy-admin"], function ($, ea) {
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',

View File

@@ -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 || '';