Commit 9398da98 by chenwq

新增礼包-选择礼包弹窗

1 parent 9fcf5a1b
...@@ -197,26 +197,31 @@ export default { ...@@ -197,26 +197,31 @@ export default {
mounted() { mounted() {
this.userInfo = this.$globalState.session this.userInfo = this.$globalState.session
this.getList({}, true) this.getList({}, true, true)
}, },
methods: { methods: {
getList(page, isReset = false) { getList(page, isResetPage = false, isMount = false) {
var params = { var params = {
...this.searchForm, ...this.searchForm,
discountType: this.selectedGiftList[this.activeName].discountType, discountType: this.selectedGiftList[this.activeName].discountType,
pageNum: isReset ? 1 : this.$refs[this.activeName + 'Ref'].page.pageNum, pageNum: isResetPage ? 1 : this.$refs[this.activeName + 'Ref'].page.pageNum,
pageSize: isReset ? 10 : this.$refs[this.activeName + 'Ref'].page.pageSize pageSize: isResetPage ? 10 : this.$refs[this.activeName + 'Ref'].page.pageSize
} }
this.loading = true this.loading = true
this.$apis.giftBag this.$apis.giftBag
.getDirectionalGiftListApi(params) .getDirectionalGiftListApi(params)
.then(res => { .then(res => {
// 重置分页组件
if (this.$refs[this.activeName + 'Ref'] && isResetPage) {
this.$refs[this.activeName + 'Ref'].page.pageNum = 1
this.$refs[this.activeName + 'Ref'].page.pageSize = 10
}
this.giftList = res.list this.giftList = res.list
this.giftList.forEach(item => { this.giftList.forEach(item => {
item.couponAnticipatedCost = item.anticipatedCost item.couponAnticipatedCost = item.anticipatedCost
}) })
this.fnCallBack = true // this.fnCallBack = true
this.$refs[this.activeName + 'Ref'].tableTotal = res.total this.$refs[this.activeName + 'Ref'].tableTotal = res.total
this.recoverySelected() this.recoverySelected()
this.recoveryTotal() this.recoveryTotal()
...@@ -229,10 +234,12 @@ export default { ...@@ -229,10 +234,12 @@ export default {
handleTabClick() { handleTabClick() {
this.getList({}, true) this.getList({}, true)
this.recoverySelected()
}, },
handleSearch() { handleSearch() {
this.getList({}, true) this.getList({}, true)
this.recoverySelected()
}, },
toLabelText(row) { toLabelText(row) {
...@@ -266,31 +273,49 @@ export default { ...@@ -266,31 +273,49 @@ export default {
}, },
// 恢复选择 // 恢复选择
recoverySelected() { addSelected() {
this.$nextTick(() => {
if (this.selectedGiftList[this.activeName].list && this.selectedGiftList[this.activeName].list.length) { if (this.selectedGiftList[this.activeName].list && this.selectedGiftList[this.activeName].list.length) {
this.selectedGiftList[this.activeName].list.forEach(row => { this.selectedGiftList[this.activeName].list.forEach(row => {
if (row.status != '3') { var idx = this.giftList.findIndex(k => k.id == row.id)
this.$refs[this.activeName + 'Ref'].$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(row, true) if (idx != -1 && row.status != '3') {
this.$refs[this.activeName + 'Ref'].$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(this.giftList[idx], true)
} }
}) })
} else { }
this.$refs[this.activeName + 'Ref'].$refs[this.tableParams.mutiSelectName + 'MutiTable'].clearSelection() })
},
recoverySelected() {
// 翻页,去掉已选项
var selectedData = this.$refs[this.activeName + 'Ref'].mutiSelectArr.list
var deleteList = []
this.addSelected()
if (selectedData) {
selectedData.forEach(item => {
if (this.selectedGiftList[this.activeName].list.findIndex(subItem => subItem.id == item.id) == -1) {
deleteList.push(item)
}
})
this.deleteSelected(deleteList)
} }
}, },
// 删除选中 // 删除选中
deleteSelected(deleteItem) { deleteSelected(deleteList) {
deleteItem.forEach(row => { this.$nextTick(() => {
deleteList.forEach(row => {
var idx = this.giftList.findIndex(k => k.id == row.id) var idx = this.giftList.findIndex(k => k.id == row.id)
if (idx != -1 && row.status != '3') { if (idx != -1 && row.status != '3') {
this.$refs[this.activeName + 'Ref'].$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(this.giftList[idx], false) this.$refs[this.activeName + 'Ref'].$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(this.giftList[idx], false)
} }
}) })
})
}, },
handleGiftDelete(attr, idx) { handleGiftDelete(attr, idx) {
var deleteItem = this.selectedGiftList[attr].list.splice(idx, 1) var deleteList = this.selectedGiftList[attr].list.splice(idx, 1)
this.deleteSelected(deleteItem) this.deleteSelected(deleteList)
this.recoveryTotal() this.recoveryTotal()
}, },
......
...@@ -76,14 +76,19 @@ export default { ...@@ -76,14 +76,19 @@ export default {
}, },
methods: { methods: {
getList(page, isReset = false) { getList(page, isResetPage = false) {
var params = { var params = {
...this.searchForm, ...this.searchForm,
pageNum: isReset ? 1 : this.$refs.mutiProRef.page.pageNum, pageNum: isResetPage ? 1 : this.$refs.mutiProRef.page.pageNum,
pageSize: isReset ? 10 : this.$refs.mutiProRef.page.pageSize pageSize: isResetPage ? 10 : this.$refs.mutiProRef.page.pageSize
} }
this.loading = true this.loading = true
this.$apis.giftBag.getFollowerStaffListApi(params).then(res => { this.$apis.giftBag.getFollowerStaffListApi(params).then(res => {
// 重置分页组件
if (this.$refs.mutiProRef && isResetPage) {
this.$refs.mutiProRef.page.pageNum = 1
this.$refs.mutiProRef.page.pageSize = 10
}
this.staffList = res.data this.staffList = res.data
this.loading = false this.loading = false
this.fnCallBack = true this.fnCallBack = true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!