[update] 修改检索历史
This commit is contained in:
@@ -10,19 +10,21 @@
|
||||
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<template v-if="model && Object.keys(model).length > 0">
|
||||
<div v-for="(item, key) in model" :key="key" class="content-wrapper" ref="contentWrapper" @scroll="contentWrapperScroll">
|
||||
<p class="time-p">{{ isCurrentDate(key) ? '最近' : key }}</p>
|
||||
<div class="content-wrapper" ref="contentWrapper" @scroll="contentWrapperScroll">
|
||||
<a-checkbox-group @change="onCheckChange">
|
||||
<div v-for="arrItem in item" :key="arrItem.id" class="search-value-div">
|
||||
<a-checkbox :value="arrItem.id"></a-checkbox>
|
||||
<a-tooltip>
|
||||
<template #title>
|
||||
{{ arrItem.searchContent }}
|
||||
</template>
|
||||
<p>{{ arrItem.searchContent }}</p>
|
||||
</a-tooltip>
|
||||
<i class="iconfont icon-shanchu_" @click="handleDelete(arrItem.id)"></i>
|
||||
</div>
|
||||
<template v-for="(item, key) in model">
|
||||
<p :key="key" class="time-p">{{ isCurrentDate(key) ? '最近' : key }}</p>
|
||||
<div v-for="arrItem in item" :key="arrItem.id" class="search-value-div">
|
||||
<a-checkbox :value="arrItem.id"></a-checkbox>
|
||||
<a-tooltip>
|
||||
<template #title>
|
||||
{{ arrItem.searchContent }}
|
||||
</template>
|
||||
<p>{{ arrItem.searchContent }}</p>
|
||||
</a-tooltip>
|
||||
<i class="iconfont icon-shanchu_" @click="handleDelete(arrItem.id)"></i>
|
||||
</div>
|
||||
</template>
|
||||
</a-checkbox-group>
|
||||
</div>
|
||||
<!--<div class="record-item" v-for="record in recordList" :key="record.id">-->
|
||||
@@ -68,7 +70,7 @@ export default {
|
||||
open () {
|
||||
this.page = {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
pageSize: 100,
|
||||
total: 0,
|
||||
pages: 0
|
||||
}
|
||||
@@ -89,7 +91,7 @@ export default {
|
||||
},
|
||||
// 内容展示区域滚动事件
|
||||
contentWrapperScroll () {
|
||||
const contentWrapper = this.$refs.contentWrapper[0]
|
||||
const contentWrapper = this.$refs.contentWrapper
|
||||
// 滚动条触底,并且还不是最后一页时获取下一页
|
||||
if (contentWrapper.scrollTop + contentWrapper.clientHeight === contentWrapper.scrollHeight && this.page.pageNo < this.page.pages) {
|
||||
this.page.pageNo++
|
||||
@@ -97,7 +99,10 @@ export default {
|
||||
}
|
||||
},
|
||||
// 获取列表数据
|
||||
initData () {
|
||||
initData (arg) {
|
||||
if (arg === 1) {
|
||||
this.page.pageNo = 1
|
||||
}
|
||||
const param = {}
|
||||
param.pageNo = this.page.pageNo
|
||||
param.pageSize = this.page.pageSize
|
||||
@@ -124,18 +129,6 @@ export default {
|
||||
this.confirmLoading = false
|
||||
})
|
||||
},
|
||||
// 重新计算分页
|
||||
reCalculatePage (count) {
|
||||
// 总数量-count
|
||||
const total = this.page.total - count
|
||||
// 获取删除后的分页数
|
||||
const currentIndex = Math.ceil(total / this.page.pageSize)
|
||||
// 删除后的分页数<所在当前页
|
||||
if (currentIndex < this.page.pageNo) {
|
||||
this.page.current = currentIndex
|
||||
}
|
||||
console.log('currentIndex', currentIndex)
|
||||
},
|
||||
// 多选变化
|
||||
onCheckChange (checkedValue) {
|
||||
this.checkedArr = checkedValue
|
||||
@@ -146,10 +139,12 @@ export default {
|
||||
if (res.success) {
|
||||
this.$message.success(res.message)
|
||||
// 判断当前删除的数据是否是最后一页的最后一条数据,如果是的话页码减一
|
||||
if (this.page.pageNo > 1 && ((this.page.pageNo - 1) * this.page.pageSize) + 1 === this.page.total) {
|
||||
this.page.pageNo -= 1
|
||||
}
|
||||
this.initData()
|
||||
// if (this.page.pageNo > 1 && ((this.page.pageNo - 1) * this.page.pageSize) + 1 === this.page.total) {
|
||||
// this.page.pageNo -= 1
|
||||
// }
|
||||
this.model = {}
|
||||
this.dataList = []
|
||||
this.initData(1)
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
}
|
||||
@@ -157,12 +152,13 @@ export default {
|
||||
},
|
||||
// 批量删除
|
||||
handleBatchDel () {
|
||||
batchDeleteSearchHistory({ ids: this.checkedArr.join(',') }).then(res => {
|
||||
batchDeleteSearchHistory({ id: this.checkedArr.join(',') }).then(res => {
|
||||
if (res.success) {
|
||||
this.reCalculatePage(this.checkedArr.length)
|
||||
this.$message.success(res.message)
|
||||
this.checkedArr = []
|
||||
this.initData()
|
||||
this.model = {}
|
||||
this.dataList = []
|
||||
this.initData(1)
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
}
|
||||
@@ -186,6 +182,7 @@ export default {
|
||||
overflow-y: auto;
|
||||
}
|
||||
.time-p {
|
||||
margin: 10px 0;
|
||||
color: @primary-color;
|
||||
}
|
||||
/deep/ .ant-checkbox-group {
|
||||
|
||||
Reference in New Issue
Block a user