From 6303bd1e2c1a7ce30dec81924a6f5225a0981c03 Mon Sep 17 00:00:00 2001 From: guanj Date: Fri, 14 Nov 2025 09:33:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/table/index.vue | 58 +++- src/utils/tableStore.ts | 36 +- src/views/auth/role/index.vue | 326 ++++++++++--------- src/views/govern/manage/monthly.vue | 26 +- src/views/govern/mxgraph/graphList/index.vue | 6 +- types/table.d.ts | 22 +- 6 files changed, 256 insertions(+), 218 deletions(-) diff --git a/src/components/table/index.vue b/src/components/table/index.vue index e6154ea..8d969a6 100644 --- a/src/components/table/index.vue +++ b/src/components/table/index.vue @@ -1,24 +1,44 @@ @@ -125,6 +150,7 @@ watch( () => tableStore.table.allFlag, newVal => { if (tableStore.table.allFlag) { + console.log('🚀 ~ tableStore.table.allData:', tableStore.table.allData) tableRef.value?.exportData({ filename: tableStore.exportName || document.querySelectorAll('.ba-nav-tab.active')[0].textContent || '', // 文件名字 diff --git a/src/utils/tableStore.ts b/src/utils/tableStore.ts index c08503f..0c5d4e9 100644 --- a/src/utils/tableStore.ts +++ b/src/utils/tableStore.ts @@ -18,6 +18,7 @@ interface TableStoreParams { publicHeight?: number //计算高度 resetCallback?: () => void // 重置 loadCallback?: () => void // 接口调用后的回调 + exportProcessingData?: () => void //导出处理数据 beforeSearchFun?: () => void // 接口调用前的回调 } @@ -47,6 +48,7 @@ export default class TableStore { column: [], loadCallback: null, resetCallback: null, + exportProcessingData: null, beforeSearchFun: null, height: '', publicHeight: 0 @@ -64,6 +66,7 @@ export default class TableStore { this.table.publicHeight = options.publicHeight || 0 this.table.resetCallback = options.resetCallback || null this.table.loadCallback = options.loadCallback || null + this.table.exportProcessingData = options.exportProcessingData || null this.table.beforeSearchFun = options.beforeSearchFun || null Object.assign(this.table.params, options.params) this.table.height = mainHeight(20 + (this.showPage ? 58 : 0) + this.table.publicHeight).height as string @@ -187,26 +190,21 @@ export default class TableStore { [ 'export', () => { - ElMessage({ - message: '正在导出,请稍等...', - type: 'info', - duration: 1000 - }) + // this.index() let params = { ...this.table.params, pageNum: 1, pageSize: this.table.total } - setTimeout(() => { - createAxios( - Object.assign( - { - url: this.url, - method: this.method - }, - requestPayload(this.method, params, this.paramsPOST) - ) - ).then(res => { - this.table.allData = filtration(res.data.records || res.data) - this.table.allFlag = data.showAllFlag || true - }) - }, 1500) + createAxios( + Object.assign( + { + url: this.url, + method: this.method + }, + requestPayload(this.method, params, this.paramsPOST) + ) + ).then(res => { + this.table.allData = filtration(res.data.records || res.data) + this.table.exportProcessingData && this.table.exportProcessingData() + this.table.allFlag = data.showAllFlag || true + }) } ] ]) diff --git a/src/views/auth/role/index.vue b/src/views/auth/role/index.vue index f3ada40..aab5dc2 100644 --- a/src/views/auth/role/index.vue +++ b/src/views/auth/role/index.vue @@ -1,162 +1,164 @@ - - + + diff --git a/src/views/govern/manage/monthly.vue b/src/views/govern/manage/monthly.vue index e31b35c..d47da44 100644 --- a/src/views/govern/manage/monthly.vue +++ b/src/views/govern/manage/monthly.vue @@ -96,14 +96,14 @@ const tableStore = new TableStore({ fixed: 'right', render: 'tag', custom: { - 功能调试: 'warning', - 出厂调试: 'warning', - 正式投运: 'success' + 2: 'warning', + 3: 'warning', + 4: 'success' }, replaceValue: { - 功能调试: '功能调试', - 出厂调试: '出厂调试', - 正式投运: '正式投运' + 2: '功能调试', + 3: '出厂调试', + 4: '正式投运' }, minWidth: 80 }, @@ -142,11 +142,14 @@ const tableStore = new TableStore({ { title: '完整性(%)', fixed: 'right', width: 100, field: 'integrity', sortable: true } ], beforeSearchFun: () => {}, - loadCallback: () => { - tableStore.table.data.forEach(item => { + exportProcessingData: () => { + tableStore.table.allData = tableStore.table.allData.filter(item => { item.process = item.process == 2 ? '功能调试' : item.process == 3 ? '出厂调试' : '正式投运' + return item }) - + console.log('🚀 ~ tableStore.table.allData:', tableStore.table.allData) + }, + loadCallback: () => { let name = tableStore.table.params.name let data = tableStore.table.copyData.filter(item => { // 处理latestTime默认值 @@ -182,7 +185,10 @@ const exportTab = () => { sheetName: 'Sheet1', type: 'xlsx', //导出文件类型 xlsx 和 csv useStyle: true, - data: tableStore.table.copyData, // 数据源 // 过滤那个字段导出 + data: tableStore.table.copyData.filter(item => { + item.process = item.process == 2 ? '功能调试' : item.process == 3 ? '出厂调试' : '正式投运' + return item + }), // 数据源 // 过滤那个字段导出 columnFilterMethod: function (column: any) { return !( column.column.title === undefined || diff --git a/src/views/govern/mxgraph/graphList/index.vue b/src/views/govern/mxgraph/graphList/index.vue index 41059e0..9a0f589 100644 --- a/src/views/govern/mxgraph/graphList/index.vue +++ b/src/views/govern/mxgraph/graphList/index.vue @@ -107,8 +107,8 @@ const editd = (e: any) => { } // 设计 const Aclick = (e: any) => { - // window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false&&graphicDisplay=zl`) window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false&&graphicDisplay=zl`) + // window.open('http://192.168.1.128:4001' + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false&&graphicDisplay=zl`) } // 删除 @@ -143,8 +143,8 @@ const deleted = (e: any) => { } const imgData = (e: any) => { - // window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`) - window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`) + window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`) + // window.open('http://192.168.1.128:4001' + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`) } diff --git a/types/table.d.ts b/types/table.d.ts index 7852316..80874eb 100644 --- a/types/table.d.ts +++ b/types/table.d.ts @@ -8,8 +8,8 @@ declare global { interface CnTable { ref: VxeTableInstance | null data: TableRow[] | any - copyData: TableRow[] | any allData: TableRow[] | any + filename: any allFlag: Boolean // 前端分页数据 webPagingData: TableRow[][] @@ -29,6 +29,7 @@ declare global { loadCallback: (() => void) | null resetCallback: (() => void) | null beforeSearchFun: (() => void) | null + exportProcessingData: (() => void) | null height: string publicHeight: number } @@ -50,6 +51,7 @@ declare global { | 'buttons' | 'slot' | 'customTemplate' + | 'renderFormatter' | 'customRender' // 默认值 default?: any @@ -59,14 +61,15 @@ declare global { custom?: any // 值替换数据,如{open: '开'} replaceValue?: any + effect?: any // 时间格式化 timeFormat?: string - // 开关控制 - onChangeField?: (row: TableRow, value: any) => void - activeValue?: string - inactiveValue?: string - activeText?: string - inactiveText?: string + // 开关控制 + onChangeField?: (row: TableRow, value: any) => void + activeValue?: string + inactiveValue?: string + activeText?: string + inactiveText?: string // 自定义组件/函数渲染 customRender?: string | Component // 使用了 render 属性时,渲染前对字段值的预处理方法,请返回新值 @@ -80,6 +83,8 @@ declare global { index: number ) => string children?: TableColumn[] + property?: string + clickable?: boolean // 是否可点击 } /* 表格右侧操作按钮 */ @@ -90,15 +95,16 @@ declare global { title?: string text?: string class?: string - loading?: string type: ButtonType icon: string popconfirm?: Partial> disabledTip?: boolean // 自定义点击事件 click?: (row: TableRow, field: TableColumn) => void + // 按钮是否禁用,请返回布尔值 disabled?: (row: TableRow, field: TableColumn) => boolean + showDisabled?: (row: TableRow, field: TableColumn) => boolean // 自定义el-button属性 attr?: Partial> }