修复退款失败的问题

修复商品选择优惠券可能出错的问题
This commit is contained in:
stivepeim
2021-01-11 16:22:39 +08:00
parent 590fec398e
commit 89fbecbcee
4 changed files with 202 additions and 215 deletions

View File

@@ -91,178 +91,178 @@
</template>
<script>
import { marketingListApi, couponUserApi } from '@/api/marketing'
export default {
name: 'CouponList',
props: {
handle: {
type: String,
default: ''
},
couponData: {
type: Array,
default: () => []
},
keyNum: {
type: Number,
default: 0
},
userIds: {
type: String,
default: ''
}
},
data() {
return {
listLoading: true,
tableData: {
data: [],
total: 0
import { marketingListApi, couponUserApi } from '@/api/marketing'
export default {
name: 'CouponList',
props: {
handle: {
type: String,
default: ''
},
tableFrom: {
page: 1,
limit: 10,
name: '',
// type: 0,
isDel: 0,
status: 1
couponData: {
type: Array,
default: () => []
},
multipleSelection: [],
multipleSelectionAll: [],
idKey: 'id',
nextPageFlag: false,
attr: []
}
},
watch: {
keyNum: {
deep: true,
handler(val) {
this.getList()
keyNum: {
type: Number,
default: 0
},
userIds: {
type: String,
default: ''
}
}
},
mounted() {
this.tableFrom.page = 1
this.getList()
this.multipleSelectionAll = this.couponData
},
methods: {
close() {
this.multipleSelection = []
},
handleSelectionChange(val) {
this.multipleSelection = val
setTimeout(() => {
this.changePageCoreRecordData()
}, 50)
},
// 设置选中的方法
setSelectRow() {
if (!this.multipleSelectionAll || this.multipleSelectionAll.length <= 0) {
return
data() {
return {
listLoading: true,
tableData: {
data: [],
total: 0
},
tableFrom: {
page: 1,
limit: 10,
name: '',
// type: 0,
isDel: 0,
status: 1
},
multipleSelection: [],
multipleSelectionAll: [],
idKey: 'id',
nextPageFlag: false,
attr: []
}
// 标识当前行的唯一键的名称
const idKey = this.idKey
const selectAllIds = []
this.multipleSelectionAll.forEach(row => {
selectAllIds.push(row[idKey])
})
this.$refs.table.clearSelection()
for (var i = 0; i < this.tableData.data.length; i++) {
if (selectAllIds.indexOf(this.tableData.data[i][idKey]) >= 0) {
// 设置选中记住table组件需要使用ref="table"
this.$refs.table.toggleRowSelection(this.tableData.data[i], true)
},
watch: {
keyNum: {
deep: true,
handler(val) {
this.getList()
}
}
},
// 记忆选择核心方法
changePageCoreRecordData() {
// 标识当前行的唯一键的名称
const idKey = this.idKey
const that = this
// 如果总记忆中还没有选择的数据,那么就直接取当前页选中的数据,不需要后面一系列计算
if (this.multipleSelectionAll.length <= 0) {
this.multipleSelectionAll = this.multipleSelection
return
}
// 总选择里面的key集合
const selectAllIds = []
this.multipleSelectionAll.forEach(row => {
selectAllIds.push(row[idKey])
})
const selectIds = []
// 获取当前页选中的id
this.multipleSelection.forEach(row => {
selectIds.push(row[idKey])
// 如果总选择里面不包含当前页选中的数据,那么就加入到总选择集合里
if (selectAllIds.indexOf(row[idKey]) < 0) {
that.multipleSelectionAll.push(row)
mounted() {
this.tableFrom.page = 1
this.getList()
this.multipleSelectionAll = this.couponData || []
},
methods: {
close() {
this.multipleSelection = []
},
handleSelectionChange(val) {
this.multipleSelection = val
setTimeout(() => {
this.changePageCoreRecordData()
}, 50)
},
// 设置选中的方法
setSelectRow() {
if (!this.multipleSelectionAll || this.multipleSelectionAll.length <= 0) {
return
}
})
const noSelectIds = []
// 得到当前页没有选中的id
this.tableData.data.forEach(row => {
if (selectIds.indexOf(row[idKey]) < 0) {
noSelectIds.push(row[idKey])
}
})
noSelectIds.forEach(id => {
if (selectAllIds.indexOf(id) >= 0) {
for (let i = 0; i < that.multipleSelectionAll.length; i++) {
if (that.multipleSelectionAll[i][idKey] == id) {
// 如果总选择中有未被选中的,那么就删除这条
that.multipleSelectionAll.splice(i, 1)
break
}
// 标识当前行的唯一键的名称
const idKey = this.idKey
const selectAllIds = []
this.multipleSelectionAll.forEach(row => {
selectAllIds.push(row[idKey])
})
this.$refs.table.clearSelection()
for (var i = 0; i < this.tableData.data.length; i++) {
if (selectAllIds.indexOf(this.tableData.data[i][idKey]) >= 0) {
// 设置选中记住table组件需要使用ref="table"
this.$refs.table.toggleRowSelection(this.tableData.data[i], true)
}
}
})
},
ok() {
if (this.multipleSelection.length > 0) {
this.$emit('getCouponId', this.multipleSelectionAll)
// this.close()
} else {
this.$message.warning('请先选择优惠劵')
},
// 记忆选择核心方法
changePageCoreRecordData() {
// 标识当前行的唯一键的名称
const idKey = this.idKey
const that = this
// 如果总记忆中还没有选择的数据,那么就直接取当前页选中的数据,不需要后面一系列计算
if (this.multipleSelectionAll.length <= 0) {
this.multipleSelectionAll = this.multipleSelection
return
}
// 总选择里面的key集合
const selectAllIds = []
this.multipleSelectionAll.forEach(row => {
selectAllIds.push(row[idKey])
})
const selectIds = []
// 获取当前页选中的id
this.multipleSelection.forEach(row => {
selectIds.push(row[idKey])
// 如果总选择里面不包含当前页选中的数据,那么就加入到总选择集合里
if (selectAllIds.indexOf(row[idKey]) < 0) {
that.multipleSelectionAll.push(row)
}
})
const noSelectIds = []
// 得到当前页没有选中的id
this.tableData.data.forEach(row => {
if (selectIds.indexOf(row[idKey]) < 0) {
noSelectIds.push(row[idKey])
}
})
noSelectIds.forEach(id => {
if (selectAllIds.indexOf(id) >= 0) {
for (let i = 0; i < that.multipleSelectionAll.length; i++) {
if (that.multipleSelectionAll[i][idKey] == id) {
// 如果总选择中有未被选中的,那么就删除这条
that.multipleSelectionAll.splice(i, 1)
break
}
}
}
})
},
ok() {
if (this.multipleSelection.length > 0) {
this.$emit('getCouponId', this.multipleSelectionAll)
// this.close()
} else {
this.$message.warning('请先选择优惠劵')
}
},
// 列表
getList(num) {
this.listLoading = true
this.tableFrom.page = num ? num : this.tableFrom.page
marketingListApi(this.tableFrom).then(res => {
this.tableData.data = res.list
this.tableData.total = res.total
this.listLoading = false
this.$nextTick(function() {
this.setSelectRow()// 调用跨页选中方法
})
}).catch(res => {
this.listLoading = false
})
},
pageChange(page) {
this.changePageCoreRecordData()
this.tableFrom.page = page
this.getList()
},
handleSizeChange(val) {
this.changePageCoreRecordData()
this.tableFrom.limit = val
this.getList()
},
// 发送
sendGrant(id){
this.$modalSure('发送优惠劵吗').then(() => {
couponUserApi({ couponId:id, uid:this.userIds }).then(() => {
this.$message.success('发送成功')
this.getList()
})
})
}
},
// 列表
getList(num) {
this.listLoading = true
this.tableFrom.page = num ? num : this.tableFrom.page
marketingListApi(this.tableFrom).then(res => {
this.tableData.data = res.list
this.tableData.total = res.total
this.listLoading = false
this.$nextTick(function() {
this.setSelectRow()// 调用跨页选中方法
})
}).catch(res => {
this.listLoading = false
})
},
pageChange(page) {
this.changePageCoreRecordData()
this.tableFrom.page = page
this.getList()
},
handleSizeChange(val) {
this.changePageCoreRecordData()
this.tableFrom.limit = val
this.getList()
},
// 发送
sendGrant(id){
this.$modalSure('发送优惠劵吗').then(() => {
couponUserApi({ couponId:id, uid:this.userIds }).then(() => {
this.$message.success('发送成功')
this.getList()
})
})
}
}
}
</script>
<style scoped lang="scss">

View File

@@ -573,6 +573,7 @@
handleCloseCoupon(tag) {
this.isAttr = true
this.formValidate.coupons.splice(this.formValidate.coupons.indexOf(tag), 1)
this.formValidate.couponIds.splice(this.formValidate.couponIds.indexOf(tag.id), 1)
},
addCoupon() {
const _this = this
@@ -894,6 +895,7 @@
giveIntegral: info.giveIntegral,
ficti: info.ficti,
coupons: info.coupons,
couponIds: info.couponIds,
activity: info.activityStr ? info.activityStr.split(',') : ['默认','秒杀','砍价','拼团']
}
if(info.isHot) this.checkboxGroup.push('isHot')