feat: подсправочники — отображение в форме задачи, фильтрация и отображение значений
This commit is contained in:
@@ -27,6 +27,7 @@ export default function TableFieldSelect({
|
||||
const opts = options && !Array.isArray(options) ? (options as Record<string, any>) : {};
|
||||
const tableId = opts.tableId as number | undefined;
|
||||
const displayColumn = (opts.displayColumn as string) || '';
|
||||
const rowFilters = opts.filters as Record<string, string> | undefined;
|
||||
|
||||
const { data: tableData, isLoading, error } = useQuery<{
|
||||
table: {
|
||||
@@ -43,13 +44,17 @@ export default function TableFieldSelect({
|
||||
retry: false,
|
||||
});
|
||||
|
||||
const filtersStr = useMemo(() => (rowFilters ? JSON.stringify(rowFilters) : ''), [rowFilters]);
|
||||
|
||||
const { data: treeData } = useQuery<{
|
||||
columnIndex: number | null;
|
||||
nodes: DirectoryTreeNode[];
|
||||
}>({
|
||||
queryKey: ['/api/directories', tableId, 'rows', 'tree'],
|
||||
queryKey: ['/api/directories', tableId, 'rows', 'tree', filtersStr],
|
||||
queryFn: async () => {
|
||||
const res = await apiRequest('GET', `/api/directories/${tableId}/rows/tree`);
|
||||
const params = new URLSearchParams();
|
||||
if (filtersStr) params.set('filters', filtersStr);
|
||||
const res = await apiRequest('GET', `/api/directories/${tableId}/rows/tree?${params.toString()}`);
|
||||
return res.json();
|
||||
},
|
||||
enabled: !!tableId && !!tableData,
|
||||
|
||||
Reference in New Issue
Block a user