From e4b4f5ddb9eaddd21d7c9ad9e32bf8e3fb56c5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=BF=9C?= <2970639877@qq.com> Date: Fri, 20 Mar 2026 10:42:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layout/Sidebar.vue | 54 +++---- src/router/index.ts | 4 +- src/utils/exportToExcel/index.ts | 131 +++++++++++++++++ src/views/account/client/index.vue | 10 ++ src/views/account/client/options.ts | 2 +- src/views/funding/receiverAccount/index.vue | 2 +- src/views/funding/transferDetail/index.vue | 135 +++++------------- src/views/funding/transferDetail/options.ts | 33 ++--- src/views/notice/index.vue | 25 ++-- .../system/{menuManagement => menu}/index.vue | 0 .../{menuManagement => menu}/options.ts | 0 .../system/{menuManagement => menu}/rules.ts | 0 .../system/{roleManagement => role}/index.vue | 0 .../{roleManagement => role}/options.ts | 0 .../system/{roleManagement => role}/rules.ts | 0 src/views/trade/variety/rules.ts | 74 ++++++---- 16 files changed, 284 insertions(+), 186 deletions(-) create mode 100644 src/utils/exportToExcel/index.ts rename src/views/system/{menuManagement => menu}/index.vue (100%) rename src/views/system/{menuManagement => menu}/options.ts (100%) rename src/views/system/{menuManagement => menu}/rules.ts (100%) rename src/views/system/{roleManagement => role}/index.vue (100%) rename src/views/system/{roleManagement => role}/options.ts (100%) rename src/views/system/{roleManagement => role}/rules.ts (100%) diff --git a/src/components/layout/Sidebar.vue b/src/components/layout/Sidebar.vue index 71e6118..64370c8 100644 --- a/src/components/layout/Sidebar.vue +++ b/src/components/layout/Sidebar.vue @@ -78,21 +78,21 @@ const staticMenuList = ref( icon: 'HomeFilled' // 对应 图标 }, // 模板配置(子菜单) - { - id: 2, - label: '模板配置', - path: '2', // 对应 el-sub-menu 的 index="2" - icon: 'List', // 对应 图标 - children: [ - { - id: 21, - label: '头寸模板', - path: '2-1', // 对应 el-menu-item 的 index="2-1" - icon: '' - // 二级菜单无图标(模板中未设置) - } - ] - }, + // { + // id: 2, + // label: '模板配置', + // path: '2', // 对应 el-sub-menu 的 index="2" + // icon: 'List', // 对应 图标 + // children: [ + // { + // id: 21, + // label: '头寸模板', + // path: '2-1', // 对应 el-menu-item 的 index="2-1" + // icon: '' + // // 二级菜单无图标(模板中未设置) + // } + // ] + // }, // 账户管理(子菜单) { id: 3, @@ -197,18 +197,18 @@ const staticMenuList = ref( // path: '/funding/flowDetail', // index="6-6" // icon: '' // }, - { - id: 67, - label: '收款账户列表', - path: '/funding/receiverAccount', // index="6-7" - icon: '' - }, - { - id: 68, - label: '存款渠道', - path: '/funding/depositChannel', // index="6-8" - icon: '' - } + // { + // id: 67, + // label: '收款账户列表', + // path: '/funding/receiverAccount', // index="6-7" + // icon: '' + // }, + // { + // id: 68, + // label: '存款渠道', + // path: '/funding/depositChannel', // index="6-8" + // icon: '' + // } ] }, // 系统管理(子菜单) diff --git a/src/router/index.ts b/src/router/index.ts index 9866757..d296003 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -63,7 +63,7 @@ const routes = [ { path: 'menu', name: 'Menu', - component: () => import('@/views/system/menuManagement/index.vue'), + component: () => import('@/views/system/menu/index.vue'), meta: { title: '菜单管理', // 左侧菜单显示的标题 } @@ -71,7 +71,7 @@ const routes = [ { path: 'role', name: 'Role', - component: () => import('@/views/system/roleManagement/index.vue'), + component: () => import('@/views/system/role/index.vue'), meta: { title: '角色管理', // 左侧菜单显示的标题 } diff --git a/src/utils/exportToExcel/index.ts b/src/utils/exportToExcel/index.ts new file mode 100644 index 0000000..9766b68 --- /dev/null +++ b/src/utils/exportToExcel/index.ts @@ -0,0 +1,131 @@ +// src/utils/excel.ts +import { ElMessageBox, ElNotification, ElMessage } from 'element-plus' +import * as XLSX from 'xlsx' +import { saveAs } from 'file-saver' +import dayjs from 'dayjs' + +/** + * 通用 Excel 导出方法(自动拼接时间戳,避免文件重名) + * @param options 导出配置项 + * @returns Promise + */ +export const exportToExcel = async (options: { + /** 表格数据(数组) */ + tableData: any[] + /** 列配置(包含 label: 表头文字, prop: 字段名) */ + columns: Array<{ label: string; prop: string }> + /** 弹窗标题(默认:导出表格) */ + title?: string + /** 默认文件名前缀(默认:导出数据) */ + defaultFileNamePrefix?: string + /** 时间格式化格式(默认:YYYYMMDDHHmmss,避免特殊字符) */ + timeFormat?: string + /** 通知自定义类名(可选) */ + notificationClass?: string + /** 工作表名称(默认:Sheet1) */ + sheetName?: string +}) => { + // 解构配置项并设置默认值 + const { + tableData, + columns, + title = '导出表格', + defaultFileNamePrefix = '导出数据', + // 优化:默认格式去掉空格和冒号,避免文件名非法 + timeFormat = 'YYYY-MM-DD', + notificationClass = 'global-notification', + sheetName = 'Sheet1' + } = options + + try { + // 1. 校验表格数据 + if (!tableData || tableData.length === 0) { + ElNotification({ + message: '暂无表格数据可导出!', + type: 'error', + duration: 2000, + customClass: notificationClass + }) + return + } + + // 2. 弹出输入框让用户输入文件名(兼容不同版本返回值) + const rawFileName = await ElMessageBox.prompt( + '请输入导出文件名称(会自动附带时间)', // 提示用户会附带时间 + title, + { + confirmButtonText: '确定', + cancelButtonText: '取消', + inputPlaceholder: '例如:转账明细', + // 输入框校验:允许空输入(空输入时用默认前缀+时间) + inputValidator: (value) => { + if (value && !value.trim()) { + return '文件名不能仅包含空格!' + } + return true + }, + inputErrorMessage: '文件名不能仅包含空格!' + } + ) + + // 核心修复:兼容 string / { value: string } 两种返回格式 + let fileName = '' + if (typeof rawFileName === 'string') { + fileName = rawFileName + } else if (rawFileName && typeof (rawFileName as { value: string }).value === 'string') { + fileName = (rawFileName as { value: string }).value + } + + // 3. 处理文件名:强制拼接时间(核心修改点) + const timeStr = dayjs().format(timeFormat) + // 优先级:用户输入的名称 → 默认前缀;无论哪种都拼接时间 + const fileNamePrefix = fileName.trim() || defaultFileNamePrefix + const finalFileName = `${fileNamePrefix}_${timeStr}` + + // 4. 构建带表头的Excel数据 + const exportData = tableData.map(item => { + const row: Record = {} + columns.forEach(header => { + row[header.label] = item[header.prop] || '' + }) + return row + }) + + // 5. 创建工作表(包含表头) + const ws = XLSX.utils.json_to_sheet(exportData, { + header: columns.map(h => h.label), // 指定表头顺序 + skipHeader: false // 不跳过表头(关键!保证表头显示) + }) + + // 6. 创建工作簿并添加工作表 + const wb = XLSX.utils.book_new() + XLSX.utils.book_append_sheet(wb, ws, sheetName) + + // 7. 生成Excel二进制数据 + const wbout = XLSX.write(wb, { + bookType: 'xlsx', + bookSST: false, + type: 'array' + }) + + // 8. 触发下载(拼接.xlsx后缀) + saveAs( + new Blob([wbout], { type: 'application/octet-stream' }), + `${finalFileName}.xlsx` + ) + + // 9. 导出成功提示 + ElNotification({ + message: `文件「${finalFileName}.xlsx」导出成功!`, + type: 'success', + duration: 2000, + customClass: notificationClass + }) + } catch (e: any) { + // 取消导出时不提示错误 + if (e !== 'cancel') { + ElMessage.error('导出失败,请重试!') + console.error('Excel 导出失败:', e) + } + } +} \ No newline at end of file diff --git a/src/views/account/client/index.vue b/src/views/account/client/index.vue index 51ea1aa..3a5729c 100644 --- a/src/views/account/client/index.vue +++ b/src/views/account/client/index.vue @@ -280,6 +280,16 @@ const handleChange = (row: any) => { dialogTitle.value = '修改客户' dialogType.value = 'change' useId.value = row.id + clientForm.value = { + //手续费模板 + feeTemplate: row.wallet_capital.fee_setting_id, + //风控模板 + riskTemplate: row.wallet_capital.risk_control_id, + userName: row.username, + status: row.status, + isUpgrade: 1, + } as any + console.log('rowrowrowrowrowrowrowrowrow', clientForm.value) getOptions() } diff --git a/src/views/account/client/options.ts b/src/views/account/client/options.ts index d0119b0..dc774c6 100644 --- a/src/views/account/client/options.ts +++ b/src/views/account/client/options.ts @@ -72,7 +72,7 @@ export const clientAddFormItem = [ export const clientChangeFormItem = [ { prop: 'feeTemplate', label: '手续费模板', type: 'select' as const, placeholder: '选择手续费模板' }, { prop: 'riskTemplate', label: '风控模板', type: 'select' as const, placeholder: '选择风控模板' }, - { prop: 'changeName', label: '客户名称', type: 'input' as const, placeholder: '客户名称' }, + { prop: 'userName', label: '客户名称', type: 'input' as const, placeholder: '客户名称' }, { prop: 'isUpgrade', label: '是否升级为代理', type: 'radio' as const, placeholder: '是否升级为代理', labelWidth: '140px' }, { prop: 'status', label: '选择状态', type: 'radio' as const, placeholder: '请选择状态', labelWidth: '140px' }, ] diff --git a/src/views/funding/receiverAccount/index.vue b/src/views/funding/receiverAccount/index.vue index 4b28b57..59345d4 100644 --- a/src/views/funding/receiverAccount/index.vue +++ b/src/views/funding/receiverAccount/index.vue @@ -3,7 +3,7 @@
添加 编辑 - 启用 + 启用 禁用 导出
diff --git a/src/views/funding/transferDetail/index.vue b/src/views/funding/transferDetail/index.vue index 1e3dbba..4b08e11 100644 --- a/src/views/funding/transferDetail/index.vue +++ b/src/views/funding/transferDetail/index.vue @@ -4,12 +4,6 @@