span rel="diff-541efe4306cbc71b055fc96d730a0e38ea429d9bR358">358
+ })
+ }
+ }
+}
+</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> |