Просмотр исходного кода

enhance TableList: auto search after editing (#3380)

何乐 7 лет назад
Родитель
Сommit
bdc92d5c99
3 измененных файлов с 11 добавлено и 14 удалено
  1. 1 8
      mock/rule.js
  2. 7 3
      src/pages/List/TableList.js
  3. 3 3
      src/services/api.js

+ 1 - 8
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 {

+ 7 - 3
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,
+        },
       },
     });
 

+ 3 - 3
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',
     },
   });