升级bootstrap-table到最新版本1.22.6

master
RuoYi 2024-06-03 13:29:36 +08:00
parent ec6d84aa88
commit 4c9bfd8683
13 changed files with 253 additions and 173 deletions

File diff suppressed because one or more lines are too long

View File

@ -49,8 +49,8 @@ $.BootstrapTable = class extends $.BootstrapTable {
<button class="auto-refresh ${this.constants.buttonsClass} <button class="auto-refresh ${this.constants.buttonsClass}
${this.options.autoRefreshStatus ? ` ${this.constants.classes.buttonActive}` : ''}" ${this.options.autoRefreshStatus ? ` ${this.constants.classes.buttonActive}` : ''}"
type="button" name="autoRefresh" title="${this.options.formatAutoRefresh()}"> type="button" name="autoRefresh" title="${this.options.formatAutoRefresh()}">
${ this.options.showButtonIcons ? Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.autoRefresh) : ''} ${this.options.showButtonIcons ? Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.autoRefresh) : ''}
${ this.options.showButtonText ? this.options.formatAutoRefresh() : ''} ${this.options.showButtonText ? this.options.formatAutoRefresh() : ''}
</button> </button>
`, `,
event: this.toggleAutoRefresh event: this.toggleAutoRefresh

View File

@ -5,65 +5,81 @@
var Utils = $.fn.bootstrapTable.utils var Utils = $.fn.bootstrapTable.utils
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
customView: false, customView: false,
showCustomView: false, showCustomView: false,
showCustomViewButton: false customViewDefaultView: false
}) })
$.extend($.fn.bootstrapTable.defaults.icons, { Object.assign($.fn.bootstrapTable.defaults.icons, {
customView: { customViewOn: {
bootstrap3: 'glyphicon glyphicon-list',
bootstrap5: 'bi-list',
bootstrap4: 'fa fa-list',
semantic: 'fa fa-list',
foundation: 'fa fa-list',
bulma: 'fa fa-list',
materialize: 'list'
}[$.fn.bootstrapTable.theme] || 'fa-list',
customViewOff: {
bootstrap3: 'glyphicon glyphicon-eye-open', bootstrap3: 'glyphicon glyphicon-eye-open',
bootstrap5: 'bi-eye', bootstrap5: 'bi-grid',
bootstrap4: 'fa fa-eye', bootstrap4: 'fa fa-th',
semantic: 'fa fa-eye', semantic: 'fa fa-th',
foundation: 'fa fa-eye', foundation: 'fa fa-th',
bulma: 'fa fa-eye', bulma: 'fa fa-th',
materialize: 'remove_red_eye' materialize: 'grid_on'
}[$.fn.bootstrapTable.theme] || 'fa-eye' }[$.fn.bootstrapTable.theme] || 'fa-th'
}) })
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
onCustomViewPostBody () { onCustomViewPostBody () {
return false return false
}, },
onCustomViewPreBody () { onCustomViewPreBody () {
return false return false
},
onToggleCustomView () {
return false
} }
}) })
$.extend($.fn.bootstrapTable.locales, { Object.assign($.fn.bootstrapTable.locales, {
formatToggleCustomView () { formatToggleCustomViewOn () {
return 'Toggle custom view' return 'Show custom view'
},
formatToggleCustomViewOff () {
return 'Hide custom view'
} }
}) })
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales) Object.assign($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)
$.fn.bootstrapTable.methods.push('toggleCustomView') $.fn.bootstrapTable.methods.push('toggleCustomView')
$.extend($.fn.bootstrapTable.Constructor.EVENTS, { Object.assign($.fn.bootstrapTable.events, {
'custom-view-post-body.bs.table': 'onCustomViewPostBody', 'custom-view-post-body.bs.table': 'onCustomViewPostBody',
'custom-view-pre-body.bs.table': 'onCustomViewPreBody' 'custom-view-pre-body.bs.table': 'onCustomViewPreBody',
'toggle-custom-view.bs.table': 'onToggleCustomView'
}) })
$.BootstrapTable = class extends $.BootstrapTable { $.BootstrapTable = class extends $.BootstrapTable {
init () { init () {
this.showCustomView = this.options.showCustomView this.customViewDefaultView = this.options.customViewDefaultView
super.init() super.init()
} }
initToolbar (...args) { initToolbar (...args) {
if (this.options.customView && this.options.showCustomViewButton) { if (this.options.customView && this.options.showCustomView) {
this.buttons = Object.assign(this.buttons, { this.buttons = Object.assign(this.buttons, {
customView: { customView: {
text: this.options.formatToggleCustomView(), text: this.options.customViewDefaultView ? this.options.formatToggleCustomViewOff() : this.options.formatToggleCustomViewOn(),
icon: this.options.icons.customView, icon: this.options.customViewDefaultView ? this.options.icons.customViewOn : this.options.icons.customViewOff,
event: this.toggleCustomView, event: this.toggleCustomView,
attributes: { attributes: {
'aria-label': this.options.formatToggleCustomView(), 'aria-label': this.options.customViewDefaultView ? this.options.formatToggleCustomViewOff() : this.options.formatToggleCustomViewOn(),
title: this.options.formatToggleCustomView() title: this.options.customViewDefaultView ? this.options.formatToggleCustomViewOff() : this.options.formatToggleCustomViewOn()
} }
} }
}) })
@ -84,7 +100,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
$table.hide() $table.hide()
$customViewContainer.hide() $customViewContainer.hide()
if (!this.options.customView || !this.showCustomView) { if (!this.options.customView || !this.customViewDefaultView) {
$table.show() $table.show()
return return
} }
@ -103,7 +119,17 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
toggleCustomView () { toggleCustomView () {
this.showCustomView = !this.showCustomView this.customViewDefaultView = !this.customViewDefaultView
const icon = this.options.showButtonIcons ? this.customViewDefaultView ? this.options.icons.customViewOn : this.options.icons.customViewOff : ''
const text = this.options.showButtonText ? this.customViewDefaultView ? this.options.formatToggleCustomViewOff() : this.options.formatToggleCustomViewOn() : ''
this.$toolbar.find('button[name="customView"]')
.html(`${Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, icon)} ${text}`)
.attr('aria-label', text)
.attr('title', text)
this.initBody() this.initBody()
this.trigger('toggle-custom-view', this.customViewDefaultView)
} }
} }

View File

@ -19,28 +19,20 @@ const TYPE_NAME = {
pdf: 'PDF' pdf: 'PDF'
} }
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
showExport: false, showExport: false,
exportDataType: 'basic', // basic, all, selected exportDataType: 'basic', // basic, all, selected
exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'], exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
exportOptions: { exportOptions: {},
onCellHtmlData (cell, rowIndex, colIndex, htmlData) {
if (cell.is('th')) {
return cell.find('.th-inner').text()
}
return htmlData
}
},
exportFooter: false exportFooter: false
}) })
$.extend($.fn.bootstrapTable.columnDefaults, { Object.assign($.fn.bootstrapTable.columnDefaults, {
forceExport: false, forceExport: false,
forceHide: false forceHide: false
}) })
$.extend($.fn.bootstrapTable.defaults.icons, { Object.assign($.fn.bootstrapTable.defaults.icons, {
export: { export: {
bootstrap3: 'glyphicon-export icon-share', bootstrap3: 'glyphicon-export icon-share',
bootstrap5: 'bi-download', bootstrap5: 'bi-download',
@ -49,24 +41,28 @@ $.extend($.fn.bootstrapTable.defaults.icons, {
}[$.fn.bootstrapTable.theme] || 'fa-download' }[$.fn.bootstrapTable.theme] || 'fa-download'
}) })
$.extend($.fn.bootstrapTable.locales, { Object.assign($.fn.bootstrapTable.locales, {
formatExport () { formatExport () {
return 'Export data' return 'Export data'
} }
}) })
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales) Object.assign($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)
$.fn.bootstrapTable.methods.push('exportTable') $.fn.bootstrapTable.methods.push('exportTable')
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
onExportSaved (exportedRows) { onExportSaved (exportedRows) {
return false return false
},
onExportStarted () {
return false
} }
}) })
$.extend($.fn.bootstrapTable.Constructor.EVENTS, { Object.assign($.fn.bootstrapTable.events, {
'export-saved.bs.table': 'onExportSaved' 'export-saved.bs.table': 'onExportSaved',
'export-started.bs.table': 'onExportStarted'
}) })
$.BootstrapTable = class extends $.BootstrapTable { $.BootstrapTable = class extends $.BootstrapTable {
@ -84,6 +80,10 @@ $.BootstrapTable = class extends $.BootstrapTable {
exportTypes = types.map(t => t.slice(1, -1)) exportTypes = types.map(t => t.slice(1, -1))
} }
if (typeof o.exportOptions === 'string') {
o.exportOptions = Utils.calculateObjectValue(null, o.exportOptions)
}
this.$export = this.$toolbar.find('>.columns div.export') this.$export = this.$toolbar.find('>.columns div.export')
if (this.$export.length) { if (this.$export.length) {
this.updateExportButton() this.updateExportButton()
@ -93,13 +93,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.buttons = Object.assign(this.buttons, { this.buttons = Object.assign(this.buttons, {
export: { export: {
html: html:
(() => { () => {
if (exportTypes.length === 1) { if (exportTypes.length === 1) {
return ` return `
<div class="export ${this.constants.classes.buttonsDropdown}" <div class="export ${this.constants.classes.buttonsDropdown}"
data-type="${exportTypes[0]}"> data-type="${exportTypes[0]}">
<button class="${this.constants.buttonsClass}" <button class="${this.constants.buttonsClass}"
aria-label="Export" aria-label="${o.formatExport()}"
type="button" type="button"
title="${o.formatExport()}"> title="${o.formatExport()}">
${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''} ${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
@ -114,7 +114,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
html.push(` html.push(`
<div class="export ${this.constants.classes.buttonsDropdown}"> <div class="export ${this.constants.classes.buttonsDropdown}">
<button class="${this.constants.buttonsClass} dropdown-toggle" <button class="${this.constants.buttonsClass} dropdown-toggle"
aria-label="Export" aria-label="${o.formatExport()}"
${this.constants.dataToggle}="dropdown" ${this.constants.dataToggle}="dropdown"
type="button" type="button"
title="${o.formatExport()}"> title="${o.formatExport()}">
@ -136,7 +136,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
html.push(this.constants.html.toolbarDropdown[1], '</div>') html.push(this.constants.html.toolbarDropdown[1], '</div>')
return html.join('') return html.join('')
}) }
} }
}) })
} }
@ -152,19 +152,15 @@ $.BootstrapTable = class extends $.BootstrapTable {
let $exportButtons = this.$export.find('[data-type]') let $exportButtons = this.$export.find('[data-type]')
if (exportTypes.length === 1) { if (exportTypes.length === 1) {
$exportButtons = this.$export.find('button') $exportButtons = this.$export
} }
$exportButtons.click(e => { $exportButtons.click(e => {
e.preventDefault() e.preventDefault()
this.trigger('export-started')
const type = $(e.currentTarget).data('type') this.exportTable({
const exportOptions = { type: $(e.currentTarget).data('type')
type, })
escape: false
}
this.exportTable(exportOptions)
}) })
this.handleToolbar() this.handleToolbar()
} }
@ -206,7 +202,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
o.exportOptions.ignoreColumn = [detailViewIndex].concat(o.exportOptions.ignoreColumn || []) o.exportOptions.ignoreColumn = [detailViewIndex].concat(o.exportOptions.ignoreColumn || [])
} }
if (o.exportFooter) { if (o.exportFooter && o.height) {
const $footerRow = this.$tableFooter.find('tr').first() const $footerRow = this.$tableFooter.find('tr').first()
const footerData = {} const footerData = {}
const footerHtml = [] const footerHtml = []
@ -240,7 +236,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
options.fileName = o.exportOptions.fileName() options.fileName = o.exportOptions.fileName()
} }
this.$el.tableExport($.extend({ this.$el.tableExport(Utils.extend({
onAfterSaveToFile: () => { onAfterSaveToFile: () => {
if (o.exportFooter) { if (o.exportFooter) {
this.load(data) this.load(data)
@ -277,15 +273,17 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.$el.one(eventName, () => { this.$el.one(eventName, () => {
setTimeout(() => { setTimeout(() => {
const data = this.getData()
doExport(() => { doExport(() => {
this.options.virtualScroll = virtualScroll this.options.virtualScroll = virtualScroll
this.togglePagination() this.togglePagination()
}) })
this.trigger('export-saved', data)
}, 0) }, 0)
}) })
this.options.virtualScroll = false this.options.virtualScroll = false
this.togglePagination() this.togglePagination()
this.trigger('export-saved', this.getData())
} else if (o.exportDataType === 'selected') { } else if (o.exportDataType === 'selected') {
let data = this.getData() let data = this.getData()
let selectedData = this.getSelections() let selectedData = this.getSelections()
@ -334,4 +332,4 @@ $.BootstrapTable = class extends $.BootstrapTable {
.prop('disabled', !this.getSelections().length) .prop('disabled', !this.getSelections().length)
} }
} }
} }

View File

@ -1,6 +1,5 @@
/** /**
* @author: Dennis Hernández * @author: Dennis Hernández
* @webSite: http://djhvscf.github.io/Blog
* @update zhixin wen <wenzhixin2010@gmail.com> * @update zhixin wen <wenzhixin2010@gmail.com>
*/ */
@ -18,7 +17,7 @@ const debounce = (func, wait) => {
} }
} }
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
mobileResponsive: false, mobileResponsive: false,
minWidth: 562, minWidth: 562,
minHeight: undefined, minHeight: undefined,
@ -108,9 +107,9 @@ $.BootstrapTable = class extends $.BootstrapTable {
changeView (width, height) { changeView (width, height) {
if (this.options.minHeight) { if (this.options.minHeight) {
if ((width <= this.options.minWidth) && (height <= this.options.minHeight)) { if (width <= this.options.minWidth && height <= this.options.minHeight) {
this.conditionCardView() this.conditionCardView()
} else if ((width > this.options.minWidth) && (height > this.options.minHeight)) { } else if (width > this.options.minWidth && height > this.options.minHeight) {
this.conditionFullView() this.conditionFullView()
} }
} else if (width <= this.options.minWidth) { } else if (width <= this.options.minWidth) {
@ -121,4 +120,4 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.resetView() this.resetView()
} }
} }

View File

@ -4,76 +4,80 @@
var Utils = $.fn.bootstrapTable.utils var Utils = $.fn.bootstrapTable.utils
function printPageBuilderDefault (table) { function printPageBuilderDefault (table, styles) {
return ` return `
<html> <html>
<head> <head>
<style type="text/css" media="print"> ${styles}
@page { <style type="text/css" media="print">
size: auto; @page {
margin: 25px 0 25px 0; size: auto;
} margin: 25px 0 25px 0;
</style> }
<style type="text/css" media="all"> </style>
table { <style type="text/css" media="all">
border-collapse: collapse; table {
font-size: 12px; border-collapse: collapse;
} font-size: 12px;
table, th, td { }
border: 1px solid grey; table, th, td {
} border: 1px solid grey;
th, td { }
text-align: center; th, td {
vertical-align: middle; text-align: center;
} vertical-align: middle;
p { }
font-weight: bold; p {
margin-left:20px; font-weight: bold;
} margin-left:20px;
table { }
width:94%; table {
margin-left:3%; width: 94%;
margin-right:3%; margin-left: 3%;
} margin-right: 3%;
div.bs-table-print { }
text-align:center; div.bs-table-print {
} text-align: center;
</style> }
</head> </style>
<title>Print Table</title> </head>
<body> <title>Print Table</title>
<p>Printed on: ${new Date} </p> <body>
<div class="bs-table-print">${table}</div> <p>Printed on: ${new Date} </p>
</body> <div class="bs-table-print">${table}</div>
</html>` </body>
</html>
`
} }
$.extend($.fn.bootstrapTable.locales, { Object.assign($.fn.bootstrapTable.locales, {
formatPrint () { formatPrint () {
return 'Print' return 'Print'
} }
}) })
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales) Object.assign($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
showPrint: false, showPrint: false,
printAsFilteredAndSortedOnUI: true, printAsFilteredAndSortedOnUI: true,
printSortColumn: undefined, printSortColumn: undefined,
printSortOrder: 'asc', printSortOrder: 'asc',
printPageBuilder (table) { printStyles: [],
return printPageBuilderDefault(table) printPageBuilder (table, styles) {
return printPageBuilderDefault(table, styles)
} }
}) })
$.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, { Object.assign($.fn.bootstrapTable.columnDefaults, {
printFilter: undefined, printFilter: undefined,
printIgnore: false, printIgnore: false,
printFormatter: undefined printFormatter: undefined
}) })
$.extend($.fn.bootstrapTable.defaults.icons, { Object.assign($.fn.bootstrapTable.defaults.icons, {
print: { print: {
bootstrap3: 'glyphicon-print icon-share', bootstrap3: 'glyphicon-print icon-share',
bootstrap5: 'bi-printer',
'bootstrap-table': 'icon-printer' 'bootstrap-table': 'icon-printer'
}[$.fn.bootstrapTable.theme] || 'fa-print' }[$.fn.bootstrapTable.theme] || 'fa-print'
}) })
@ -133,10 +137,15 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
doPrint (data) { doPrint (data) {
const canPrint = column => {
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.calculateObjectValue(column, const value = Utils.calculateObjectValue(column,
column.printFormatter || column.formatter, column.printFormatter || column.formatter,
[$.common.getItemField(row, column.field), row, i], $.common.getItemField(row, column.field)) [value_, row, i], value_)
return typeof value === 'undefined' || value === null ? return typeof value === 'undefined' || value === null ?
this.options.undefinedText : value this.options.undefinedText : value
@ -149,7 +158,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
for (const columns of columnsArray) { for (const columns of columnsArray) {
html.push('<tr>') html.push('<tr>')
for (let h = 0; h < columns.length; h++) { for (let h = 0; h < columns.length; h++) {
if (!columns[h].printIgnore) { if (canPrint(columns[h])) {
html.push( html.push(
`<th `<th
${Utils.sprintf(' rowspan="%s"', columns[h].rowspan)} ${Utils.sprintf(' rowspan="%s"', columns[h].rowspan)}
@ -162,7 +171,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
html.push('</thead><tbody>') html.push('</thead><tbody>')
const dontRender = [] const notRender = []
if (this.mergedCells) { if (this.mergedCells) {
for (let mc = 0; mc < this.mergedCells.length; mc++) { for (let mc = 0; mc < this.mergedCells.length; mc++) {
@ -174,7 +183,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
for (let cs = 0; cs < currentMergedCell.colspan; cs++) { for (let cs = 0; cs < currentMergedCell.colspan; cs++) {
const col = currentMergedCell.col + cs const col = currentMergedCell.col + cs
dontRender.push(`${row },${ col}`) notRender.push(`${row},${col}`)
} }
} }
} }
@ -207,11 +216,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
if ( if (
!columns[j].printIgnore && columns[j].field && canPrint(columns[j]) &&
( (
!dontRender.includes(`${i },${ j}`) || !notRender.includes(`${i},${j}`) ||
(rowspan > 0 && colspan > 0) rowspan > 0 && colspan > 0
) )
) { ) {
if (rowspan > 0 && colspan > 0) { if (rowspan > 0 && colspan > 0) {
html.push(`<td ${Utils.sprintf(' rowspan="%s"', rowspan)} ${Utils.sprintf(' colspan="%s"', colspan)}>`, formatValue(data[i], i, columns[j]), '</td>') html.push(`<td ${Utils.sprintf(' rowspan="%s"', rowspan)} ${Utils.sprintf(' colspan="%s"', colspan)}>`, formatValue(data[i], i, columns[j]), '</td>')
@ -221,7 +230,6 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
} }
html.push('</tr>') html.push('</tr>')
} }
@ -231,7 +239,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
for (const columns of columnsArray) { for (const columns of columnsArray) {
for (let h = 0; h < columns.length; h++) { for (let h = 0; h < columns.length; h++) {
if (!columns[h].printIgnore) { if (canPrint(columns)) {
const footerData = Utils.trToData(columns, this.$el.find('>tfoot>tr')) const footerData = Utils.trToData(columns, this.$el.find('>tfoot>tr'))
const footerValue = Utils.calculateObjectValue(columns[h], columns[h].footerFormatter, [data], footerData[0] && footerData[0][columns[h].field] || '') const footerValue = Utils.calculateObjectValue(columns[h], columns[h].footerFormatter, [data], footerData[0] && footerData[0][columns[h].field] || '')
@ -252,8 +260,8 @@ $.BootstrapTable = class extends $.BootstrapTable {
} }
let reverse = sortOrder !== 'asc' let reverse = sortOrder !== 'asc'
reverse = -((+reverse) || -1) reverse = -(+reverse || -1)
return data.sort((a, b) => reverse * (a[colName].localeCompare(b[colName]))) return data.sort((a, b) => reverse * a[colName].localeCompare(b[colName]))
} }
const filterRow = (row, filters) => { const filterRow = (row, filters) => {
@ -275,11 +283,30 @@ $.BootstrapTable = class extends $.BootstrapTable {
data = sortRows(data, this.options.printSortColumn, this.options.printSortOrder) data = sortRows(data, this.options.printSortColumn, this.options.printSortOrder)
const table = buildTable(data, this.options.columns) const table = buildTable(data, this.options.columns)
const newWin = window.open('') const newWin = window.open('')
const printStyles = typeof this.options.printStyles === 'string' ?
this.options.printStyles.replace(/\[|\]| /g, '').toLowerCase().split(',') :
this.options.printStyles
const styles = printStyles.map(it =>
`<link rel="stylesheet" href="${it}" />`).join('')
newWin.document.write(this.options.printPageBuilder.call(this, table)) const calculatedPrintPage = Utils.calculateObjectValue(this, this.options.printPageBuilder,
[table, styles], printPageBuilderDefault(table, styles))
const startPrint = () => {
newWin.focus()
newWin.print()
newWin.close()
}
newWin.document.write(calculatedPrintPage)
newWin.document.close() newWin.document.close()
newWin.focus()
newWin.print() if (printStyles.length) {
newWin.close() const links = document.getElementsByTagName('link')
const lastLink = links[links.length - 1]
lastLink.onload = startPrint
} else {
startPrint()
}
} }
} }

View File

@ -1,6 +1,5 @@
/** /**
* @author: Dennis Hernández * @author: Dennis Hernández
* @webSite: http://djhvscf.github.io/Blog
* @update: https://github.com/wenzhixin * @update: https://github.com/wenzhixin
* @version: v1.2.0 * @version: v1.2.0
*/ */
@ -60,7 +59,7 @@ const filterFn = () => {
} }
} }
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
reorderableColumns: false, reorderableColumns: false,
maxMovingRows: 10, maxMovingRows: 10,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -70,7 +69,7 @@ $.extend($.fn.bootstrapTable.defaults, {
dragaccept: null dragaccept: null
}) })
$.extend($.fn.bootstrapTable.Constructor.EVENTS, { Object.assign($.fn.bootstrapTable.events, {
'reorder-column.bs.table': 'onReorderColumn' 'reorder-column.bs.table': 'onReorderColumn'
}) })
@ -84,7 +83,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
return return
} }
this.makeRowsReorderable() this.makeColumnsReorderable()
} }
_toggleColumn (...args) { _toggleColumn (...args) {
@ -94,7 +93,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
return return
} }
this.makeRowsReorderable() this.makeColumnsReorderable()
} }
toggleView (...args) { toggleView (...args) {
@ -108,7 +107,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
return return
} }
this.makeRowsReorderable() this.makeColumnsReorderable()
} }
resetView (...args) { resetView (...args) {
@ -118,10 +117,10 @@ $.BootstrapTable = class extends $.BootstrapTable {
return return
} }
this.makeRowsReorderable() this.makeColumnsReorderable()
} }
makeRowsReorderable (order = null) { makeColumnsReorderable (order = null) {
try { try {
$(this.$el).dragtable('destroy') $(this.$el).dragtable('destroy')
} catch (e) { } catch (e) {
@ -208,6 +207,6 @@ $.BootstrapTable = class extends $.BootstrapTable {
orderColumns (order) { orderColumns (order) {
this.columnsSortOrder = order this.columnsSortOrder = order
this.makeRowsReorderable() this.makeColumnsReorderable()
} }
} }

View File

@ -1,6 +1,5 @@
/** /**
* @author: Dennis Hernández * @author: Dennis Hernández
* @webSite: http://djhvscf.github.io/Blog
* @update zhixin wen <wenzhixin2010@gmail.com> * @update zhixin wen <wenzhixin2010@gmail.com>
*/ */
@ -8,11 +7,11 @@ const rowAttr = (row, index) => ({
id: `customId_${index}` id: `customId_${index}`
}) })
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
reorderableRows: false, reorderableRows: false,
onDragStyle: null, onDragStyle: null,
onDropStyle: null, onDropStyle: null,
onDragClass: 'reorder_rows_onDragClass', onDragClass: 'reorder-rows-on-drag-class',
dragHandle: '>tbody>tr>td:not(.bs-checkbox)', dragHandle: '>tbody>tr>td:not(.bs-checkbox)',
useRowAttrFunc: false, useRowAttrFunc: false,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -26,10 +25,14 @@ $.extend($.fn.bootstrapTable.defaults, {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
onReorderRow (newData) { onReorderRow (newData) {
return false return false
},
onDragStop () {},
onAllowDrop () {
return true
} }
}) })
$.extend($.fn.bootstrapTable.Constructor.EVENTS, { Object.assign($.fn.bootstrapTable.events, {
'reorder-row.bs.table': 'onReorderRow' 'reorder-row.bs.table': 'onReorderRow'
}) })
@ -61,6 +64,8 @@ $.BootstrapTable = class extends $.BootstrapTable {
onDragStyle: this.options.onDragStyle, onDragStyle: this.options.onDragStyle,
onDropStyle: this.options.onDropStyle, onDropStyle: this.options.onDropStyle,
onDragClass: this.options.onDragClass, onDragClass: this.options.onDragClass,
onAllowDrop: (hoveredRow, draggedRow) => this.onAllowDrop(hoveredRow, draggedRow),
onDragStop: (table, draggedRow) => this.onDragStop(table, draggedRow),
onDragStart: (table, droppedRow) => this.onDropStart(table, droppedRow), onDragStart: (table, droppedRow) => this.onDropStart(table, droppedRow),
onDrop: (table, droppedRow) => this.onDrop(table, droppedRow), onDrop: (table, droppedRow) => this.onDrop(table, droppedRow),
dragHandle: this.options.dragHandle dragHandle: this.options.dragHandle
@ -74,8 +79,26 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.options.onReorderRowsDrag(this.data[this.draggingIndex]) this.options.onReorderRowsDrag(this.data[this.draggingIndex])
} }
onDragStop (table, draggedRow) {
const rowIndexDraggedRow = $(draggedRow).data('index')
const draggedRowItem = this.data[rowIndexDraggedRow]
this.options.onDragStop(table, draggedRowItem, draggedRow)
}
onAllowDrop (hoveredRow, draggedRow) {
const rowIndexDraggedRow = $(draggedRow).data('index')
const rowIndexHoveredRow = $(hoveredRow).data('index')
const draggedRowItem = this.data[rowIndexDraggedRow]
const hoveredRowItem = this.data[rowIndexHoveredRow]
return this.options.onAllowDrop(hoveredRowItem, draggedRowItem, hoveredRow, draggedRow)
}
onDrop (table) { onDrop (table) {
this.$draggingTd.css('cursor', '') this.$draggingTd.css('cursor', '')
const pageNum = this.options.pageNumber
const pageSize = this.options.pageSize
const newData = [] const newData = []
for (let i = 0; i < table.tBodies[0].rows.length; i++) { for (let i = 0; i < table.tBodies[0].rows.length; i++) {
@ -88,13 +111,17 @@ $.BootstrapTable = class extends $.BootstrapTable {
const draggingRow = this.data[this.draggingIndex] const draggingRow = this.data[this.draggingIndex]
const droppedIndex = newData.indexOf(this.data[this.draggingIndex]) const droppedIndex = newData.indexOf(this.data[this.draggingIndex])
const droppedRow = this.data[droppedIndex] const droppedRow = this.data[droppedIndex]
const index = this.options.data.indexOf(this.data[droppedIndex]) const index = (pageNum - 1) * pageSize + this.options.data.indexOf(this.data[droppedIndex])
this.options.data.splice(this.options.data.indexOf(draggingRow), 1) this.options.data.splice(this.options.data.indexOf(draggingRow), 1)
this.options.data.splice(index, 0, draggingRow) this.options.data.splice(index, 0, draggingRow)
this.initSearch() this.initSearch()
if (this.options.sidePagination === 'server') {
this.data = [...this.options.data]
}
// Call the user defined function // Call the user defined function
this.options.onReorderRowsDrop(droppedRow) this.options.onReorderRowsDrop(droppedRow)
@ -115,4 +142,4 @@ $.BootstrapTable = class extends $.BootstrapTable {
super.initSort() super.initSort()
} }
} }

View File

@ -1,6 +1,5 @@
/** /**
* @author: Dennis Hernández * @author: Dennis Hernández
* @webSite: http://djhvscf.github.io/Blog
* @version: v2.0.0 * @version: v2.0.0
*/ */
@ -30,7 +29,7 @@ const reInitResizable = that => {
initResizable(that) initResizable(that)
} }
$.extend($.fn.bootstrapTable.defaults, { Object.assign($.fn.bootstrapTable.defaults, {
resizable: false resizable: false
}) })
@ -66,4 +65,4 @@ $.BootstrapTable = class extends $.BootstrapTable {
}, 100) }, 100)
} }
} }
} }

