1
1
<template >
2
- <div >
3
- <el-container >
4
- <el-header style =" display : inline-block ; margin-top : 0px ;" >
5
- <el-row type =" flex" justify =" end" >
6
- <el-col :span =" 2" >
7
- <el-button type =" primary" round @click =" dialogFormVisible = true"
8
- >新增</el-button
2
+ <el-container >
3
+ <el-header style =" height : 24px " >
4
+ <el-row type =" flex" justify =" end" >
5
+ <el-col :span =" 2" >
6
+ <el-button type =" primary" round @click =" dialogFormVisible = true"
7
+ >新增</el-button
8
+ >
9
+ </el-col >
10
+ <el-col :span =" 6" >
11
+ <el-input placeholder =" 请输入查询商品" v-model =" search" >
12
+ <el-button slot =" append" icon =" el-icon-search" ></el-button >
13
+ </el-input >
14
+
15
+ <div style =" clear : both " ></div >
16
+ </el-col >
17
+ </el-row >
18
+ </el-header >
19
+ <el-main >
20
+ <el-table
21
+ :data ="
22
+ tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
23
+ "
24
+ style =" width : 100% "
25
+ height =" 74vh"
26
+ :row-style =" { height: '10px' }"
27
+ >
28
+ <el-table-column prop =" imgUrl" label =" 图片链接" width =" 100px" >
29
+ <template slot-scope="scope">
30
+ <img :src =" scope.row.imgUrl" style =" height : 100px " />
31
+ </template >
32
+ </el-table-column >
33
+ <el-table-column label =" 商品名" min-width =" 150px" >
34
+ <template slot-scope="scope">
35
+ <a :href =" scope.row.materialUrl" target =" _blank" >{{
36
+ scope.row.name
37
+ }}</a >
38
+ </template >
39
+ </el-table-column >
40
+ <el-table-column prop =" unitPrice" label =" 单价" > </el-table-column >
41
+ <el-table-column prop =" bestPrice" label =" 活动价" > </el-table-column >
42
+ <el-table-column prop =" startDate" label =" 开始日期" > </el-table-column >
43
+ <el-table-column prop =" endDate" label =" 结束日期" > </el-table-column >
44
+ <el-table-column prop =" catagory" label =" 类别" > </el-table-column >
45
+ <el-table-column prop =" isJdSale" label =" 自营" > </el-table-column >
46
+ <el-table-column fixed =" right" label =" 操作" width =" 100" >
47
+ <template slot-scope="scope">
48
+ <el-button @click =" handleClick(scope.row)" type =" text" size =" small"
49
+ >编辑</el-button
9
50
>
10
- </el-col >
11
- <el-col :span =" 4" >
12
- <el-input placeholder =" 请输入内容" v-model =" search" >
13
- <el-button slot =" append" icon =" el-icon-search" ></el-button >
14
- </el-input >
15
- <div style =" clear : both " ></div >
16
- </el-col >
17
- </el-row >
18
- </el-header >
19
- <el-main >
20
- <el-table
21
- :data ="
22
- tableData.slice(
23
- (currentPage - 1) * pageSize,
24
- currentPage * pageSize
25
- )
26
- "
27
- style =" width : 100% "
51
+ <el-button type =" text" size =" small" >删除</el-button >
52
+ </template >
53
+ </el-table-column >
54
+ </el-table >
55
+ <div class =" block" >
56
+ <el-pagination
57
+ @size-change =" handleSizeChange"
58
+ @current-change =" handleCurrentChange"
59
+ :current-page =" currentPage"
60
+ :page-sizes =" [10, 20, 30, 50, 100]"
61
+ :page-size =" pageSize"
62
+ layout =" prev, pager, next"
63
+ :total =" tableData.length"
28
64
>
29
- <el-table-column prop =" imgUrl" label =" 图片链接" width =" 100px" >
30
- <template slot-scope="scope">
31
- <img :src =" scope.row.imgUrl" style =" height : 100px " />
32
- </template >
33
- </el-table-column >
34
- <el-table-column label =" 商品名" min-width =" 150px" >
35
- <template slot-scope="scope">
36
- <a :href =" scope.row.materialUrl" target =" _blank" >{{
37
- scope.row.name
38
- }}</a >
39
- </template >
40
- </el-table-column >
41
- <el-table-column prop =" unitPrice" label =" 单价" > </el-table-column >
42
- <el-table-column prop =" bestPrice" label =" 活动价" > </el-table-column >
43
- <el-table-column prop =" startDate" label =" 开始日期" > </el-table-column >
44
- <el-table-column prop =" endDate" label =" 结束日期" > </el-table-column >
45
- <el-table-column prop =" catagory" label =" 类别" > </el-table-column >
46
- <el-table-column prop =" isJdSale" label =" 自营" > </el-table-column >
47
- <el-table-column fixed =" right" label =" 操作" width =" 100" >
48
- <template slot-scope="scope">
49
- <el-button
50
- @click =" handleClick(scope.row)"
51
- type =" text"
52
- size =" small"
53
- >编辑</el-button
54
- >
55
- <el-button type =" text" size =" small" >删除</el-button >
56
- </template >
57
- </el-table-column >
58
- </el-table >
59
- <div class =" block" >
60
- <el-pagination
61
- @size-change =" handleSizeChange"
62
- @current-change =" handleCurrentChange"
63
- :current-page =" currentPage"
64
- :page-sizes =" [10, 20, 30, 50, 100]"
65
- :page-size =" pageSize"
66
- layout =" prev, pager, next"
67
- :total =" tableData.length"
68
- style =" float : right "
69
- >
70
- </el-pagination >
71
- </div >
72
- </el-main >
73
- </el-container >
74
- <div >
65
+ </el-pagination >
66
+ </div >
75
67
<el-dialog
76
68
title =" 新增商品"
77
69
:visible.sync =" dialogFormVisible"
100
92
<el-button type =" primary" @click =" addProduct" >确 定</el-button >
101
93
</div >
102
94
</el-dialog >
103
- </div >
104
- </div >
95
+ </el-main >
96
+ </el-container >
105
97
</template >
106
98
107
99
<script >
108
100
import axios from " axios" ;
101
+ import { API } from " ../../config.js" ;
109
102
export default {
110
103
name: " AddProductions" ,
111
104
data () {
112
105
return {
113
106
pageSize: 4 , // 每页多少条
114
107
currentPage: 1 , // 当前页
115
108
tableData: [],
109
+ formLabelWidth: " 120px" ,
116
110
form: {
117
111
skuid: " " ,
118
112
bestPrice: " " ,
119
113
},
120
114
dialogFormVisible: false ,
121
- formLabelWidth: " 120px" ,
122
115
search: " " ,
123
116
};
124
117
},
@@ -134,11 +127,21 @@ export default {
134
127
handleClick (row ) {
135
128
console .log (row .name );
136
129
},
130
+ getProducts () {
131
+ let tableDataP = axios
132
+ .post (API .GET_PRODUCTS_INFO , { goodsName: " " })
133
+ .then ((res ) => {
134
+ return res .data .data ;
135
+ });
136
+ tableDataP .then ((res ) => {
137
+ this .tableData = res;
138
+ });
139
+ },
137
140
addProduct () {
138
141
this .dialogFormVisible = false ;
139
142
// 此处通过skuid传参调取api,去抓取京东商品信息
140
143
let product_info = axios
141
- .post (" http://localhost:5000/get_product_info " , {
144
+ .post (API . ADD_PRODUCT_INFO , {
142
145
skuid: this .form .skuid ,
143
146
bestPrice: this .form .bestPrice ,
144
147
})
@@ -150,18 +153,12 @@ export default {
150
153
});
151
154
product_info .then ((data ) => {
152
155
this .$message (data .msg );
156
+ this .getProducts ();
153
157
});
154
158
},
155
159
},
156
160
mounted : function () {
157
- let tableDataP = axios
158
- .post (" http://localhost:5000/get_goods_list" , { goodsName: " " })
159
- .then ((res ) => {
160
- return res .data .data ;
161
- });
162
- tableDataP .then ((res ) => {
163
- this .tableData = res;
164
- });
161
+ this .getProducts ();
165
162
},
166
163
};
167
164
</script >
0 commit comments