Przeglądaj źródła

fix: columns error

jiangmaniu 4 miesięcy temu
rodzic
commit
fdc7fa385f
1 zmienionych plików z 41 dodań i 46 usunięć
  1. 41 46
      src/pages/Settings/Staff.tsx

+ 41 - 46
src/pages/Settings/Staff.tsx

@@ -107,10 +107,6 @@ const Edit: React.FC<{ bundle: EditBundle; onSuccess?: () => void }> = (props) =
         props.onSuccess?.();
         bundle.close();
       }}
-      onClose={() => {
-        form.resetFields();
-        bundle.close();
-      }}
       onCancel={() => {
         form.resetFields();
         bundle.close();
@@ -231,7 +227,47 @@ const Staff: React.FC = () => {
               data: res.data.records,
             };
           }}
-          columns={1}
+          columns={[
+            {
+              title: 'ID',
+              dataIndex: 'id',
+            },
+            {
+              title: '账号',
+              dataIndex: 'username',
+              filters: true,
+            },
+            {
+              title: '姓名',
+              dataIndex: 'nickname',
+              copyable: true,
+              ellipsis: true,
+            },
+            {
+              title: '角色列表',
+              dataIndex: 'roles',
+              render: (roles: Role[]) => roles.map(role => role.name).join(', '),
+            },
+            {
+              title: '操作',
+              valueType: 'option',
+              render: (_, record) => [
+                <a key={'edit'} onClick={() => bundle.update(record.id as number)}>
+                  编辑
+                </a>,
+                <a
+                  key={'delete'}
+                  onClick={async () => {
+                    await Service.remove(record.id as number);
+                    ref.current?.reload();
+                  }}
+                >
+                  删除
+                </a>,
+              ],
+            },
+          ]
+          }
           search={{
             labelWidth: 'auto',
           }}
@@ -257,44 +293,3 @@ const Staff: React.FC = () => {
 };
 
 export default Staff;
-
-const a = [
-  {
-    title: 'ID',
-    dataIndex: 'id',
-  },
-  {
-    title: '账号',
-    dataIndex: 'username',
-    filters: true,
-  },
-  {
-    title: '姓名',
-    dataIndex: 'nickname',
-    copyable: true,
-    ellipsis: true,
-  },
-  {
-    title: '角色列表',
-    dataIndex: 'roles',
-    render: (roles: Role[]) => roles.map(role => role.name).join(', '),
-  },
-  {
-    title: '操作',
-    valueType: 'option',
-    render: (_, record) => [
-      <a key={'edit'} onClick={() => bundle.update(record.id as number)}>
-        编辑
-      </a>,
-      <a
-        key={'delete'}
-        onClick={async () => {
-          await Service.remove(record.id as number);
-          ref.current?.reload();
-        }}
-      >
-        删除
-      </a>,
-    ],
-  },
-]