Commit 18451f49 by 李伟康

增加分页

1 parent fefea6c9
...@@ -62,10 +62,13 @@ ...@@ -62,10 +62,13 @@
</template> </template>
<div class="table-box"> <div class="table-box">
<GLTable <GLTable
:tableData="importObject.detailList" :tableData="importObject.detailList[pageNum - 1]"
:tableParams="tableParams" :tableParams="tableParams"
:hasPage="false"
ref="listRef" ref="listRef"
:pageConf="pageConf"
:tableTotal="totalForm.customerTotal"
:pageSizes="[50]"
@refreshTable="refreshTable"
> >
<template <template
slot="cashBackValue" slot="cashBackValue"
...@@ -254,14 +257,17 @@ export default { ...@@ -254,14 +257,17 @@ export default {
return { return {
NP, NP,
loading: false, loading: false,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
rule: { rule: {
table: [{ table: [{
required: true, trigger: 'change', validator: (rule, value, callback) => { required: true, trigger: 'change', validator: (rule, value, callback) => {
const { detailList } = this.importObject const { detailList } = this.importObject
if (detailList && detailList.length) { if (detailList && detailList.length) {
detailList.map(e => { detailList.map(i => {
i.map(e => {
if (e.cashBackValue < 1 && e.buyValue < 1) callback(new Error('返现金额和商品兑换积分二者至少需填写一个正整数的数值')) if (e.cashBackValue < 1 && e.buyValue < 1) callback(new Error('返现金额和商品兑换积分二者至少需填写一个正整数的数值'))
}) })
})
callback() callback()
} else callback(new Error('请导入充值人群')) } else callback(new Error('请导入充值人群'))
} }
...@@ -395,7 +401,8 @@ export default { ...@@ -395,7 +401,8 @@ export default {
chargeObject: { chargeObject: {
gasCardServiceCharge: 0, gasCardServiceCharge: 0,
passageServiceCharge: 0 passageServiceCharge: 0
} },
pageNum: 1
} }
}, },
mounted () { mounted () {
...@@ -404,6 +411,9 @@ export default { ...@@ -404,6 +411,9 @@ export default {
else this.getMerchantCharge() else this.getMerchantCharge()
}, },
methods: { methods: {
refreshTable ({ pageNum }) {
this.pageNum = pageNum
},
async getDetail (id, type) { async getDetail (id, type) {
try { try {
this.loading = true this.loading = true
...@@ -429,10 +439,12 @@ export default { ...@@ -429,10 +439,12 @@ export default {
status: res.status status: res.status
} }
this.totalForm.customerTotal = detailList.length this.totalForm.customerTotal = detailList.length
const list = this.splitArray(detailList, 50)
this.importObject = { this.importObject = {
detailList detailList: list
} }
this.loading = false this.loading = false
this.pageNum = 1
this.setTableHeight(detailList) this.setTableHeight(detailList)
} catch (error) { } catch (error) {
this.loading = false this.loading = false
...@@ -449,7 +461,8 @@ export default { ...@@ -449,7 +461,8 @@ export default {
const { merchantId, merchantName } = this.configForm, const { merchantId, merchantName } = this.configForm,
list = this.importObject.detailList list = this.importObject.detailList
let detailList = [] let detailList = []
list.map(e => { list.map(i => {
i.map(e => {
let oilList = [], couponList = [] let oilList = [], couponList = []
e.oilList?.map(o => { e.oilList?.map(o => {
oilList.push({ oilList.push({
...@@ -477,6 +490,7 @@ export default { ...@@ -477,6 +490,7 @@ export default {
couponList couponList
}) })
}) })
})
let params = { let params = {
merchantId, merchantId,
merchantName, merchantName,
...@@ -524,8 +538,9 @@ export default { ...@@ -524,8 +538,9 @@ export default {
detailList.map((row, index) => { detailList.map((row, index) => {
this.updateTotal(row, index) this.updateTotal(row, index)
}) })
const list = this.splitArray(detailList, 50)
this.importObject = { this.importObject = {
detailList, detailList: list,
name: file.name name: file.name
} }
this.$message({ this.$message({
...@@ -533,6 +548,7 @@ export default { ...@@ -533,6 +548,7 @@ export default {
type: 'success' type: 'success'
}) })
this.totalForm.customerTotal = detailList.length this.totalForm.customerTotal = detailList.length
this.pageNum = 1
this.validateField('table') this.validateField('table')
this.setTableHeight(detailList) this.setTableHeight(detailList)
} else this.importObj = { } else this.importObj = {
...@@ -551,12 +567,10 @@ export default { ...@@ -551,12 +567,10 @@ export default {
} }
}, },
setTableHeight (detailList = []) { setTableHeight (detailList = []) {
const { listRef } = this.$refs, const { listRef } = this.$refs
{ id } = this.pageObject,
height = id ? 56 : 67.39
if (listRef) { if (listRef) {
let length = detailList.length let length = detailList.length
listRef.tableHeightValues = `${(length > 10 ? 10 : length) * height + 56}px` listRef.tableHeightValues = `${(length > 10 ? 10 : length) * 56 + 56}px`
} else setTimeout(() => { } else setTimeout(() => {
this.setTableHeight(detailList) this.setTableHeight(detailList)
}, 100) }, 100)
...@@ -660,6 +674,14 @@ export default { ...@@ -660,6 +674,14 @@ export default {
return name == 'oilList' ? `${i.aliasName}*${i.amount} (${NP.times(i.amount, i.faceValue)}积分)` : `${i.couponName}*${i.amount}` return name == 'oilList' ? `${i.aliasName}*${i.amount} (${NP.times(i.amount, i.faceValue)}积分)` : `${i.couponName}*${i.amount}`
}) || [] }) || []
}, },
splitArray (arr, size) {
let result = [],
newArr = JSON.parse(JSON.stringify(arr))
for (let i = 0; i < newArr.length; i += size) {
result.push(newArr.slice(i, i + size))
}
return result
}
} }
} }
</script> </script>
...@@ -810,4 +832,13 @@ export default { ...@@ -810,4 +832,13 @@ export default {
color: #5850ff; color: #5850ff;
cursor: pointer; cursor: pointer;
} }
/deep/.el-pagination__sizes {
width: 88px;
.el-select {
width: 100%;
.el-input {
width: 100%;
}
}
}
</style> </style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!