From 71050974cf2ce2e6042099e2edfcb2cd080df4de Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 21 Oct 2019 11:37:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DemoOperateController.java | 11 + .../bootstrap-table/bootstrap-table.min.js | 2 +- .../columns/bootstrap-table-fixed-columns.js | 2 +- .../main/resources/static/ruoyi/js/common.js | 2 +- .../main/resources/static/ruoyi/js/ry-ui.js | 278 ++++++++++++------ .../resources/templates/demo/table/curd.html | 18 +- .../templates/demo/table/editable.html | 4 +- .../resources/templates/demo/table/multi.html | 62 ++-- 8 files changed, 250 insertions(+), 129 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java index 8c35b23e..a628ebec 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoOperateController.java @@ -103,6 +103,17 @@ public class DemoOperateController extends BaseController } } } + else if (StringUtils.isNotEmpty(userModel.getUserName())) + { + userList.clear(); + for (Map.Entry entry : users.entrySet()) + { + if (entry.getValue().getUserName().equals(userModel.getUserName())) + { + userList.add(entry.getValue()); + } + } + } PageDomain pageDomain = TableSupport.buildPageRequest(); if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) { diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js index f8a0bb04..b2766578 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js +++ b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/bootstrap-table.min.js @@ -4,4 +4,4 @@ * https://github.com/wenzhixin/bootstrap-table/ */ (function(j){var k=null;var m=function(u){var s=arguments,r=true,t=1;u=u.replace(/%s/g,function(){var v=s[t++];if(typeof v==="undefined"){r=false;return""}return v});return r?u:""};var c=function(t,v,u,s){var r="";j.each(t,function(w,x){if(x[v]===s){r=x[u];return false}return true});return r};var i=function(s,t){var r=-1;j.each(s,function(u,v){if(v.field===t){r=u;return false}return true});return r};var l=function(u){var y,x,w,A=0,B=[];for(y=0;y").addClass("fixed-table-scroll-inner"),u=j("
").addClass("fixed-table-scroll-outer"),s,r;u.append(t);j("body").append(u);s=t[0].offsetWidth;u.css("overflow","scroll");r=t[0].offsetWidth;if(s===r){r=u[0].clientWidth}u.remove();k=s-r}return k};var q=function(s,u,t,r){var v=u;if(typeof u==="string"){var w=u.split(".");if(w.length>1){v=window;j.each(w,function(x,y){v=v[y]})}else{v=window[u]}}if(typeof v==="object"){return v}if(typeof v==="function"){return v.apply(s,t)}if(!v&&typeof u==="string"&&m.apply(this,[u].concat(t))){return m.apply(this,[u].concat(t))}return r};var f=function(s,r,w){var x=Object.getOwnPropertyNames(s),u=Object.getOwnPropertyNames(r),v="";if(w){if(x.length!==u.length){return false}}for(var t=0;t-1){if(s[v]!==r[v]){return false}}}return true};var p=function(r){if(typeof r==="string"){return r.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`")}return r};var d=function(s){var r=0;s.children().each(function(){if(r0||!!navigator.userAgent.match(/Trident.*rv\:11\./))};var h=function(){if(!Object.keys){Object.keys=(function(){var t=Object.prototype.hasOwnProperty,u=!({toString:null}).propertyIsEnumerable("toString"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],r=s.length;return function(x){if(typeof x!=="object"&&(typeof x!=="function"||x===null)){throw new TypeError("Object.keys called on non-object")}var v=[],y,w;for(y in x){if(t.call(x,y)){v.push(y)}}if(u){for(w=0;w','
',this.options.paginationVAlign==="top"||this.options.paginationVAlign==="both"?'
':"",'
','
','
','
',this.options.formatLoadingMessage(),"
","
",'',this.options.paginationVAlign==="bottom"||this.options.paginationVAlign==="both"?'
':"","
","
"].join(""));this.$container.insertAfter(this.$el);this.$tableContainer=this.$container.find(".fixed-table-container");this.$tableHeader=this.$container.find(".fixed-table-header");this.$tableBody=this.$container.find(".fixed-table-body");this.$tableLoading=this.$container.find(".fixed-table-loading");this.$tableFooter=this.$container.find(".fixed-table-footer");this.$toolbar=this.$container.find(".fixed-table-toolbar");this.$pagination=this.$container.find(".fixed-table-pagination");this.$tableBody.append(this.$el);this.$container.after('
');this.$el.addClass(this.options.classes);if(this.options.striped){this.$el.addClass("table-striped")}if(j.inArray("table-no-bordered",this.options.classes.split(" "))!==-1){this.$tableContainer.addClass("table-no-bordered")}};e.prototype.initTable=function(){var t=this,s=[],u=[];this.$header=this.$el.find(">thead");if(!this.$header.length){this.$header=j("").appendTo(this.$el)}this.$header.find("tr").each(function(){var v=[];j(this).find("th").each(function(){if(typeof j(this).data("field")!=="undefined"){j(this).data("field",j(this).data("field")+"")}v.push(j.extend({},{title:j(this).html(),"class":j(this).attr("class"),titleTooltip:j(this).attr("title"),rowspan:j(this).attr("rowspan")?+j(this).attr("rowspan"):undefined,colspan:j(this).attr("colspan")?+j(this).attr("colspan"):undefined},j(this).data()))});s.push(v)});if(!j.isArray(this.options.columns[0])){this.options.columns=[this.options.columns]}this.options.columns=j.extend(true,[],s,this.options.columns);this.columns=[];l(this.options.columns);j.each(this.options.columns,function(w,v){j.each(v,function(x,y){y=j.extend({},e.COLUMN_DEFAULTS,y);if(typeof y.fieldIndex!=="undefined"){t.columns[y.fieldIndex]=y}t.options.columns[w][x]=y})});if(this.options.data.length){return}var r=[];this.$el.find(">tbody>tr").each(function(w){var v={};v._id=j(this).attr("id");v._class=j(this).attr("class");v._data=g(j(this).data());j(this).find(">td").each(function(z){var E=j(this),B=+E.attr("colspan")||1,C=+E.attr("rowspan")||1,A,y;for(;r[w]&&r[w][z];z++){}for(A=z;A");if(v===0&&!t.options.cardView&&t.options.detailView){s.push(m('
',t.options.columns.length))}j.each(u,function(B,A){var F="",C="",E="",w="",D=m(' class="%s"',A["class"]),z=t.options.sortOrder||A.order,y="px",x=A.width;if(A.width!==undefined&&(!t.options.cardView)){if(typeof A.width==="string"){if(A.width.indexOf("%")!==-1){y="%"}}}if(A.width&&typeof A.width==="string"){x=A.width.replace("%","").replace("px","")}C=m("text-align: %s; ",A.halign?A.halign:A.align);E=m("text-align: %s; ",A.align);w=m("vertical-align: %s; ",A.valign);w+=m("width: %s; ",(A.checkbox||A.radio)&&!x?"36px":(x?x+y:undefined));if(typeof A.fieldIndex!=="undefined"){t.header.fields[A.fieldIndex]=A.field;t.header.styles[A.fieldIndex]=E+w;t.header.classes[A.fieldIndex]=D;t.header.formatters[A.fieldIndex]=A.formatter;t.header.events[A.fieldIndex]=A.events;t.header.sorters[A.fieldIndex]=A.sorter;t.header.sortNames[A.fieldIndex]=A.sortName;t.header.cellStyles[A.fieldIndex]=A.cellStyle;t.header.searchables[A.fieldIndex]=A.searchable;if(!A.visible){return}if(t.options.cardView&&(!A.cardVisible)){return}r[A.field]=A}s.push("");s.push(m('
',t.options.sortable&&A.sortable?"sortable both":""));F=A.title;if(A.checkbox){if(!t.options.singleSelect&&t.options.checkboxHeader){F=''}t.header.stateField=A.field}if(A.radio){F="";t.header.stateField=A.field;t.options.singleSelect=true}s.push(F);s.push("
");s.push('
');s.push("");s.push("")});s.push("")});this.$header.html(s.join(""));this.$header.find("th[data-field]").each(function(u){j(this).data(r[j(this).data("field")])});this.$container.off("click",".th-inner").on("click",".th-inner",function(u){var v=j(this);if(t.options.detailView){if(v.closest(".bootstrap-table")[0]!==t.$container[0]){return false}}if(t.options.sortable&&v.parent().data().sortable){t.onSort(u)}});this.$header.children().children().off("keypress").on("keypress",function(v){if(t.options.sortable&&j(this).data().sortable){var u=v.keyCode||v.which;if(u==13){t.onSort(v)}}});j(window).off("resize.bootstrap-table");if(!this.options.showHeader||this.options.cardView){this.$header.hide();this.$tableHeader.hide();this.$tableLoading.css("top",0)}else{this.$header.show();this.$tableHeader.show();this.$tableLoading.css("top",this.$header.outerHeight()+1);this.getCaret();j(window).on("resize.bootstrap-table",j.proxy(this.resetWidth,this))}this.$selectAll=this.$header.find('[name="btSelectAll"]');this.$selectAll.off("click").on("click",function(){var u=j(this).prop("checked");t[u?"checkAll":"uncheckAll"]();t.updateSelected()})};e.prototype.initFooter=function(){if(!this.options.showFooter||this.options.cardView){this.$tableFooter.hide()}else{this.$tableFooter.show()}};e.prototype.initData=function(s,r){if(r==="append"){this.data=this.data.concat(s)}else{if(r==="prepend"){this.data=[].concat(s).concat(this.data)}else{this.data=s||this.options.data}}if(r==="append"){this.options.data=this.options.data.concat(s)}else{if(r==="prepend"){this.options.data=[].concat(s).concat(this.options.data)}else{this.options.data=this.data}}if(this.options.sidePagination==="server"){return}this.initSort()};e.prototype.initSort=function(){var u=this,t=this.options.sortName,r=this.options.sortOrder==="desc"?-1:1,s=j.inArray(this.options.sortName,this.header.fields);if(this.options.customSort!==j.noop){this.options.customSort.apply(this,[this.options.sortName,this.options.sortOrder]);return}if(s!==-1){if(this.options.sortStable){j.each(this.data,function(v,w){if(!w.hasOwnProperty("_position")){w._position=v}})}this.data.sort(function(w,v){if(u.header.sortNames[s]){t=u.header.sortNames[s]}var y=o(w,t,u.options.escape),z=o(v,t,u.options.escape),x=q(u.header,u.header.sorters[s],[y,z]);if(x!==undefined){return r*x}if(y===undefined||y===null){y=""}if(z===undefined||z===null){z=""}if(u.options.sortStable&&y===z){y=w._position;z=v._position}if(j.isNumeric(y)&&j.isNumeric(z)){y=parseFloat(y);z=parseFloat(z);if(y',this.options.toolbarAlign)).appendTo(this.$toolbar).append(j(this.options.toolbar))}t=[m('
',this.options.buttonsAlign,this.options.buttonsAlign)];if(typeof this.options.icons==="string"){this.options.icons=q(null,this.options.icons)}if(this.options.showSearch){t.push(m('")}if(this.options.showPaginationSwitch){t.push(m('")}if(this.options.showRefresh){t.push(m('")}if(this.options.showToggle){t.push(m('")}if(this.options.showColumns){t.push(m('
',this.options.formatColumns()),'",'","
")}t.push("
");if(this.showToolbar||t.length>2){this.$toolbar.append(t.join(""))}if(this.options.showPaginationSwitch){this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",j.proxy(this.togglePagination,this))}if(this.options.showRefresh){this.$toolbar.find('button[name="refresh"]').off("click").on("click",j.proxy(this.refresh,this))}if(this.options.showToggle){this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){u.toggleView()})}if(this.options.showSearch){this.$toolbar.find('button[name="showSearch"]').off("click").on("click",function(){j(".search-collapse").slideToggle()})}if(this.options.showColumns){s=this.$toolbar.find(".keep-open");if(r<=this.options.minimumCountColumns){s.find("input").prop("disabled",true)}s.find("li").off("click").on("click",function(x){x.stopImmediatePropagation()});s.find("input").off("click").on("click",function(){var x=j(this);u.toggleColumn(j(this).val(),x.prop("checked"),false);u.trigger("column-switch",j(this).data("field"),x.prop("checked"))})}if(this.options.search){t=[];t.push('");this.$toolbar.append(t.join(""));v=this.$toolbar.find(".search input");v.off("keyup drop").on("keyup drop",function(x){if(u.options.searchOnEnterKey&&x.keyCode!==13){return}if(j.inArray(x.keyCode,[37,38,39,40])>-1){return}clearTimeout(w);w=setTimeout(function(){u.onSearch(x)},u.options.searchTimeOut)});if(b()){v.off("mouseup").on("mouseup",function(x){clearTimeout(w);w=setTimeout(function(){u.onSearch(x)},u.options.searchTimeOut)})}}};e.prototype.onSearch=function(r){var s=j.trim(j(r.currentTarget).val());if(this.options.trimOnSearch&&j(r.currentTarget).val()!==s){j(r.currentTarget).val(s)}if(s===this.searchText){return}this.searchText=s;this.options.searchText=s;this.options.pageNumber=1;this.initSearch();this.updatePagination();this.trigger("search",s)};e.prototype.initSearch=function(){var t=this;if(this.options.sidePagination!=="server"){if(this.options.customSearch!==j.noop){this.options.customSearch.apply(this,[this.searchText]);return}var r=this.searchText&&(this.options.escape?p(this.searchText):this.searchText).toLowerCase();var u=j.isEmptyObject(this.filterColumns)?null:this.filterColumns;this.data=u?j.grep(this.options.data,function(w,v){for(var s in u){if(j.isArray(u[s])&&j.inArray(w[s],u[s])===-1||w[s]!==u[s]){return false}}return true}):this.options.data;this.data=r?j.grep(this.data,function(A,x){for(var v=0;v-1){r=true}}}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1;this.options.totalPages=this.totalPages}if(this.totalPages>0&&this.options.pageNumber>this.totalPages){this.options.pageNumber=this.totalPages}this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1;this.pageTo=this.options.pageNumber*this.options.pageSize;if(this.pageTo>this.options.totalRows){this.pageTo=this.options.totalRows}x.push('
','',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),"");if(!this.options.onlyInfoPagination){x.push('');var F=[m('',this.options.paginationVAlign==="top"||this.options.paginationVAlign==="both"?"dropdown":"dropup"),'",'");x.push(this.options.formatRecordsPerPage(F.join("")));x.push("");x.push("
",'")}this.$pagination.html(x.join(""));if(!this.options.onlyInfoPagination){w=this.$pagination.find(".page-list a");G=this.$pagination.find(".page-first");I=this.$pagination.find(".page-pre");E=this.$pagination.find(".page-next");y=this.$pagination.find(".page-last");u=this.$pagination.find(".page-number");if(this.options.smartDisplay){if(this.totalPages<=1){this.$pagination.find("div.pagination").hide()}if(t.length<2||this.options.totalRows<=t[0]){this.$pagination.find("span.page-list").hide()}this.$pagination[this.getData().length?"show":"hide"]()}if(r){this.options.pageSize=this.options.formatAllRows()}w.off("click").on("click",j.proxy(this.onPageListChange,this));G.off("click").on("click",j.proxy(this.onPageFirst,this));I.off("click").on("click",j.proxy(this.onPagePre,this));E.off("click").on("click",j.proxy(this.onPageNext,this));y.off("click").on("click",j.proxy(this.onPageLast,this));u.off("click").on("click",j.proxy(this.onPageNumber,this))}if(this.options.showPageGo){var v=this,C=this.$pagination.find("ul.pagination"),B=C.find("li.pageGo");if(!B.length){B=j(['
  • ',m('',this.options.pageNumber),'","
  • "].join("")).appendTo(C);B.find("button").click(function(){var K=parseInt(B.find("input").val())||1;if(K<1||K>v.options.totalPages){K=1}v.selectPage(K)})}}};e.prototype.updatePagination=function(r){if(r&&j(r.currentTarget).hasClass("disabled")){return}if(!this.options.maintainSelected){this.resetRows()}this.initPagination();if(this.options.sidePagination==="server"){this.initServer()}else{this.initBody()}this.trigger("page-change",this.options.pageNumber,this.options.pageSize)};e.prototype.onPageListChange=function(r){var s=j(r.currentTarget);s.parent().addClass("active").siblings().removeClass("active");this.options.pageSize=s.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+s.text();this.$toolbar.find(".page-size").text(this.options.pageSize);this.updatePagination(r)};e.prototype.onPageFirst=function(r){this.options.pageNumber=1;this.updatePagination(r)};e.prototype.onPagePre=function(r){if((this.options.pageNumber-1)===0){this.options.pageNumber=this.options.totalPages}else{this.options.pageNumber--}this.updatePagination(r)};e.prototype.onPageNext=function(r){if((this.options.pageNumber+1)>this.options.totalPages){this.options.pageNumber=1}else{this.options.pageNumber++}this.updatePagination(r)};e.prototype.onPageLast=function(r){this.options.pageNumber=this.totalPages;this.updatePagination(r)};e.prototype.onPageNumber=function(r){if(this.options.pageNumber===+j(r.currentTarget).text()){return}this.options.pageNumber=+j(r.currentTarget).text();this.updatePagination(r)};e.prototype.initBody=function(x){var z=this,y=[],v=this.getData();this.trigger("pre-body",v);this.$body=this.$el.find(">tbody");if(!this.$body.length){this.$body=j("").appendTo(this.$el)}if(!this.options.pagination||this.options.sidePagination==="server"){this.pageFrom=1;this.pageTo=v.length}for(var w=this.pageFrom-1;w");if(this.options.cardView){y.push(m('
    ',this.header.fields.length))}if(!this.options.cardView&&this.options.detailView){y.push("",'',m('',this.options.iconsPrefix,this.options.icons.detailOpen),"","")}j.each(this.header.fields,function(I,L){var P="",M=o(C,L,z.options.escape),K="",E={},Q="",J=z.header.classes[I],G="",O="",R="",H="",F=z.columns[I];if(z.fromHtml&&typeof M==="undefined"){return}if(!F.visible){return}if(z.options.cardView&&!F.cardVisible){return}r=m('style="%s"',s.concat(z.header.styles[I]).join("; "));if(C["_"+L+"_id"]){Q=m(' id="%s"',C["_"+L+"_id"])}if(C["_"+L+"_class"]){J=m(' class="%s"',C["_"+L+"_class"])}if(C["_"+L+"_rowspan"]){O=m(' rowspan="%s"',C["_"+L+"_rowspan"])}if(C["_"+L+"_colspan"]){R=m(' colspan="%s"',C["_"+L+"_colspan"])}if(C["_"+L+"_title"]){H=m(' title="%s"',C["_"+L+"_title"])}E=q(z.header,z.header.cellStyles[I],[M,C,w,L],E);if(E.classes){J=m(' class="%s"',E.classes)}if(E.css){var D=[];for(var N in E.css){D.push(N+": "+E.css[N])}r=m('style="%s"',D.concat(z.header.styles[I]).join("; "))}M=q(F,z.header.formatters[I],[M,C,w],M);if(C["_"+L+"_data"]&&!j.isEmptyObject(C["_"+L+"_data"])){j.each(C["_"+L+"_data"],function(T,S){if(T==="index"){return}G+=m(' data-%s="%s"',T,S)})}if(F.checkbox||F.radio){K=F.checkbox?"checkbox":K;K=F.radio?"radio":K;P=[m(z.options.cardView?'
    ':'',F["class"]||""),"",z.header.formatters[I]&&typeof M==="string"?M:"",z.options.cardView?"
    ":""].join("");C[z.header.stateField]=M===true||(M&&M.checked)}else{M=typeof M==="undefined"||M===null?z.options.undefinedText:M;P=z.options.cardView?['
    ',z.options.showHeader?m('%s',r,c(z.columns,"field","title",L)):"",m('%s',M),"
    "].join(""):[m("",Q,J,r,G,O,R,H),M,""].join("");if(z.options.cardView&&z.options.smartDisplay&&M===""){P='
    '}}y.push(P)});if(this.options.cardView){y.push("
    ")}y.push("")}if(!y.length){y.push('',m('%s',this.$header.find("th").length,this.options.formatNoMatches()),"")}this.$body.html(y.join(""));if(!x){this.scrollTo(0)}this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(J){var D=j(this),F=D.parent(),M=z.data[F.data("index")],H=D[0].cellIndex,G=z.getVisibleFields(),K=G[z.options.detailView&&!z.options.cardView?H-1:H],E=z.columns[i(z.columns,K)],L=o(M,K,z.options.escape);if(D.find(".detail-icon").length){return}z.trigger(J.type==="click"?"click-cell":"dbl-click-cell",K,L,M,D);z.trigger(J.type==="click"?"click-row":"dbl-click-row",M,F,K);if(J.type==="click"&&z.options.clickToSelect&&E.clickToSelect){var I=F.find(m('[name="%s"]',z.options.selectItemName));if(I.length){I[0].click()}}});this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var H=j(this),G=H.parent().parent(),E=G.data("index"),I=v[E];if(G.next().is("tr.detail-view")){H.find("i").attr("class",m("%s %s",z.options.iconsPrefix,z.options.icons.detailOpen));G.next().remove();z.trigger("collapse-row",E,I)}else{H.find("i").attr("class",m("%s %s",z.options.iconsPrefix,z.options.icons.detailClose));G.after(m('',G.find("td").length));var D=G.next().find("td");var F=q(z.options,z.options.detailFormatter,[E,I,D],"");if(D.length===1){D.append(F)}z.trigger("expand-row",E,I,D)}z.resetView()});this.$selectItem=this.$body.find(m('[name="%s"]',this.options.selectItemName));this.$selectItem.off("click").on("click",function(E){E.stopImmediatePropagation();var F=j(this),D=F.prop("checked"),G=z.data[F.data("index")];if(z.options.maintainSelected&&j(this).is(":radio")){j.each(z.options.data,function(H,I){I[z.header.stateField]=false})}G[z.header.stateField]=D;if(z.options.singleSelect){z.$selectItem.not(this).each(function(){z.data[j(this).data("index")][z.header.stateField]=false});z.$selectItem.filter(":checked").not(this).prop("checked",false)}z.updateSelected();z.trigger(D?"check":"uncheck",G,F)});j.each(this.header.events,function(G,F){if(!F){return}if(typeof F==="string"){F=q(null,F)}var H=z.header.fields[G],D=j.inArray(H,z.getVisibleFields());if(z.options.detailView&&!z.options.cardView){D+=1}for(var E in F){z.$body.find(">tr:not(.no-records-found)").each(function(){var M=j(this),N=M.find(z.options.cardView?".card-view":"td").eq(D),J=E.indexOf(" "),I=E.substring(0,J),K=E.substring(J+1),L=F[E];N.find(K).off(I).on(I,function(Q){var O=M.data("index"),R=z.data[O],P=R[H];L.apply(this,[Q,P,R,O])})})}});this.updateSelected();this.resetView();this.trigger("post-body",v)};e.prototype.initServer=function(r,w,s){var u=this,v={},x={searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder},t;if(this.options.pagination){x.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize;x.pageNumber=this.options.pageNumber}if(!this.options.firstLoad&&isFirstLoad){isFirstLoad=false;return}if(!(s||this.options.url)&&!this.options.ajax){return}if(this.options.queryParamsType==="limit"){x={search:x.searchText,sort:x.sortName,order:x.sortOrder};if(this.options.pagination){x.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1);x.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize}}if(!(j.isEmptyObject(this.filterColumnsPartial))){x.filter=JSON.stringify(this.filterColumnsPartial,null)}v=q(this.options,this.options.queryParams,[x],v);j.extend(v,w||{});if(v===false){return}if(!r){this.$tableLoading.show()}t=j.extend({},q(null,this.options.ajaxOptions),{type:this.options.method,url:s||this.options.url,data:this.options.contentType==="application/json"&&this.options.method==="post"?JSON.stringify(v):v,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(y){y=q(u.options,u.options.responseHandler,[y],y);u.load(y);u.trigger("load-success",y);if(!r){u.$tableLoading.hide()}},error:function(y){u.trigger("load-error",y.status,y);if(!r){u.$tableLoading.hide()}}});if(this.options.ajax){q(this,this.options.ajax,[t],null)}else{if(this._xhr&&this._xhr.readyState!==4){this._xhr.abort()}this._xhr=j.ajax(t)}};e.prototype.initSearchText=function(){if(this.options.search){if(this.options.searchText!==""){var r=this.$toolbar.find(".search input");r.val(this.options.searchText);this.onSearch({currentTarget:r})}}};e.prototype.getCaret=function(){var r=this;j.each(this.$header.find("th"),function(s,t){j(t).find(".sortable").removeClass("desc asc").addClass((j(t).data("field")===r.options.sortName||j(t).data("sortName")===r.options.sortName)?r.options.sortOrder:"both")})};e.prototype.updateSelected=function(){var r=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;var s=j(".left-fixed-table-columns input[name=btSelectItem]");if(s.length>0){r=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===s.filter(":enabled").filter(":checked").length}this.$selectAll.add(this.$selectAll_).prop("checked",r);this.$selectItem.each(function(){j(this).closest("tr")[j(this).prop("checked")?"addClass":"removeClass"]("selected")})};e.prototype.updateRows=function(){var r=this;this.$selectItem.each(function(){r.data[j(this).data("index")][r.header.stateField]=j(this).prop("checked")})};e.prototype.resetRows=function(){var r=this;j.each(this.data,function(s,t){r.$selectAll.prop("checked",false);r.$selectItem.prop("checked",false);if(r.header.stateField){t[r.header.stateField]=false}})};e.prototype.trigger=function(s){var r=Array.prototype.slice.call(arguments,1);s+=".bs.table";this.options[e.EVENTS[s]].apply(this.options,r);this.$el.trigger(j.Event(s),r);this.options.onAll(s,r);this.$el.trigger(j.Event("all.bs.table"),[s,r])};e.prototype.resetHeader=function(){clearTimeout(this.timeoutId_);this.timeoutId_=setTimeout(j.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)};e.prototype.fitHeader=function(){var t=this,u,r,x,y;if(t.$el.is(":hidden")){t.timeoutId_=setTimeout(j.proxy(t.fitHeader,t),100);return}u=this.$tableBody.get(0);r=u.scrollWidth>u.clientWidth&&u.scrollHeight>u.clientHeight+this.$header.outerHeight()?a():0;this.$el.css("margin-top",-this.$header.outerHeight());x=j(":focus");if(x.length>0){var z=x.parents("th");if(z.length>0){var A=z.attr("data-field");if(A!==undefined){var s=this.$header.find("[data-field='"+A+"']");if(s.length>0){s.find(":input").addClass("focus-temp")}}}}this.$header_=this.$header.clone(true,true);this.$selectAll_=this.$header_.find('[name="btSelectAll"]');this.$tableHeader.css({"margin-right":r}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_);y=j(".focus-temp:visible:eq(0)");if(y.length>0){y.focus();this.$header.find(".focus-temp").removeClass("focus-temp")}this.$header.find("th[data-field]").each(function(B){t.$header_.find(m('th[data-field="%s"]',j(this).data("field"))).data(j(this).data())});var w=this.getVisibleFields(),v=this.$header_.find("th");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(C){var E=j(this),B=C;if(t.options.detailView&&!t.options.cardView){if(C===0){t.$header_.find("th.detail").find(".fht-cell").width(E.innerWidth())}B=C-1}var D=t.$header_.find(m('th[data-field="%s"]',w[B]));if(D.length>1){D=j(v[E[0].cellIndex])}D.find(".fht-cell").width(E.innerWidth())});this.$tableBody.off("scroll").on("scroll",function(){t.$tableHeader.scrollLeft(j(this).scrollLeft());if(t.options.showFooter&&!t.options.cardView){t.$tableFooter.scrollLeft(j(this).scrollLeft())}});t.trigger("post-header")};e.prototype.resetFooter=function(){var s=this,t=s.getData(),r=[];if(!this.options.showFooter||this.options.cardView){return}if(!this.options.cardView&&this.options.detailView){r.push('
     
    ')}j.each(this.columns,function(x,z){var w,B="",v="",A=[],y={},u=m(' class="%s"',z["class"]);if(!z.visible){return}if(s.options.cardView&&(!z.cardVisible)){return}B=m("text-align: %s; ",z.falign?z.falign:z.align);v=m("vertical-align: %s; ",z.valign);y=q(null,s.options.footerStyle);if(y&&y.css){for(w in y.css){A.push(w+": "+y.css[w])}}r.push("");r.push('
    ');r.push(q(z,z.footerFormatter,[t]," ")||" ");r.push("
    ");r.push('
    ');r.push("");r.push("")});this.$tableFooter.find("tr").html(r.join(""));this.$tableFooter.show();clearTimeout(this.timeoutFooter_);this.timeoutFooter_=setTimeout(j.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0)};e.prototype.fitFooter=function(){var u=this,r,t,s;clearTimeout(this.timeoutFooter_);if(this.$el.is(":hidden")){this.timeoutFooter_=setTimeout(j.proxy(this.fitFooter,this),100);return}t=this.$el.css("width");s=t>this.$tableBody.width()?a():0;this.$tableFooter.css({"margin-right":s}).find("table").css("width",t).attr("class",this.$el.attr("class"));r=this.$tableFooter.find("td");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(v){var w=j(this);r.eq(v).find(".fht-cell").width(w.innerWidth()+1)})};e.prototype.toggleColumn=function(r,s,u){if(r===-1){return}this.columns[r].visible=s;this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var t=this.$toolbar.find(".keep-open input").prop("disabled",false);if(u){t.filter(m('[value="%s"]',r)).prop("checked",s)}if(t.filter(":checked").length<=this.options.minimumCountColumns){t.filter(":checked").prop("disabled",true)}}};e.prototype.toggleRow=function(r,t,s){if(r===-1){return}this.$body.find(typeof r!=="undefined"?m('tr[data-index="%s"]',r):m('tr[data-uniqueid="%s"]',t))[s?"show":"hide"]()};e.prototype.getVisibleFields=function(){var s=this,r=[];j.each(this.header.fields,function(t,v){var u=s.columns[i(s.columns,v)];if(!u.visible){return}r.push(v)});return r};e.prototype.resetView=function(u){var s=0;if(u&&u.height){this.options.height=u.height}this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length);if(this.options.height){var t=d(this.$toolbar),v=d(this.$pagination),r=this.options.height-t-v;this.$tableContainer.css("height",r+"px")}if(this.options.cardView){this.$el.css("margin-top","0");this.$tableContainer.css("padding-bottom","0");this.$tableFooter.hide();return}if(this.options.showHeader&&this.options.height){this.$tableHeader.show();this.resetHeader();s+=this.$header.outerHeight()}else{this.$tableHeader.hide();this.trigger("post-header")}if(this.options.showFooter){this.resetFooter();if(this.options.height){s+=this.$tableFooter.outerHeight()+1}}this.getCaret();this.$tableContainer.css("padding-bottom",s+"px");this.trigger("reset-view")};e.prototype.getData=function(r){return(this.searchText||!j.isEmptyObject(this.filterColumns)||!j.isEmptyObject(this.filterColumnsPartial))?(r?this.data.slice(this.pageFrom-1,this.pageTo):this.data):(r?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data)};e.prototype.load=function(s){var r=false;if(this.options.sidePagination==="server"){this.options.totalRows=s.total;r=s.fixedScroll;s=s[this.options.dataField]}else{if(!j.isArray(s)){r=s.fixedScroll;s=s.data}}this.initData(s);this.initSearch();this.initPagination();this.initBody(r)};e.prototype.append=function(r){this.initData(r,"append");this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.prepend=function(r){this.initData(r,"prepend");this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.remove=function(u){var r=this.options.data.length,s,t;if(!u.hasOwnProperty("field")||!u.hasOwnProperty("values")){return}for(s=r-1;s>=0;s--){t=this.options.data[s];if(!t.hasOwnProperty(u.field)){continue}if(j.inArray(t[u.field],u.values)!==-1){this.options.data.splice(s,1)}}if(r===this.options.data.length){return}this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.removeAll=function(){if(this.options.data.length>0){this.options.data.splice(0,this.options.data.length);this.initSearch();this.initPagination();this.initBody(true)}};e.prototype.getRowByUniqueId=function(x){var w=this.options.uniqueId,r=this.options.data.length,s=null,t,v,u;for(t=r-1;t>=0;t--){v=this.options.data[t];if(v.hasOwnProperty(w)){u=v[w]}else{if(v._data.hasOwnProperty(w)){u=v._data[w]}else{continue}}if(typeof u==="string"){x=x.toString()}else{if(typeof u==="number"){if((Number(u)===u)&&(u%1===0)){x=parseInt(x)}else{if((u===Number(u))&&(u!==0)){x=parseFloat(x)}}}}if(u===x){s=v;break}}return s};e.prototype.removeByUniqueId=function(t){var r=this.options.data.length,s=this.getRowByUniqueId(t);if(s){this.options.data.splice(this.options.data.indexOf(s),1)}if(r===this.options.data.length){return}this.initSearch();this.initPagination();this.initBody(true)};e.prototype.updateByUniqueId=function(t){var r=this;var s=j.isArray(t)?t:[t];j.each(s,function(u,w){var v;if(!w.hasOwnProperty("id")||!w.hasOwnProperty("row")){return}v=j.inArray(r.getRowByUniqueId(w.id),r.options.data);if(v===-1){return}j.extend(r.options.data[v],w.row)});this.initSearch();this.initSort();this.initBody(true)};e.prototype.insertRow=function(r){if(!r.hasOwnProperty("index")||!r.hasOwnProperty("row")){return}this.data.splice(r.index,0,r.row);this.initSearch();this.initPagination();this.initSort();this.initBody(true)};e.prototype.updateRow=function(t){var r=this;var s=j.isArray(t)?t:[t];j.each(s,function(u,v){if(!v.hasOwnProperty("index")||!v.hasOwnProperty("row")){return}j.extend(r.options.data[v.index],v.row)});this.initSearch();this.initSort();this.initBody(true)};e.prototype.showRow=function(r){if(!r.hasOwnProperty("index")&&!r.hasOwnProperty("uniqueId")){return}this.toggleRow(r.index,r.uniqueId,true)};e.prototype.hideRow=function(r){if(!r.hasOwnProperty("index")&&!r.hasOwnProperty("uniqueId")){return}this.toggleRow(r.index,r.uniqueId,false)};e.prototype.getRowsHidden=function(r){var t=j(this.$body[0]).children().filter(":hidden"),s=0;if(r){for(;str"),r;if(this.options.detailView&&!this.options.cardView){t+=1}r=x.eq(y).find(">td").eq(t);if(y<0||t<0||y>=this.data.length){return}for(w=y;wtd").eq(v).hide()}}r.attr("rowspan",u).attr("colspan",s).show()};e.prototype.updateCell=function(r){if(!r.hasOwnProperty("index")||!r.hasOwnProperty("field")||!r.hasOwnProperty("value")){return}this.data[r.index][r.field]=r.value;if(r.reinit===false){return}this.initSort();this.initBody(true)};e.prototype.getOptions=function(){return this.options};e.prototype.getSelections=function(){var r=this;return j.grep(this.options.data,function(s){return s[r.header.stateField]})};e.prototype.getAllSelections=function(){var r=this;return j.grep(this.options.data,function(s){return s[r.header.stateField]})};e.prototype.checkAll=function(){this.checkAll_(true)};e.prototype.uncheckAll=function(){this.checkAll_(false)};e.prototype.checkInvert=function(){var s=this;var t=s.$selectItem.filter(":enabled");var r=t.filter(":checked");t.each(function(){j(this).prop("checked",!j(this).prop("checked"))});s.updateRows();s.updateSelected();s.trigger("uncheck-some",r);r=s.getSelections();s.trigger("check-some",r)};e.prototype.checkAll_=function(r){var s;if(!r){s=this.getSelections()}this.$selectAll.add(this.$selectAll_).prop("checked",r);this.$selectItem.filter(":enabled").prop("checked",r);this.updateRows();if(r){s=this.getSelections()}this.trigger(r?"check-all":"uncheck-all",s)};e.prototype.check=function(r){this.check_(true,r)};e.prototype.uncheck=function(r){this.check_(false,r)};e.prototype.check_=function(t,r){var s=this.$selectItem.filter(m('[data-index="%s"]',r)).prop("checked",t); -this.data[r][this.header.stateField]=t;this.updateSelected();this.trigger(t?"check":"uncheck",this.data[r],s)};e.prototype.checkBy=function(r){this.checkBy_(true,r)};e.prototype.uncheckBy=function(r){this.checkBy_(false,r)};e.prototype.checkBy_=function(s,u){if(!u.hasOwnProperty("field")||!u.hasOwnProperty("values")){return}var r=this,t=[];j.each(this.options.data,function(v,x){if(!x.hasOwnProperty(u.field)){return false}if(j.inArray(x[u.field],u.values)!==-1){var w=r.$selectItem.filter(":enabled").filter(m('[data-index="%s"]',v)).prop("checked",s);x[r.header.stateField]=s;t.push(x);r.trigger(s?"check":"uncheck",x,w)}});this.updateSelected();this.trigger(s?"check-some":"uncheck-some",t)};e.prototype.destroy=function(){this.$el.insertBefore(this.$container);j(this.options.toolbar).insertBefore(this.$el);this.$container.next().remove();this.$container.remove();this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")};e.prototype.showLoading=function(){this.$tableLoading.show()};e.prototype.hideLoading=function(){this.$tableLoading.hide()};e.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var r=this.$toolbar.find('button[name="paginationSwitch"] i');if(this.options.pagination){r.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown)}else{r.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp)}this.updatePagination()};e.prototype.refresh=function(r){if(r&&r.url){this.options.pageNumber=1}if(selectionIds.length>0){selectionIds=[]}if(selectionRows.length>0){selectionRows=[]}this.initServer(r&&r.silent,r&&r.query,r&&r.url);this.trigger("refresh",r)};e.prototype.resetWidth=function(){if(this.options.showHeader&&this.options.height){this.fitHeader()}if(this.options.showFooter){this.fitFooter()}};e.prototype.showColumn=function(r){this.toggleColumn(i(this.columns,r),true,true)};e.prototype.hideColumn=function(r){this.toggleColumn(i(this.columns,r),false,true)};e.prototype.getHiddenColumns=function(){return j.grep(this.columns,function(r){return !r.visible})};e.prototype.getVisibleColumns=function(){return j.grep(this.columns,function(r){return r.visible})};e.prototype.toggleAllColumns=function(r){j.each(this.columns,function(t,u){this.columns[t].visible=r});this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var s=this.$toolbar.find(".keep-open input").prop("disabled",false);if(s.filter(":checked").length<=this.options.minimumCountColumns){s.filter(":checked").prop("disabled",true)}}};e.prototype.showAllColumns=function(){this.toggleAllColumns(true)};e.prototype.hideAllColumns=function(){this.toggleAllColumns(false)};e.prototype.filterBy=function(r){this.filterColumns=j.isEmptyObject(r)?{}:r;this.options.pageNumber=1;this.initSearch();this.updatePagination()};e.prototype.scrollTo=function(r){if(typeof r==="string"){r=r==="bottom"?this.$tableBody[0].scrollHeight:0}if(typeof r==="number"){this.$tableBody.scrollTop(r)}if(typeof r==="undefined"){return this.$tableBody.scrollTop()}};e.prototype.getScrollPosition=function(){return this.scrollTo()};e.prototype.selectPage=function(r){if(r>0&&r<=this.options.totalPages){this.options.pageNumber=r;this.updatePagination()}};e.prototype.prevPage=function(){if(this.options.pageNumber>1){this.options.pageNumber--;this.updatePagination()}};e.prototype.nextPage=function(){if(this.options.pageNumber tr[data-index="%s"]',r));if(t.next().is("tr.detail-view")===(s?false:true)){t.find("> td > .detail-icon").click()}};e.prototype.expandRow=function(r){this.expandRow_(true,r)};e.prototype.collapseRow=function(r){this.expandRow_(false,r)};e.prototype.expandAllRows=function(r){if(r){var w=this.$body.find(m('> tr[data-index="%s"]',0)),x=this,u=null,v=false,s=-1;if(!w.next().is("tr.detail-view")){w.find("> td > .detail-icon").click();v=true}else{if(!w.next().next().is("tr.detail-view")){w.next().find(".detail-icon").click();v=true}}if(v){try{s=setInterval(function(){u=x.$body.find("tr.detail-view").last().find(".detail-icon");if(u.length>0){u.click()}else{clearInterval(s)}},1)}catch(z){clearInterval(s)}}}else{var y=this.$body.children();for(var t=0;t0){selectionIds=[]}if(selectionRows.length>0){selectionRows=[]}this.initServer(r&&r.silent,r&&r.query,r&&r.url);this.trigger("refresh",r)};e.prototype.resetWidth=function(){if(this.options.showHeader&&this.options.height){this.fitHeader()}if(this.options.showFooter){this.fitFooter()}};e.prototype.showColumn=function(r){this.toggleColumn(i(this.columns,r),true,true)};e.prototype.hideColumn=function(r){this.toggleColumn(i(this.columns,r),false,true)};e.prototype.getHiddenColumns=function(){return j.grep(this.columns,function(r){return !r.visible})};e.prototype.getVisibleColumns=function(){return j.grep(this.columns,function(r){return r.visible})};e.prototype.toggleAllColumns=function(r){j.each(this.columns,function(t,u){this.columns[t].visible=r});this.initHeader();this.initSearch();this.initPagination();this.initBody();if(this.options.showColumns){var s=this.$toolbar.find(".keep-open input").prop("disabled",false);if(s.filter(":checked").length<=this.options.minimumCountColumns){s.filter(":checked").prop("disabled",true)}}};e.prototype.showAllColumns=function(){this.toggleAllColumns(true)};e.prototype.hideAllColumns=function(){this.toggleAllColumns(false)};e.prototype.filterBy=function(r){this.filterColumns=j.isEmptyObject(r)?{}:r;this.options.pageNumber=1;this.initSearch();this.updatePagination()};e.prototype.scrollTo=function(r){if(typeof r==="string"){r=r==="bottom"?this.$tableBody[0].scrollHeight:0}if(typeof r==="number"){this.$tableBody.scrollTop(r)}if(typeof r==="undefined"){return this.$tableBody.scrollTop()}};e.prototype.getScrollPosition=function(){return this.scrollTo()};e.prototype.selectPage=function(r){if(r>0&&r<=this.options.totalPages){this.options.pageNumber=r;this.updatePagination()}};e.prototype.prevPage=function(){if(this.options.pageNumber>1){this.options.pageNumber--;this.updatePagination()}};e.prototype.nextPage=function(){if(this.options.pageNumber tr[data-index="%s"]',r));if(t.next().is("tr.detail-view")===(s?false:true)){t.find("> td > .detail-icon").click()}};e.prototype.expandRow=function(r){this.expandRow_(true,r)};e.prototype.collapseRow=function(r){this.expandRow_(false,r)};e.prototype.expandAllRows=function(r){if(r){var w=this.$body.find(m('> tr[data-index="%s"]',0)),x=this,u=null,v=false,s=-1;if(!w.next().is("tr.detail-view")){w.find("> td > .detail-icon").click();v=true}else{if(!w.next().next().is("tr.detail-view")){w.next().find(".detail-icon").click();v=true}}if(v){try{s=setInterval(function(){u=x.$body.find("tr.detail-view").last().find(".detail-icon");if(u.length>0){u.click()}else{clearInterval(s)}},1)}catch(z){clearInterval(s)}}}else{var y=this.$body.children();for(var t=0;t 1) { + var tableId = $.common.isEmpty(id) ? $(event.currentTarget).parents(".bootstrap-table").find(".table").attr("id") : id; + if ($.common.isNotEmpty(tableId)) { + table.options = table.get(tableId); + } + } + }, + // 获取实例配置 + get: function(id) { + return table.config[id]; + }, + // 记住选择实例组 + rememberSelecteds: {}, + // 记住选择ID组 + rememberSelectedIds: {} +}; + (function ($) { $.extend({ _tree: {}, - btTable: {}, bttTable: {}, // 表格封装处理 table: { - _option: {}, // 初始化表格参数 init: function(options) { var defaults = { @@ -45,8 +68,8 @@ rowStyle: {}, }; var options = $.extend(defaults, options); - $.table._option = options; - $.btTable = $('#' + options.id); + table.options = options; + table.config[options.id] = options; $.table.initEvent(); $('#' + options.id).bootstrapTable({ url: options.url, // 请求后台的URL(*) @@ -102,6 +125,15 @@ detailFormatter: options.detailFormatter, // 在行下面展示其他数据列表 }); }, + // 获取实例ID,如存在多个返回#id1,#id2 delimeter分隔符 + getOptionsIds: function(separator) { + var _separator = $.common.isEmpty(separator) ? "," : separator; + var optionsIds = ""; + $.each(table.config, function(key, value){ + optionsIds += "#" + key + _separator; + }); + return optionsIds.substring(0, optionsIds.length - 1); + }, // 查询条件 queryParams: function(params) { var curParams = { @@ -112,22 +144,22 @@ orderByColumn: params.sort, isAsc: params.order }; - var currentId = $.common.isEmpty($.table._option.formId) ? $('form').attr('id') : $.table._option.formId; + var currentId = $.common.isEmpty(table.options.formId) ? $('form').attr('id') : table.options.formId; return $.extend(curParams, $.common.formToJSON(currentId)); }, // 请求获取数据后处理回调函数 responseHandler: function(res) { - if (typeof $.table._option.responseHandler == "function") { - $.table._option.responseHandler(res); + if (typeof table.options.responseHandler == "function") { + table.options.responseHandler(res); } if (res.code == 0) { - if ($.common.isNotEmpty($.table._option.sidePagination) && $.table._option.sidePagination == 'client') { + if ($.common.isNotEmpty(table.options.sidePagination) && table.options.sidePagination == 'client') { return res.rows; } else { - if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { - var column = $.common.isEmpty($.table._option.uniqueId) ? $.table._option.columns[1].field : $.table._option.uniqueId; + if ($.common.isNotEmpty(table.options.rememberSelected) && table.options.rememberSelected) { + var column = $.common.isEmpty(table.options.uniqueId) ? table.options.columns[1].field : table.options.uniqueId; $.each(res.rows, function(i, row) { - row.state = $.inArray(row[column], selectionIds) !== -1; + row.state = $.inArray(row[column], table.rememberSelectedIds[table.options.id]) !== -1; }) } return { rows: res.rows, total: res.total }; @@ -138,28 +170,46 @@ } }, // 初始化事件 - initEvent: function(data) { - // 绑定选中事件、取消事件、全部选中、全部取消 - $.btTable.on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rows) { + initEvent: function() { + // 实例ID信息 + var optionsIds = $.table.getOptionsIds(); + // 监听事件处理 + $(optionsIds).on(TABLE_EVENTS, function () { + table.set($(this).attr("id")); + }); + // 选中、取消、全部选中、全部取消(事件) + $(optionsIds).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) { + if ($.common.isNotEmpty(table.options.rememberSelected) && table.options.rememberSelected) { func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference'; - selectionIds = _[func](selectionIds, rowIds); - selectionRows = _[func](selectionRows, rows); + var selectedIds = table.rememberSelectedIds[table.options.id]; + if($.common.isNotEmpty(selectedIds)) { + table.rememberSelectedIds[table.options.id] = _[func](selectedIds, rowIds); + } else { + table.rememberSelectedIds[table.options.id] = _[func]([], rowIds); + } + var selectedRows = table.rememberSelecteds[table.options.id]; + if($.common.isNotEmpty(selectedRows)) { + table.rememberSelecteds[table.options.id] = _[func](selectedRows, rows); + } else { + table.rememberSelecteds[table.options.id] = _[func]([], rows); + } } }); - // 触发行点击事件 加载成功事件 - $.btTable.on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table load-success.bs.table", function () { + // 加载成功、选中、取消、全部选中、全部取消(事件) + $(optionsIds).on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table load-success.bs.table", function () { + var toolbar = table.options.toolbar; + var uniqueId = table.options.uniqueId; // 工具栏按钮控制 - var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); + var rows = $.common.isEmpty(uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(uniqueId); // 非多个禁用 - $('#' + $.table._option.toolbar + ' .multiple').toggleClass('disabled', !rows.length); + $('#' + toolbar + ' .multiple').toggleClass('disabled', !rows.length); // 非单个禁用 - $('#' + $.table._option.toolbar + ' .single').toggleClass('disabled', rows.length!=1); + $('#' + toolbar + ' .single').toggleClass('disabled', rows.length!=1); }); // 图片预览事件 - $.btTable.on('click', '.img-circle', function() { + $(optionsIds).off("click").on("click", '.img-circle', function() { var src = $(this).attr('src'); var target = $(this).data('target'); var height = $(this).data('height'); @@ -178,7 +228,7 @@ } }); // 单击tooltip事件 - $.btTable.on('click', '.tooltip-show', function() { + $(optionsIds).on("click", '.tooltip-show', function() { var target = $(this).data('target'); var input = $(this).prev(); if ($.common.equals("copy", target)) { @@ -196,22 +246,23 @@ }, // 当所有数据被加载时触发 onLoadSuccess: function(data) { - if (typeof $.table._option.onLoadSuccess == "function") { - $.table._option.onLoadSuccess(data); + if (typeof table.options.onLoadSuccess == "function") { + table.options.onLoadSuccess(data); } // 浮动提示框特效 $("[data-toggle='tooltip']").tooltip(); }, // 表格销毁 destroy: function (tableId) { - var currentId = $.common.isEmpty(tableId) ? $.table._option.id : tableId; + var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId; $("#" + currentId).bootstrapTable('destroy'); }, // 序列号生成 - serialNumber: function (index) { - var table = $.btTable.bootstrapTable('getOptions'); - var pageSize = table.pageSize; - var pageNumber = table.pageNumber; + serialNumber: function (index, tableId) { + var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId; + var tableParams = $("#" + currentId).bootstrapTable('getOptions'); + var pageSize = tableParams.pageSize; + var pageNumber = tableParams.pageNumber; return pageSize * (pageNumber - 1) + index + 1; }, // 列超出指定长度浮动提示 target(copy单击复制文本 open弹窗打开文本) @@ -262,9 +313,10 @@ }, // 搜索-默认第一个form search: function(formId, tableId, data) { + table.set(tableId); var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId; - var params = $.common.isEmpty(tableId) ? $.btTable.bootstrapTable('getOptions') : $("#" + tableId).bootstrapTable('getOptions'); - params.queryParams = function(params) { + var params = $.common.isEmpty(tableId) ? $("#" + table.options.id).bootstrapTable('getOptions') : $("#" + tableId).bootstrapTable('getOptions'); + params.queryParams = function(params) { var search = $.common.formToJSON(currentId); if($.common.isNotEmpty(data)){ $.each(data, function(key) { @@ -281,15 +333,16 @@ if($.common.isNotEmpty(tableId)){ $("#" + tableId).bootstrapTable('refresh', params); } else{ - $.btTable.bootstrapTable('refresh', params); + $("#" + table.options.id).bootstrapTable('refresh', params); } }, // 导出数据 exportExcel: function(formId) { - $.modal.confirm("确定导出所有" + $.table._option.modalName + "吗?", function() { + table.set(); + $.modal.confirm("确定导出所有" + table.options.modalName + "吗?", function() { var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId; $.modal.loading("正在导出数据,请稍后..."); - $.post($.table._option.exportUrl, $("#" + currentId).serializeArray(), function(result) { + $.post(table.options.exportUrl, $("#" + currentId).serializeArray(), function(result) { if (result.code == web_status.SUCCESS) { window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true; } else if (result.code == web_status.WARNING) { @@ -303,7 +356,8 @@ }, // 下载模板 importTemplate: function() { - $.get($.table._option.importTemplateUrl, function(result) { + table.set(); + $.get(table.options.importTemplateUrl, function(result) { if (result.code == web_status.SUCCESS) { window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true; } else if (result.code == web_status.WARNING) { @@ -315,6 +369,7 @@ }, // 导入数据 importExcel: function(formId) { + table.set(); var currentId = $.common.isEmpty(formId) ? 'importTpl' : formId; layer.open({ type: 1, @@ -323,7 +378,7 @@ //不固定 maxmin: true, shade: 0.3, - title: '导入' + $.table._option.modalName + '数据', + title: '导入' + table.options.modalName + '数据', content: $('#' + currentId).html(), btn: [' 导入', ' 取消'], // 弹层外区域关闭 @@ -340,7 +395,7 @@ formData.append("file", $('#file')[0].files[0]); formData.append("updateSupport", $("input[name='updateSupport']").is(':checked')); $.ajax({ - url: $.table._option.importUrl, + url: table.options.importUrl, data: formData, cache: false, contentType: false, @@ -366,26 +421,30 @@ }); }, // 刷新表格 - refresh: function() { - $.btTable.bootstrapTable('refresh', { + refresh: function(tableId) { + var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId; + $("#" + currentId).bootstrapTable('refresh', { silent: true }); }, // 查询表格指定列值 selectColumns: function(column) { - var rows = $.map($.btTable.bootstrapTable('getSelections'), function (row) { + var rows = $.map($("#" + table.options.id).bootstrapTable('getSelections'), function (row) { return row[column]; }); - if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { - rows = $.map(selectionRows, function (row) { - return row[column]; - }); + if ($.common.isNotEmpty(table.options.rememberSelected) && table.options.rememberSelected) { + var selectedRows = table.rememberSelecteds[table.options.id]; + if($.common.isNotEmpty(selectedRows)) { + rows = $.map(table.rememberSelecteds[table.options.id], function (row) { + return row[column]; + }); + } } return $.common.uniqueFn(rows); }, // 获取当前页选中或者取消的行ID affectedRowIds: function(rows) { - var column = $.common.isEmpty($.table._option.uniqueId) ? $.table._option.columns[1].field : $.table._option.uniqueId; + var column = $.common.isEmpty(table.options.uniqueId) ? table.options.columns[1].field : table.options.uniqueId; var rowIds; if ($.isArray(rows)) { rowIds = $.map(rows, function(row) { @@ -398,13 +457,16 @@ }, // 查询表格首列值 selectFirstColumns: function() { - var rows = $.map($.btTable.bootstrapTable('getSelections'), function (row) { - return row[$.table._option.columns[1].field]; + var rows = $.map($("#" + table.options.id).bootstrapTable('getSelections'), function (row) { + return row[table.options.columns[1].field]; }); - if ($.common.isNotEmpty($.table._option.rememberSelected) && $.table._option.rememberSelected) { - rows = $.map(selectionRows, function (row) { - return row[$.table._option.columns[1].field]; - }); + if ($.common.isNotEmpty(table.options.rememberSelected) && table.options.rememberSelected) { + var selectedRows = table.rememberSelecteds[table.options.id]; + if($.common.isNotEmpty(selectedRows)) { + rows = $.map(selectedRows, function (row) { + return row[table.options.columns[1].field]; + }); + } } return $.common.uniqueFn(rows); }, @@ -421,12 +483,14 @@ return actions.join(''); }, // 显示表格指定列 - showColumn: function(column) { - $.btTable.bootstrapTable('showColumn', column); + showColumn: function(column, tableId) { + var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId; + $("#" + currentId).bootstrapTable('showColumn', column); }, // 隐藏表格指定列 - hideColumn: function(column) { - $.btTable.bootstrapTable('hideColumn', column); + hideColumn: function(column, tableId) { + var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId; + $("#" + currentId).bootstrapTable('hideColumn', column); } }, // 表格树封装处理 @@ -449,7 +513,8 @@ expandFirst: true }; var options = $.extend(defaults, options); - $.table._option = options; + table.options = options; + table.config[options.id] = options; $.bttTable = $('#' + options.id).bootstrapTreeTable({ code: options.code, // 用于设置父子关系 parentCode: options.parentCode, // 用于设置父子关系 @@ -503,11 +568,12 @@ form: { // 表单重置 reset: function(formId, tableId) { + table.set(tableId); var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId; $("#" + currentId)[0].reset(); - if ($.table._option.type == table_type.bootstrapTable) { + if (table.options.type == table_type.bootstrapTable) { if($.common.isEmpty(tableId)){ - $.btTable.bootstrapTable('refresh'); + $("#" + table.options.id).bootstrapTable('refresh'); } else{ $("#" + tableId).bootstrapTable('refresh'); } @@ -809,6 +875,7 @@ }, // 详细信息 detail: function(id, width, height) { + table.set(); var _url = $.operate.detailUrl(id); var _width = $.common.isEmpty(width) ? "800" : width; var _height = $.common.isEmpty(height) ? ($(window).height() - 50) : height; @@ -818,10 +885,10 @@ _height = 'auto'; } var options = { - title: $.table._option.modalName + "详细", + title: table.options.modalName + "详细", width: _width, height: _height, - url: $.operate.detailUrl(id), + url: _url, skin: 'layui-layer-gray', btn: ['关闭'], yes: function (index, layero) { @@ -834,22 +901,23 @@ detailUrl: function(id) { var url = "/404.html"; if ($.common.isNotEmpty(id)) { - url = $.table._option.detailUrl.replace("{id}", id); + url = table.options.detailUrl.replace("{id}", id); } else { - var id = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); + var id = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId); if (id.length == 0) { $.modal.alertWarning("请至少选择一条记录"); return; } - url = $.table._option.detailUrl.replace("{id}", id); + url = table.options.detailUrl.replace("{id}", id); } return url; }, // 删除信息 remove: function(id) { - $.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗?", function() { - var url = $.common.isEmpty(id) ? $.table._option.removeUrl : $.table._option.removeUrl.replace("{id}", id); - if($.table._option.type == table_type.bootstrapTreeTable) { + table.set(); + $.modal.confirm("确定删除该条" + table.options.modalName + "信息吗?", function() { + var url = $.common.isEmpty(id) ? table.options.removeUrl : table.options.removeUrl.replace("{id}", id); + if(table.options.type == table_type.bootstrapTreeTable) { $.operate.get(url); } else { var data = { "ids": id }; @@ -860,83 +928,91 @@ }, // 批量删除信息 removeAll: function() { - var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); + table.set(); + var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId); if (rows.length == 0) { $.modal.alertWarning("请至少选择一条记录"); return; } $.modal.confirm("确认要删除选中的" + rows.length + "条数据吗?", function() { - var url = $.table._option.removeUrl; + var url = table.options.removeUrl; var data = { "ids": rows.join() }; $.operate.submit(url, "post", "json", data); }); }, // 清空信息 clean: function() { - $.modal.confirm("确定清空所有" + $.table._option.modalName + "吗?", function() { - var url = $.table._option.cleanUrl; + table.set(); + $.modal.confirm("确定清空所有" + table.options.modalName + "吗?", function() { + var url = table.options.cleanUrl; $.operate.submit(url, "post", "json", ""); }); }, // 添加信息 add: function(id) { - $.modal.open("添加" + $.table._option.modalName, $.operate.addUrl(id)); + table.set(); + $.modal.open("添加" + table.options.modalName, $.operate.addUrl(id)); }, // 添加信息,以tab页展现 addTab: function (id) { - $.modal.openTab("添加" + $.table._option.modalName, $.operate.addUrl(id)); + table.set(); + $.modal.openTab("添加" + table.options.modalName, $.operate.addUrl(id)); }, // 添加信息 全屏 addFull: function(id) { - var url = $.common.isEmpty(id) ? $.table._option.createUrl : $.table._option.createUrl.replace("{id}", id); - $.modal.openFull("添加" + $.table._option.modalName, url); + table.set(); + var url = $.common.isEmpty(id) ? table.options.createUrl : table.options.createUrl.replace("{id}", id); + $.modal.openFull("添加" + table.options.modalName, url); }, // 添加访问地址 addUrl: function(id) { - var url = $.common.isEmpty(id) ? $.table._option.createUrl.replace("{id}", "") : $.table._option.createUrl.replace("{id}", id); + var url = $.common.isEmpty(id) ? table.options.createUrl.replace("{id}", "") : table.options.createUrl.replace("{id}", id); return url; }, // 修改信息 edit: function(id) { - if($.common.isEmpty(id) && $.table._option.type == table_type.bootstrapTreeTable) { - var row = $.bttTable.bootstrapTreeTable('getSelections')[0]; + table.set(); + if($.common.isEmpty(id) && table.options.type == table_type.bootstrapTreeTable) { + var row = $("#" + table.options.id).bootstrapTreeTable('getSelections')[0]; if ($.common.isEmpty(row)) { $.modal.alertWarning("请至少选择一条记录"); return; } - var url = $.table._option.updateUrl.replace("{id}", row[$.table._option.uniqueId]); - $.modal.open("修改" + $.table._option.modalName, url); + var url = table.options.updateUrl.replace("{id}", row[table.options.uniqueId]); + $.modal.open("修改" + table.options.modalName, url); } else { - $.modal.open("修改" + $.table._option.modalName, $.operate.editUrl(id)); + $.modal.open("修改" + table.options.modalName, $.operate.editUrl(id)); } }, // 修改信息,以tab页展现 editTab: function(id) { - $.modal.openTab("修改" + $.table._option.modalName, $.operate.editUrl(id)); + table.set(); + $.modal.openTab("修改" + table.options.modalName, $.operate.editUrl(id)); }, // 修改信息 全屏 editFull: function(id) { + table.set(); var url = "/404.html"; if ($.common.isNotEmpty(id)) { - url = $.table._option.updateUrl.replace("{id}", id); + url = table.options.updateUrl.replace("{id}", id); } else { - var row = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); - url = $.table._option.updateUrl.replace("{id}", row); + var row = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId); + url = table.options.updateUrl.replace("{id}", row); } - $.modal.openFull("修改" + $.table._option.modalName, url); + $.modal.openFull("修改" + table.options.modalName, url); }, // 修改访问地址 editUrl: function(id) { var url = "/404.html"; if ($.common.isNotEmpty(id)) { - url = $.table._option.updateUrl.replace("{id}", id); + url = table.options.updateUrl.replace("{id}", id); } else { - var id = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId); + var id = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId); if (id.length == 0) { $.modal.alertWarning("请至少选择一条记录"); return; } - url = $.table._option.updateUrl.replace("{id}", id); + url = table.options.updateUrl.replace("{id}", id); } return url; }, @@ -1007,10 +1083,10 @@ }, // 保存结果弹出msg刷新table表格 ajaxSuccess: function (result) { - if (result.code == web_status.SUCCESS && $.table._option.type == table_type.bootstrapTable) { + if (result.code == web_status.SUCCESS && table.options.type == table_type.bootstrapTable) { $.modal.msgSuccess(result.msg); $.table.refresh(); - } else if (result.code == web_status.SUCCESS && $.table._option.type == table_type.bootstrapTreeTable) { + } else if (result.code == web_status.SUCCESS && table.options.type == table_type.bootstrapTreeTable) { $.modal.msgSuccess(result.msg); $.treeTable.refresh(); } else if (result.code == web_status.WARNING) { @@ -1035,11 +1111,11 @@ successCallback: function(result) { if (result.code == web_status.SUCCESS) { var parent = window.parent; - if (parent.$.table._option.type == table_type.bootstrapTable) { + if (parent.table.options.type == table_type.bootstrapTable) { $.modal.close(); parent.$.modal.msgSuccess(result.msg); parent.$.table.refresh(); - } else if (parent.$.table._option.type == table_type.bootstrapTreeTable) { + } else if (parent.table.options.type == table_type.bootstrapTreeTable) { $.modal.close(); parent.$.modal.msgSuccess(result.msg); parent.$.treeTable.refresh(); @@ -1063,9 +1139,9 @@ $.modal.close(); $contentWindow.$.modal.msgSuccess(result.msg); $contentWindow.$(".layui-layer-padding").removeAttr("style"); - if ($contentWindow.$.table._option.type == table_type.bootstrapTable) { + if ($contentWindow.table.options.type == table_type.bootstrapTable) { $contentWindow.$.table.refresh(); - } else if ($contentWindow.$.table._option.type == table_type.bootstrapTreeTable) { + } else if ($contentWindow.table.options.type == table_type.bootstrapTreeTable) { $contentWindow.$.treeTable.refresh(); } $.modal.closeTab(); @@ -1383,6 +1459,16 @@ } }); return json; + }, + // 获取obj对象长度 + getLength: function(obj) { + var count = 0;   + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + count++; + }   + } + return count; } } }); diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/curd.html b/ruoyi-admin/src/main/resources/templates/demo/table/curd.html index 3a67d878..ee761772 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/curd.html +++ b/ruoyi-admin/src/main/resources/templates/demo/table/curd.html @@ -88,7 +88,7 @@ /* 新增表格行 */ function insertRow(){ var randomId = 100 + ~~(Math.random() * 100) - $.btTable.bootstrapTable('insertRow', { + $("#" + table.options.id).bootstrapTable('insertRow', { index: 0, // 你想插入到哪,0表示第一行 row: { userId: randomId, @@ -108,7 +108,7 @@ $.modal.alertWarning("请至少选择一条记录"); return; } - $.btTable.bootstrapTable('remove', { + $("#" + table.options.id).bootstrapTable('remove', { field: 'userId', values: ids }) @@ -116,18 +116,18 @@ /* 删除行ID值为1的数据 */ function removeRowByUniqueId(){ - $.btTable.bootstrapTable('removeByUniqueId', 1) + $("#" + table.options.id).bootstrapTable('removeByUniqueId', 1) } /* 删除所有表格行 */ function removeRowAll(){ - $.btTable.bootstrapTable('removeAll') + $("#" + table.options.id).bootstrapTable('removeAll') } /* 修改表格行 */ function updateRow(){ var randomId = 100 + ~~(Math.random() * 100) - $.btTable.bootstrapTable('updateRow', { + $("#" + table.options.id).bootstrapTable('updateRow', { index: 0, // 你想修改哪行,0表示第一行 row: { userId: randomId, @@ -143,7 +143,7 @@ /* 修改行ID值为1的数据 */ function updateRowByUniqueId(){ var randomId = 100 + ~~(Math.random() * 100) - $.btTable.bootstrapTable('updateByUniqueId', { + $("#" + table.options.id).bootstrapTable('updateByUniqueId', { id: 1, row: { userId: randomId, @@ -158,19 +158,19 @@ /* 查询表格所有数据值 */ function getData(){ - var data = $.btTable.bootstrapTable('getData'); + var data = $("#" + table.options.id).bootstrapTable('getData'); alert(JSON.stringify(data)) } /* 查询行ID值为1的数据 */ function getRowByUniqueId(){ - var data = $.btTable.bootstrapTable('getRowByUniqueId', 1); + var data = $("#" + table.options.id).bootstrapTable('getRowByUniqueId', 1); alert(JSON.stringify(data)) } /* 查询表格选择行数据值 */ function getSelections(){ - var data = $.btTable.bootstrapTable('getSelections'); + var data = $("#" + table.options.id).bootstrapTable('getSelections'); alert(JSON.stringify(data)) } diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/editable.html b/ruoyi-admin/src/main/resources/templates/demo/table/editable.html index e931e8d6..345a74a0 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/editable.html +++ b/ruoyi-admin/src/main/resources/templates/demo/table/editable.html @@ -114,13 +114,13 @@ /* 查询表格所有数据值 */ function getData(){ - var data = $.btTable.bootstrapTable('getData'); + var data = $("#" + table.options.id).bootstrapTable('getData'); alert(JSON.stringify(data)) } /* 查询表格选择行数据值 */ function getSelections(){ - var data = $.btTable.bootstrapTable('getSelections'); + var data = $("#" + table.options.id).bootstrapTable('getSelections'); alert(JSON.stringify(data)) } diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/multi.html b/ruoyi-admin/src/main/resources/templates/demo/table/multi.html index f89e2b0a..155f687f 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/multi.html +++ b/ruoyi-admin/src/main/resources/templates/demo/table/multi.html @@ -22,13 +22,16 @@ @@ -57,13 +60,16 @@ @@ -74,7 +80,7 @@
    \ No newline at end of file