index.vue
4.08 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
<!-- 选择商品 - 单选 -->
<template>
<glsx-dialog class="single-pro" title="选择商品" :isVisible.sync="isSingleSelectVisible" width="900px" @confirmDialog="handleSingleSelectConfirm" @closeDialog="handleSingleSelectClose">
<el-radio-group v-model="infoId">
<el-radio class="pro-box" v-for="item in productList" :key="item.id" :label="item.id">
<img :src="item.goodsImage" />
<div class="txt-box">
<p :title="item.goodsName" class="ellipsis">{{ item.goodsName }}</p>
<p class="f-s-12">销量:{{ item.saleAmount }}</p>
<p class="f-s-12">库存:{{ item.goodsStock }}</p>
<p class="f-s-12">零售价:{{ item.retailPrice }}</p>
<p :title="item.merchantName" class="ellipsis f-s-12">门店名称:{{ item.merchantName }}</p>
</div>
</el-radio>
</el-radio-group>
</glsx-dialog>
</template>
<script>
// import { getGoodsList } from '@/api/modules/common'
import glsxDialog from '@/components/glsx-dialog'
export default {
name: 'selectSingleProDialog',
data() {
return {
infoId: '',
minRatilPrice: '',
productList: []
}
},
props: {
isSingleSelectVisible: {
type: Boolean,
default: false
},
selectedProInfo: {
type: Object,
default: () => {}
}
},
components: {
glsxDialog
},
computed: {},
mounted() {
this.infoId = this.selectedProInfo.id
this.getList()
},
methods: {
getList() {
var params = {
goodsStatus: 1,
goodsSource: 1,
pageNum: 1,
pageSize: 100000
}
var that = this
this.$apis.common.getMerchantGoodsListApi(params).then(res => {
// console.log(res)
this.productList = res.list
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
}
})
})
},
handleSingleSelectConfirm() {
if (!this.infoId) {
this.$message.error('请选择商品')
return true
}
var selectInfo = this.productList.find(item => item.id === this.infoId)
this.$emit('handleSingleSelectConfirm', selectInfo)
},
handleSingleSelectClose() {
this.$emit('handleSingleSelectClose')
}
}
}
</script>
<style>
.single-pro .pro-box {
width: 202px;
border: 1px solid #cccccc;
margin: 0 10px 10px 0;
}
.single-pro p {
margin: 0 0 8px 0;
}
.single-pro .f-s-12 {
font-size: 12px;
}
.single-pro .pro-box img {
width: 202px;
height: 202px;
}
.single-pro .el-radio__input {
position: absolute;
top: 8px;
left: 8px;
}
.single-pro .el-radio__label {
padding: 0;
}
.single-pro .txt-box {
padding: 10px 10px 0;
color: #666666;
}
.single-pro .ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>