indexForCoupon.vue
4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!-- 选择商品弹窗 -->
<template>
<GLDialog class="muti-pro" bigTitle="选择商品" mode="big" :visible.sync="isMutiSelectVisible" :before-close="handleMutiSelectClose" :okText="productList.length ? '确定' : '创建商品'" @onOk="handleMutiSelectConfirm" @onCancel="handleMutiSelectClose" :noClose="false" :noCancel="true" :showClose="true">
<div style="max-height:60vh">
<div class="noproDiv" v-if="!productList.length && fnCallBack">
<img src="@/assets/noPro.png" />
<p class="noproP">系统暂无已创建的商品</p>
</div>
<div v-if="productList.length">
<el-form :inline="true" :model="searchProForm">
<el-form-item label="商品名称:">
<el-input :size="size" v-model="searchProForm.name" placeholder="请输入商品名称" maxlength="20" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button :size="size" type="primary" @click="handleConfigSearch">查询</el-button>
<el-button :size="size" @click="handleConfigReset">重置</el-button>
</el-form-item>
</el-form>
<GLTable ref="mutiProRef" :tableData="productList" :hasPage="false" :tableParams="tableParams" @refreshTable="getList">
<span slot="goodsImage" slot-scope="scope">
<img class="m-t-10 img-60" :src="scope.scope.goodsImage" />
</span>
</GLTable>
</div>
</div>
</GLDialog>
</template>
<script>
export default {
name: 'selectMutiProForcouponDialog',
data() {
return {
// 表格组件
productList: [],
userInfo: {},
searchProForm: {
name: ''
},
// 表格参数
tableParams: {
listName: 'list',
// 行数据的key
mutiSelectUniqueKey: 'id',
// 多选ref的名称
mutiSelectName: 'list',
tableColumns: [
{
label: '商品名称',
prop: 'goodsName'
},
{
label: '缩略图',
prop: 'goodsImage',
addHtml: 'goodsImage'
},
{
label: '零售价(元)',
prop: 'retailPrice'
},
{
label: '来源门店',
prop: 'merchantName'
}
]
},
fnCallBack: false
}
},
props: {
isMutiSelectVisible: {
type: Boolean,
default: false
},
selectedProList: {
type: Array,
default: () => []
}
},
mounted() {
this.userInfo = this.$globalState.session
this.getList({}, true)
},
methods: {
getList(page, isMounted = false) {
var params = {
goodsStatus: 1,
currentPage: 1,
pageNum: 1,
pageSize: 100000,
pageStart: 0,
goodsName: this.searchProForm.name
}
var that = this
this.$apis.couponManage.getAllGoodsApi(params).then(res => {
this.fnCallBack = true
// console.log(res)
this.productList = res.list
this.productList.forEach(function (item) {
item.retailPrice = (item.retailPrice / 100).toFixed(2)
})
this.recoverySelected()
})
},
recoverySelected() {
if (this.selectedProList.length) {
this.selectedProList.forEach(row => {
this.$refs.mutiProRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(row)
})
}
},
handleMutiSelectConfirm() {
if (!this.productList.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 = this.$refs.mutiProRef.mutiSelectArr[this.tableParams.mutiSelectName]
if (!selectedData) {
this.$message({
message: '未选择商品',
type: 'error',
customClass: 'message-Z-zinde'
})
return
}
this.$emit('handleMutiSelectConfirm', selectedData)
},
handleMutiSelectClose() {
this.$emit('handleMutiSelectClose')
},
handleConfigSearch() {
this.getList({}, true)
},
handleConfigReset() {
this.searchProForm.name = ''
this.getList({}, true)
}
}
}
</script>
<style>
.muti-pro .m-t-10 {
margin-top: 10px;
}
</style>