visuddhinanda 2 лет назад
Родитель
Сommit
dfb882cd75
1 измененных файлов с 16 добавлено и 2 удалено
  1. 16 2
      dashboard/src/pages/admin/relation/list.tsx

+ 16 - 2
dashboard/src/pages/admin/relation/list.tsx

@@ -161,8 +161,9 @@ const Widget = () => {
             title: intl.formatMessage({
               id: "forms.fields.relation.label",
             }),
-            dataIndex: "relation",
-            key: "relation",
+            dataIndex: "name",
+            key: "name",
+            sorter: (a, b) => (a < b ? 1 : -1),
             render: (text, row, index, action) => {
               return (
                 <RelationEdit
@@ -300,6 +301,19 @@ const Widget = () => {
           if (filter.case) {
             url += `&case=${filter.case.join()}`;
           }
+          if (sorter) {
+            for (const key in sorter) {
+              if (Object.prototype.hasOwnProperty.call(sorter, key)) {
+                const element = sorter[key];
+                const dir = element === "ascend" ? "asc" : "desc";
+                let orderby = key;
+                if (orderby === "updatedAt") {
+                  orderby = "updated_at";
+                }
+                url += `&order=${orderby}&dir=${dir}`;
+              }
+            }
+          }
           console.log("url", url);
           const res = await get<IRelationListResponse>(url);
           const items: IRelation[] = res.data.rows.map((item, id) => {