Browse Source

优化Table.api.replaceurl自动添加ids参数正则

jianglei 2 years ago
parent
commit
242d670b5a
1 changed files with 2 additions and 1 deletions
  1. 2 1
      public/assets/js/require-table.js

+ 2 - 1
public/assets/js/require-table.js

@@ -914,7 +914,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                 row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0);
                 row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0);
                 url = url == null || url.length === 0 ? '' : url.toString();
                 url = url == null || url.length === 0 ? '' : url.toString();
                 //自动添加ids参数
                 //自动添加ids参数
-                url = !url.match(/\{ids\}/i) ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
+                url = !url.match(/(?=([?&]ids=)|(\/ids\/)|(\{ids}))/i) ? 
+                    url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
                 url = url.replace(/\{(.*?)\}/gi, function (matched) {
                 url = url.replace(/\{(.*?)\}/gi, function (matched) {
                     matched = matched.substring(1, matched.length - 1);
                     matched = matched.substring(1, matched.length - 1);
                     if (matched.indexOf(".") !== -1) {
                     if (matched.indexOf(".") !== -1) {