2021-10-09 16:47:38 +08:00
|
|
|
export default {
|
|
|
|
|
props: {},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
detailType: 'list',
|
2021-10-11 14:05:07 +08:00
|
|
|
detailViewRightObj: '',
|
2021-10-12 16:53:59 +08:00
|
|
|
detailViewLoading: false,
|
|
|
|
|
detailTimer: ''
|
2021-10-09 16:47:38 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-10-11 14:05:07 +08:00
|
|
|
created () {
|
|
|
|
|
this.detailType = localStorage.getItem('detail-view-' + this.tableId) || 'list'
|
|
|
|
|
},
|
2021-10-09 16:47:38 +08:00
|
|
|
methods: {
|
|
|
|
|
changeDetailType (flag) {
|
|
|
|
|
if (this.detailType === flag) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.detailType = flag
|
2021-10-11 14:05:07 +08:00
|
|
|
localStorage.setItem('detail-view-' + this.tableId, this.detailType)
|
2021-10-09 16:47:38 +08:00
|
|
|
this.pageObj.pageNo = 1
|
2021-10-11 14:05:07 +08:00
|
|
|
this.detailViewLoading = true
|
2021-10-09 16:47:38 +08:00
|
|
|
if (flag === 'list') {
|
2021-10-11 14:05:07 +08:00
|
|
|
this.searchLabel = {}
|
|
|
|
|
this.searchCheckBox = {}
|
2021-10-09 16:47:38 +08:00
|
|
|
this.getTableData()
|
|
|
|
|
} else {
|
|
|
|
|
this.getDetail()
|
|
|
|
|
}
|
2021-10-11 14:05:07 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
|
this.detailViewLoading = false
|
2021-10-11 16:12:09 +08:00
|
|
|
this.$refs.clickSearch && this.$refs.clickSearch.needMore()
|
2021-10-11 14:05:07 +08:00
|
|
|
}, 100)
|
2021-10-09 16:47:38 +08:00
|
|
|
},
|
2021-10-12 16:53:59 +08:00
|
|
|
searchDetail (searchObj) {
|
|
|
|
|
this.searchLabel = {}
|
|
|
|
|
this.pageObj.pageNo = 1
|
|
|
|
|
for (const item in searchObj) {
|
|
|
|
|
if (typeof searchObj[item] !== 'undefined' && searchObj[item] !== null && searchObj[item] !== '') {
|
|
|
|
|
this.$set(this.searchLabel, item, searchObj[item])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (this.searchDetailObj) {
|
|
|
|
|
for (const item in this.searchDetailObj) {
|
|
|
|
|
if (typeof this.searchDetailObj[item] !== 'undefined' && this.searchDetailObj[item] !== null && this.searchDetailObj[item] !== '') {
|
|
|
|
|
if (this.searchDetailObj[item].join(',') !== '') {
|
|
|
|
|
this.$set(this.searchLabel, item, this.searchDetailObj[item].join(','))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (this.$refs.dataTable) {
|
|
|
|
|
this.$refs.dataTable.$refs.dataTable.bodyWrapper.scrollTop = 0
|
|
|
|
|
}
|
2021-10-09 16:47:38 +08:00
|
|
|
this.getDetail()
|
|
|
|
|
},
|
2021-10-12 16:53:59 +08:00
|
|
|
searchDetailTop () {
|
|
|
|
|
if (!this.detailTimer) {
|
|
|
|
|
this.detailTimer = setTimeout(() => {
|
|
|
|
|
this.searchDetail()
|
|
|
|
|
clearTimeout(this.detailTimer)
|
|
|
|
|
this.detailTimer = ''
|
|
|
|
|
}, 1000)
|
|
|
|
|
} else {
|
|
|
|
|
clearTimeout(this.detailTimer)
|
|
|
|
|
this.detailTimer = setTimeout(() => {
|
|
|
|
|
this.searchDetail()
|
|
|
|
|
clearTimeout(this.detailTimer)
|
|
|
|
|
this.detailTimer = ''
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-10-09 16:47:38 +08:00
|
|
|
getDetail () {
|
|
|
|
|
const params = {
|
|
|
|
|
pageNo: this.pageObj.pageNo,
|
2021-10-11 14:05:07 +08:00
|
|
|
pageSize: this.pageObj.pageSize
|
2021-10-09 16:47:38 +08:00
|
|
|
}
|
|
|
|
|
this.tools.loading = true
|
2021-10-12 16:53:59 +08:00
|
|
|
this.$get(this.url, { ...this.searchLabel, ...params }).then(response => {
|
2021-10-09 16:47:38 +08:00
|
|
|
this.tools.loading = false
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.tableData = response.data.list
|
|
|
|
|
this.detailViewRightObj = this.tableData[0]
|
|
|
|
|
this.pageObj.total = response.data.total
|
|
|
|
|
this.pageObj.pages = response.data.pages
|
|
|
|
|
if (!this.scrollbarWrap) {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.scrollbarWrap = this.$refs.dataTable.$refs.dataTable.bodyWrapper
|
|
|
|
|
this.toTopBtnHandler(this.scrollbarWrap)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
detailViewRightShow (item) {
|
|
|
|
|
this.detailViewRightObj = item
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|