fix
This commit is contained in:
parent
53c1b6f523
commit
6b20b9190e
29
src/App.tsx
29
src/App.tsx
@ -168,6 +168,8 @@ type TreeNode = {
|
||||
expanded: boolean;
|
||||
loading: boolean;
|
||||
loaded: boolean;
|
||||
hasData?: boolean;
|
||||
dataStatus?: 'normal' | 'empty';
|
||||
};
|
||||
type SelectedContentNode = {
|
||||
id: string;
|
||||
@ -269,6 +271,24 @@ function readText(row: Record<string, unknown>, keys: string[]) {
|
||||
return '';
|
||||
}
|
||||
|
||||
function readIndicatorDataStatus(row: Record<string, unknown>) {
|
||||
const rawStatus = readText(row, ['dataStatus', 'datastatus']).toLowerCase();
|
||||
const rawHasData = row.hasData ?? row.hasdata;
|
||||
const hasDataField = rawStatus === 'normal' || rawStatus === 'empty' || rawHasData !== undefined;
|
||||
const hasData =
|
||||
!hasDataField ||
|
||||
rawStatus === 'normal' ||
|
||||
rawHasData === true ||
|
||||
rawHasData === 1 ||
|
||||
rawHasData === '1' ||
|
||||
rawHasData === 'true';
|
||||
|
||||
return {
|
||||
hasData,
|
||||
dataStatus: rawStatus === 'empty' || !hasData ? 'empty' as const : 'normal' as const,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeTreeRows(rows: unknown[]): TreeNode[] {
|
||||
return rows
|
||||
.filter((row): row is Record<string, unknown> => !!row && typeof row === 'object')
|
||||
@ -331,6 +351,7 @@ function normalizeFlatIndicatorRows(rows: unknown[]): TreeNode[] {
|
||||
.filter((childId) => rowsById.has(childId))
|
||||
.map(buildNode);
|
||||
const label = readText(row, ['label', 'name', 'title', 'text', 'zbbh', 'mbmc']) || id;
|
||||
const dataStatus = readIndicatorDataStatus(row);
|
||||
return {
|
||||
id,
|
||||
label,
|
||||
@ -340,6 +361,8 @@ function normalizeFlatIndicatorRows(rows: unknown[]): TreeNode[] {
|
||||
expanded: children.length > 0,
|
||||
loading: false,
|
||||
loaded: true,
|
||||
hasData: dataStatus.hasData,
|
||||
dataStatus: dataStatus.dataStatus,
|
||||
};
|
||||
};
|
||||
|
||||
@ -579,6 +602,7 @@ function renderFilterTreeNodes(
|
||||
<ul className="content-tree-list filter-tree-list" role={depth === 0 ? 'tree' : 'group'}>
|
||||
{nodes.map((node) => {
|
||||
const selected = selectedNodeKeys.has(getFilterSelectionKey(filterKey, node.id));
|
||||
const showNoData = filterKey === 'indicatorTree' && node.dataStatus === 'empty';
|
||||
|
||||
return (
|
||||
<li className="content-tree-node" role="treeitem" aria-expanded={node.hasChildren ? node.expanded : undefined} key={node.id}>
|
||||
@ -591,14 +615,15 @@ function renderFilterTreeNodes(
|
||||
<span className="content-tree-caret is-leaf" />
|
||||
)}
|
||||
<button
|
||||
className="content-tree-select filter-tree-select"
|
||||
className={`content-tree-select filter-tree-select${showNoData ? ' is-empty-data' : ''}`}
|
||||
type="button"
|
||||
aria-pressed={selected}
|
||||
onClick={() => onSelect(node)}
|
||||
title={node.label}
|
||||
title={showNoData ? `${node.label}(无数据)` : node.label}
|
||||
>
|
||||
<span className="filter-tree-check" aria-hidden="true" />
|
||||
<span className="content-tree-label">{node.label}</span>
|
||||
{showNoData ? <span className="filter-tree-empty-badge">无数据</span> : null}
|
||||
</button>
|
||||
{node.loading ? <span className="content-tree-loading">加载中</span> : null}
|
||||
</div>
|
||||
|
||||
@ -899,6 +899,30 @@ button {
|
||||
content: "";
|
||||
}
|
||||
|
||||
.filter-tree-select.is-empty-data {
|
||||
color: #8a8279;
|
||||
}
|
||||
|
||||
.filter-tree-select.is-empty-data .content-tree-label {
|
||||
opacity: 0.58;
|
||||
}
|
||||
|
||||
.filter-tree-select.is-empty-data .filter-tree-check {
|
||||
opacity: 0.62;
|
||||
}
|
||||
|
||||
.filter-tree-empty-badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 1px 5px;
|
||||
border: 1px solid rgba(122, 112, 103, 0.22);
|
||||
border-radius: 3px;
|
||||
color: #7a7067;
|
||||
background: rgba(255, 252, 248, 0.72);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
@ -231,3 +231,7 @@ Port 5173 is in use, trying another one...
|
||||
[2m12:22:51[22m [36m[1m[vite][22m[39m [90m[2m(client)[22m[39m [32mhmr update [39m[2m/src/App.tsx[22m
|
||||
[2m12:44:18[22m [36m[1m[vite][22m[39m [90m[2m(client)[22m[39m [32mhmr update [39m[2m/src/App.tsx[22m
|
||||
[2m12:45:27[22m [36m[1m[vite][22m[39m [90m[2m(client)[22m[39m [32mhmr update [39m[2m/src/App.tsx[22m
|
||||
[2m14:35:53[22m [36m[1m[vite][22m[39m [90m[2m(client)[22m[39m [32mhmr update [39m[2m/src/App.tsx[22m
|
||||
[2m15:23:18[22m [36m[1m[vite][22m[39m [90m[2m(client)[22m[39m [32mhmr update [39m[2m/src/App.tsx[22m
|
||||
[2m15:23:36[22m [36m[1m[vite][22m[39m [90m[2m(client)[22m[39m [32mhmr update [39m[2m/src/App.tsx[22m
|
||||
[2m15:41:18[22m [36m[1m[vite][22m[39m [90m[2m(client)[22m[39m [32mhmr update [39m[2m/src/App.tsx[22m
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user