From 8e88e1c9dc2873abf4ae5c6ba342ac939ff9309d Mon Sep 17 00:00:00 2001 From: Karson Date: Tue, 2 Apr 2024 17:50:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E6=97=B6=E6=96=87=E6=9C=AC=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Conflicts: # public/assets/js/require-table.js --- public/assets/js/require-table.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index ceeb0b07..3502d36a 100644 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -831,8 +831,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table }, search: function (value, row, index) { var field = this.field; - if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') { - value = row[this.customField]; + if (typeof this.customField !== 'undefined') { + var customValue = this.customField.split('.').reduce(function (obj, key) { + return obj === null || obj === undefined ? '' : obj[key]; + }, row); + value = Fast.api.escape(customValue); field = this.customField; } return '' + value + ''; @@ -856,8 +859,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table colorArr = $.extend(colorArr, this.custom); } var field = this.field; - if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') { - value = row[this.customField]; + if (typeof this.customField !== 'undefined') { + var customValue = this.customField.split('.').reduce(function (obj, key) { + return obj === null || obj === undefined ? '' : obj[key]; + }, row); + value = Fast.api.escape(customValue); field = this.customField; } if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') { @@ -1007,17 +1013,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url; url = url.replace(/\{(.*?)\}/gi, function (matched) { matched = matched.substring(1, matched.length - 1); - if (matched.indexOf(".") !== -1) { - var temp = row; - var arr = matched.split(/\./); - for (var i = 0; i < arr.length; i++) { - if (typeof temp[arr[i]] !== 'undefined') { - temp = temp[arr[i]]; - } - } - return typeof temp === 'object' ? '' : temp; - } - return row[matched]; + var temp = matched.split('.').reduce(function (obj, key) { + return obj === null || obj === undefined ? '' : obj[key]; + }, row); + temp = Fast.api.escape(temp); + return temp; }); return url; },