9R67">67
+ </el-table-column>
+ <el-table-column label="顾客地址" align="center">
+ <template slot-scope="{row}">
+ <span>{{ row.province + row.city + row.county + row.address }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="直播主题" align="center">
+ <template slot-scope="{row}">
+ <span>{{ row.room_name }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="快递单号" align="center">
+ <template slot-scope="{row}">
+ <span>{{ row.tracking_number }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="支付状态" align="center" width="150px">
+ <template slot-scope="{row}">
+ <el-tag :type="row.pay_status | statusFilter">
+ {{ statusOptions[row.pay_status] }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column label="时间" align="center" width="150px">
+ <template slot-scope="{row}">
+ <span>{{ row.paid_at }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="Actions" align="center" class-name="small-padding fixed-width" fixed="right" width="100">
+ <template slot-scope="{row,$index}">
+ <el-button v-if="(row.tracking_number === null || row.tracking_number === '') && row.pay_status === 1" type="primary" @click="handleDelivery(row, $index)">发货</el-button>
+ <el-button v-else-if="row.tracking_number !== null && row.pay_status === 1" type="success" disabled>已发货</el-button>
+ <el-button v-else type="info" disabled>发货</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+
+ <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.num" @pagination="getList" />
+ </div>
+</template>
+
+<script>
+import { fetchOrderList, deliveryOrder } from '@/api/live'
+import waves from '@/directive/waves' // waves directive
+import Pagination from '@/components/Pagination' // secondary package based on el-pagination
+
+export default {
+ name: 'ComplexTable',
+ components: { Pagination },
+ directives: { waves },
+ filters: {
+ statusFilter(status) {
+ const statusMap = {
+ 1: 'success',
+ 0: 'warn',
+ 2: 'danger'
+ }
+ return statusMap[status]
+ }
+ },
+ data() {
+ return {
+ tableKey: 0,
+ list: null,
+ total: 0,
+ listLoading: true,
+ searchNetworkLoading: false,
+ statusOptions: ['支付中', '已支付', '支付失败'],
+ showOrderID: false,
+ showTransactionID: false,
+
+ listQuery: {
+ page: 1,
+ num: 20,
+ pay_status: '',
+ query: ''
+ }
+ }
+ },
+ created() {
+ this.getList()
+ },
+ methods: {
+ getList(query) {
+ this.listLoading = true
+ var _self = this
+ fetchOrderList(this.listQuery).then(response => {
+ _self.list = response.data.orders
+ _self.total = response.data.count
+ // Just to simulate the time of the request
+ _self.listLoading = false
+ _self.searchNetworkLoading = false
+ })
+ },
+
+ handleFilter() {
+ this.searchNetworkLoading = true
+ this.getList(this.listQuery.title)
+ },
+
+ handleDelivery(row, index) {
+ this.listLoading = true
+ var _self = this
+ deliveryOrder(row).then(response => {
+ _self.$set(_self.list, index, response.data.order)
+ _self.listLoading = false
+ })
+ }
+ }
+}
+</script>
@@ -0,0 +1,362 @@ |
||
1 |
+<template> |
|
2 |
+ <div class="app-container"> |
|
3 |
+ <div class="filter-container"> |
|
4 |
+ <el-input v-model="listQuery.query" placeholder="搜索直播主题" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" /> |
|
5 |
+ <el-select v-model="listQuery.live_status" placeholder="直播状态" clearable class="filter-item" style="width: 130px"> |
|
6 |
+ <el-option v-for="(k, v) in statusOptions" :key="k" :value="v" :label="k" /> |
|
7 |
+ </el-select> |
|
8 |
+ <el-button v-waves :loading="networkLoading" class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter"> |
|
9 |
+ 搜索 |
|
10 |
+ </el-button> |
|
11 |
+ <el-button v-waves :loading="networkLoading" class="filter-item" type="primary" icon="el-icon-refresh" @click="handleRefresh"> |
|
12 |
+ 从微信获取直播列表 |
|
13 |
+ </el-button> |
|
14 |
+ </div> |
|
15 |
+ |
|
16 |
+ <el-table |
|
17 |
+ id="room-table" |
|
18 |
+ :key="tableKey" |
|
19 |
+ ref="multipleTable" |
|
20 |
+ v-loading="listLoading" |
|
21 |
+ :data="list" |
|
22 |
+ border |
|
23 |
+ fit |
|
24 |
+ highlight-current-row |
|
25 |
+ style="width: 100%;" |
|
26 |
+ > |
|
27 |
+ <el-table-column label="room_id" prop="房间号" align="center" width="80"> |
|
28 |
+ <template slot-scope="{row}"> |
|
29 |
+ <span>{{ row.room_id }}</span> |
|
30 |
+ </template> |
|
31 |
+ </el-table-column> |
|
32 |
+ <el-table-column label="直播主题" align="center"> |
|
33 |
+ <template slot-scope="{row}"> |
|
34 |
+ <span>{{ row.name }}</span> |
|
35 |
+ </template> |
|
36 |
+ </el-table-column> |
|
37 |
+ <el-table-column label="主播" align="center"> |
|
38 |
+ <template slot-scope="{row}"> |
|
39 |
+ <el-avatar shape="square" :src="row.anchor_avatar" /> |
|
40 |
+ <span>{{ row.anchor_name }}</span> |
|
41 |
+ </template> |
|
42 |
+ </el-table-column> |
|
43 |
+ <el-table-column label="直播状态" align="center"> |
|
44 |
+ <template slot-scope="{row}"> |
|
45 |
+ <el-tag :type="row.live_status | statusFilter"> |
|
46 |
+ {{ statusOptions[row.live_status] }} |
|
47 |
+ </el-tag> |
|
48 |
+ </template> |
|
49 |
+ </el-table-column> |
|
50 |
+ <el-table-column label="直播封面" align="center"> |
|
51 |
+ <template slot-scope="{row}"> |
|
52 |
+ <el-image |
|
53 |
+ style="width: 100px; height: 100px" |
|
54 |
+ :src="row.cover_img" |
|
55 |
+ fit="contain" |
|
56 |
+ /> |
|
57 |
+ </template> |
|
58 |
+ </el-table-column> |
|
59 |
+ <el-table-column label="直播分享卡片" align="center"> |
|
60 |
+ <template slot-scope="{row}"> |
|
61 |
+ <el-image |
|
62 |
+ style="width: 200px; height: 160px" |
|
63 |
+ :src="row.share_img" |
|
64 |
+ fit="contain" |
|
65 |
+ /> |
|
66 |
+ </template> |
|
67 |
+ </el-table-column> |
|
68 |
+ <el-table-column label="Actions" align="center" class-name="small-padding fixed-width" fixed="right"> |
|
69 |
+ <template slot-scope="{row}"> |
|
70 |
+ <el-button v-if="row.live_status == 102 || row.live_status == 101" type="primary" @click="handleAddGoods(row)">添加商品</el-button> |
|
71 |
+ <el-button v-else type="info" disabled>添加商品</el-button> |
|
72 |
+ </template> |
|
73 |
+ </el-table-column> |
|
74 |
+ </el-table> |
|
75 |
+ |
|
76 |
+ <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.num" @pagination="getList" /> |
|
77 |
+ |
|
78 |
+ <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible"> |
|
79 |
+ <el-table |
|
80 |
+ id="room-table" |
|
81 |
+ v-loading="goodsListLoading" |
|
82 |
+ :data="goodsList" |
|
83 |
+ fit |
|
84 |
+ highlight-current-row |
|
85 |
+ height="400px" |
|
86 |
+ style="width: 100%;" |
|
87 |
+ @selection-change="handleSelectionChange" |
|
88 |
+ > |
|
89 |
+ <el-table-column |
|
90 |
+ type="selection" |
|
91 |
+ width="30" |
|
92 |
+ /> |
|
93 |
+ <el-table-column label="商品图片" align="center"> |
|
94 |
+ <template slot-scope="{row}"> |
|
95 |
+ <el-image |
|
96 |
+ style="width: 60px; height: 60px" |
|
97 |
+ :src="row.goods_img" |
|
98 |
+ fit="contain" |
|
99 |
+ /> |
|
100 |
+ </template> |
|
101 |
+ </el-table-column> |
|
102 |
+ <el-table-column label="商品名称" align="center"> |
|
103 |
+ <template slot-scope="{row}"> |
|
104 |
+ <span>{{ row.name }}</span> |
|
105 |
+ </template> |
|
106 |
+ </el-table-column> |
|
107 |
+ <el-table-column label="价格" align="center" width="150px"> |
|
108 |
+ <template slot-scope="{row}"> |
|
109 |
+ <span v-if="row.price_type === 1">{{ row.price / 100 }}元</span> |
|
110 |
+ <span v-if="row.price_type === 3">原价:{{ row.price / 100 }}元 <br> 折扣价:{{ row.price2 / 100 }}元</span> |
|
111 |
+ </template> |
|
112 |
+ </el-table-column> |
|
113 |
+ <pagination v-show="goodsTotal>0" :total="goodsTotal" :page.sync="goodsListQuery.page" :limit.sync="goodsListQuery.num" @pagination="getGoodsList" /> |
|
114 |
+ </el-table> |
|
115 |
+ <div slot="footer" class="dialog-footer"> |
|
116 |
+ <el-button @click="handleUnaddGoods"> |
|
117 |
+ 取消 |
|
118 |
+ </el-button> |
|
119 |
+ <el-button :disabled="temp.goods_list.length === 0" type="primary" @click="handleAddGoodsNextStep()"> |
|
120 |
+ 下一步 |
|
121 |
+ </el-button> |
|
122 |
+ </div> |
|
123 |
+ </el-dialog> |
|
124 |
+ <el-dialog :title="dialogTitle" :visible.sync="dialogForAddGoodsFormVisible"> |
|
125 |
+ <el-table |
|
126 |
+ id="room-table" |
|
127 |
+ :data="temp.goods_list" |
|
128 |
+ fit |
|
129 |
+ highlight-current-row |
|
130 |
+ height="300px" |
|
131 |
+ style="width: 100%;" |
|
132 |
+ @selection-change="handleSelectionChange" |
|
133 |
+ > |
|
134 |
+ <el-table-column label="商品图片" align="center"> |
|
135 |
+ <template slot-scope="{row}"> |
|
136 |
+ <el-image |
|
137 |
+ style="width: 60px; height: 60px" |
|
138 |
+ :src="row.goods_img" |
|
139 |
+ fit="contain" |
|
140 |
+ /> |
|
141 |
+ </template> |
|
142 |
+ </el-table-column> |
|
143 |
+ <el-table-column label="商品名称" align="center"> |
|
144 |
+ <template slot-scope="{row}"> |
|
145 |
+ <span>{{ row.name }}</span> |
|
146 |
+ </template> |
|
147 |
+ </el-table-column> |
|
148 |
+ <el-table-column label="价格" align="center" width="150px"> |
|
149 |
+ <template slot-scope="{row}"> |
|
150 |
+ <span v-if="row.price_type === 1">{{ row.price / 100 }}元</span> |
|
151 |
+ <span v-if="row.price_type === 3">原价:{{ row.price / 100 }}元 <br> 折扣价:{{ row.price2 / 100 }}元</span> |
|
152 |
+ </template> |
|
153 |
+ </el-table-column> |
|
154 |
+ <el-table-column label="库存" align="center" width="150px"> |
|
155 |
+ <template slot-scope="{row}"> |
|
156 |
+ <el-input-number v-model="row.inventory" :min="1" size="small" label="描述文字" @change="handleInventoryChanged" /> |
|
157 |
+ </template> |
|
158 |
+ </el-table-column> |
|
159 |
+ <pagination :total="temp.goods_list.length" /> |
|
160 |
+ </el-table> |
|
161 |
+ <div slot="footer" class="dialog-footer"> |
|
162 |
+ <el-button @click="handleUnaddGoods"> |
|
163 |
+ 取消 |
|
164 |
+ </el-button> |
|
165 |
+ <el-button type="primary" @click="handleAddGoodsPrevStep"> |
|
166 |
+ 上一步 |
|
167 |
+ </el-button> |
|
168 |
+ <el-button v-waves :loading="networkLoading" :disabled="addGoodsEnable" type="primary" @click="handleAddGoodsToRoom()"> |
|
169 |
+ 添加 |
|
170 |
+ </el-button> |
|
171 |
+ </div> |
|
172 |
+ </el-dialog> |
|
173 |
+ </div> |
|
174 |
+</template> |
|
175 |
+ |
|
176 |
+<script> |
|
177 |
+import { addRoomGoods, fetchGoodsList, fetchRoomList, refreshWxRoomList } from '@/api/live' |
|
178 |
+import waves from '@/directive/waves' // waves directive |
|
179 |
+import Pagination from '@/components/Pagination' // secondary package based on el-pagination |
|
180 |
+ |
|
181 |
+export default { |
|
182 |
+ name: 'ComplexTable', |
|
183 |
+ components: { Pagination }, |
|
184 |
+ directives: { waves }, |
|
185 |
+ filters: { |
|
186 |
+ statusFilter(status) { |
|
187 |
+ const statusMap = { |
|
188 |
+ 101: '', |
|
189 |
+ 102: 'success', |
|
190 |
+ 103: 'info', |
|
191 |
+ 104: 'danger', |
|
192 |
+ 105: 'danger', |
|
193 |
+ 106: 'danger', |
|
194 |
+ 107: 'warning' |
|
195 |
+ |
|
196 |
+ } |
|
197 |
+ return statusMap[status] |
|
198 |
+ } |
|
199 |
+ }, |
|
200 |
+ data() { |
|
201 |
+ return { |
|
202 |
+ tableKey: 0, |
|
203 |
+ list: null, |
|
204 |
+ total: 0, |
|
205 |
+ listLoading: true, |
|
206 |
+ listQuery: { |
|
207 |
+ page: 1, |
|
208 |
+ num: 20, |
|
209 |
+ query: '', |
|
210 |
+ live_status: '' |
|
211 |
+ }, |
|
212 |
+ |
|
213 |
+ statusOptions: { |
|
214 |
+ 101: '直播中', |
|
215 |
+ 102: '未开始', |
|
216 |
+ 103: '已结束', |
|
217 |
+ 104: '禁播', |
|
218 |
+ 105: '暂停中', |
|
219 |
+ 106: '异常', |
|
220 |
+ 107: '已过期' |
|
221 |
+ }, |
|
222 |
+ networkLoading: false, |
|
223 |
+ dialogFormVisible: false, |
|
224 |
+ dialogTitle: '', |
|
225 |
+ |
|
226 |
+ goodsList: null, |
|
227 |
+ goodsTotal: 0, |
|
228 |
+ goodsListLoading: true, |
|
229 |
+ goodsListQuery: { |
|
230 |
+ page: 1, |
|
231 |
+ num: 20, |
|
232 |
+ room_id: '' |
|
233 |
+ }, |
|
234 |
+ |
|
235 |
+ temp: { |
|
236 |
+ room_id: '', |
|
237 |
+ anchor_id: '', |
|
238 |
+ goods_list: [] |
|
239 |
+ }, |
|
240 |
+ dialogForAddGoodsFormVisible: false, |
|
241 |
+ addGoodsEnable: false |
|
242 |
+ } |
|
243 |
+ }, |
|
244 |
+ created() { |
|
245 |
+ this.getList() |
|
246 |
+ }, |
|
247 |
+ methods: { |
|
248 |
+ getList() { |
|
249 |
+ this.listLoading = true |
|
250 |
+ var _self = this |
|
251 |
+ fetchRoomList(this.listQuery).then(response => { |
|
252 |
+ _self.list = response.data.rooms |
|
253 |
+ _self.total = response.data.count |
|
254 |
+ // Just to simulate the time of the request |
|
255 |
+ _self.listLoading = false |
|
256 |
+ _self.networkLoading = false |
|
257 |
+ }) |
|
258 |
+ }, |
|
259 |
+ |
|
260 |
+ getGoodsList(room_id) { |
|
261 |
+ this.goodsListLoading = true |
|
262 |
+ var _self = this |
|
263 |
+ this.goodsListQuery.room_id = room_id |
|
264 |
+ fetchGoodsList(this.goodsListQuery).then(response => { |
|
265 |
+ _self.goodsList = response.data.goods_list |
|
266 |
+ _self.goodsTotal = response.data.count |
|
267 |
+ // Just to simulate the time of the request |
|
268 |
+ this.goodsListLoading = false |
|
269 |
+ }) |
|
270 |
+ }, |
|
271 |
+ |
|
272 |
+ resetTemp() { |
|
273 |
+ this.goodsList = null |
|
274 |
+ this.goodsTotal = 0 |
|
275 |
+ this.goodsListQuery = { |
|
276 |
+ page: 1, |
|
277 |
+ num: 20, |
|
278 |
+ room_id: '' |
|
279 |
+ } |
|
280 |
+ |
|
281 |
+ this.temp = { |
|
282 |
+ room_id: '', |
|
283 |
+ anchor_id: '', |
|
284 |
+ goods_list: [] |
|
285 |
+ } |
|
286 |
+ }, |
|
287 |
+ |
|
288 |
+ handleFilter() { |
|
289 |
+ this.getList() |
|
290 |
+ }, |
|
291 |
+ |
|
292 |
+ handleRefresh() { |
|
293 |
+ this.listLoading = true |
|
294 |
+ this.networkLoading = true |
|
295 |
+ var _self = this |
|
296 |
+ refreshWxRoomList().then(response => { |
|
297 |
+ fetchRoomList().then(response => { |
|
298 |
+ _self.list = response.data.rooms |
|
299 |
+ _self.total = response.data.count |
|
300 |
+ // Just to simulate the time of the request |
|
301 |
+ this.listLoading = false |
|
302 |
+ _self.networkLoading = false |
|
303 |
+ }) |
|
304 |
+ }) |
|
305 |
+ }, |
|
306 |
+ |
|
307 |
+ handleAddGoods(row) { |
|
308 |
+ this.dialogFormVisible = true |
|
309 |
+ this.dialogTitle = row.name |
|
310 |
+ this.temp.room_id = row.room_id |
|
311 |
+ this.temp.anchor_id = row.anchor_id |
|
312 |
+ this.getGoodsList(row.room_id) |
|
313 |
+ }, |
|
314 |
+ |
|
315 |
+ handleSelectionChange(v) { |
|
316 |
+ this.temp.goods_list = v |
|
317 |
+ this.$set(this.temp, 'goods_list', v) |
|
318 |
+ }, |
|
319 |
+ |
|
320 |
+ handleUnaddGoods() { |
|
321 |
+ this.dialogForAddGoodsFormVisible = false |
|
322 |
+ this.dialogFormVisible = false |
|
323 |
+ this.resetTemp() |
|
324 |
+ }, |
|
325 |
+ |
|
326 |
+ handleAddGoodsNextStep() { |
|
327 |
+ this.dialogForAddGoodsFormVisible = true |
|
328 |
+ console.log(this.temp) |
|
329 |
+ this.temp.goods_list = this.temp.goods_list.map(goods => { |
|
330 |
+ goods.inventory = '' |
|
331 |
+ return goods |
|
332 |
+ }) |
|
333 |
+ }, |
|
334 |
+ |
|
335 |
+ handleInventoryChanged(v) { |
|
336 |
+ this.temp.goods_list.filter(v => { |
|
337 |
+ return v.inventory !== '' |
|
338 |
+ }) |
|
339 |
+ }, |
|
340 |
+ |
|
341 |
+ handleAddGoodsPrevStep() { |
|
342 |
+ this.dialogForAddGoodsFormVisible = false |
|
343 |
+ }, |
|
344 |
+ |
|
345 |
+ handleAddGoodsToRoom() { |
|
346 |
+ var _self = this |
|
347 |
+ this.networkLoading = true |
|
348 |
+ const params = Object.assign({}, this.temp) |
|
349 |
+ params.goods_list = JSON.stringify(this.temp.goods_list) |
|
350 |
+ addRoomGoods(params).then(response => { |
|
351 |
+ console.log(response) |
|
352 |
+ if (response.status === 200) { |
|
353 |
+ _self.dialogForAddGoodsFormVisible = false |
|
354 |
+ _self.dialogFormVisible = false |
|
355 |
+ _self.networkLoading = false |
|
356 |
+ _self.resetTemp() |
|
357 |
+ } |
|
358 |
+ }) |
|
359 |
+ } |
|
360 |
+ } |
|
361 |
+} |
|
362 |
+</script> |
@@ -0,0 +1,216 @@ |
||
1 |
+<template> |
|
2 |
+ <div class="app-container"> |
|
3 |
+ <div class="filter-container"> |
|
4 |
+ <el-checkbox v-model="showGoodsID" class="filter-item" style="margin-left:15px;"> |
|
5 |
+ 商品ID |
|
6 |
+ </el-checkbox> |
|
7 |
+ <el-checkbox v-model="showWXGoodsID" class="filter-item" style="margin-left:15px;"> |
|
8 |
+ 微信商品ID |
|
9 |
+ </el-checkbox> |
|
10 |
+ <el-checkbox v-model="showRoomID" class="filter-item" style="margin-left:15px;"> |
|
11 |
+ 直播间ID |
|
12 |
+ </el-checkbox> |
|
13 |
+ </div> |
|
14 |
+ |
|
15 |
+ <el-table |
|
16 |
+ id="goods-table" |
|
17 |
+ v-loading="listLoading" |
|
18 |
+ :data="list" |
|
19 |
+ border |
|
20 |
+ fit |
|
21 |
+ highlight-current-row |
|
22 |
+ style="width: 100%;" |
|
23 |
+ > |
|
24 |
+ <el-table-column v-if="showRoomID" label="房间ID" prop="id" align="center"> |
|
25 |
+ <template slot-scope="{row}"> |
|
26 |
+ <span>{{ row.room_id }}</span> |
|
27 |
+ </template> |
|
28 |
+ </el-table-column> |
|
29 |
+ <el-table-column label="直播主题" prop="id" align="center"> |
|
30 |
+ <template slot-scope="{row}"> |
|
31 |
+ <span>{{ row.room_name }}</span> |
|
32 |
+ </template> |
|
33 |
+ </el-table-column> |
|
34 |
+ <el-table-column label="主播" prop="id" align="center"> |
|
35 |
+ <template slot-scope="{row}"> |
|
36 |
+ <span>{{ row.anchor_name }}</span> |
|
37 |
+ </template> |
|
38 |
+ </el-table-column> |
|
39 |
+ <el-table-column v-if="showGoodsID" label="商品ID" prop="id" align="center"> |
|
40 |
+ <template slot-scope="{row}"> |
|
41 |
+ <span>{{ row.goods_id }}</span> |
|
42 |
+ </template> |
|
43 |
+ </el-table-column> |
|
44 |
+ <el-table-column v-if="showWXGoodsID" label="微信商品ID" prop="id" align="center"> |
|
45 |
+ <template slot-scope="{row}"> |
|
46 |
+ <span>{{ row.wx_goods_id }}</span> |
|
47 |
+ </template> |
|
48 |
+ </el-table-column> |
|
49 |
+ <el-table-column label="商品名称" align="center"> |
|
50 |
+ <template slot-scope="{row}"> |
|
51 |
+ <span>{{ row.goods_name }}</span> |
|
52 |
+ </template> |
|
53 |
+ </el-table-column> |
|
54 |
+ <el-table-column label="商品图片" align="center" width="120px"> |
|
55 |
+ <template slot-scope="{row}"> |
|
56 |
+ <el-image |
|
57 |
+ style="width: 90px; height: 90px" |
|
58 |
+ :src="row.goods_img" |
|
59 |
+ fit="contain" |
|
60 |
+ /> |
|
61 |
+ </template> |
|
62 |
+ </el-table-column> |
|
63 |
+ <el-table-column label="价格" align="center" width="150px"> |
|
64 |
+ <template slot-scope="{row}"> |
|
65 |
+ <span v-if="row.price_type === 1">{{ row.price / 100 }}元</span> |
|
66 |
+ <span v-if="row.price_type === 3">原价:{{ row.price / 100 }}元 <br> 折扣价:{{ row.price2 / 100 }}元</span> |
|
67 |
+ </template> |
|
68 |
+ </el-table-column> |
|
69 |
+ <el-table-column label="商品状态" align="center"> |
|
70 |
+ <template slot-scope="{row}"> |
|
71 |
+ <el-tag :type="row.goods_status | statusFilter">{{ statusOptions[row.goods_status] }}</el-tag> |
|
72 |
+ </template> |
|
73 |
+ </el-table-column> |
|
74 |
+ <el-table-column label="库存" align="center" width="200px"> |
|
75 |
+ <template slot-scope="{row}"> |
|
76 |
+ <div v-if="!row.isEditable"> |
|
77 |
+ <span v-if="row.inventory > 0">{{ row.inventory }}</span> |
|
78 |
+ <el-tag v-else type="danger">库存不足</el-tag> |
|
79 |
+ </div> |
|
80 |
+ <div v-if="row.isEditable"> |
|
81 |
+ <el-input v-model="inventory" style="width:50px;" @keyup.enter.native="handleInventoryChanged(row)" /> |
|
82 |
+ <el-button type="info" size="mini" @click="handleUpdateCancel(row)">取消</el-button> |
|
83 |
+ </div> |
|
84 |
+ </template> |
|
85 |
+ </el-table-column> |
|
86 |
+ <el-table-column label="销售数量" align="center"> |
|
87 |
+ <template slot-scope="{row}"> |
|
88 |
+ <span>{{ row.sale_count }}</span> |
|
89 |
+ </template> |
|
90 |
+ </el-table-column> |
|
91 |
+ <el-table-column label="动作" align="center" class-name="small-padding fixed-width" fixed="right" width="200"> |
|
92 |
+ <template slot-scope="{row}"> |
|
93 |
+ <el-button v-if="(row.goods_status === 1 || row.goods_status === 2) && (row.room_status == 102 || row.room_status == 101)" type="success" size="mini" @click="handlePublish(row)"> |
|
94 |
+ 上架 |
|
95 |
+ </el-button> |
|
96 |
+ <el-button v-else-if="(row.goods_status === 0) && (row.room_status == 102 || row.room_status == 101)" type="danger" size="mini" @click="handleOff(row)"> |
|
97 |
+ 下架 |
|
98 |
+ </el-button> |
|
99 |
+ <el-button v-else type="info" size="mini" disabled @click="handleOff(row)"> |
|
100 |
+ 已结束 |
|
101 |
+ </el-button> |
|
102 |
+ <el-button type="primary" size="mini" @click="handleUpdate(row)"> |
|
103 |
+ 更新 |
|
104 |
+ </el-button> |
|
105 |
+ </template> |
|
106 |
+ </el-table-column> |
|
107 |
+ </el-table> |
|
108 |
+ |
|
109 |
+ <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.num" @pagination="getList" /> |
|
110 |
+ </div> |
|
111 |
+</template> |
|
112 |
+ |
|
113 |
+<script> |
|
114 |
+import { fetchRoomGoodsList, publishRoomGoods, offRoomGoods, updateRoomGoods } from '@/api/live' |
|
115 |
+import waves from '@/directive/waves' // waves directive |
|
116 |
+import Pagination from '@/components/Pagination' // secondary package based on el-pagination |
|
117 |
+ |
|
118 |
+export default { |
|
119 |
+ name: 'ComplexTable', |
|
120 |
+ components: { Pagination }, |
|
121 |
+ directives: { waves }, |
|
122 |
+ filters: { |
|
123 |
+ statusFilter(status) { |
|
124 |
+ const statusMap = { |
|
125 |
+ 0: 'success', |
|
126 |
+ 1: 'info', |
|
127 |
+ 2: 'danger' |
|
128 |
+ } |
|
129 |
+ return statusMap[status] |
|
130 |
+ } |
|
131 |
+ }, |
|
132 |
+ data() { |
|
133 |
+ return { |
|
134 |
+ list: null, |
|
135 |
+ total: 0, |
|
136 |
+ listLoading: true, |
|
137 |
+ listQuery: { |
|
138 |
+ page: 1, |
|
139 |
+ num: 20 |
|
140 |
+ }, |
|
141 |
+ |
|
142 |
+ temp: { |
|
143 |
+ goods_name: '', |
|
144 |
+ price_type: '1', |
|
145 |
+ price: '', |
|
146 |
+ price2: '' |
|
147 |
+ }, |
|
148 |
+ |
|
149 |
+ statusOptions: ['已上架', '草稿', '已下架'], |
|
150 |
+ showGoodsID: false, |
|
151 |
+ showWXGoodsID: false, |
|
152 |
+ showRoomID: false, |
|
153 |
+ inventory: 0 |
|
154 |
+ } |
|
155 |
+ }, |
|
156 |
+ created() { |
|
157 |
+ this.getList() |
|
158 |
+ }, |
|
159 |
+ methods: { |
|
160 |
+ getList() { |
|
161 |
+ this.listLoading = true |
|
162 |
+ var _self = this |
|
163 |
+ fetchRoomGoodsList(this.listQuery).then(response => { |
|
164 |
+ _self.list = response.data.goods_list.map(goods => { |
|
165 |
+ goods.isEditable = false |
|
166 |
+ return goods |
|
167 |
+ }) |
|
168 |
+ _self.total = response.data.count |
|
169 |
+ // Just to simulate the time of the request |
|
170 |
+ this.listLoading = false |
|
171 |
+ }) |
|
172 |
+ }, |
|
173 |
+ |
|
174 |
+ handleFilter() { |
|
175 |
+ this.getList() |
|
176 |
+ }, |
|
177 |
+ |
|
178 |
+ handleOff(row) { |
|
179 |
+ var _self = this |
|
180 |
+ this.$alert(`确定从${row.room_name}下架${row.goods_name}`, '下架产品', { |
|
181 |
+ confirmButtonText: '下架', |
|
182 |
+ callback: action => { |
|
183 |
+ offRoomGoods(row).then(response => { |
|
184 |
+ _self.getList() |
|
185 |
+ }) |
|
186 |
+ } |
|
187 |
+ }) |
|
188 |
+ }, |
|
189 |
+ |
|
190 |
+ handlePublish(row) { |
|
191 |
+ var _self = this |
|
192 |
+ publishRoomGoods(row).then(response => { |
|
193 |
+ _self.getList() |
|
194 |
+ }) |
|
195 |
+ }, |
|
196 |
+ |
|
197 |
+ handleUpdate(row) { |
|
198 |
+ row.isEditable = true |
|
199 |
+ this.inventory = row.inventory |
|
200 |
+ }, |
|
201 |
+ |
|
202 |
+ handleUpdateCancel(row) { |
|
203 |
+ row.isEditable = false |
|
204 |
+ }, |
|
205 |
+ |
|
206 |
+ handleInventoryChanged(row) { |
|
207 |
+ var _self = this |
|
208 |
+ const goods = row |
|
209 |
+ goods.inventory = this.inventory |
|
210 |
+ updateRoomGoods(goods).then(response => { |
|
211 |
+ _self.getList() |
|
212 |
+ }) |
|
213 |
+ } |
|
214 |
+ } |
|
215 |
+} |
|
216 |
+</script> |