fix
This commit is contained in:
1 parent
53c1b6f523
commit
6b20b9190e
3 files changed
+55
-2
No files matched your search
+27
-2
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user