View File

@ -1067,7 +1067,7 @@ table.rc-table-resizing thead > th > a {
} }
/** 表格行拖拽样式 **/ /** 表格行拖拽样式 **/
.reorder_rows_onDragClass td { .reorder-rows-on-drag-class td {
color:yellow!important; color:yellow!important;
background-color:#999!important; background-color:#999!important;
text-shadow:0 0 10px black,0 0 10px black,0 0 8px black,0 0 6px black,0 0 6px black; text-shadow:0 0 10px black,0 0 10px black,0 0 8px black,0 0 6px black,0 0 6px black;

View File

@ -9,7 +9,7 @@
<div class="col-sm-12 select-table table-striped"> <div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-page-size="10" <table id="bootstrap-table" data-page-size="10"
data-show-custom-view="true" data-custom-view="customViewFormatter" data-show-custom-view="true" data-custom-view="customViewFormatter"
data-show-custom-view-button="true"> data-custom-view-default-view="true">
</table> </table>
</div> </div>
</div> </div>

View File

@ -9,7 +9,7 @@
<div class="col-sm-12 select-table table-striped"> <div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-page-size="10" data-search-align="left" <table id="bootstrap-table" data-page-size="10" data-search-align="left"
data-show-custom-view="true" data-custom-view="customViewFormatter" data-show-custom-view="true" data-custom-view="customViewFormatter"
data-show-custom-view-button="true"> data-custom-view-default-view="true">
</table> </table>
</div> </div>
</div> </div>

View File

@ -9,7 +9,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.18.3}" rel="stylesheet"/> <link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=1.22.6}" 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.7.8}" rel="stylesheet"/> <link th:href="@{/ruoyi/css/ry-ui.css?v=4.7.8}" rel="stylesheet"/>
@ -22,15 +22,15 @@
<script th:src="@{/js/jquery.min.js?v=3.6.3}"></script> <script th:src="@{/js/jquery.min.js?v=3.6.3}"></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.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=1.22.6}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=1.18.3}"></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/extensions/mobile/bootstrap-table-mobile.js?v=1.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js?v=1.22.6}"></script>
<!-- jquery-validate 表单验证插件 --> <!-- jquery-validate 表单验证插件 -->
<script th:src="@{/ajax/libs/validate/jquery.validate.min.js?v=1.19.3}"></script> <script th:src="@{/ajax/libs/validate/jquery.validate.min.js?v=1.19.3}"></script>
<script th:src="@{/ajax/libs/validate/jquery.validate.extend.js?v=1.19.3}"></script> <script th:src="@{/ajax/libs/validate/jquery.validate.extend.js?v=1.19.3}"></script>
<script th:src="@{/ajax/libs/validate/messages_zh.js?v=1.19.3}"></script> <script th:src="@{/ajax/libs/validate/messages_zh.js?v=1.19.3}"></script>
<!-- bootstrap-table 表格树插件 --> <!-- bootstrap-table 表格树插件 -->
<script th:src="@{/ajax/libs/bootstrap-table/extensions/tree/bootstrap-table-tree.min.js?v=1.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/tree/bootstrap-table-tree.min.js?v=1.22.6}"></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>
@ -170,20 +170,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.18.3}"></script> <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/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.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder-columns/bootstrap-table-reorder-columns.js?v=1.22.6}"></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.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/bootstrap-table-resizable.js?v=1.22.6}"></script>
</div> </div>
<!-- 表格行内编辑插件 --> <!-- 表格行内编辑插件 -->
@ -192,31 +192,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.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-table-editable.js?v=1.22.6}"></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.18.3}"></script> <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/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.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js?v=1.22.6}"></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.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/auto-refresh/bootstrap-table-auto-refresh.js?v=1.22.6}"></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.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/print/bootstrap-table-print.js?v=1.22.6}"></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.18.3}"></script> <script th:src="@{/ajax/libs/bootstrap-table/extensions/custom-view/bootstrap-table-custom-view.js?v=1.22.6}"></script>
</div>
<!-- 表格保存状态插件 -->
<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>
</div> </div>