diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js index 273a64d1e..845d77e71 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js @@ -308,7 +308,7 @@ function createMenuItem(dataUrl, menuName) { return false; } -//日志打印封装处理 +// 日志打印封装处理 var log = { log: function(msg) { console.log(msg); @@ -324,7 +324,7 @@ var log = { } }; -//本地缓存处理 +// 本地缓存处理 var storage = { set: function(key, value) { window.localStorage.setItem(key, value); @@ -340,6 +340,52 @@ var storage = { } }; +// 主子表操作封装处理 +var sub = { + editColumn: function() { + var count = $("#" + table.options.id).bootstrapTable('getData').length; + var params = new Array(); + for (var dataIndex = 0; dataIndex <= count; dataIndex++) { + var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td'); + var obj = new Object(); + for (var i = 0; i < columns.length; i++) { + var inputValue = $(columns[i]).find('input'); + var selectValue = $(columns[i]).find('select'); + var key = table.options.columns[i].field; + if ($.common.isNotEmpty(inputValue.val())) { + obj[key] = inputValue.val(); + } else if ($.common.isNotEmpty(selectValue.val())) { + obj[key] = selectValue.val(); + } else { + obj[key] = ""; + } + } + params.push({ index: dataIndex, row: obj }); + } + $("#" + table.options.id).bootstrapTable("updateRow", params); + }, + delColumn: function(column) { + var subColumn = $.common.isEmpty(column) ? "index" : column; + var ids = $.table.selectColumns(subColumn); + if (ids.length == 0) { + $.modal.alertWarning("请至少选择一条记录"); + return; + } + $("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids }); + if($.common.equals("index", subColumn)) + { + sub.resetIndex(); + } + }, + resetIndex: function(msg) { + var count = $("#" + table.options.id).bootstrapTable('getData').length; + for (var index = 0; index <= count; index++) { + // 重置序号 + $("#" + table.options.id).bootstrapTable('updateRow', { index: index, row: { index: parseInt(index + 1) } }) + } + } +}; + /** 设置全局ajax处理 */ $.ajaxSetup({ complete: function(XMLHttpRequest, textStatus) { diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index 49087ee58..1195d074f 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -1523,6 +1523,20 @@ var table = { }); return json; }, + // 数据字典转下拉框 + dictToSelect: function(datas, value, name) { + var actions = []; + actions.push($.common.sprintf("'); + return actions.join(''); + }, // 获取obj对象长度 getLength: function(obj) { var count = 0; diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/subdata.html b/ruoyi-admin/src/main/resources/templates/demo/table/subdata.html index ba30bfc9c..519adf6fe 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/subdata.html +++ b/ruoyi-admin/src/main/resources/templates/demo/table/subdata.html @@ -63,8 +63,8 @@