From e3bcd9aa54ca0e80cab6b3203757aac88f9386b4 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 10 Jul 2019 09:07:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=91=E8=A1=A8=E6=A0=BC=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=9A=E5=B1=82=E7=BA=A7=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bootstrap-treetable/bootstrap-treetable.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js index 3bb3221e..25d9f401 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js +++ b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js @@ -335,13 +335,13 @@ } // 增加formatter渲染 if (column.formatter) { - $td.html(column.formatter.call(this, item[column.field], item, index)); + $td.html(column.formatter.call(this, getItemField(item, column.field), item, index)); } else { if(options.showTitle){ // 只在字段没有formatter时才添加title属性 $td.attr("title",item[column.field]); } - $td.text(item[column.field]); + $td.text(getItemField(item, column.field)); } if (options.expandColumn == index) { if (!isP) { @@ -583,6 +583,19 @@ $input.prop("checked", ''); } } + // ruoyi 解析数据,支持多层级访问 + var getItemField = function (item, field) { + var value = item; + + if (typeof field !== 'string' || item.hasOwnProperty(field)) { + return item[field]; + } + var props = field.split('.'); + for (var p in props) { + value = value && value[props[p]]; + } + return value; + }; // 初始化 init(); return target;