Commit 18451f49 by 李伟康

增加分页

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