diff --git a/src/views/dataCenter/goods/Index.vue b/src/views/dataCenter/goods/Index.vue index 7e332d1..f2acbc8 100644 --- a/src/views/dataCenter/goods/Index.vue +++ b/src/views/dataCenter/goods/Index.vue @@ -121,7 +121,8 @@ import CategoryModel from '@/common/model/Category' const columns = [ { title: '商品ID', - dataIndex: 'goods_id' + dataIndex: 'goods_id', + sorter: true }, { title: '渠道', @@ -142,15 +143,18 @@ const columns = [ { title: '商品价格', dataIndex: 'goods_price_min', - scopedSlots: { customRender: 'goods_price_min' } + scopedSlots: { customRender: 'goods_price_min' }, + sorter: true }, { title: '总销量', - dataIndex: 'sales_actual' + dataIndex: 'sales_actual', + sorter: true }, { title: '库存总量', - dataIndex: 'stock_total' + dataIndex: 'stock_total', + sorter: true }, { title: '状态', @@ -159,12 +163,14 @@ const columns = [ }, { title: '排序', - dataIndex: 'sort' + dataIndex: 'sort', + sorter: true }, { title: '添加时间', width: '180px', - dataIndex: 'create_time' + dataIndex: 'create_time', + sorter: true }, { title: '操作', @@ -199,7 +205,23 @@ export default { selectedRowKeys: [], // 加载数据方法 必须为 Promise 对象 loadData: (param) => { - return GoodsApi.list({ ...param, ...this.queryParam }).then((response) => { + const data = { ...param, ...this.queryParam } + const orderEnum = { + ascend: 'asc', + descend: 'desc' + } + + if (data.sortField && data.sortOrder && orderEnum[data.sortOrder]) { + data.sort = data.sortField + data.order = orderEnum[data.sortOrder] + delete data.sortField + delete data.sortOrder + } else { + delete data.sortField + delete data.sortOrder + } + + return GoodsApi.list(data).then((response) => { return response.data.list }) }, @@ -278,9 +300,6 @@ export default { // 修改商品状态(上下架) handleUpdateStatus (goodsIds, state = true) { - if (!this.$auth('/goods/index.status')) { - return false - } this.isLoading = true GoodsApi.state({ goodsIds, state }) .then((result) => {