From b08ca3eab18fade7395874a099d200341112e6fd Mon Sep 17 00:00:00 2001 From: ye1023 <12588209+ye1023@user.noreply.gitee.com> Date: Thu, 28 May 2026 10:46:50 +0800 Subject: [PATCH] =?UTF-8?q?yxk-20260527-=E5=B7=A1=E8=A7=86=E6=95=B4?= =?UTF-8?q?=E6=94=B9=E6=8F=90=E5=8D=87=E5=8F=B0=E8=B4=A6=EF=BC=8C=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E6=B8=85=E5=8D=95=E6=A0=91=E5=BD=A2=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E6=94=B9=E9=80=A0=20=E7=82=B9=E5=87=BB=E6=9F=90=E4=B8=80?= =?UTF-8?q?=E8=A1=8C=E5=B0=B1=E8=83=BD=E5=B1=95=E5=BC=80=E6=88=96=E8=80=85?= =?UTF-8?q?=E6=94=B6=E8=B5=B7=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspectProblem/DqInspectProblem.data.ts | 73 +++++------ .../inspectProblem/DqInspectProblemList.vue | 122 ++++++++++++++---- 2 files changed, 132 insertions(+), 63 deletions(-) diff --git a/src/views/dq/inspectProblem/DqInspectProblem.data.ts b/src/views/dq/inspectProblem/DqInspectProblem.data.ts index f164775..949a14e 100644 --- a/src/views/dq/inspectProblem/DqInspectProblem.data.ts +++ b/src/views/dq/inspectProblem/DqInspectProblem.data.ts @@ -5,6 +5,11 @@ import { render } from '/@/utils/common/renderUtils'; import { getWeekMonthQuarterYear } from '/@/utils'; //列表数据 export const columns: BasicColumn[] = [ + { + title: '问题名称', + align: 'left', + dataIndex: 'problemName' + }, { title: '类型', align: 'center', @@ -13,42 +18,6 @@ export const columns: BasicColumn[] = [ return render.renderDict(text, 'super_dq_ins_type'); }, }, - { - title: '密级', - align: 'center', - dataIndex: 'secretLevel_dictText' - }, - { - title: '年份', - align: 'center', - dataIndex: 'year_dictText' - }, - { - title: '父节点ID', - align: 'center', - dataIndex: 'pid' - }, - { - title: '是否有子节点', - align: 'center', - dataIndex: 'hasChild' - }, - - { - title: '问题名称', - align: 'left', - dataIndex: 'problemName' - }, - { - title: '问题编码/分类字典值', - align: 'center', - dataIndex: 'problemCode' - }, - { - title: '排序', - align: 'center', - dataIndex: 'sortNo' - }, { title: '巡视建议', align: 'center', @@ -64,6 +33,38 @@ export const columns: BasicColumn[] = [ align: 'center', dataIndex: 'questionResDept_dictText' }, + { + title: '年份', + align: 'center', + dataIndex: 'year_dictText' + }, + { + title: '密级', + align: 'center', + dataIndex: 'secretLevel_dictText' + }, + { + title: '父节点ID', + align: 'center', + dataIndex: 'pid' + }, + { + title: '是否有子节点', + align: 'center', + dataIndex: 'hasChild' + }, + + { + title: '问题编码/分类字典值', + align: 'center', + dataIndex: 'problemCode' + }, + { + title: '排序', + align: 'center', + dataIndex: 'sortNo' + }, + ]; // 高级查询数据 diff --git a/src/views/dq/inspectProblem/DqInspectProblemList.vue b/src/views/dq/inspectProblem/DqInspectProblemList.vue index 589979f..ed357ee 100644 --- a/src/views/dq/inspectProblem/DqInspectProblemList.vue +++ b/src/views/dq/inspectProblem/DqInspectProblemList.vue @@ -4,21 +4,22 @@
- - - - - - + + + + + + + + + + + 查询 重置 - - {{ toggleSearchStatus ? '收起' : '展开' }} - - @@ -91,6 +92,14 @@ canResize:false, useSearchForm: false, isTreeTable: true, + customRow: (record) => { + return { + onClick: (event) => handleRowClick(record, event), + style: { + cursor: hasExpandableChildren(record) ? 'pointer' : 'default', + }, + }; + }, actionColumn: { width: 120, fixed: 'right', @@ -120,6 +129,19 @@ xs: 24, sm: 20, }); + const ROW_CLICK_IGNORE_SELECTOR = [ + 'a', + 'button', + 'input', + 'textarea', + 'select', + '.ant-btn', + '.ant-checkbox-wrapper', + '.ant-dropdown-trigger', + '.ant-table-row-expand-icon', + '.ant-table-selection-column', + '.ant-table-cell-fix-right', + ].join(','); // 高级查询配置 const superQueryConfig = reactive(superQuerySchema); @@ -172,7 +194,7 @@ const ids = selectedRowKeys.value.filter((item) => !item.includes('loadChild')); await batchDeleteDqInspectProblem({ id: ids }, success); } - + /** * 成功回调刷新页面 */ @@ -227,14 +249,14 @@ } } } - + /** * 接口请求成功后回调 */ function onFetchSuccess(result) { getDataByResult(result.items) && loadDataByExpandedRows(); } - + /** * 根据已展开的行查询数据(用于保存后刷新时异步加载子级的数据) */ @@ -271,7 +293,7 @@ } } } - + /** * 处理数据集 */ @@ -287,15 +309,62 @@ }); } } - + + /** + * 行点击展开前先过滤按钮、复选框、展开图标等交互区,避免和原有操作互相触发。 + */ + async function handleRowClick(record, event) { + if (!hasExpandableChildren(record) || isInteractiveClick(event)) { + return; + } + if (expandedRowKeys.value.includes(record.id)) { + collapseTreeNode(record); + } else { + await handleExpand(true, record); + } + } + + /** + * 判断当前节点是否具备展开能力;loading 占位行和叶子节点不参与行点击切换。 + */ + function hasExpandableChildren(record) { + return !!record && !record.isLoading && (record.hasChild == '1' || (record.children && record.children.length > 0)); + } + + function isInteractiveClick(event) { + const target = event?.target; + return !!target?.closest && !!target.closest(ROW_CLICK_IGNORE_SELECTOR); + } + + /** + * 收起当前节点时同步清理已展开子孙节点,避免再次展开时残留旧展开状态。 + */ + function collapseTreeNode(record) { + const removeKeys = new Set([record.id]); + collectChildKeys(record.children, removeKeys); + expandedRowKeys.value = expandedRowKeys.value.filter((key) => !removeKeys.has(key)); + } + + function collectChildKeys(children, keys) { + if (!children || children.length === 0) { + return; + } + children.forEach((child) => { + keys.add(child.id); + collectChildKeys(child.children, keys); + }); + } + /** *树节点展开合并 */ async function handleExpand(expanded, record) { // 判断是否是展开状态,展开状态(expanded)并且存在子集(children)并且未加载过(isLoading)的就去查询子节点数据 if (expanded) { - expandedRowKeys.value.push(record.id); - if (record.children.length > 0 && !!record.children[0].isLoading) { + if (!expandedRowKeys.value.includes(record.id)) { + expandedRowKeys.value.push(record.id); + } + if (record.hasChild == '1' && (!record.children || record.children.length === 0 || !!record.children[0].isLoading)) { let result = await getChildList({ pid: record.id}); result = result.records ? result.records : result; if (result && result.length > 0) { @@ -306,19 +375,18 @@ } } } else { - let keyIndex = expandedRowKeys.value.indexOf(record.id); - if (keyIndex >= 0) { - expandedRowKeys.value.splice(keyIndex, 1); - } + collapseTreeNode(record); } } - + /** * 操作表格后处理树节点展开合并 */ async function expandTreeNode(key) { let record = findTableDataRecord(key); - expandedRowKeys.value.push(key); + if (!expandedRowKeys.value.includes(key)) { + expandedRowKeys.value.push(key); + } let result = await getChildList({ pid: key }); if (result && result.length > 0) { record.children = getDataByResult(result); @@ -327,8 +395,8 @@ record.hasChild = '0'; } updateTableDataRecord(key, record); - } - + } + /** * 操作栏 */ @@ -376,7 +444,7 @@ function searchQuery() { reload(); } - + /** * 重置 */ @@ -386,7 +454,7 @@ //刷新数据 reload(); } - + /** * form点击事件(以逗号分割)