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:
@@ -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',
|
||||
|
||||
@@ -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 || '';
|
||||
|
||||
Reference in New Issue
Block a user