From 5963863b0b40540475d8cd89cc4a4f72476ed2d1 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Thu, 23 Oct 2025 13:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config.js | 4 +- .../components/right-table.vue | 124 +++++++++++------- .../data-set-manage/components/share.vue | 12 +- 3 files changed, 85 insertions(+), 55 deletions(-) diff --git a/src/views/archivesManagement/archClass/fileClassificationNamingConvention/config.js b/src/views/archivesManagement/archClass/fileClassificationNamingConvention/config.js index c249c7d..1b56560 100644 --- a/src/views/archivesManagement/archClass/fileClassificationNamingConvention/config.js +++ b/src/views/archivesManagement/archClass/fileClassificationNamingConvention/config.js @@ -10,9 +10,9 @@ export const formLabel = [ ] export const columnsList = [ - { t_props: 'standardType', t_label: '文件命名识别规范类型' }, + { t_props: 'standardTypeName', t_label: '文件命名识别规范类型' }, { t_props: 'standardName', t_label: '规范识别值' }, { t_props: 'updateUserName', t_label: '更新人' }, { t_props: 'updateTime', t_label: '更新时间' }, { t_props: 'remark', t_label: '备注' } -] \ No newline at end of file +] diff --git a/src/views/data-collect/data-set-manage/components/right-table.vue b/src/views/data-collect/data-set-manage/components/right-table.vue index 373658b..714b368 100644 --- a/src/views/data-collect/data-set-manage/components/right-table.vue +++ b/src/views/data-collect/data-set-manage/components/right-table.vue @@ -82,12 +82,12 @@ export default { // 分享 handleShare(row) { // console.log(row); - + this.isflag = true; row.selectedNodeName = this.selectedNodeName; row.selectedNodeId = this.selectedNodeId; row.jsonId = row.id; - + this.row = row; }, closeDialog() { @@ -96,7 +96,7 @@ export default { showColose() { this.isflag = false; }, - + // 查询:按第一列字段做模糊匹配 onHandleQuery() { if (!Array.isArray(this.columns) || this.columns.length < 1) return @@ -108,13 +108,13 @@ export default { this.filteredManual = null return } - + // 安全校验 if (!validSecurity(keyword)) { this.$message.error('搜索内容包含非法字符,请重新输入') return } - + // 执行一次性本地过滤 const source = Array.isArray(this.tableData) ? this.tableData : [] const kw = keyword.toLowerCase() @@ -134,56 +134,80 @@ export default { }, // 获取数据列表 - async getListDataSetClassFun(node) { - const params = { - dataClassifyId: node, + async getListDataSetClassFun(node) { + const params = { + dataClassifyId: node, + } + const res = await getListDataSetAPI(params) + + // 安全解析与渲染 + this.columns = [] + this.tableData = [] + if (!res || !Array.isArray(res.rows) || res.rows.length === 0) { + this.forceTableLayout() + return + } + + const firstRow = res.rows[0] + if (!firstRow || !firstRow.dataJson) { + this.forceTableLayout() + return + } + + let dataList = [] + try { + dataList = JSON.parse(firstRow.dataJson) + } catch (e) { + console.warn('数据集 dataJson 解析失败:', e) + this.forceTableLayout() + return + } + + if (!Array.isArray(dataList) || dataList.length === 0) { + this.forceTableLayout() + return + } + + const [header, ...rows] = dataList + if (header && typeof header === 'object') { + this.columns = Object.entries(header) + .filter(([prop]) => String(prop).toLowerCase() !== 'id') + .map(([prop, label], index) => ({ + label: String(label), + prop: String(prop), + width: index === 0 ? '120' : undefined, + align: index === 0 ? 'left' : 'center', + })) + } + + const propOrder = this.columns.map(c => c.prop) + this.tableData = rows.map(row => { + if (Array.isArray(row)) { + const obj = {} + for (let i = 0; i < propOrder.length; i++) { + obj[propOrder[i]] = row[i] } - const res = await getListDataSetAPI(params) + return obj + } + return row || {} + }) - // 安全解析与渲染 - this.columns = [] - this.tableData = [] - if (!res || !Array.isArray(res.rows) || res.rows.length === 0) return + this.forceTableLayout() + }, - const firstRow = res.rows[0] - if (!firstRow || !firstRow.dataJson) return - - let dataList = [] - try { - dataList = JSON.parse(firstRow.dataJson) - } catch (e) { - console.warn('数据集 dataJson 解析失败:', e) - return +// 强制表格重新布局 + forceTableLayout() { + this.$nextTick(() => { + setTimeout(() => { + // 获取表格实例并调用 doLayout + const table = this.$el.querySelector('.el-table') + if (table && table.__vue__) { + table.__vue__.doLayout() } - - if (!Array.isArray(dataList) || dataList.length === 0) return - - const [header, ...rows] = dataList - if (header && typeof header === 'object') { - this.columns = Object.entries(header) - .filter(([prop]) => String(prop).toLowerCase() !== 'id') - .map(([prop, label], index) => ({ - label: String(label), - prop: String(prop), - width: index === 0 ? '120' : undefined, - align: index === 0 ? 'left' : 'center', - })) - } - // 将数据行统一转换为对象行,按 columns 的 prop 顺序映射,确保搜索可用 - const propOrder = this.columns.map(c => c.prop) - this.tableData = rows.map(row => { - if (Array.isArray(row)) { - const obj = {} - for (let i = 0; i < propOrder.length; i++) { - obj[propOrder[i]] = row[i] - } - return obj - } - return row || {} - }) - // 数据变更后重新计算高度 this.computeTableHeight() - }, + }, 100) + }) + }, // 计算表格高度(使用固定 height,滚动更顺滑) computeTableHeight() { this.$nextTick(() => { diff --git a/src/views/data-collect/data-set-manage/components/share.vue b/src/views/data-collect/data-set-manage/components/share.vue index f306cd5..f48d22c 100644 --- a/src/views/data-collect/data-set-manage/components/share.vue +++ b/src/views/data-collect/data-set-manage/components/share.vue @@ -17,7 +17,7 @@