selectSingleProDialog.vue
2.69 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
<!-- 选择商品 - 单选 -->
<template>
<glsx-dialog
class="single-pro"
title="选择商品"
:isVisible.sync="isSingleSelectVisible"
width="70%"
@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 class="ellipsis">{{item.goodsName}}</p>
<p>销量:{{item.goodsCode}}</p>
<p>库存:{{item.goodsCode}}</p>
<p>零售价:{{item.goodsCode}}</p>
</div>
</el-radio>
</el-radio-group>
</glsx-dialog>
</template>
<script>
import glsxDialog from '@/components/glsx-dialog'
export default {
name: 'selectSingleProDialog',
data() {
return {
infoId: '',
productList: [{
id: '1',
goodsName: '商品名称11111111111111',
goodsImage: 'https://img0.baidu.com/it/u=4276914015,335466661&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
goodsCode: '111'
}, {
id: '2',
goodsName: '商品名称2',
goodsImage: 'https://img0.baidu.com/it/u=4276914015,335466661&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
goodsCode: '111'
}, {
id: '3',
goodsName: '商品名称3',
goodsImage: 'https://img0.baidu.com/it/u=4276914015,335466661&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
goodsCode: '111'
}]
}
},
props: {
isSingleSelectVisible: {
type: Boolean,
default: false
},
selectedProInfo: {
type: Object,
default: () => { }
}
},
components: {
glsxDialog
},
computed: {},
mounted() {
this.infoId = this.selectedProInfo.id
},
methods: {
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: 150px;
border: 1px solid #cccccc;
margin-right: 10px;
}
.single-pro p {
margin: 0 0 8px 0;
}
.single-pro .pro-box img {
width: 150px;
height: 150px;
}
.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>