From 6db15425cc641ba1fe693e4a635ab3575e727817 Mon Sep 17 00:00:00 2001 From: ericyuan614 <46084226+ericyuan614@users.noreply.github.com> Date: Tue, 18 Feb 2025 00:59:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=8F=8A=E6=A8=A1=E6=8B=9F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=92=8C=E5=8A=A8=E6=80=81=E5=88=97=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/table/index.ts | 41 ++++++++- src/api/table/types.ts | 15 ++- src/views/Level/Menu2.vue | 121 +++++++++++++++++++++++-- src/views/Level/modules/TableColumn.ts | 26 ++++++ src/views/ProjectMenu/ProjectMenu.vue | 105 +++++++++++++++++++++ 5 files changed, 290 insertions(+), 18 deletions(-) create mode 100644 src/views/Level/modules/TableColumn.ts create mode 100644 src/views/ProjectMenu/ProjectMenu.vue diff --git a/src/api/table/index.ts b/src/api/table/index.ts index c870f25..6628b80 100644 --- a/src/api/table/index.ts +++ b/src/api/table/index.ts @@ -1,8 +1,45 @@ import request from '@/axios' import type { TableData } from './types' -export const getTableListApi = (params: any) => { - return request.get({ url: '/mock/example/list', params }) +interface Result { + list: TableData[] + total: number +} + +// 生成模拟数据的辅助函数 +const generateMockData = (count: number): TableData[] => { + const stages = ['开发阶段', '测试阶段', '生产阶段', '验证阶段', '量产阶段'] + const carTypes = ['SUV', '轿车', 'MPV', '跑车', '新能源'] + const creators = ['张三', '李四', '王五', '赵六', '钱七'] + + return Array.from({ length: count }, (_, index) => ({ + ProjectId: `PRJ${String(index + 1).padStart(3, '0')}`, + ProjectStage: stages[Math.floor(Math.random() * stages.length)], + CarType: carTypes[Math.floor(Math.random() * carTypes.length)], + Creator: creators[Math.floor(Math.random() * creators.length)], + CreateTime: new Date(Date.now() - Math.floor(Math.random() * 90) * 24 * 60 * 60 * 1000) + .toISOString() + .split('T')[0], + id: index + 1 + })) +} + +export const getTableListApi = (params: any): Promise> => { + const mockData = generateMockData(100) + const { pageIndex = 1, pageSize = 10 } = params + const start = (pageIndex - 1) * pageSize + const end = start + pageSize + + return Promise.resolve({ + code: 0, + data: { + list: mockData.slice(start, end), + total: mockData.length + } + }) + + // 如果要切换到真实API,只需取消注释下面的代码 + // return request.get({ url: '/mock/example/list', params }) } export const getCardTableListApi = (params: any) => { diff --git a/src/api/table/types.ts b/src/api/table/types.ts index 876c111..7c18179 100644 --- a/src/api/table/types.ts +++ b/src/api/table/types.ts @@ -1,9 +1,8 @@ -export type TableData = { - id: string - author: string - title: string - content: string - importance: number - display_time: string - pageviews: number +export interface TableData { + ProjectId: string + ProjectStage: string + CarType: string + Creator: string + CreateTime: string + id?: number } diff --git a/src/views/Level/Menu2.vue b/src/views/Level/Menu2.vue index 72e2abb..4312668 100644 --- a/src/views/Level/Menu2.vue +++ b/src/views/Level/Menu2.vue @@ -1,20 +1,125 @@ - + + diff --git a/src/views/Level/modules/TableColumn.ts b/src/views/Level/modules/TableColumn.ts new file mode 100644 index 0000000..f65e991 --- /dev/null +++ b/src/views/Level/modules/TableColumn.ts @@ -0,0 +1,26 @@ +import { ElTag } from 'element-plus' + +const columns = [ + { + field: 'ProjectId', + label: '項目ID' + }, + { + field: 'ProjectStage', + label: '項目階段' + }, + { + field: 'CarType', + label: '車輛類型' + }, + { + field: 'Creator', + label: '創建人' + }, + { + field: 'CreateTime', + label: '創建時間' + } +] + +export default columns diff --git a/src/views/ProjectMenu/ProjectMenu.vue b/src/views/ProjectMenu/ProjectMenu.vue new file mode 100644 index 0000000..1d9124a --- /dev/null +++ b/src/views/ProjectMenu/ProjectMenu.vue @@ -0,0 +1,105 @@ + + +