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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<template>
<el-dialog title="复制链接" :visible.sync="show" :modal="false" width="80%">
<el-form ref="searchFrom" :model="searchFrom" label-width="100px" class="search-form" inline>
<el-form-item label="商品名称">
<el-input v-model="searchFrom.name"></el-input>
</el-form-item>
<el-form-item label="商品类型">
<el-select v-model="searchFrom.goods_type" placeholder="请选择" @change="getList">
<el-option value="" label="请选择"></el-option>
<el-option
:label="'普通商品'"
:value="1">
</el-option>
<el-option
:label="'团购商品'"
:value="2">
</el-option>
<el-option
:label="'续课商品'"
:value="3">
</el-option>
<el-option
:label="'优惠券商品'"
:value="4">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="课程">
<el-select v-model="searchFrom.course_id" placeholder="请选择" @change="getList">
<el-option value="" label="请选择"></el-option>
<el-option
v-for="(data,index) in classList"
:key="index"
:label="data.title"
:value="data.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="商品状态" >
<el-select v-model="searchFrom.status" placeholder="请选择" @change="getList">
<el-option value="" label="请选择"></el-option>
<el-option value="0" label="编辑中"></el-option>
<el-option value="1" label="上架"></el-option>
<el-option value="2" label="下架"></el-option>
</el-select>
</el-form-item>
<el-form-item label="商品现价/团购价" label-width="120px">
<el-input-number v-model="searchFrom.current_price"></el-input-number>
</el-form-item>
<el-form-item>
<div class="search-btn-block">
<el-button type="primary" plain @click="getList" icon="el-icon-search">搜索</el-button>
</div>
</el-form-item>
</el-form>
<el-table
:data="goodsList"
style="width: 100%">
<el-table-column
prop="name"
label="名称">
<template slot-scope="scope">
<router-link :to="{name:'periods', query: { goods_id: scope.row.id}}" >
{{scope.row.name}}
</router-link>
</template>
</el-table-column>
<el-table-column
label="商品类型">
<template slot-scope="scope">
{{scope.row.goods_type | goodsType}}
</template>
</el-table-column>
<el-table-column
label="商品原价/直购价">
<template slot-scope="scope">
{{scope.row.original_price/100}}元
</template>
</el-table-column>
<el-table-column
label="商品现价/团购价">
<template slot-scope="scope">
{{scope.row.current_price/100}}元
</template>
</el-table-column>
<el-table-column
prop="course_title"
label="课程名称">
</el-table-column>
<el-table-column
label="课程类别">
<template slot-scope="scope">
{{scope.row.course_type | lessonType}}
</template>
</el-table-column>
<el-table-column
label="是否有实物">
<template slot-scope="scope">
{{scope.row.is_real | isOrNot}}
</template>
</el-table-column>
<el-table-column
prop="buy_nums"
label="商品购买数量">
</el-table-column>
<el-table-column
label="状态">
<template slot-scope="scope">
{{scope.row.status | goodsStatus}}
</template>
</el-table-column>
<el-table-column
label="备注">
<template slot-scope="scope">
{{scope.row.desc | goodsDesc}}
</template>
</el-table-column>
<el-table-column
width="100"
label="操作">
<template slot-scope="scope">
<el-button size="mini" plain type="success" @click="copyUrl(scope.row.id)">
复制链接
</el-button>
</template>
</el-table-column>
</el-table>
<page :total="total" :limit="limit" @pageChange="onPageChange" @sizeChange="onSizeChange"/>
</el-dialog>
</template>
<script>
import {getGoodsListApi,getLessonApi} from "../../service/api";
import page from '../framework/page'
import {ISORNOT,GOODSTYPE,LESSONTYPE,GOODSSTATUS} from "../../util/wordbook";
export default {
name: "goodsList",
props:[
'dialogObj'
],
data(){
return {
searchFrom:{
name:'',
goods_type: '',
status: '',
course_id: ''
},
goodsList:[],
classList: [],
total:0,
nowPage:1,
limit: 10,
show:false,
code: ''
}
},
components:{
page,
},
filters:{
isOrNot(value){
return ISORNOT[value]
},
goodsType(value){
return GOODSTYPE[value]
},
lessonType(value){
return LESSONTYPE[value]
},
goodsStatus(value){
return GOODSSTATUS[value]
},
goodsDesc(value){
let _desc = JSON.parse(value)
return _desc.desc
}
},
methods:{
getList(){
let json = {
limit: this.limit,
page: this.nowPage
};
if (this.searchFrom.name) {
json.name = this.searchFrom.name
}
if (this.searchFrom.goods_type){
json.goods_type = this.searchFrom.goods_type
}
if (this.searchFrom.course_id) {
json.course_id = this.searchFrom.course_id
}
if (this.searchFrom.status) {
json.status = this.searchFrom.status
}
if (this.searchFrom.current_price) {
json.current_price = this.searchFrom.current_price * 100
}
getGoodsListApi(json).then(res=>{
this.goodsList = res.list;
this.total = res.total
})
},
getClassList(){
let json = {
limit: 200,
page: 1
}
getLessonApi(json).then(res=>{
console.log(res)
this.classList = res.list;
})
},
copyUrl(data){
if (!this.code) return;
let url = `${process.env.INVITE_URL}#/buyDetail?shopId=${data}&invite_code=${this.code}`;
let oInput = document.createElement('input');
oInput.value = url;
document.body.appendChild(oInput);
oInput.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
this.$message({
message: '已成功复制到剪切板',
type: 'success'
});
oInput.remove()
this.$emit("changeShow");
},
onPageChange(val){
this.nowPage = val;
this.getList()
},
onSizeChange(val){
this.limit = val;
this.nowPage = 1;
this.getList()
},
initDialog(){
this.show = this.dialogObj.show;
if (this.dialogObj.code) {
this.code = this.dialogObj.code;
}
},
},
// mounted(){
// this.initDialog();
// },
watch:{
'dialogObj.show'(value){
if(value){
this.initDialog();
this.getClassList();
this.getList();
}
},
show(value){
this.$emit("changeShow",value);
}
}
}
</script>
<style>
.f-c > div{
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
}
</style>