indexForCoupon.vue
6.32 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!-- 选择商品弹窗 -->
<template>
<glsx-dialog class="muti-pro" title="选择商品" :isVisible.sync="isMutiSelectVisible" :btnOkLabel="productList.length ? '确定' : '创建商品'" width="70%" @confirmDialog="handleMutiSelectConfirm" @closeDialog="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>
</glsx-dialog>
</template>
<script>
// import { getGoodsList } from '@/api/modules/common'
import glsxDialog from '@/components/glsx-dialog'
export default {
name: 'selectMutiProForcouponDialog',
data() {
return {
// 表格组件
// getListApi: this.$apis.common.getGoodsListApi,
productList: [],
userInfo: {},
// pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
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: () => []
}
},
components: {
glsxDialog
},
mounted() {
this.userInfo = this.$globalState.session
this.getList({}, true)
},
methods: {
getList(page, isMounted = false) {
var params = {
goodsStatus: 1,
goodsSource: 1,
// pageNum: isMounted ? 1 : this.$refs.mutiProRef.page.pageNum,
// pageSize: isMounted ? 10 : this.$refs.mutiProRef.page.pageSize
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
this.productList = res.list
// this.$refs.mutiProRef.tableTotal = res.total
this.productList.forEach(function(item) {
// item.saleAmount = item.goodsStatistics.saleAmount
// if (item.specificationDetailList.length > 1) {
// let retailPriceList = item.specificationDetailList.sort(function(a, b) {
// return a.retailPrice - b.retailPrice
// })
// let stockeList = item.specificationDetailList.sort(function(a, b) {
// return a.stock - b.stock
// })
// let minRatilPrice = retailPriceList[0].retailPrice / 100
// let maxRatilPrice = retailPriceList[retailPriceList.length - 1].retailPrice / 100
// let minStock = stockeList[0].stock
// let maxStock = stockeList[stockeList.length - 1].stock
// item.retailPrice = minRatilPrice == maxRatilPrice ? minRatilPrice.toFixed(2) : minRatilPrice.toFixed(2) + '-' + maxRatilPrice.toFixed(2)
// item.minRatilPrice = minRatilPrice.toFixed(2)
// item.goodsStock = minStock == maxStock ? minStock : minStock + '-' + maxStock
// } else if (item.specificationDetailList.length == 1) {
// item.retailPrice = (item.specificationDetailList[0].retailPrice / 100).toFixed(2)
// item.minRatilPrice = item.retailPrice
// item.goodsStock = item.specificationDetailList[0].stock
// } else {
// item.retailPrice = (item.retailPrice / 100).toFixed(2)
// item.minRatilPrice = item.retailPrice
// }
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>