From bdc92d5c991f72d720fa460995dc19bcd83c5817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E4=B9=90?= Date: Thu, 17 Jan 2019 14:10:18 +0800 Subject: [PATCH] enhance TableList: auto search after editing (#3380) --- mock/rule.js | 9 +-------- src/pages/List/TableList.js | 10 +++++++--- src/services/api.js | 6 +++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/mock/rule.js b/mock/rule.js index 35d36c3b..87d235b0 100644 --- a/mock/rule.js +++ b/mock/rule.js @@ -122,14 +122,7 @@ function postRule(req, res, u, b) { break; } - const result = { - list: tableListDataSource, - pagination: { - total: tableListDataSource.length, - }, - }; - - return res.json(result); + return getRule(req, res, u); } export default { diff --git a/src/pages/List/TableList.js b/src/pages/List/TableList.js index 102cf858..13f5fb60 100644 --- a/src/pages/List/TableList.js +++ b/src/pages/List/TableList.js @@ -483,12 +483,16 @@ class TableList extends PureComponent { handleUpdate = fields => { const { dispatch } = this.props; + const { formValues } = this.state; dispatch({ type: 'rule/update', payload: { - name: fields.name, - desc: fields.desc, - key: fields.key, + query: formValues, + body: { + name: fields.name, + desc: fields.desc, + key: fields.key, + }, }, }); diff --git a/src/services/api.js b/src/services/api.js index 8cdf4fa8..f79cefff 100644 --- a/src/services/api.js +++ b/src/services/api.js @@ -33,11 +33,11 @@ export async function addRule(params) { }); } -export async function updateRule(params) { - return request('/api/rule', { +export async function updateRule(params = {}) { + return request(`/api/rule?${stringify(params.query)}`, { method: 'POST', body: { - ...params, + ...params.body, method: 'update', }, }); -- GitLab