Преглед изворни кода

优化主子表单删方法

RuoYi пре 3 година
родитељ
комит
53bb1da7a1

+ 1 - 2
ruoyi-admin/src/main/resources/static/ruoyi/js/common.js

@@ -465,9 +465,8 @@ var sub = {
         }
         $("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
     },
-    delRowByIndex: function(defindex, index) {
+    delRowByIndex: function(value) {
     	sub.editRow();
-        var value = $.common.isNotEmpty(index) ? index : defindex;
         $("#" + table.options.id).bootstrapTable('remove', { field: "index", values: [value] });
         sub.editRow();
     },

+ 2 - 1
ruoyi-admin/src/main/resources/templates/demo/table/subdata.html

@@ -171,7 +171,8 @@
                     title: '操作',
                     align: 'center',
                     formatter: function(value, row, index) {
-                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + $.table.serialNumber(index) + '\', \'' + row.index + '\')"><i class="fa fa-remove"></i>删除</a>';
+                    	var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
+                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                     }
                 }]
 		    };

+ 2 - 1
ruoyi-generator/src/main/resources/vm/html/add.html.vm

@@ -351,7 +351,8 @@
                     title: '操作',
                     align: 'center',
                     formatter: function(value, row, index) {
-                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + $.table.serialNumber(index) + '\', \'' + row.index + '\')"><i class="fa fa-remove"></i>删除</a>';
+                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
+                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                     }
                 }]
             };

+ 2 - 1
ruoyi-generator/src/main/resources/vm/html/edit.html.vm

@@ -363,7 +363,8 @@
                     title: '操作',
                     align: 'center',
                     formatter: function(value, row, index) {
-                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + $.table.serialNumber(index) + '\', \'' + row.index + '\')"><i class="fa fa-remove"></i>删除</a>';
+                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
+                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                     }
                 }]
             };