升级bootstrap-table到最新版本1.24.1

springboot2
RuoYi 1 year ago
parent 723d8d50cb
commit 93f9e0048c

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -6,7 +6,7 @@
var Utils = $.fn.bootstrapTable.utils var Utils = $.fn.bootstrapTable.utils
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
autoRefresh: false, autoRefresh: false,
showAutoRefresh: true, showAutoRefresh: true,
autoRefreshInterval: 60, autoRefreshInterval: 60,
@ -15,22 +15,21 @@ $.extend($.fn.bootstrapTable.defaults, {
autoRefreshFunction: null autoRefreshFunction: null
}) })
$.extend($.fn.bootstrapTable.defaults.icons, { Utils.assignIcons($.fn.bootstrapTable.icons, 'autoRefresh', {
autoRefresh: { glyphicon: 'glyphicon-time icon-time',
bootstrap3: 'glyphicon-time icon-time', fa: 'fa-clock',
bootstrap5: 'bi-clock', bi: 'bi-clock',
materialize: 'access_time', icon: 'icon-clock',
'bootstrap-table': 'icon-clock' 'material-icons': 'access_time'
}[$.fn.bootstrapTable.theme] || 'fa-clock'
}) })
$.extend($.fn.bootstrapTable.locales, { Object.assign($.fn.bootstrapTable.locales, {
formatAutoRefresh () { formatAutoRefresh () {
return 'Auto Refresh' return 'Auto Refresh'
} }
}) })
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales) Object.assign($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)
$.BootstrapTable = class extends $.BootstrapTable { $.BootstrapTable = class extends $.BootstrapTable {
init (...args) { init (...args) {
@ -45,15 +44,14 @@ $.BootstrapTable = class extends $.BootstrapTable {
if (this.options.autoRefresh) { if (this.options.autoRefresh) {
this.buttons = Object.assign(this.buttons, { this.buttons = Object.assign(this.buttons, {
autoRefresh: { autoRefresh: {
html: ` text: this.options.formatAutoRefresh(),
<button class="auto-refresh ${this.constants.buttonsClass} icon: this.options.icons.autoRefresh,
${this.options.autoRefreshStatus ? ` ${this.constants.classes.buttonActive}` : ''}" render: false,
type="button" name="autoRefresh" title="${this.options.formatAutoRefresh()}"> event: this.toggleAutoRefresh,
${this.options.showButtonIcons ? Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.autoRefresh) : ''} attributes: {
${this.options.showButtonText ? this.options.formatAutoRefresh() : ''} 'aria-label': this.options.formatAutoRefresh(),
</button> title: this.options.formatAutoRefresh()
`, }
event: this.toggleAutoRefresh
} }
}) })
} }

@ -11,6 +11,7 @@ var UtilsCookie = {
pageNumber: 'bs.table.pageNumber', pageNumber: 'bs.table.pageNumber',
pageList: 'bs.table.pageList', pageList: 'bs.table.pageList',
hiddenColumns: 'bs.table.hiddenColumns', hiddenColumns: 'bs.table.hiddenColumns',
columns: 'bs.table.columns',
cardView: 'bs.table.cardView', cardView: 'bs.table.cardView',
customView: 'bs.table.customView', customView: 'bs.table.customView',
searchText: 'bs.table.searchText', searchText: 'bs.table.searchText',
@ -28,6 +29,9 @@ var UtilsCookie = {
return navigator.cookieEnabled return navigator.cookieEnabled
}, },
isCookieEnabled (that, cookieName) { isCookieEnabled (that, cookieName) {
if (cookieName === 'bs.table.columns') {
return that.options.cookiesEnabled.includes('bs.table.hiddenColumns')
}
return that.options.cookiesEnabled.includes(cookieName) return that.options.cookiesEnabled.includes(cookieName)
}, },
setCookie (that, cookieName, cookieValue) { setCookie (that, cookieName, cookieValue) {
@ -228,6 +232,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
try { try {
filterByCookie = JSON.parse(filterByCookieValue) filterByCookie = JSON.parse(filterByCookieValue)
} catch (e) { } catch (e) {
console.error(e)
throw new Error('Could not parse the json of the filterBy cookie!') throw new Error('Could not parse the json of the filterBy cookie!')
} }
this.filterColumns = filterByCookie ? filterByCookie : {} this.filterColumns = filterByCookie ? filterByCookie : {}
@ -242,27 +247,25 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.options.cookiesEnabled this.options.cookiesEnabled
if (this.options.filterControl) { if (this.options.filterControl) {
const that = this
this.$el.on('column-search.bs.table', (e, field, text) => { this.$el.on('column-search.bs.table', (e, field, text) => {
let isNewField = true let isNewField = true
for (let i = 0; i < that._filterControls.length; i++) { for (let i = 0; i < this._filterControls.length; i++) {
if (that._filterControls[i].field === field) { if (this._filterControls[i].field === field) {
that._filterControls[i].text = text this._filterControls[i].text = text
isNewField = false isNewField = false
break break
} }
} }
if (isNewField) { if (isNewField) {
that._filterControls.push({ this._filterControls.push({
field, field,
text text
}) })
} }
UtilsCookie.setCookie(that, UtilsCookie.cookieIds.filterControl, JSON.stringify(that._filterControls)) UtilsCookie.setCookie(this, UtilsCookie.cookieIds.filterControl, JSON.stringify(this._filterControls))
}).on('created-controls.bs.table', UtilsCookie.initCookieFilters(that)) }).on('created-controls.bs.table', UtilsCookie.initCookieFilters(this))
} }
} }
super.init() super.init()
@ -365,7 +368,10 @@ $.BootstrapTable = class extends $.BootstrapTable {
if (!this.options.cookie) { if (!this.options.cookie) {
return return
} }
UtilsCookie.setCookie(this, UtilsCookie.cookieIds.hiddenColumns, JSON.stringify(this.getHiddenColumns().map(column => column.field))) UtilsCookie.setCookie(this, UtilsCookie.cookieIds.hiddenColumns,
JSON.stringify(this.getHiddenColumns().map(column => column.field)))
UtilsCookie.setCookie(this, UtilsCookie.cookieIds.columns,
JSON.stringify(this.columns.map(column => column.field)))
} }
_toggleAllColumns (...args) { _toggleAllColumns (...args) {
@ -373,7 +379,10 @@ $.BootstrapTable = class extends $.BootstrapTable {
if (!this.options.cookie) { if (!this.options.cookie) {
return return
} }
UtilsCookie.setCookie(this, UtilsCookie.cookieIds.hiddenColumns, JSON.stringify(this.getHiddenColumns().map(column => column.field))) UtilsCookie.setCookie(this, UtilsCookie.cookieIds.hiddenColumns,
JSON.stringify(this.getHiddenColumns().map(column => column.field)))
UtilsCookie.setCookie(this, UtilsCookie.cookieIds.columns,
JSON.stringify(this.columns.map(column => column.field)))
} }
toggleView () { toggleView () {
@ -444,18 +453,23 @@ $.BootstrapTable = class extends $.BootstrapTable {
const cardViewCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.cardView) const cardViewCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.cardView)
const customViewCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.customView) const customViewCookie = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.customView)
const hiddenColumnsCookieValue = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.hiddenColumns) const hiddenColumnsCookieValue = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.hiddenColumns)
const columnsCookieValue = UtilsCookie.getCookie(this, UtilsCookie.cookieIds.columns)
let hiddenColumnsCookie = {} let hiddenColumnsCookie = {}
let columnsCookie = {}
try { try {
hiddenColumnsCookie = JSON.parse(hiddenColumnsCookieValue) hiddenColumnsCookie = JSON.parse(hiddenColumnsCookieValue)
columnsCookie = JSON.parse(columnsCookieValue)
} catch (e) { } catch (e) {
throw new Error('Could not parse the json of the hidden columns cookie!', hiddenColumnsCookieValue) console.error(e)
throw new Error('Could not parse the json of the columns cookie!')
} }
try { try {
sortPriorityCookie = JSON.parse(sortPriorityCookie) sortPriorityCookie = JSON.parse(sortPriorityCookie)
} catch (e) { } catch (e) {
console.error(e)
throw new Error('Could not parse the json of the sortPriority cookie!', sortPriorityCookie) throw new Error('Could not parse the json of the sortPriority cookie!', sortPriorityCookie)
} }
@ -493,8 +507,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.customViewDefaultView = customViewCookie === 'true' this.customViewDefaultView = customViewCookie === 'true'
if (hiddenColumnsCookie) { if (hiddenColumnsCookie) {
columnsCookie = columnsCookie || this.columns.map(column => column.field)
for (const column of this.columns) { for (const column of this.columns) {
if (!column.switchable) { if (
!column.switchable ||
!columnsCookie.includes(column.field)
) {
continue continue
} }
@ -505,12 +524,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
getCookies () { getCookies () {
const bootstrapTable = this
const cookies = {} const cookies = {}
for (const [key, value] of Object.entries(UtilsCookie.cookieIds)) { for (const [key, value] of Object.entries(UtilsCookie.cookieIds)) {
cookies[key] = UtilsCookie.getCookie(bootstrapTable, value) cookies[key] = UtilsCookie.getCookie(this, value)
if (key === 'columns' || key === 'hiddenColumns' || key === 'sortPriority') { if (['columns', 'hiddenColumns', 'sortPriority'].includes(key)) {
cookies[key] = JSON.parse(cookies[key]) cookies[key] = JSON.parse(cookies[key])
} }
} }
@ -518,7 +536,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
deleteCookie (cookieName) { deleteCookie (cookieName) {
if (!cookieName) { if (!cookieName || !this.options.cookie) {
return return
} }
@ -526,56 +544,50 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
configureStorage () { configureStorage () {
const that = this
this._storage = {} this._storage = {}
switch (this.options.cookieStorage) { switch (this.options.cookieStorage) {
case 'cookieStorage': case 'cookieStorage':
this._storage.setItem = function (cookieName, cookieValue) { this._storage.setItem = (cookieName, cookieValue) => {
document.cookie = [ document.cookie = [
cookieName, '=', encodeURIComponent(cookieValue), cookieName, '=', encodeURIComponent(cookieValue),
`; expires=${UtilsCookie.calculateExpiration(that.options.cookieExpire)}`, `; expires=${UtilsCookie.calculateExpiration(this.options.cookieExpire)}`,
that.options.cookiePath ? `; path=${that.options.cookiePath}` : '', this.options.cookiePath ? `; path=${this.options.cookiePath}` : '',
that.options.cookieDomain ? `; domain=${that.options.cookieDomain}` : '', this.options.cookieDomain ? `; domain=${this.options.cookieDomain}` : '',
that.options.cookieSecure ? '; secure' : '', this.options.cookieSecure ? '; secure' : '',
`;SameSite=${that.options.cookieSameSite}` `;SameSite=${this.options.cookieSameSite}`
].join('') ].join('')
} }
this._storage.getItem = function (cookieName) { this._storage.getItem = cookieName => {
const value = `; ${document.cookie}` const value = `; ${document.cookie}`
const parts = value.split(`; ${cookieName}=`) const parts = value.split(`; ${cookieName}=`)
return parts.length === 2 ? decodeURIComponent(parts.pop().split(';').shift()) : null return parts.length === 2 ? decodeURIComponent(parts.pop().split(';').shift()) : null
} }
this._storage.removeItem = function (cookieName) { this._storage.removeItem = cookieName => {
document.cookie = [ document.cookie = [
encodeURIComponent(cookieName), '=', encodeURIComponent(cookieName), '=',
'; expires=Thu, 01 Jan 1970 00:00:00 GMT', '; expires=Thu, 01 Jan 1970 00:00:00 GMT',
that.options.cookiePath ? `; path=${that.options.cookiePath}` : '', this.options.cookiePath ? `; path=${this.options.cookiePath}` : '',
that.options.cookieDomain ? `; domain=${that.options.cookieDomain}` : '', this.options.cookieDomain ? `; domain=${this.options.cookieDomain}` : '',
`;SameSite=${that.options.cookieSameSite}` `;SameSite=${this.options.cookieSameSite}`
].join('') ].join('')
} }
break break
case 'localStorage': case 'localStorage':
this._storage.setItem = function (cookieName, cookieValue) { this._storage.setItem = (cookieName, cookieValue) => {
localStorage.setItem(cookieName, cookieValue) localStorage.setItem(cookieName, cookieValue)
} }
this._storage.getItem = function (cookieName) { this._storage.getItem = cookieName => localStorage.getItem(cookieName)
return localStorage.getItem(cookieName) this._storage.removeItem = cookieName => {
}
this._storage.removeItem = function (cookieName) {
localStorage.removeItem(cookieName) localStorage.removeItem(cookieName)
} }
break break
case 'sessionStorage': case 'sessionStorage':
this._storage.setItem = function (cookieName, cookieValue) { this._storage.setItem = (cookieName, cookieValue) => {
sessionStorage.setItem(cookieName, cookieValue) sessionStorage.setItem(cookieName, cookieValue)
} }
this._storage.getItem = function (cookieName) { this._storage.getItem = cookieName => sessionStorage.getItem(cookieName)
return sessionStorage.getItem(cookieName) this._storage.removeItem = cookieName => {
}
this._storage.removeItem = function (cookieName) {
sessionStorage.removeItem(cookieName) sessionStorage.removeItem(cookieName)
} }
break break
@ -588,16 +600,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
throw new Error('The following options must be set while using the customStorage: cookieCustomStorageSet, cookieCustomStorageGet and cookieCustomStorageDelete') throw new Error('The following options must be set while using the customStorage: cookieCustomStorageSet, cookieCustomStorageGet and cookieCustomStorageDelete')
} }
this._storage.setItem = function (cookieName, cookieValue) { this._storage.setItem = (cookieName, cookieValue) => {
Utils.calculateObjectValue(that.options, that.options.cookieCustomStorageSet, [cookieName, cookieValue], '') Utils.calculateObjectValue(this.options, this.options.cookieCustomStorageSet, [cookieName, cookieValue], '')
} }
this._storage.getItem = function (cookieName) { this._storage.getItem = cookieName => Utils.calculateObjectValue(this.options, this.options.cookieCustomStorageGet, [cookieName], '')
return Utils.calculateObjectValue(that.options, that.options.cookieCustomStorageGet, [cookieName], '') this._storage.removeItem = cookieName => {
Utils.calculateObjectValue(this.options, this.options.cookieCustomStorageDelete, [cookieName], '')
} }
this._storage.removeItem = function (cookieName) {
Utils.calculateObjectValue(that.options, that.options.cookieCustomStorageDelete, [cookieName], '')
}
break break
default: default:
throw new Error('Storage method not supported.') throw new Error('Storage method not supported.')

@ -11,25 +11,20 @@ Object.assign($.fn.bootstrapTable.defaults, {
customViewDefaultView: false customViewDefaultView: false
}) })
Object.assign($.fn.bootstrapTable.defaults.icons, { Utils.assignIcons($.fn.bootstrapTable.icons, 'customViewOn', {
customViewOn: { glyphicon: 'glyphicon-list',
bootstrap3: 'glyphicon glyphicon-list', fa: 'fa-list',
bootstrap5: 'bi-list', bi: 'bi-list',
bootstrap4: 'fa fa-list', icon: 'list',
semantic: 'fa fa-list', 'material-icons': 'list'
foundation: 'fa fa-list', })
bulma: 'fa fa-list',
materialize: 'list' Utils.assignIcons($.fn.bootstrapTable.icons, 'customViewOff', {
}[$.fn.bootstrapTable.theme] || 'fa-list', glyphicon: 'glyphicon-thumbnails',
customViewOff: { fa: 'fa-th',
bootstrap3: 'glyphicon glyphicon-eye-open', bi: 'bi-grid',
bootstrap5: 'bi-grid', icon: 'grid_on',
bootstrap4: 'fa fa-th', 'material-icons': 'grid_on'
semantic: 'fa fa-th',
foundation: 'fa fa-th',
bulma: 'fa fa-th',
materialize: 'grid_on'
}[$.fn.bootstrapTable.theme] || 'fa-th'
}) })
Object.assign($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {

@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
/** /**
* @author zhixin wen <wenzhixin2010@gmail.com> * @author zhixin wen <wenzhixin2010@gmail.com>
* extensions: https://github.com/vitalets/x-editable * extensions: https://github.com/vitalets/x-editable
@ -6,7 +5,7 @@
var Utils = $.fn.bootstrapTable.utils var Utils = $.fn.bootstrapTable.utils
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
editable: true, editable: true,
onEditableInit () { onEditableInit () {
return false return false
@ -22,11 +21,11 @@ $.extend($.fn.bootstrapTable.defaults, {
} }
}) })
$.extend($.fn.bootstrapTable.columnDefaults, { Object.assign($.fn.bootstrapTable.columnDefaults, {
alwaysUseFormatter: false alwaysUseFormatter: false
}) })
$.extend($.fn.bootstrapTable.events, { Object.assign($.fn.bootstrapTable.events, {
'editable-init.bs.table': 'onEditableInit', 'editable-init.bs.table': 'onEditableInit',
'editable-save.bs.table': 'onEditableSave', 'editable-save.bs.table': 'onEditableSave',
'editable-shown.bs.table': 'onEditableShown', 'editable-shown.bs.table': 'onEditableShown',
@ -48,7 +47,6 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
const editableOptions = {} const editableOptions = {}
const editableDataMarkup = []
const editableDataPrefix = 'editable-' const editableDataPrefix = 'editable-'
const processDataOptions = (key, value) => { const processDataOptions = (key, value) => {
// Replace camel case with dashes. // Replace camel case with dashes.
@ -59,12 +57,14 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
} }
const formatterIsSet = column.formatter ? true : false
$.each(this.options, processDataOptions) $.each(this.options, processDataOptions)
column.formatter = column.formatter || (value => value) column.formatter = column.formatter || (value => value)
column._formatter = column._formatter ? column._formatter : column.formatter column._formatter = column._formatter ? column._formatter : column.formatter
column.formatter = (value, row, index, field) => { column.formatter = (value, row, index, field) => {
let result = Utils.calculateObjectValue(column, column._formatter, [value, row, index], value) let result = Utils.calculateObjectValue(column, column._formatter, [value, row, index, field], value)
result = typeof result === 'undefined' || result === null ? this.options.undefinedText : result result = typeof result === 'undefined' || result === null ? this.options.undefinedText : result
if (this.options.uniqueId !== undefined && !column.alwaysUseFormatter) { if (this.options.uniqueId !== undefined && !column.alwaysUseFormatter) {
@ -77,26 +77,26 @@ $.BootstrapTable = class extends $.BootstrapTable {
$.each(column, processDataOptions) $.each(column, processDataOptions)
$.each(editableOptions, (key, value) => {
editableDataMarkup.push(` ${key}="${value}"`)
})
let noEditFormatter = false
const editableOpts = Utils.calculateObjectValue(column, const editableOpts = Utils.calculateObjectValue(column,
column.editable, [index, row], {}) column.editable, [index, row], {})
const noEditFormatter = editableOpts.hasOwnProperty('noEditFormatter') &&
editableOpts.noEditFormatter(value, row, index, field)
if (editableOpts.hasOwnProperty('noEditFormatter')) { if (noEditFormatter) {
noEditFormatter = editableOpts.noEditFormatter(value, row, index, field) return noEditFormatter
} }
if (noEditFormatter === false) { let editableDataMarkup = ''
return `<a href="javascript:void(0)"
data-name="${column.field}" $.each(editableOptions, (key, value) => {
data-pk="${row[this.options.idField]}" editableDataMarkup += ` ${key}="${value}"`
data-value="${result}" })
${editableDataMarkup.join('')}></a>`
} return `<a href="javascript:void(0)"
return noEditFormatter data-name="${column.field}"
data-pk="${row[this.options.idField]}"
data-value="${value || ''}"
${editableDataMarkup}>${formatterIsSet ? result : ''}</a>` // expand all data-editable-XXX
} }
}) })
} }
@ -178,7 +178,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
for (const row of data) { for (const row of data) {
for (const [key, value] of Object.entries(row)) { for (const [key, value] of Object.entries(row)) {
if (typeof(value) !== "number") { if (typeof(value) !== "number") {
row[key] = Utils.unescapeHTML(value) row[key] = Utils.unescapeHTML(value)
} }
} }
} }

@ -32,13 +32,12 @@ Object.assign($.fn.bootstrapTable.columnDefaults, {
forceHide: false forceHide: false
}) })
Object.assign($.fn.bootstrapTable.defaults.icons, { Utils.assignIcons($.fn.bootstrapTable.icons, 'export', {
export: { glyphicon: 'glyphicon-export icon-share',
bootstrap3: 'glyphicon-export icon-share', fa: 'fa-download',
bootstrap5: 'bi-download', bi: 'bi-download',
materialize: 'file_download', icon: 'icon-download',
'bootstrap-table': 'icon-download' 'material-icons': 'file_download'
}[$.fn.bootstrapTable.theme] || 'fa-download'
}) })
Object.assign($.fn.bootstrapTable.locales, { Object.assign($.fn.bootstrapTable.locales, {
@ -207,7 +206,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
const footerData = {} const footerData = {}
const footerHtml = [] const footerHtml = []
$.each($footerRow.children(), (index, footerCell) => { $footerRow.children().forEach((footerCell, index) => {
const footerCellHtml = $(footerCell).children('.th-inner').first().html() const footerCellHtml = $(footerCell).children('.th-inner').first().html()
footerData[this.columns[index].field] = footerCellHtml === '&nbsp;' ? null : footerCellHtml footerData[this.columns[index].field] = footerCellHtml === '&nbsp;' ? null : footerCellHtml
@ -219,7 +218,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.$body.append(this.$body.children().last()[0].outerHTML) this.$body.append(this.$body.children().last()[0].outerHTML)
const $lastTableRow = this.$body.children().last() const $lastTableRow = this.$body.children().last()
$.each($lastTableRow.children(), (index, lastTableRowCell) => { $lastTableRow.children().forEach((lastTableRowCell, index) => {
$(lastTableRowCell).html(footerHtml[index]) $(lastTableRowCell).html(footerHtml[index])
}) })
} }

@ -74,12 +74,12 @@ Object.assign($.fn.bootstrapTable.columnDefaults, {
printFormatter: undefined printFormatter: undefined
}) })
Object.assign($.fn.bootstrapTable.defaults.icons, { Utils.assignIcons($.fn.bootstrapTable.icons, 'print', {
print: { glyphicon: 'glyphicon-print icon-share',
bootstrap3: 'glyphicon-print icon-share', fa: 'fa-print',
bootstrap5: 'bi-printer', bi: 'bi-printer',
'bootstrap-table': 'icon-printer' icon: 'icon-printer',
}[$.fn.bootstrapTable.theme] || 'fa-print' 'material-icons': 'print'
}) })
$.BootstrapTable = class extends $.BootstrapTable { $.BootstrapTable = class extends $.BootstrapTable {
@ -131,15 +131,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.mergedCells.push({ this.mergedCells.push({
row: options.index, row: options.index,
col, col,
rowspan: options.rowspan || 1, rowspan: +options.rowspan || 1,
colspan: options.colspan || 1 colspan: +options.colspan || 1
}) })
} }
doPrint (data) { doPrint (data) {
const canPrint = column => { const canPrint = column => !column.printIgnore && column.visible
return !column.printIgnore && column.visible
}
const formatValue = (row, i, column) => { const formatValue = (row, i, column) => {
const value_ = Utils.getItemField(row, column.field, this.options.escape, column.escape) const value_ = Utils.getItemField(row, column.field, this.options.escape, column.escape)
@ -148,7 +146,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
[value_, row, i], value_) [value_, row, i], value_)
return typeof value === 'undefined' || value === null ? return typeof value === 'undefined' || value === null ?
this.options.undefinedText : value this.options.undefinedText : $('<div>').html(value).html()
} }
const buildTable = (data, columnsArray) => { const buildTable = (data, columnsArray) => {
@ -194,9 +192,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
const columns = columnsArray.flat(1) const columns = columnsArray.flat(1)
columns.sort((c1, c2) => { columns.sort((c1, c2) => c1.colspanIndex - c2.colspanIndex)
return c1.colspanIndex - c2.colspanIndex
})
for (let j = 0; j < columns.length; j++) { for (let j = 0; j < columns.length; j++) {
if (columns[j].colspanGroup > 0) continue if (columns[j].colspanGroup > 0) continue

@ -124,7 +124,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
try { try {
$(this.$el).dragtable('destroy') $(this.$el).dragtable('destroy')
} catch (e) { } catch (e) {
// do nothing console.error(e)
} }
$(this.$el).dragtable({ $(this.$el).dragtable({
maxMovingRows: this.options.maxMovingRows, maxMovingRows: this.options.maxMovingRows,
@ -136,7 +136,9 @@ $.BootstrapTable = class extends $.BootstrapTable {
const sortOrder = {} const sortOrder = {}
table.el.find('th').each((i, el) => { table.el.find('th').each((i, el) => {
sortOrder[$(el).data('field')] = i if (el.dataset.field !== undefined) {
sortOrder[el.dataset.field] = i
}
}) })
this.columnsSortOrder = sortOrder this.columnsSortOrder = sortOrder
@ -177,7 +179,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.columns = columns this.columns = columns
filterFn() // Support <IE9 filterFn() // Support <IE9
$.each(this.columns, (i, column) => { for (const column of this.columns) {
let found = false let found = false
const field = column.field const field = column.field
@ -189,7 +191,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
return true return true
}) })
}) }
this.options.columns[0] = optionsColumns this.options.columns[0] = optionsColumns

@ -10,7 +10,7 @@
<link th:href="@{/css/bootstrap.min.css?v=3.3.7}" rel="stylesheet"/> <link th:href="@{/css/bootstrap.min.css?v=3.3.7}" rel="stylesheet"/>
<link th:href="@{/css/font-awesome.min.css?v=4.7.0}" rel="stylesheet"/> <link th:href="@{/css/font-awesome.min.css?v=4.7.0}" rel="stylesheet"/>
<!-- bootstrap-table 表格插件样式 --> <!-- bootstrap-table 表格插件样式 -->
<link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=1.22.6}" rel="stylesheet"/> <link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=1.24.1}" rel="stylesheet"/>
<link th:href="@{/css/animate.min.css?v=20210831}" rel="stylesheet"/> <link th:href="@{/css/animate.min.css?v=20210831}" rel="stylesheet"/>
<link th:href="@{/css/style.min.css?v=20210831}" rel="stylesheet"/> <link th:href="@{/css/style.min.css?v=20210831}" rel="stylesheet"/>
<link th:href="@{/ruoyi/css/ry-ui.css?v=4.8.0}" rel="stylesheet"/> <link th:href="@{/ruoyi/css/ry-ui.css?v=4.8.0}" rel="stylesheet"/>
@ -23,15 +23,15 @@
<script th:src="@{/js/jquery.min.js?v=3.7.1}"></script> <script th:src="@{/js/jquery.min.js?v=3.7.1}"></script>
<script th:src="@{/js/bootstrap.min.js?v=3.3.7}"></script> <script th:src="@{/js/bootstrap.min.js?v=3.3.7}"></script>
<!-- bootstrap-table 表格插件 --> <!-- bootstrap-table 表格插件 -->
<script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=1.24.1}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=1.24.1}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js?v=1.24.1}"></script>
<!-- jquery-validate 表单验证插件 --> <!-- jquery-validate 表单验证插件 -->
<script th:src="@{/ajax/libs/validate/jquery.validate.min.js?v=1.21.0}"></script> <script th:src="@{/ajax/libs/validate/jquery.validate.min.js?v=1.21.0}"></script>
<script th:src="@{/ajax/libs/validate/jquery.validate.extend.js?v=1.21.0}"></script> <script th:src="@{/ajax/libs/validate/jquery.validate.extend.js?v=1.21.0}"></script>
<script th:src="@{/ajax/libs/validate/messages_zh.js?v=1.21.0}"></script> <script th:src="@{/ajax/libs/validate/messages_zh.js?v=1.21.0}"></script>
<!-- bootstrap-table 表格树插件 --> <!-- bootstrap-table 表格树插件 -->
<script th:src="@{/ajax/libs/bootstrap-table/extensions/tree/bootstrap-table-tree.min.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/tree/bootstrap-table-tree.min.js?v=1.24.1}"></script>
<!-- 遮罩层 --> <!-- 遮罩层 -->
<script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js?v=2.70.0}"></script> <script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js?v=2.70.0}"></script>
<script th:src="@{/ajax/libs/iCheck/icheck.min.js?v=1.0.3}"></script> <script th:src="@{/ajax/libs/iCheck/icheck.min.js?v=1.0.3}"></script>
@ -171,20 +171,20 @@
<!-- 表格行拖拽插件 --> <!-- 表格行拖拽插件 -->
<div th:fragment="bootstrap-table-reorder-rows-js"> <div th:fragment="bootstrap-table-reorder-rows-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js?v=1.24.1}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-rows/jquery.tablednd.js?v=1.0.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-rows/jquery.tablednd.js?v=1.0.3}"></script>
</div> </div>
<!-- 表格列拖拽插件 --> <!-- 表格列拖拽插件 -->
<div th:fragment="bootstrap-table-reorder-columns-js"> <div th:fragment="bootstrap-table-reorder-columns-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-columns/jquery.dragtable.js?v=5.3.5}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-columns/jquery.dragtable.js?v=5.3.5}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-columns/bootstrap-table-reorder-columns.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-columns/bootstrap-table-reorder-columns.js?v=1.24.1}"></script>
</div> </div>
<!-- 表格列宽拖动插件 --> <!-- 表格列宽拖动插件 -->
<div th:fragment="bootstrap-table-resizable-js"> <div th:fragment="bootstrap-table-resizable-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/jquery.resizableColumns.min.js?v=0.1.0}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/jquery.resizableColumns.min.js?v=0.1.0}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/bootstrap-table-resizable.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/bootstrap-table-resizable.js?v=1.24.1}"></script>
</div> </div>
<!-- 表格行内编辑插件 --> <!-- 表格行内编辑插件 -->
@ -193,36 +193,36 @@
</div> </div>
<div th:fragment="bootstrap-table-editable-js"> <div th:fragment="bootstrap-table-editable-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-editable.min.js?v=1.5.1}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-editable.min.js?v=1.5.1}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.js?v=1.24.1}"></script>
</div> </div>
<!-- 表格导出插件 --> <!-- 表格导出插件 -->
<div th:fragment="bootstrap-table-export-js"> <div th:fragment="bootstrap-table-export-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js?v=1.24.1}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/export/tableExport.min.js?v=1.10.24}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/export/tableExport.min.js?v=1.10.24}"></script>
</div> </div>
<!-- 表格冻结列插件 --> <!-- 表格冻结列插件 -->
<div th:fragment="bootstrap-table-fixed-columns-js"> <div th:fragment="bootstrap-table-fixed-columns-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js?v=1.24.1}"></script>
</div> </div>
<!-- 表格自动刷新插件 --> <!-- 表格自动刷新插件 -->
<div th:fragment="bootstrap-table-auto-refresh-js"> <div th:fragment="bootstrap-table-auto-refresh-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/auto-refresh/bootstrap-table-auto-refresh.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/auto-refresh/bootstrap-table-auto-refresh.js?v=1.24.1}"></script>
</div> </div>
<!-- 表格打印插件 --> <!-- 表格打印插件 -->
<div th:fragment="bootstrap-table-print-js"> <div th:fragment="bootstrap-table-print-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/print/bootstrap-table-print.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/print/bootstrap-table-print.js?v=1.24.1}"></script>
</div> </div>
<!-- 表格视图分页插件 --> <!-- 表格视图分页插件 -->
<div th:fragment="bootstrap-table-custom-view-js"> <div th:fragment="bootstrap-table-custom-view-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/custom-view/bootstrap-table-custom-view.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/custom-view/bootstrap-table-custom-view.js?v=1.24.1}"></script>
</div> </div>
<!-- 表格保存状态插件 --> <!-- 表格保存状态插件 -->
<div th:fragment="bootstrap-table-cookie-js"> <div th:fragment="bootstrap-table-cookie-js">
<script th:src="@{/ajax/libs/bootstrap-table/extensions/cookie/bootstrap-table-cookie.js?v=1.22.6}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/cookie/bootstrap-table-cookie.js?v=1.24.1}"></script>
</div> </div>

Loading…
Cancel
Save