From 39bdf44d4fa25f594363d297750659771f709a46 Mon Sep 17 00:00:00 2001 From: fanfan Date: Mon, 25 Mar 2024 10:16:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/goods/Index.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/views/goods/Index.vue b/src/views/goods/Index.vue index a5150b8..af2e48d 100644 --- a/src/views/goods/Index.vue +++ b/src/views/goods/Index.vue @@ -203,7 +203,22 @@ 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 }) }