升级bootstrap-table到最新版本1.22.6
parent
ec6d84aa88
commit
4c9bfd8683
File diff suppressed because one or more lines are too long
|
@ -49,8 +49,8 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
<button class="auto-refresh ${this.constants.buttonsClass}
|
||||
${this.options.autoRefreshStatus ? ` ${this.constants.classes.buttonActive}` : ''}"
|
||||
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.showButtonText ? this.options.formatAutoRefresh() : ''}
|
||||
${this.options.showButtonIcons ? Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.autoRefresh) : ''}
|
||||
${this.options.showButtonText ? this.options.formatAutoRefresh() : ''}
|
||||
</button>
|
||||
`,
|
||||
event: this.toggleAutoRefresh
|
||||
|
|
|
@ -5,65 +5,81 @@
|
|||
|
||||
var Utils = $.fn.bootstrapTable.utils
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
Object.assign($.fn.bootstrapTable.defaults, {
|
||||
customView: false,
|
||||
showCustomView: false,
|
||||
showCustomViewButton: false
|
||||
customViewDefaultView: false
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults.icons, {
|
||||
customView: {
|
||||
Object.assign($.fn.bootstrapTable.defaults.icons, {
|
||||
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',
|
||||
bootstrap5: 'bi-eye',
|
||||
bootstrap4: 'fa fa-eye',
|
||||
semantic: 'fa fa-eye',
|
||||
foundation: 'fa fa-eye',
|
||||
bulma: 'fa fa-eye',
|
||||
materialize: 'remove_red_eye'
|
||||
}[$.fn.bootstrapTable.theme] || 'fa-eye'
|
||||
bootstrap5: 'bi-grid',
|
||||
bootstrap4: 'fa fa-th',
|
||||
semantic: 'fa fa-th',
|
||||
foundation: 'fa fa-th',
|
||||
bulma: 'fa fa-th',
|
||||
materialize: 'grid_on'
|
||||
}[$.fn.bootstrapTable.theme] || 'fa-th'
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
Object.assign($.fn.bootstrapTable.defaults, {
|
||||
onCustomViewPostBody () {
|
||||
return false
|
||||
},
|
||||
onCustomViewPreBody () {
|
||||
return false
|
||||
},
|
||||
onToggleCustomView () {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.locales, {
|
||||
formatToggleCustomView () {
|
||||
return 'Toggle custom view'
|
||||
Object.assign($.fn.bootstrapTable.locales, {
|
||||
formatToggleCustomViewOn () {
|
||||
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')
|
||||
|
||||
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
||||
Object.assign($.fn.bootstrapTable.events, {
|
||||
'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 {
|
||||
|
||||
init () {
|
||||
this.showCustomView = this.options.showCustomView
|
||||
this.customViewDefaultView = this.options.customViewDefaultView
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
initToolbar (...args) {
|
||||
if (this.options.customView && this.options.showCustomViewButton) {
|
||||
if (this.options.customView && this.options.showCustomView) {
|
||||
this.buttons = Object.assign(this.buttons, {
|
||||
customView: {
|
||||
text: this.options.formatToggleCustomView(),
|
||||
icon: this.options.icons.customView,
|
||||
text: this.options.customViewDefaultView ? this.options.formatToggleCustomViewOff() : this.options.formatToggleCustomViewOn(),
|
||||
icon: this.options.customViewDefaultView ? this.options.icons.customViewOn : this.options.icons.customViewOff,
|
||||
event: this.toggleCustomView,
|
||||
attributes: {
|
||||
'aria-label': this.options.formatToggleCustomView(),
|
||||
title: this.options.formatToggleCustomView()
|
||||
'aria-label': this.options.customViewDefaultView ? this.options.formatToggleCustomViewOff() : this.options.formatToggleCustomViewOn(),
|
||||
title: this.options.customViewDefaultView ? this.options.formatToggleCustomViewOff() : this.options.formatToggleCustomViewOn()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -84,7 +100,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
$table.hide()
|
||||
$customViewContainer.hide()
|
||||
if (!this.options.customView || !this.showCustomView) {
|
||||
if (!this.options.customView || !this.customViewDefaultView) {
|
||||
$table.show()
|
||||
return
|
||||
}
|
||||
|
@ -103,7 +119,17 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
}
|
||||
|
||||
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.trigger('toggle-custom-view', this.customViewDefaultView)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,28 +19,20 @@ const TYPE_NAME = {
|
|||
pdf: 'PDF'
|
||||
}
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
Object.assign($.fn.bootstrapTable.defaults, {
|
||||
showExport: false,
|
||||
exportDataType: 'basic', // basic, all, selected
|
||||
exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
|
||||
exportOptions: {
|
||||
onCellHtmlData (cell, rowIndex, colIndex, htmlData) {
|
||||
if (cell.is('th')) {
|
||||
return cell.find('.th-inner').text()
|
||||
}
|
||||
|
||||
return htmlData
|
||||
}
|
||||
},
|
||||
exportOptions: {},
|
||||
exportFooter: false
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.columnDefaults, {
|
||||
Object.assign($.fn.bootstrapTable.columnDefaults, {
|
||||
forceExport: false,
|
||||
forceHide: false
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults.icons, {
|
||||
Object.assign($.fn.bootstrapTable.defaults.icons, {
|
||||
export: {
|
||||
bootstrap3: 'glyphicon-export icon-share',
|
||||
bootstrap5: 'bi-download',
|
||||
|
@ -49,24 +41,28 @@ $.extend($.fn.bootstrapTable.defaults.icons, {
|
|||
}[$.fn.bootstrapTable.theme] || 'fa-download'
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.locales, {
|
||||
Object.assign($.fn.bootstrapTable.locales, {
|
||||
formatExport () {
|
||||
return 'Export data'
|
||||
}
|
||||
})
|
||||
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)
|
||||
Object.assign($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)
|
||||
|
||||
$.fn.bootstrapTable.methods.push('exportTable')
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
Object.assign($.fn.bootstrapTable.defaults, {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
onExportSaved (exportedRows) {
|
||||
return false
|
||||
},
|
||||
onExportStarted () {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
||||
'export-saved.bs.table': 'onExportSaved'
|
||||
Object.assign($.fn.bootstrapTable.events, {
|
||||
'export-saved.bs.table': 'onExportSaved',
|
||||
'export-started.bs.table': 'onExportStarted'
|
||||
})
|
||||
|
||||
$.BootstrapTable = class extends $.BootstrapTable {
|
||||
|
@ -84,6 +80,10 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
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')
|
||||
if (this.$export.length) {
|
||||
this.updateExportButton()
|
||||
|
@ -93,13 +93,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
this.buttons = Object.assign(this.buttons, {
|
||||
export: {
|
||||
html:
|
||||
(() => {
|
||||
() => {
|
||||
if (exportTypes.length === 1) {
|
||||
return `
|
||||
<div class="export ${this.constants.classes.buttonsDropdown}"
|
||||
data-type="${exportTypes[0]}">
|
||||
<button class="${this.constants.buttonsClass}"
|
||||
aria-label="Export"
|
||||
aria-label="${o.formatExport()}"
|
||||
type="button"
|
||||
title="${o.formatExport()}">
|
||||
${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
|
||||
|
@ -114,7 +114,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
html.push(`
|
||||
<div class="export ${this.constants.classes.buttonsDropdown}">
|
||||
<button class="${this.constants.buttonsClass} dropdown-toggle"
|
||||
aria-label="Export"
|
||||
aria-label="${o.formatExport()}"
|
||||
${this.constants.dataToggle}="dropdown"
|
||||
type="button"
|
||||
title="${o.formatExport()}">
|
||||
|
@ -136,7 +136,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
html.push(this.constants.html.toolbarDropdown[1], '</div>')
|
||||
return html.join('')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -152,19 +152,15 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
let $exportButtons = this.$export.find('[data-type]')
|
||||
|
||||
if (exportTypes.length === 1) {
|
||||
$exportButtons = this.$export.find('button')
|
||||
$exportButtons = this.$export
|
||||
}
|
||||
|
||||
$exportButtons.click(e => {
|
||||
e.preventDefault()
|
||||
|
||||
const type = $(e.currentTarget).data('type')
|
||||
const exportOptions = {
|
||||
type,
|
||||
escape: false
|
||||
}
|
||||
|
||||
this.exportTable(exportOptions)
|
||||
this.trigger('export-started')
|
||||
this.exportTable({
|
||||
type: $(e.currentTarget).data('type')
|
||||
})
|
||||
})
|
||||
this.handleToolbar()
|
||||
}
|
||||
|
@ -206,7 +202,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
o.exportOptions.ignoreColumn = [detailViewIndex].concat(o.exportOptions.ignoreColumn || [])
|
||||
}
|
||||
|
||||
if (o.exportFooter) {
|
||||
if (o.exportFooter && o.height) {
|
||||
const $footerRow = this.$tableFooter.find('tr').first()
|
||||
const footerData = {}
|
||||
const footerHtml = []
|
||||
|
@ -240,7 +236,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
options.fileName = o.exportOptions.fileName()
|
||||
}
|
||||
|
||||
this.$el.tableExport($.extend({
|
||||
this.$el.tableExport(Utils.extend({
|
||||
onAfterSaveToFile: () => {
|
||||
if (o.exportFooter) {
|
||||
this.load(data)
|
||||
|
@ -277,15 +273,17 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
this.$el.one(eventName, () => {
|
||||
setTimeout(() => {
|
||||
const data = this.getData()
|
||||
|
||||
doExport(() => {
|
||||
this.options.virtualScroll = virtualScroll
|
||||
this.togglePagination()
|
||||
})
|
||||
this.trigger('export-saved', data)
|
||||
}, 0)
|
||||
})
|
||||
this.options.virtualScroll = false
|
||||
this.togglePagination()
|
||||
this.trigger('export-saved', this.getData())
|
||||
} else if (o.exportDataType === 'selected') {
|
||||
let data = this.getData()
|
||||
let selectedData = this.getSelections()
|
||||
|
@ -334,4 +332,4 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
.prop('disabled', !this.getSelections().length)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
/**
|
||||
* @author: Dennis Hernández
|
||||
* @webSite: http://djhvscf.github.io/Blog
|
||||
* @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,
|
||||
minWidth: 562,
|
||||
minHeight: undefined,
|
||||
|
@ -108,9 +107,9 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
changeView (width, height) {
|
||||
if (this.options.minHeight) {
|
||||
if ((width <= this.options.minWidth) && (height <= this.options.minHeight)) {
|
||||
if (width <= this.options.minWidth && height <= this.options.minHeight) {
|
||||
this.conditionCardView()
|
||||
} else if ((width > this.options.minWidth) && (height > this.options.minHeight)) {
|
||||
} else if (width > this.options.minWidth && height > this.options.minHeight) {
|
||||
this.conditionFullView()
|
||||
}
|
||||
} else if (width <= this.options.minWidth) {
|
||||
|
@ -121,4 +120,4 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
this.resetView()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,76 +4,80 @@
|
|||
|
||||
var Utils = $.fn.bootstrapTable.utils
|
||||
|
||||
function printPageBuilderDefault (table) {
|
||||
function printPageBuilderDefault (table, styles) {
|
||||
return `
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css" media="print">
|
||||
@page {
|
||||
size: auto;
|
||||
margin: 25px 0 25px 0;
|
||||
}
|
||||
</style>
|
||||
<style type="text/css" media="all">
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
}
|
||||
table, th, td {
|
||||
border: 1px solid grey;
|
||||
}
|
||||
th, td {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
p {
|
||||
font-weight: bold;
|
||||
margin-left:20px;
|
||||
}
|
||||
table {
|
||||
width:94%;
|
||||
margin-left:3%;
|
||||
margin-right:3%;
|
||||
}
|
||||
div.bs-table-print {
|
||||
text-align:center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<title>Print Table</title>
|
||||
<body>
|
||||
<p>Printed on: ${new Date} </p>
|
||||
<div class="bs-table-print">${table}</div>
|
||||
</body>
|
||||
</html>`
|
||||
<html>
|
||||
<head>
|
||||
${styles}
|
||||
<style type="text/css" media="print">
|
||||
@page {
|
||||
size: auto;
|
||||
margin: 25px 0 25px 0;
|
||||
}
|
||||
</style>
|
||||
<style type="text/css" media="all">
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
}
|
||||
table, th, td {
|
||||
border: 1px solid grey;
|
||||
}
|
||||
th, td {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
p {
|
||||
font-weight: bold;
|
||||
margin-left:20px;
|
||||
}
|
||||
table {
|
||||
width: 94%;
|
||||
margin-left: 3%;
|
||||
margin-right: 3%;
|
||||
}
|
||||
div.bs-table-print {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<title>Print Table</title>
|
||||
<body>
|
||||
<p>Printed on: ${new Date} </p>
|
||||
<div class="bs-table-print">${table}</div>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
}
|
||||
|
||||
$.extend($.fn.bootstrapTable.locales, {
|
||||
Object.assign($.fn.bootstrapTable.locales, {
|
||||
formatPrint () {
|
||||
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,
|
||||
printAsFilteredAndSortedOnUI: true,
|
||||
printSortColumn: undefined,
|
||||
printSortOrder: 'asc',
|
||||
printPageBuilder (table) {
|
||||
return printPageBuilderDefault(table)
|
||||
printStyles: [],
|
||||
printPageBuilder (table, styles) {
|
||||
return printPageBuilderDefault(table, styles)
|
||||
}
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
|
||||
Object.assign($.fn.bootstrapTable.columnDefaults, {
|
||||
printFilter: undefined,
|
||||
printIgnore: false,
|
||||
printFormatter: undefined
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults.icons, {
|
||||
Object.assign($.fn.bootstrapTable.defaults.icons, {
|
||||
print: {
|
||||
bootstrap3: 'glyphicon-print icon-share',
|
||||
bootstrap5: 'bi-printer',
|
||||
'bootstrap-table': 'icon-printer'
|
||||
}[$.fn.bootstrapTable.theme] || 'fa-print'
|
||||
})
|
||||
|
@ -133,10 +137,15 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
}
|
||||
|
||||
doPrint (data) {
|
||||
const canPrint = column => {
|
||||
return !column.printIgnore && column.visible
|
||||
}
|
||||
|
||||
const formatValue = (row, i, column) => {
|
||||
const value_ = Utils.getItemField(row, column.field, this.options.escape, column.escape)
|
||||
const value = Utils.calculateObjectValue(column,
|
||||
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 ?
|
||||
this.options.undefinedText : value
|
||||
|
@ -149,7 +158,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
for (const columns of columnsArray) {
|
||||
html.push('<tr>')
|
||||
for (let h = 0; h < columns.length; h++) {
|
||||
if (!columns[h].printIgnore) {
|
||||
if (canPrint(columns[h])) {
|
||||
html.push(
|
||||
`<th
|
||||
${Utils.sprintf(' rowspan="%s"', columns[h].rowspan)}
|
||||
|
@ -162,7 +171,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
html.push('</thead><tbody>')
|
||||
|
||||
const dontRender = []
|
||||
const notRender = []
|
||||
|
||||
if (this.mergedCells) {
|
||||
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++) {
|
||||
const col = currentMergedCell.col + cs
|
||||
|
||||
dontRender.push(`${row },${ col}`)
|
||||
notRender.push(`${row},${col}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,11 +216,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
}
|
||||
|
||||
if (
|
||||
!columns[j].printIgnore && columns[j].field &&
|
||||
(
|
||||
!dontRender.includes(`${i },${ j}`) ||
|
||||
(rowspan > 0 && colspan > 0)
|
||||
)
|
||||
canPrint(columns[j]) &&
|
||||
(
|
||||
!notRender.includes(`${i},${j}`) ||
|
||||
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>')
|
||||
|
@ -221,7 +230,6 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
html.push('</tr>')
|
||||
}
|
||||
|
||||
|
@ -231,7 +239,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
for (const columns of columnsArray) {
|
||||
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 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'
|
||||
|
||||
reverse = -((+reverse) || -1)
|
||||
return data.sort((a, b) => reverse * (a[colName].localeCompare(b[colName])))
|
||||
reverse = -(+reverse || -1)
|
||||
return data.sort((a, b) => reverse * a[colName].localeCompare(b[colName]))
|
||||
}
|
||||
|
||||
const filterRow = (row, filters) => {
|
||||
|
@ -275,11 +283,30 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
data = sortRows(data, this.options.printSortColumn, this.options.printSortOrder)
|
||||
const table = buildTable(data, this.options.columns)
|
||||
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.focus()
|
||||
newWin.print()
|
||||
newWin.close()
|
||||
|
||||
if (printStyles.length) {
|
||||
const links = document.getElementsByTagName('link')
|
||||
const lastLink = links[links.length - 1]
|
||||
|
||||
lastLink.onload = startPrint
|
||||
} else {
|
||||
startPrint()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
/**
|
||||
* @author: Dennis Hernández
|
||||
* @webSite: http://djhvscf.github.io/Blog
|
||||
* @update: https://github.com/wenzhixin
|
||||
* @version: v1.2.0
|
||||
*/
|
||||
|
@ -60,7 +59,7 @@ const filterFn = () => {
|
|||
}
|
||||
}
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
Object.assign($.fn.bootstrapTable.defaults, {
|
||||
reorderableColumns: false,
|
||||
maxMovingRows: 10,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
@ -70,7 +69,7 @@ $.extend($.fn.bootstrapTable.defaults, {
|
|||
dragaccept: null
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
||||
Object.assign($.fn.bootstrapTable.events, {
|
||||
'reorder-column.bs.table': 'onReorderColumn'
|
||||
})
|
||||
|
||||
|
@ -84,7 +83,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
return
|
||||
}
|
||||
|
||||
this.makeRowsReorderable()
|
||||
this.makeColumnsReorderable()
|
||||
}
|
||||
|
||||
_toggleColumn (...args) {
|
||||
|
@ -94,7 +93,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
return
|
||||
}
|
||||
|
||||
this.makeRowsReorderable()
|
||||
this.makeColumnsReorderable()
|
||||
}
|
||||
|
||||
toggleView (...args) {
|
||||
|
@ -108,7 +107,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
return
|
||||
}
|
||||
|
||||
this.makeRowsReorderable()
|
||||
this.makeColumnsReorderable()
|
||||
}
|
||||
|
||||
resetView (...args) {
|
||||
|
@ -118,10 +117,10 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
return
|
||||
}
|
||||
|
||||
this.makeRowsReorderable()
|
||||
this.makeColumnsReorderable()
|
||||
}
|
||||
|
||||
makeRowsReorderable (order = null) {
|
||||
makeColumnsReorderable (order = null) {
|
||||
try {
|
||||
$(this.$el).dragtable('destroy')
|
||||
} catch (e) {
|
||||
|
@ -208,6 +207,6 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
orderColumns (order) {
|
||||
this.columnsSortOrder = order
|
||||
this.makeRowsReorderable()
|
||||
this.makeColumnsReorderable()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
/**
|
||||
* @author: Dennis Hernández
|
||||
* @webSite: http://djhvscf.github.io/Blog
|
||||
* @update zhixin wen <wenzhixin2010@gmail.com>
|
||||
*/
|
||||
|
||||
|
@ -8,11 +7,11 @@ const rowAttr = (row, index) => ({
|
|||
id: `customId_${index}`
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
Object.assign($.fn.bootstrapTable.defaults, {
|
||||
reorderableRows: false,
|
||||
onDragStyle: null,
|
||||
onDropStyle: null,
|
||||
onDragClass: 'reorder_rows_onDragClass',
|
||||
onDragClass: 'reorder-rows-on-drag-class',
|
||||
dragHandle: '>tbody>tr>td:not(.bs-checkbox)',
|
||||
useRowAttrFunc: false,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
@ -26,10 +25,14 @@ $.extend($.fn.bootstrapTable.defaults, {
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
onReorderRow (newData) {
|
||||
return false
|
||||
},
|
||||
onDragStop () {},
|
||||
onAllowDrop () {
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
||||
Object.assign($.fn.bootstrapTable.events, {
|
||||
'reorder-row.bs.table': 'onReorderRow'
|
||||
})
|
||||
|
||||
|
@ -61,6 +64,8 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
onDragStyle: this.options.onDragStyle,
|
||||
onDropStyle: this.options.onDropStyle,
|
||||
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),
|
||||
onDrop: (table, droppedRow) => this.onDrop(table, droppedRow),
|
||||
dragHandle: this.options.dragHandle
|
||||
|
@ -74,8 +79,26 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
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) {
|
||||
this.$draggingTd.css('cursor', '')
|
||||
const pageNum = this.options.pageNumber
|
||||
const pageSize = this.options.pageSize
|
||||
const newData = []
|
||||
|
||||
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 droppedIndex = newData.indexOf(this.data[this.draggingIndex])
|
||||
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(index, 0, draggingRow)
|
||||
|
||||
this.initSearch()
|
||||
|
||||
if (this.options.sidePagination === 'server') {
|
||||
this.data = [...this.options.data]
|
||||
}
|
||||
|
||||
// Call the user defined function
|
||||
this.options.onReorderRowsDrop(droppedRow)
|
||||
|
||||
|
@ -115,4 +142,4 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
|
||||
super.initSort()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
/**
|
||||
* @author: Dennis Hernández
|
||||
* @webSite: http://djhvscf.github.io/Blog
|
||||
* @version: v2.0.0
|
||||
*/
|
||||
|
||||
|
@ -30,7 +29,7 @@ const reInitResizable = that => {
|
|||
initResizable(that)
|
||||
}
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
Object.assign($.fn.bootstrapTable.defaults, {
|
||||
resizable: false
|
||||
})
|
||||
|
||||
|
@ -66,4 +65,4 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|||
}, 100)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1067,7 +1067,7 @@ table.rc-table-resizing thead > th > a {
|
|||
}
|
||||
|
||||
/** 表格行拖拽样式 **/
|
||||
.reorder_rows_onDragClass td {
|
||||
.reorder-rows-on-drag-class td {
|
||||
color:yellow!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;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table" data-page-size="10"
|
||||
data-show-custom-view="true" data-custom-view="customViewFormatter"
|
||||
data-show-custom-view-button="true">
|
||||
data-custom-view-default-view="true">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<div class="col-sm-12 select-table table-striped">
|
||||
<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-button="true">
|
||||
data-custom-view-default-view="true">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<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"/>
|
||||
<!-- 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/style.min.css?v=20210831}" 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/bootstrap.min.js?v=3.3.7}"></script>
|
||||
<!-- 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/locale/bootstrap-table-zh-CN.min.js?v=1.18.3}"></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/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.22.6}"></script>
|
||||
<script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js?v=1.22.6}"></script>
|
||||
<!-- 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.extend.js?v=1.19.3}"></script>
|
||||
<script th:src="@{/ajax/libs/validate/messages_zh.js?v=1.19.3}"></script>
|
||||
<!-- 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/iCheck/icheck.min.js?v=1.0.3}"></script>
|
||||
|
@ -170,20 +170,20 @@
|
|||
|
||||
<!-- 表格行拖拽插件 -->
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<!-- 表格列拖拽插件 -->
|
||||
<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/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 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/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>
|
||||
|
||||
<!-- 表格行内编辑插件 -->
|
||||
|
@ -192,31 +192,36 @@
|
|||
</div>
|
||||
<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-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 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>
|
||||
</div>
|
||||
|
||||
<!-- 表格冻结列插件 -->
|
||||
<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 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 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 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>
|
||||
|
|
Loading…
Reference in New Issue