2025-04-10 23:19:13 +08:00

11 lines
9.3 KiB
JavaScript

/**
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation)
*
* @version v1.23.1
* @homepage https://bootstrap-table.com
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/)
* @license MIT
*/
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.array.sort.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("jquery")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.concat.js","core-js/modules/es.array.filter.js","core-js/modules/es.array.find.js","core-js/modules/es.array.join.js","core-js/modules/es.array.slice.js","core-js/modules/es.array.sort.js","core-js/modules/es.function.name.js","core-js/modules/es.object.assign.js","core-js/modules/es.object.to-string.js","core-js/modules/web.dom-collections.for-each.js","jquery"],o):o(null,null,null,null,null,null,null,null,null,null,(t="undefined"!=typeof globalThis?globalThis:t||self).jQuery)}(this,(function(t,o,e,r,n,i,s,a,c,p,u){"use strict";function l(t,o,e){return o=y(o),function(t,o){if(o&&("object"==typeof o||"function"==typeof o))return o;if(void 0!==o)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,h()?Reflect.construct(o,e||[],y(t).constructor):o.apply(t,e))}function f(t,o,e){return o&&function(t,o){for(var e=0;e<o.length;e++){var r=o[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,b(r.key),r)}}(t.prototype,o),Object.defineProperty(t,"prototype",{writable:!1}),t}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,o,e){var r=function(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=y(t)););return t}(t,o);if(r){var n=Object.getOwnPropertyDescriptor(r,o);return n.get?n.get.call(arguments.length<3?t:e):n.value}},d.apply(null,arguments)}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},y(t)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(h=function(){return!!t})()}function g(t,o){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},g(t,o)}function b(t){var o=function(t,o){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,o);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof o?o:o+""}function j(t){return j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},j(t)}var m,v=u.fn.bootstrapTable.utils;Object.assign(u.fn.bootstrapTable.defaults.icons,{collapseGroup:{bootstrap3:"glyphicon-chevron-up",bootstrap5:"bi-chevron-up",materialize:"arrow_drop_down"}[u.fn.bootstrapTable.theme]||"fa-angle-up",expandGroup:{bootstrap3:"glyphicon-chevron-down",bootstrap5:"bi-chevron-down",materialize:"arrow_drop_up"}[u.fn.bootstrapTable.theme]||"fa-angle-down"}),Object.assign(u.fn.bootstrapTable.defaults,{groupBy:!1,groupByField:"",groupByFormatter:void 0,groupByToggle:!1,groupByShowToggleIcon:!1,groupByCollapsedGroups:[]});var w=u.fn.bootstrapTable.Constructor,B=w.prototype.initSort,G=w.prototype.initBody,O=w.prototype.updateSelected;w.prototype.initSort=function(){for(var t=this,o=arguments.length,e=new Array(o),r=0;r<o;r++)e[r]=arguments[r];B.apply(this,Array.prototype.slice.apply(e));var n,i,s,a=this;if(this.tableGroups=[],this.options.groupBy&&""!==this.options.groupByField){this.options.sortName!==this.options.groupByField&&(this.options.customSort?v.calculateObjectValue(this.options,this.options.customSort,[this.options.sortName,this.options.sortOrder,this.data]):this.options.data.sort((function(o,e){var r=t.getGroupByFields(),n=[],i=[];return u.each(r,(function(t,r){n.push(o[r]),i.push(e[r])})),o=n.join(),e=i.join(),o.localeCompare(e,void 0,{numeric:!0})})));var c=(n=a.data,i=function(o){var e=t.getGroupByFields(),r=[];return u.each(e,(function(t,e){var n=v.getItemField(o,e,a.options.escape,o.escape);r.push(n)})),r.join(", ")},s={},n.forEach((function(t){var o=i(t);s[o]=s[o]||[],s[o].push(t)})),s),p=0;u.each(c,(function(o,e){t.tableGroups.push({id:p,name:o,data:e}),e.forEach((function(r){r._data||(r._data={}),t.isCollapsed(o,e)&&(r._class+=" hidden"),r._data["parent-index"]=p})),p++}))}},w.prototype.initBody=function(){var t=this;m=!0;for(var o=arguments.length,e=new Array(o),r=0;r<o;r++)e[r]=arguments[r];if(G.apply(this,Array.prototype.slice.apply(e)),this.options.groupBy&&""!==this.options.groupByField){var n=this,i=!1,s=0;this.columns.forEach((function(t){t.checkbox&&!n.options.singleSelect?i=!0:t.visible&&(s+=1)})),this.options.detailView&&!this.options.cardView&&(s+=1),this.tableGroups.forEach((function(o){var e=[];e.push(v.sprintf('<tr class="info group-by %s" data-group-index="%s">',t.options.groupByToggle?"expanded":"",o.id)),n.options.detailView&&!n.options.cardView&&e.push('<td class="detail"></td>'),i&&e.push('<td class="bs-checkbox">','<input name="btSelectGroup" type="checkbox" />',"</td>");var r=o.name;void 0!==n.options.groupByFormatter&&(r=v.calculateObjectValue(n.options,n.options.groupByFormatter,[o.name,o.id,o.data])),e.push("<td",v.sprintf(' colspan="%s"',s),">",r);var a=t.options.icons.collapseGroup;t.isCollapsed(o.name,o.data)&&(a=t.options.icons.expandGroup),t.options.groupByToggle&&t.options.groupByShowToggleIcon&&e.push('<span class="float-right '.concat(t.options.iconsPrefix," ").concat(a,'"></span>')),e.push("</td></tr>"),n.$body.find("tr[data-parent-index=".concat(o.id,"]:first")).before(u(e.join("")))})),this.$selectGroup=[],this.$body.find('[name="btSelectGroup"]').each((function(){var t=u(this);n.$selectGroup.push({group:t,item:n.$selectItem.filter((function(){return u(this).closest("tr").data("parent-index")===t.closest("tr").data("group-index")}))})})),this.options.groupByToggle&&this.$container.off("click",".group-by").on("click",".group-by",(function(){var t=u(this),o=t.closest("tr").data("group-index"),e=n.$body.find("tr[data-parent-index=".concat(o,"]"));t.toggleClass("expanded collapsed"),t.find("span").toggleClass("".concat(n.options.icons.collapseGroup," ").concat(n.options.icons.expandGroup)),e.toggleClass("hidden"),e.each((function(t,o){return n.collapseRow(u(o).data("index"))}))})),this.$container.off("click",'[name="btSelectGroup"]').on("click",'[name="btSelectGroup"]',(function(t){t.stopImmediatePropagation();var o=u(this).prop("checked");n[o?"checkGroup":"uncheckGroup"](u(this).closest("tr").data("group-index"))}))}m=!1,this.updateSelected()},w.prototype.updateSelected=function(){if(!m){for(var t=arguments.length,o=new Array(t),e=0;e<t;e++)o[e]=arguments[e];O.apply(this,Array.prototype.slice.apply(o)),this.options.groupBy&&""!==this.options.groupByField&&this.$selectGroup.forEach((function(t){var o=t.item.filter(":enabled").length===t.item.filter(":enabled").filter(":checked").length;t.group.prop("checked",o)}))}},w.prototype.checkGroup=function(t){this.checkGroup_(t,!0)},w.prototype.uncheckGroup=function(t){this.checkGroup_(t,!1)},w.prototype.isCollapsed=function(t,o){if(this.options.groupByCollapsedGroups){var e=v.calculateObjectValue(this,this.options.groupByCollapsedGroups,[t,o],!0);if(u.inArray(t,e)>-1)return!0}return!1},w.prototype.checkGroup_=function(t,o){var e=this.getSelections();this.$selectItem.filter((function(){return u(this).closest("tr").data("parent-index")===t})).prop("checked",o),this.updateRows(),this.updateSelected();var r=this.getSelections();o?this.trigger("check-all",r,e):this.trigger("uncheck-all",r,e)},w.prototype.getGroupByFields=function(){var t=this.options.groupByField;return u.isArray(this.options.groupByField)||(t=[this.options.groupByField]),t},u.BootstrapTable=function(t){function o(){return function(t,o){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")}(this,o),l(this,o,arguments)}return function(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(o&&o.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),o&&g(t,o)}(o,t),f(o,[{key:"scrollTo",value:function(t){if(this.options.groupBy){var e={unit:"px",value:0};if("object"===j(t)&&(e=Object.assign(e,t)),"rows"===e.unit){var r=0;return this.$body.find("> tr:not(.group-by):lt(".concat(e.value,")")).each((function(t,o){r+=u(o).outerHeight(!0)})),this.$body.find("> tr:not(.group-by):eq(".concat(e.value,")")).prevAll(".group-by").each((function(t,o){r+=u(o).outerHeight(!0)})),void this.$tableBody.scrollTop(r)}}d(y(o.prototype),"scrollTo",this).call(this,t)}}])}(u.BootstrapTable)}));