From 7d6cdabc09c372b44d1044f49a5282a6a7ecea48 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 18 Jun 2019 21:56:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A8=E6=A0=BC=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/DemoTableController.java | 9 + .../columns/bootstrap-table-fixed-columns.js | 2 +- .../main/resources/static/ruoyi/css/ry-ui.css | 2 +- .../main/resources/static/ruoyi/js/common.js | 4 +- .../main/resources/static/ruoyi/js/ry-ui.js | 38 ++-- .../templates/demo/operate/other.html | 72 ++++++- .../resources/templates/demo/table/curd.html | 178 ++++++++++++++++++ .../src/main/resources/templates/index.html | 1 + 8 files changed, 282 insertions(+), 24 deletions(-) create mode 100644 ruoyi-admin/src/main/resources/templates/demo/table/curd.html diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java index 02e735e18..f2088912e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java @@ -176,6 +176,15 @@ public class DemoTableController extends BaseController return prefix + "/image"; } + /** + * 动态增删改查 + */ + @GetMapping("/curd") + public String curd() + { + return prefix + "/curd"; + } + /** * 表格其他操作 */ diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js index 21302a308..ef3209194 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js +++ b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js @@ -210,7 +210,7 @@ that.$fixedBody.find('tbody tr:eq(' + i + ')').height($(this).height()); }); - $("#" + $.table._option.id).on("check.bs.table uncheck.bs.table", function (e, rows, $element) { + $.btTable.on("check.bs.table uncheck.bs.table", function (e, rows, $element) { var index= $element.data('index'); $(this).find('.bs-checkbox').find('input[data-index="' + index + '"]').prop("checked", true); var selectFixedItem = $('.left-fixed-table-columns input[name=btSelectItem]'); diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css b/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css index 0f5727f23..a42b82d87 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css +++ b/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css @@ -584,7 +584,7 @@ label { } .container-div { - padding: 10px 35px; + padding: 0px 28px; height: 100%; } 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 307542f7f..b4c08785f 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js @@ -131,9 +131,9 @@ $(function() { var dataExpand = $.common.isEmpty($.table._option.expandAll) ? true : $.table._option.expandAll; expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag; if (!expandFlag) { - $('#' + $.table._option.id).bootstrapTreeTable('expandAll'); + $.bttTable.bootstrapTreeTable('expandAll'); } else { - $('#' + $.table._option.id).bootstrapTreeTable('collapseAll'); + $.bttTable.bootstrapTreeTable('collapseAll'); } expandFlag = expandFlag ? false: true; }) 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 7c5b9bb01..2b64b6d2a 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 @@ -4,8 +4,9 @@ */ (function ($) { $.extend({ - _treeTable: {}, _tree: {}, + btTable: {}, + bttTable: {}, // 表格封装处理 table: { _option: {}, @@ -43,6 +44,7 @@ }; var options = $.extend(defaults, options); $.table._option = options; + $.btTable = $('#' + options.id); $.table.initEvent(); $('#' + options.id).bootstrapTable({ url: options.url, // 请求后台的URL(*) @@ -72,6 +74,7 @@ showColumns: options.showColumns, // 是否显示隐藏某列下拉框 showToggle: options.showToggle, // 是否显示详细视图和列表视图的切换按钮 showExport: options.showExport, // 是否支持导出文件 + uniqueId: options.uniqueId, // 唯 一的标识符 clickToSelect: options.clickToSelect, // 是否启用点击选中行 detailView: options.detailView, // 是否启用显示细节视图 onClickRow: options.onClickRow, // 点击某行触发的事件 @@ -130,7 +133,7 @@ // 初始化事件 initEvent: function(data) { // 触发行点击事件 加载成功事件 - $("#" + $.table._option.id).on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table load-success.bs.table", function () { + $.btTable.on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table load-success.bs.table", function () { // 工具栏按钮控制 var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); $('#' + $.table._option.toolbar + ' .btn-del').toggleClass('disabled', !rows.length); @@ -138,7 +141,7 @@ $('#' + $.table._option.toolbar + ' .btn-detail').toggleClass('disabled', rows.length!=1); }); // 绑定选中事件、取消事件、全部选中、全部取消 - $("#" + $.table._option.id).on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rows) { + $.btTable.on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rows) { // 复选框分页保留保存选中数组 var rowIds = $.table.affectedRowIds(rows); if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { @@ -147,7 +150,7 @@ } }); // 图片预览事件 - $("#" + $.table._option.id).on('click', '.img-circle', function() { + $.btTable.on('click', '.img-circle', function() { var src = $(this).attr('src'); var target = $(this).data('target'); if($.common.equals("self", target)) { @@ -179,7 +182,7 @@ }, // 序列号生成 serialNumber: function (index) { - var table = $('#' + $.table._option.id).bootstrapTable('getOptions'); + var table = $.btTable.bootstrapTable('getOptions'); var pageSize = table.pageSize; var pageNumber = table.pageNumber; return pageSize * (pageNumber - 1) + index + 1; @@ -223,7 +226,7 @@ // 搜索-默认第一个form search: function(formId, data) { var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId; - var params = $("#" + $.table._option.id).bootstrapTable('getOptions'); + var params = $.btTable.bootstrapTable('getOptions'); params.queryParams = function(params) { var search = $.common.formToJSON(currentId); if($.common.isNotEmpty(data)){ @@ -238,7 +241,7 @@ search.isAsc = params.order; return search; } - $("#" + $.table._option.id).bootstrapTable('refresh', params); + $.btTable.bootstrapTable('refresh', params); }, // 导出数据 exportExcel: function(formId) { @@ -323,13 +326,13 @@ }, // 刷新表格 refresh: function() { - $("#" + $.table._option.id).bootstrapTable('refresh', { + $.btTable.bootstrapTable('refresh', { silent: true }); }, // 查询表格指定列值 selectColumns: function(column) { - var rows = $.map($('#' + $.table._option.id).bootstrapTable('getSelections'), function (row) { + var rows = $.map($.btTable.bootstrapTable('getSelections'), function (row) { return row[column]; }); if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { @@ -352,7 +355,7 @@ }, // 查询表格首列值 selectFirstColumns: function() { - var rows = $.map($('#' + $.table._option.id).bootstrapTable('getSelections'), function (row) { + var rows = $.map($.btTable.bootstrapTable('getSelections'), function (row) { return row[$.table._option.columns[1].field]; }); if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { @@ -374,11 +377,11 @@ }, // 显示表格指定列 showColumn: function(column) { - $("#" + $.table._option.id).bootstrapTable('showColumn', column); + $.btTable.bootstrapTable('showColumn', column); }, // 隐藏表格指定列 hideColumn: function(column) { - $("#" + $.table._option.id).bootstrapTable('hideColumn', column); + $.btTable.bootstrapTable('hideColumn', column); } }, // 表格树封装处理 @@ -401,7 +404,7 @@ }; var options = $.extend(defaults, options); $.table._option = options; - var treeTable = $('#' + options.id).bootstrapTreeTable({ + $.bttTable = $('#' + options.id).bootstrapTreeTable({ code: options.code, // 用于设置父子关系 parentCode: options.parentCode, // 用于设置父子关系 type: 'get', // 请求方式(*) @@ -419,21 +422,20 @@ expandFirst: options.expandFirst, // 是否默认第一级展开--expandAll为false时生效 columns: options.columns }); - $._treeTable = treeTable; }, // 条件查询 search: function(formId) { var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId; var params = $.common.formToJSON(currentId); - $._treeTable.bootstrapTreeTable('refresh', params); + $.bttTable('refresh', params); }, // 刷新 refresh: function() { - $._treeTable.bootstrapTreeTable('refresh'); + $.bttTable('refresh'); }, // 查询表格树指定列值 selectColumns: function(column) { - var rows = $.map($('#' + $.table._option.id).bootstrapTreeTable('getSelections'), function (row) { + var rows = $.map($.btTable.bootstrapTreeTable('getSelections'), function (row) { return row[column]; }); return $.common.uniqueFn(rows); @@ -819,7 +821,7 @@ // 修改信息 edit: function(id) { if($.common.isEmpty(id) && $.table._option.type == table_type.bootstrapTreeTable) { - var row = $('#' + $.table._option.id).bootstrapTreeTable('getSelections')[0]; + var row = $.btTable.bootstrapTreeTable('getSelections')[0]; if ($.common.isEmpty(row)) { $.modal.alertWarning("请至少选择一条记录"); return; diff --git a/ruoyi-admin/src/main/resources/templates/demo/operate/other.html b/ruoyi-admin/src/main/resources/templates/demo/operate/other.html index 3887c4c23..ed0c55bbf 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/operate/other.html +++ b/ruoyi-admin/src/main/resources/templates/demo/operate/other.html @@ -3,7 +3,75 @@ - - + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+   +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+   +
+
+
+
+ + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/curd.html b/ruoyi-admin/src/main/resources/templates/demo/table/curd.html new file mode 100644 index 000000000..6b8cfc8bf --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/demo/table/curd.html @@ -0,0 +1,178 @@ + + + + + + + +
+ + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/index.html b/ruoyi-admin/src/main/resources/templates/index.html index bb47d875f..e8bed7bdb 100644 --- a/ruoyi-admin/src/main/resources/templates/index.html +++ b/ruoyi-admin/src/main/resources/templates/index.html @@ -104,6 +104,7 @@
  • 自定义触发事件
  • 表格细节视图
  • 表格图片预览
  • +
  • 动态增删改查
  • 表格其他操作