Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
scrm-micro-discover
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3bbd2f51
authored
Jan 11, 2023
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优惠券弹窗-单选
1 parent
b0f24803
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
138 additions
and
122 deletions
src/views/store/components/selectGiftDialog.vue
src/views/store/components/selectGiftDialog.vue
View file @
3bbd2f5
<!-- 选择礼包弹窗 -->
<
template
>
<GLDialog
class=
"muti-gift"
bigTitle=
"选择礼包内容"
mode=
"big"
:visible
.
sync=
"isSelectGiftVisible"
:before-close=
"handleGiftClose"
@
onOk=
"handleGiftConfirm"
@
onCancel=
"handleGiftClose"
v-loading=
"loading"
>
<!--
<div
class=
"nogiftDiv"
v-show=
"!giftList.length && fnCallBack"
>
<img
src=
"@/assets/noPro.png"
/>
<p
class=
"nogiftP"
>
系统暂无已创建的礼包
</p>
</div>
-->
<div
class=
"flex-default"
>
<div
class=
"gift-table"
>
<el-tabs
class=
"gift-tabs"
v-model=
"activeName"
@
tab-click=
"handleTabClick"
>
...
...
@@ -19,7 +15,10 @@
<el-button
:size=
"size"
type=
"primary"
@
click=
"handleSearch"
>
查询
</el-button>
</span>
</glsx-combi-form>
<GLTable
v-loading=
"loading"
v-show=
"activeName == 'service'"
ref=
"serviceRef"
:tableData=
"giftList"
:noDataImg=
"url"
:tableParams=
"tableParams"
@
refreshTable=
"getList"
@
selectionTable=
"handleSelectionTable"
>
<GLTable
v-loading=
"loading"
v-show=
"activeName == 'service'"
ref=
"serviceRef"
:tableData=
"giftList"
:noDataImg=
"url"
:tableParams=
"tableParams"
@
refreshTable=
"getList"
>
<div
slot=
"radio"
slot-scope=
"scope"
>
<el-radio
v-model=
"giftId"
:label=
"scope.scope.id"
@
change=
"handleChangeRadio"
>
{{
''
}}
</el-radio>
</div>
<span
slot=
"effectiveType"
slot-scope=
"scope"
>
<span>
{{
toLabelText
(
scope
.
scope
)
}}
</span>
</span>
...
...
@@ -27,7 +26,10 @@
<span>
{{
toRestrictLabelText
(
scope
.
scope
)
}}
</span>
</span>
</GLTable>
<GLTable
v-loading=
"loading"
v-show=
"activeName == 'cash'"
ref=
"cashRef"
:tableData=
"giftList"
:noDataImg=
"url"
:tableParams=
"tableParams"
@
refreshTable=
"getList"
@
selectionTable=
"handleSelectionTable"
>
<GLTable
v-loading=
"loading"
v-show=
"activeName == 'cash'"
ref=
"cashRef"
:tableData=
"giftList"
:noDataImg=
"url"
:tableParams=
"tableParams"
@
refreshTable=
"getList"
>
<div
slot=
"radio"
slot-scope=
"scope"
>
<el-radio
v-model=
"giftId"
:label=
"scope.scope.id"
@
change=
"handleChangeRadio"
>
{{
''
}}
</el-radio>
</div>
<span
slot=
"effectiveType"
slot-scope=
"scope"
>
<span>
{{
toLabelText
(
scope
.
scope
)
}}
</span>
</span>
...
...
@@ -35,7 +37,10 @@
<span>
{{
toCashRestrictLabelText
(
scope
.
scope
)
}}
</span>
</span>
</GLTable>
<GLTable
v-loading=
"loading"
v-show=
"activeName == 'discount'"
ref=
"discountRef"
:tableData=
"giftList"
:noDataImg=
"url"
:tableParams=
"tableParams"
@
refreshTable=
"getList"
@
selectionTable=
"handleSelectionTable"
>
<GLTable
v-loading=
"loading"
v-show=
"activeName == 'discount'"
ref=
"discountRef"
:tableData=
"giftList"
:noDataImg=
"url"
:tableParams=
"tableParams"
@
refreshTable=
"getList"
>
<div
slot=
"radio"
slot-scope=
"scope"
>
<el-radio
v-model=
"giftId"
:label=
"scope.scope.id"
@
change=
"handleChangeRadio"
>
{{
''
}}
</el-radio>
</div>
<span
slot=
"effectiveType"
slot-scope=
"scope"
>
<span>
{{
toLabelText
(
scope
.
scope
)
}}
</span>
</span>
...
...
@@ -43,7 +48,10 @@
<span>
-
</span>
</span>
</GLTable>
<GLTable
v-loading=
"loading"
v-show=
"activeName == 'exchange'"
ref=
"exchangeRef"
:tableData=
"giftList"
:noDataImg=
"url"
:tableParams=
"tableParams"
@
refreshTable=
"getList"
@
selectionTable=
"handleSelectionTable"
>
<GLTable
v-loading=
"loading"
v-show=
"activeName == 'exchange'"
ref=
"exchangeRef"
:tableData=
"giftList"
:noDataImg=
"url"
:tableParams=
"tableParams"
@
refreshTable=
"getList"
>
<div
slot=
"radio"
slot-scope=
"scope"
>
<el-radio
v-model=
"giftId"
:label=
"scope.scope.id"
@
change=
"handleChangeRadio"
>
{{
''
}}
</el-radio>
</div>
<span
slot=
"effectiveType"
slot-scope=
"scope"
>
<span>
{{
toLabelText
(
scope
.
scope
)
}}
</span>
</span>
...
...
@@ -53,7 +61,7 @@
</GLTable>
</div>
</div>
<div
class=
"selected-list"
>
<
!--
<
div
class=
"selected-list"
>
<p
class=
"list-title p-16"
>
已选(
{{
selectedSum
}}
)
</p>
<div
class=
"list-gifts"
>
<div
v-for=
"(item, index) in orderShow"
:key=
"index"
>
...
...
@@ -61,7 +69,6 @@
<div
class=
"gift-label"
>
{{
selectedGiftList
[
item
].
label
}}
</div>
<div
class=
"gift-content"
>
<div
class=
"gift-item"
v-for=
"(subItem, subIndex) in selectedGiftList[item].list"
:key=
"subIndex"
>
<!--
<i
@
click=
"handleGiftDelete(item, subIndex)"
></i>
-->
<img
class=
"muti-icon"
v-show=
"subItem.status != '3'"
src=
"@/assets/muti-selected.png"
@
click=
"handleGiftDelete(item, subIndex)"
/>
<img
class=
"muti-icon"
v-show=
"subItem.status == '3'"
src=
"@/assets/muti-no-select.png"
@
click=
"handleGiftDelete(item, subIndex)"
/>
<el-tooltip
effect=
"dark"
placement=
"top"
:disabled=
"subItem.couponName.length
<
= 8">
...
...
@@ -70,14 +77,13 @@
</el-tooltip>
<div
class=
"gift-sum"
>
<el-input-number
:disabled=
"subItem.status == '3'"
class=
"sum-input"
v-model=
"subItem.couponAmount"
@
change=
"handleChange"
:min=
"1"
:max=
"999999"
size=
"mini"
label=
"描述文字"
></el-input-number>
<!--
<p
:class=
"[subItem.status == '3' ? ' txt-grey' : '']"
v-else
>
×
{{
subItem
.
couponAmount
}}
</p>
-->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
-->
</div>
</GLDialog>
</
template
>
...
...
@@ -104,6 +110,7 @@ export default {
4
:
'exchange'
,
7
:
'service'
},
giftId
:
''
,
// 搜索
searchForm
:
{
couponName
:
''
...
...
@@ -124,11 +131,17 @@ export default {
tableParams
:
{
listName
:
'list'
,
// 行数据的key
mutiSelectUniqueKey
:
'id'
,
//
mutiSelectUniqueKey: 'id',
// 多选ref的名称
mutiSelectName
:
'list'
,
tableColumns
:
[
{
label
:
''
,
name
:
''
,
addHtml
:
'radio'
,
width
:
50
},
{
label
:
'名称'
,
prop
:
'couponName'
,
width
:
180
...
...
@@ -230,8 +243,8 @@ export default {
})
// this.fnCallBack = true
this
.
$refs
[
this
.
activeName
+
'Ref'
].
tableTotal
=
res
.
total
this
.
recoverySelected
()
this
.
recoveryTotal
()
//
this.recoverySelected()
//
this.recoveryTotal()
this
.
$refs
[
this
.
activeName
+
'Ref'
].
tableHeightValues
=
'42vh'
})
.
finally
(()
=>
{
...
...
@@ -239,14 +252,28 @@ export default {
})
},
resetRecovery
()
{
var
keyList
=
Object
.
keys
(
this
.
selectedGiftList
)
keyList
.
forEach
(
item
=>
{
this
.
selectedGiftList
[
item
].
list
=
[]
})
},
handleChangeRadio
(
e
)
{
this
.
resetRecovery
()
var
targetItem
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
giftList
.
find
(
item
=>
item
.
id
==
e
)))
targetItem
.
couponAmount
=
'1'
this
.
selectedGiftList
[
this
.
activeName
].
list
=
[
targetItem
]
},
handleTabClick
()
{
this
.
getList
({},
true
)
this
.
recoverySelected
()
//
this.recoverySelected()
},
handleSearch
()
{
this
.
getList
({},
true
)
this
.
recoverySelected
()
//
this.recoverySelected()
},
toLabelText
(
row
)
{
...
...
@@ -280,120 +307,108 @@ export default {
},
// 恢复选择
addSelected
()
{
this
.
$nextTick
(()
=>
{
var
list
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
selectedGiftList
[
this
.
activeName
].
list
))
if
(
list
&&
list
.
length
)
{
list
.
forEach
(
row
=>
{
var
idx
=
this
.
giftList
.
findIndex
(
k
=>
k
.
id
==
row
.
id
)
if
(
idx
!=
-
1
&&
row
.
status
!=
'3'
)
{
this
.
$refs
[
this
.
activeName
+
'Ref'
].
$refs
[
this
.
tableParams
.
mutiSelectName
+
'MutiTable'
].
toggleRowSelection
(
this
.
giftList
[
idx
],
true
)
}
})
}
})
},
//
addSelected() {
//
this.$nextTick(() => {
//
var list = JSON.parse(JSON.stringify(this.selectedGiftList[this.activeName].list))
//
if (list && list.length) {
//
list.forEach(row => {
//
var idx = this.giftList.findIndex(k => k.id == row.id)
//
if (idx != -1 && row.status != '3') {
//
this.$refs[this.activeName + 'Ref'].$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(this.giftList[idx], true)
//
}
//
})
//
}
//
})
//
},
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
)
}
},
//
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
(
deleteList
)
{
this
.
$nextTick
(()
=>
{
deleteList
.
forEach
(
row
=>
{
var
idx
=
this
.
giftList
.
findIndex
(
k
=>
k
.
id
==
row
.
id
)
if
(
idx
!=
-
1
&&
row
.
status
!=
'3'
)
{
this
.
$refs
[
this
.
activeName
+
'Ref'
].
$refs
[
this
.
tableParams
.
mutiSelectName
+
'MutiTable'
].
toggleRowSelection
(
this
.
giftList
[
idx
],
false
)
}
})
})
},
//
deleteSelected(deleteList) {
//
this.$nextTick(() => {
//
deleteList.forEach(row => {
//
var idx = this.giftList.findIndex(k => k.id == row.id)
//
if (idx != -1 && row.status != '3') {
//
this.$refs[this.activeName + 'Ref'].$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(this.giftList[idx], false)
//
}
//
})
//
})
//
},
handleGiftDelete
(
attr
,
idx
)
{
var
deleteList
=
this
.
selectedGiftList
[
attr
].
list
.
splice
(
idx
,
1
)
this
.
deleteSelected
(
deleteList
)
this
.
recoveryTotal
()
},
//
handleGiftDelete(attr, idx) {
//
var deleteList = this.selectedGiftList[attr].list.splice(idx, 1)
//
this.deleteSelected(deleteList)
//
this.recoveryTotal()
//
},
// 计算已选张数
recoveryTotal
()
{
this
.
selectedSum
=
0
this
.
orderShow
.
forEach
(
itme
=>
{
this
.
selectedGiftList
[
itme
].
list
.
forEach
(
subItem
=>
{
this
.
selectedSum
=
this
.
selectedSum
+
1
})
})
},
//
recoveryTotal() {
//
this.selectedSum = 0
//
this.orderShow.forEach(itme => {
//
this.selectedGiftList[itme].list.forEach(subItem => {
//
this.selectedSum = this.selectedSum + 1
//
})
//
})
//
},
// 选择/取消
handleSelectionTable
(
val
)
{
var
list
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
selectedGiftList
[
this
.
activeName
].
list
))
var
count
=
0
var
currentIdList
=
this
.
giftList
.
map
(
item
=>
item
.
id
)
val
.
map
(
item
=>
item
.
id
)
.
forEach
(
k
=>
{
if
(
currentIdList
.
indexOf
(
k
)
!=
-
1
)
{
count
=
count
+
1
}
})
if
(
count
<=
this
.
giftList
.
length
||
count
==
0
||
!
val
.
length
)
{
this
.
selectedGiftList
[
this
.
activeName
].
list
=
[]
}
val
.
forEach
(
item
=>
{
let
isSelected
=
list
.
find
(
k
=>
k
.
id
==
item
.
id
)
if
(
this
.
selectedGiftList
[
this
.
activeName
].
list
.
findIndex
(
k
=>
k
.
id
==
item
.
id
)
==
'-1'
)
{
this
.
selectedGiftList
[
this
.
activeName
].
list
.
push
({
id
:
item
.
id
,
discountType
:
item
.
discountType
,
couponName
:
item
.
couponName
,
couponAmount
:
isSelected
?
list
.
find
(
k
=>
k
.
id
==
item
.
id
).
couponAmount
:
'1'
,
couponAnticipatedCost
:
item
.
couponAnticipatedCost
,
effectiveType
:
item
.
effectiveType
,
effectiveStartTime
:
item
.
effectiveStartTime
,
effectiveEndTime
:
item
.
effectiveEndTime
,
effectiveDays
:
item
.
effectiveDays
,
residueAmount
:
item
.
residueAmount
,
status
:
'2'
})
}
})
list
.
forEach
(
item
=>
{
if
(
item
.
status
==
'3'
)
{
this
.
selectedGiftList
[
this
.
activeName
].
list
.
push
(
item
)
}
else
if
(
this
.
giftList
.
findIndex
(
k
=>
k
.
id
==
item
.
id
)
==
'-1'
&&
this
.
selectedGiftList
[
this
.
activeName
].
list
.
findIndex
(
k
=>
k
.
id
==
item
.
id
)
==
'-1'
)
{
// 没有库存的券
this
.
selectedGiftList
[
this
.
activeName
].
list
.
push
(
item
)
}
})
this
.
recoveryTotal
()
},
//
handleSelectionTable(val) {
//
var list = JSON.parse(JSON.stringify(this.selectedGiftList[this.activeName].list))
//
var count = 0
//
var currentIdList = this.giftList.map(item => item.id)
//
val
//
.map(item => item.id)
//
.forEach(k => {
//
if (currentIdList.indexOf(k) != -1) {
//
count = count + 1
//
}
//
})
//
if (count <= this.giftList.length || count == 0 || !val.length) {
//
this.selectedGiftList[this.activeName].list = []
//
}
//
val.forEach(item => {
//
let isSelected = list.find(k => k.id == item.id)
//
if (this.selectedGiftList[this.activeName].list.findIndex(k => k.id == item.id) == '-1') {
//
this.selectedGiftList[this.activeName].list.push({
//
id: item.id,
//
discountType: item.discountType,
//
couponName: item.couponName,
//
couponAmount: isSelected ? list.find(k => k.id == item.id).couponAmount : '1',
//
couponAnticipatedCost: item.couponAnticipatedCost,
//
effectiveType: item.effectiveType,
//
effectiveStartTime: item.effectiveStartTime,
//
effectiveEndTime: item.effectiveEndTime,
//
effectiveDays: item.effectiveDays,
//
residueAmount: item.residueAmount,
//
status: '2'
//
})
//
}
//
})
//
list.forEach(item => {
//
if (item.status == '3') {
//
this.selectedGiftList[this.activeName].list.push(item)
//
} else if (this.giftList.findIndex(k => k.id == item.id) == '-1' && this.selectedGiftList[this.activeName].list.findIndex(k => k.id == item.id) == '-1') {
//
// 没有库存的券
//
this.selectedGiftList[this.activeName].list.push(item)
//
}
//
})
//
this.recoveryTotal()
//
},
handleGiftConfirm
()
{
// if (!this.giftList.length) {
// var params = {
// addOrEdit: 1,
// groupOrStore: this.userInfo.accountLevel == 4 ? 2 : 1,
// $title: '新建礼包'
// }
// this.$router.push({
// path: '/productGroup/editProduct',
// query: params
// })
// return true
// }
var
selectedData
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
selectedGiftList
))
this
.
$emit
(
'handleGiftConfirm'
,
selectedData
)
},
...
...
@@ -428,7 +443,8 @@ export default {
margin-top
:
10px
;
}
.muti-gift
.gift-table
{
width
:
calc
(
100%
-
280px
);
width
:
100%
;
//
width
:
calc
(
100%
-
280px
);
border
:
1px
solid
#eeeeee
;
margin-right
:
10px
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment