Commit 4fe9392f by 前端

修复分页BUG

1 parent 607bca32
...@@ -29,30 +29,7 @@ ...@@ -29,30 +29,7 @@
:loading="$store.state.d2admin.loading.value">下一步</el-button> :loading="$store.state.d2admin.loading.value">下一步</el-button>
</div> </div>
</div> </div>
<!-- <div class="header"
slot="header">
<d2-search ref="showSearch"
class="show-search"
:search-form="searchForm"
:label-width="labelWidth"
:form-data="showFormData">
</d2-search>
<div class="up-btns">
<el-button @click="handleSearch"
size="small"
type="primary">
查询
</el-button>
<el-button size="small"
@click="handleReset">
重置
</el-button>
</div>
</div> -->
<div class="d2-container-content"> <div class="d2-container-content">
<!-- <d2-table-header>
<auth-button category="Button" />
</d2-table-header> -->
<d2-search ref="showSearch" <d2-search ref="showSearch"
class="show-search" class="show-search"
:search-form="searchForm" :search-form="searchForm"
...@@ -154,7 +131,7 @@ ...@@ -154,7 +131,7 @@
import { Util, deepClone } from '@/common/util' import { Util, deepClone } from '@/common/util'
import { mapActions, mapState, mapMutations } from 'vuex' import { mapActions, mapState, mapMutations } from 'vuex'
import { cdSignOpt, receiptStatusOpt, associationOpt } from '@/common/constants.js' import { cdSignOpt, receiptStatusOpt, associationOpt } from '@/common/constants.js'
import { receiptImport, association, saveAssociation } from '@api/theAssetData' import { receiptImport, association, saveAssociation, getImportTask } from '@api/theAssetData'
export default { export default {
name: 'ImportTwo', name: 'ImportTwo',
props: { props: {
...@@ -186,14 +163,20 @@ export default { ...@@ -186,14 +163,20 @@ export default {
changeAttr: (value, targetItem) => { changeAttr: (value, targetItem) => {
console.log("value", value) console.log("value", value)
console.log("this.allData", this.allData) console.log("this.allData", this.allData)
if (['', null].includes(value)) {
this.filterData = null
} else {
if (value == 0) { if (value == 0) {
this.tableData = this.allData.filter(item => !item.receipt) this.tableData = this.allData.filter(item => !item.receipt)
this.filterData = this.allData.filter(item => !item.receipt)
} else if (value == 1) { } else if (value == 1) {
this.tableData = this.allData.filter(item => item.receipt) this.tableData = this.allData.filter(item => item.receipt)
this.filterData = this.allData.filter(item => item.receipt)
}
} }
console.log("this.tableData", this.tableData) console.log("this.tableData", this.tableData)
// this.total = this.tableData.length this.page.currentPage = 1
this.paginatedData(this.tableData) // 重新计算分页数据 this.paginatedData() // 重新计算分页数据
} }
}], }],
// getListApi: nbcbAccDetailPage, // getListApi: nbcbAccDetailPage,
...@@ -319,7 +302,7 @@ export default { ...@@ -319,7 +302,7 @@ export default {
receiptCount: 0, receiptCount: 0,
allData: [], // 从后端获取的所有数据 allData: [], // 从后端获取的所有数据
tableData: [], // 当前展示的数据 tableData: [], // 当前展示的数据
// tableData_filter: [], // 当前展示的数据备份,用来筛选 filterData: [], // 当前筛选的数据
currentRow: null, currentRow: null,
total: 0, total: 0,
page: { page: {
...@@ -336,7 +319,7 @@ export default { ...@@ -336,7 +319,7 @@ export default {
mounted() { mounted() {
console.log('taskInfo', this.taskInfo) console.log('taskInfo', this.taskInfo)
this.getBaseData() this.getBaseData()
this.association() this.getImportTask()
}, },
methods: { methods: {
...@@ -371,33 +354,46 @@ export default { ...@@ -371,33 +354,46 @@ export default {
}) })
}, },
getImportTask() {
getImportTask({ taskId: this.taskInfo.taskId }).then(res => {
if (res) {
if (res.taskStatus == 3) { // 任务过期
this.$message({
message: "当前任务已过期,请重新导入",
type: "warning",
showClose: true
})
} else {
this.association()
}
}
})
},
association() { association() {
association({ taskId: this.taskInfo.taskId }).then(res => { association({ taskId: this.taskInfo.taskId }).then(res => {
this.allData = deepClone(res) this.allData = deepClone(res)
// this.tableData = deepClone(res)
// this.tableData_filter = deepClone(res) // 用来筛选数据的备份
this.paginatedData() this.paginatedData()
this.statReceiptCount(res) this.statReceiptCount(res)
}) })
}, },
// 前端处理数据分页 // 前端处理数据分页
paginatedData(filterData) { paginatedData() {
this.total = this.allData.length console.log('filterData', this.filterData)
// this.total = this.tableData.length
// this.tableData_filter = deepClone(this.tableData) // 用来筛选数据的备份
const start = (this.page.currentPage - 1) * this.page.pageSize const start = (this.page.currentPage - 1) * this.page.pageSize
const end = start + this.page.pageSize const end = start + this.page.pageSize
if (filterData) { if (this.filterData && this.filterData.length > 0) { // 筛选时以筛选的数据进行分页
this.tableData = filterData.slice(start, end) this.tableData = this.filterData.slice(start, end)
this.total = this.filterData.length
} else { } else {
this.tableData = this.allData.slice(start, end) this.tableData = this.allData.slice(start, end)
this.total = this.allData.length
} }
console.log('start', start) console.log('start', start)
console.log('end', end) console.log('end', end)
console.log('this.tableData', this.tableData) console.log('this.tableData', this.tableData)
return this.tableData return this.tableData
// return this.tableData.slice(start, end)
}, },
// 统计回单关联数 // 统计回单关联数
...@@ -412,7 +408,6 @@ export default { ...@@ -412,7 +408,6 @@ export default {
}, },
handleCurrentChange(newPage) { handleCurrentChange(newPage) {
console.log('newPage', newPage)
this.page.currentPage = newPage // 更新当前页码,触发计算属性重新计算paginatedData this.page.currentPage = newPage // 更新当前页码,触发计算属性重新计算paginatedData
this.paginatedData() // 重新计算分页数据 this.paginatedData() // 重新计算分页数据
}, },
...@@ -428,16 +423,13 @@ export default { ...@@ -428,16 +423,13 @@ export default {
type: 'warning', type: 'warning',
closeOnClickModal: false closeOnClickModal: false
}).then(() => { }).then(() => {
console.log('row', row)
// 删除展示数组中对应的数据 // 删除展示数组中对应的数据
const index = this.tableData.findIndex(item => item == row) const index = this.tableData.findIndex(item => item == row)
console.log('index', index)
if (index !== -1) { if (index !== -1) {
this.tableData.splice(index, 1) this.tableData.splice(index, 1)
} }
// 删除原始数组中对应的数据 // 删除原始数组中对应的数据
const index2 = this.allData.findIndex(item2 => item2 == row) const index2 = this.allData.findIndex(item2 => item2 == row)
console.log('index2', index2)
if (index2 !== -1) { if (index2 !== -1) {
this.allData.splice(index2, 1) this.allData.splice(index2, 1)
} }
...@@ -584,7 +576,6 @@ export default { ...@@ -584,7 +576,6 @@ export default {
*/ */
downLoadFile: function (url) { downLoadFile: function (url) {
const Temp = document.createElement("a") const Temp = document.createElement("a")
// url = url + `${url.includes('?') ? '&' : '?'}` + "timestamp=" + new Date().getTime()
Temp.href = url Temp.href = url
document.body.append(Temp) document.body.append(Temp)
Temp.click() Temp.click()
......
...@@ -481,7 +481,6 @@ export default { ...@@ -481,7 +481,6 @@ export default {
watch: { watch: {
taskStatus: { taskStatus: {
handler(newVal) { handler(newVal) {
console.log('newVal', newVal)
if (newVal == 1 || newVal == 2 || newVal == 3) { // 任务失败、成功、过期时,应该停止轮询 if (newVal == 1 || newVal == 2 || newVal == 3) { // 任务失败、成功、过期时,应该停止轮询
this.stopPolling() this.stopPolling()
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!