【更新】s-table问题修复,同时修改斑马纹的是否显示由开关变为选择框更美观

pull/56/head
小诺 2 years ago committed by 俞宝山
parent 07f5caf73b
commit 3817434d74

@ -13,10 +13,8 @@
data() {
return {
needTotalList: [],
selectedRows: [],
selectedRowKeys: [],
localLoading: false,
localDataSource: [],
localPagination: Object.assign({}, this.pagination),
@ -44,7 +42,7 @@
default: 1
},
size: {
// type: Number,
type: String,
default: '10'
},
showSizeChanger: {
@ -140,7 +138,7 @@
size: this.size, //this.compSize, size//
showSizeChanger: this.showSizeChanger,
showTotal: (total, range) => {
return `${range[0]}-${range[1]}${total}`
return `${range[0]}-${range[1]} ${total} `
}
})) ||
false
@ -155,14 +153,9 @@
* @param bool Boolean
*/
refresh(bool = false) {
bool &&
(this.localPagination = Object.assign(
{},
{
current: 1,
size: this.size
}
))
bool && (this.localPagination = Object.assign({}, {
current: 1, size: this.size
}))
this.loadData()
},
/**
@ -173,30 +166,22 @@
*/
loadData(pagination, filters, sorter) {
this.localLoading = true
const parameter = Object.assign(
{
current:
(pagination && pagination.current) ||
(this.showPagination && this.localPagination.current) ||
this.pageNum,
size: (pagination && pagination.pageSize) || (this.showPagination && this.localPagination.size) || this.size
const parameter = Object.assign({
current: (pagination && pagination.current) ||
this.showPagination && this.localPagination.current || this.pageNum,
size: (pagination && pagination.pageSize) ||
this.showPagination && this.localPagination.pageSize || this.pageSize
},
(sorter &&
sorter.field && {
sortField: sorter.field
}) ||
{},
(sorter &&
sorter.order && {
sortOrder: sorter.order
}) ||
{},
{
(sorter && sorter.field && {
sortField: sorter.field
}) || {},
(sorter && sorter.order && {
sortOrder: sorter.order
}) || {}, {
...filters
}
)
const result = this.data(parameter)
// r.current, r.totalCount, r.data
// eslint-disable-next-line
if (
(typeof result === 'object' || typeof result === 'function') &&
@ -213,6 +198,9 @@
current: r.current, // pageNo, //
total: r.total, // totalRows, //
showSizeChanger: this.showSizeChanger,
showTotal: (total, range) => {
return `${range[0]}-${range[1]}${total}`
},
size: (pagination && pagination.size) || this.localPagination.size
})) ||
false
@ -226,23 +214,21 @@
this.loadData()
return
}
// r.totalCount(total) this.showPagination = true current size totalCount current * size
// table
try {
if (['auto', true].includes(this.showPagination) && r.total <= r.pages * this.localPagination.size) {
/*
if ((['auto', true].includes(this.showPagination) && r.total <= (r.pages * this.localPagination.size))) {
this.localPagination.hideOnSinglePage = true
}
*/
if (!this.showPagination) {
this.localPagination.hideOnSinglePage = true
}
} catch (e) {
this.localPagination = false
}
//
if (this.showPagination === false) {
// datadata
this.localDataSource = r
} else {
this.localDataSource = r.records
}
this.localDataSource = r.records
this.localLoading = false
})
}
@ -321,7 +307,7 @@
const needTotalItems = this.needTotalList.map((item) => {
return (
<span className="mr-3">
{item.title}总计{' '}
{item.title} 总计 {' '}
<a className="font-6">{!item.customRender ? item.total : item.customRender(item.total)}</a>
</span>
)
@ -400,24 +386,23 @@
}
//
const changeRowClass = (val) => {
const changeRowClass = (value) => {
const val = value.target.checked
this.localSettings.rowClassNameSwitch = val
const evenClass = val ? (_record, index) => (index % 2 === 1 ? 'table-striped' : null) : this.rowClassName
this.localSettings.rowClassName = evenClass
}
return (
<div className="s-table-tool">
<div className="s-table-tool-left">{this.$slots.operator && this.$slots.operator()}</div>
<div className="layout-items-center s-table-tool-right">
{this.toolConfig.striped ? (
<div className="layout-items-center ml-4">
<span>斑马线</span>
<a-switch
<a-checkbox
checked={this.localSettings.rowClassNameSwitch}
onChange={changeRowClass}
className="ml-2"
/>
>斑马纹
</a-checkbox>
</div>
) : null}
@ -430,7 +415,6 @@
{tool.icon}
</a-tooltip>
)
if (tool.isPopover) {
return (
<a-popover

Loading…
Cancel
Save