|
|
@@ -7,10 +7,10 @@
|
|
|
</div>
|
|
|
<div class="modal-body">
|
|
|
<table class="table table-hover table-bordered">
|
|
|
- <thead><tr><th width="150px">列名</th><th width="50px">显示</th><th width="150px">别名</th><th width="80px">操作</th></tr></thead>
|
|
|
+ <thead><tr><th width="150px" class="text-center">列名</th><th width="50px" class="text-center">显示</th><th width="150px" class="text-center">别名</th><th width="80px" class="text-center">操作</th></tr></thead>
|
|
|
<tbody class="text-center">
|
|
|
<% for (const cs of colSet) { %>
|
|
|
- <tr code="<%- cs.field %>">
|
|
|
+ <tr code="<%- cs.field %>">
|
|
|
<td>
|
|
|
<%- cs.name %>
|
|
|
<% if (cs.hint) { %>
|
|
|
@@ -61,6 +61,9 @@
|
|
|
// 立即获取表格 tbody 并绑定事件(确保脚本加载时即可初始化)
|
|
|
const $tbody = $('#col-set').find('.modal-body table tbody');
|
|
|
|
|
|
+// 保存初始 HTML,在关闭时恢复(保证再次打开时为初始状态)
|
|
|
+const _initialColSetTbodyHtml = $tbody.html();
|
|
|
+
|
|
|
// 更新上下移链接显示状态
|
|
|
function updateMoveButtons() {
|
|
|
const $currentRows = $tbody.find('tr');
|
|
|
@@ -95,12 +98,20 @@ $('#col-set').on('shown.bs.modal', function() {
|
|
|
updateMoveButtons();
|
|
|
});
|
|
|
|
|
|
+// 模态框隐藏时恢复到初始内容并重新绑定必要状态
|
|
|
+$('#col-set').on('hidden.bs.modal', function() {
|
|
|
+ // 恢复初始 tbody 内容
|
|
|
+ $tbody.html(_initialColSetTbodyHtml);
|
|
|
+ // 重新计算按钮显示状态
|
|
|
+ updateMoveButtons();
|
|
|
+});
|
|
|
+
|
|
|
// 事件委托:从一开始就绑定上/下移事件
|
|
|
$tbody.on('click', '.move-up', function(e) {
|
|
|
e.preventDefault();
|
|
|
const $currentRow = $(this).closest('tr');
|
|
|
const $prevRow = $currentRow.prev('tr');
|
|
|
-
|
|
|
+
|
|
|
if ($prevRow.length) {
|
|
|
$currentRow.insertBefore($prevRow);
|
|
|
updateMoveButtons();
|
|
|
@@ -111,7 +122,7 @@ $tbody.on('click', '.move-down', function(e) {
|
|
|
e.preventDefault();
|
|
|
const $currentRow = $(this).closest('tr');
|
|
|
const $nextRow = $currentRow.next('tr');
|
|
|
-
|
|
|
+
|
|
|
if ($nextRow.length) {
|
|
|
$currentRow.insertAfter($nextRow);
|
|
|
updateMoveButtons();
|
|
|
@@ -144,4 +155,4 @@ function onSetCol() {
|
|
|
$('input[name=col_set]').val(JSON.stringify(colSet));
|
|
|
return true;
|
|
|
}
|
|
|
-</script>
|
|
|
+</script>
|