فهرست منبع

update: 增加table checkbox left fixed

xyh 2 سال پیش
والد
کامیت
81c833b054

+ 4 - 4
packages/app/src/components/table/hooks.tsx

@@ -40,7 +40,7 @@ function parseColumn<T extends Record<string, unknown>>(
     ...columns,
   ];
 
-  let leftPosition = 0;
+  let leftPosition = enableSelect ? 48 : 0;
   let rightPosition = parseColumns.reduce(function(prev, next) {
     if (next.fixed !== 'right') return prev;
 
@@ -113,9 +113,9 @@ function parseColumn<T extends Record<string, unknown>>(
       },
       meta: {
         align: 'center',
-        fixed: false,
+        fixed: 'left',
         disabledSort: true,
-        fixedStyle: {},
+        fixedStyle: {left: 0},
       },
     }),
   );
@@ -150,7 +150,7 @@ export function useTable<T extends Record<string, any>>(
     if (preloadData?.tableWidth)
       return JSON.parse(preloadData.tableWidth) as Record<string, number>;
 
-    const obj: Record<string, number> = {no: 64, select: 20};
+    const obj: Record<string, number> = {no: 64, select: 48};
 
     columns.forEach(function({dataIndex, width}) {
       if (dataIndex && width)

+ 1 - 0
packages/app/src/hooks/index.ts

@@ -18,3 +18,4 @@ export * from './create-basic-context';
 export * from './use-table-filter-event';
 export * from './use-upload';
 export * from './use-table-title';
+export * from './use-table-row-select';

+ 3 - 3
packages/app/src/hooks/use-table-row-select/index.ts

@@ -13,18 +13,18 @@ export function useTableRowSelect<T extends Record<string, unknown>>(
   }, [data]);
 
   const selectId = useMemo(function() {
-    const params: string[] = [];
+    const result: string[] = [];
 
     for (const [key, value] of Object.entries(rowSelection)) {
       if (value) {
         // key返回的对应的数组索引
         const id = data[Number(key)][rawKey ?? 'id'] as string;
 
-        params.push(id);
+        result.push(id);
       }
     }
 
-    return params.join(',');
+    return result;
   }, [data, rawKey, rowSelection]);
 
   return [