From 2ed0923b2dba5737fde1b1910f74cda340632656 Mon Sep 17 00:00:00 2001 From: baiqi Date: Thu, 8 Jun 2023 14:28:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B3=BB=E7=BB=9F=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/__test__/components/table.spec.ts | 6 ++- frontend/src/api/modules/dashboard/index.ts | 22 ---------- .../components/pure/ms-table/base-table.vue | 37 +++++++++------- .../components/pure/ms-table/batchAction.vue | 42 +++++++++++++++---- .../components/pure/ms-table/locale/en-US.ts | 4 +- .../components/pure/ms-table/locale/zh-CN.ts | 4 +- .../src/components/pure/ms-table/useTable.ts | 18 ++++++-- frontend/src/components/pure/navbar/index.vue | 2 - frontend/src/config/settings.json | 6 ++- frontend/src/views/api-test/index.ts | 0 frontend/src/views/api-test/index.vue | 19 +-------- 11 files changed, 85 insertions(+), 75 deletions(-) delete mode 100644 frontend/src/api/modules/dashboard/index.ts delete mode 100644 frontend/src/views/api-test/index.ts diff --git a/frontend/__test__/components/table.spec.ts b/frontend/__test__/components/table.spec.ts index 7335f7ef59..66f6b4de88 100644 --- a/frontend/__test__/components/table.spec.ts +++ b/frontend/__test__/components/table.spec.ts @@ -71,9 +71,11 @@ describe('MS-Table', () => { test('init table with useTable', async () => { const { propsRes, propsEvent, loadList, setProps } = useTable(getTableList, { columns, + scroll: { y: 750, x: 2000 }, + selectable: true, }); - const wrapper = mount(MsBaseTable, { + const wrapper = mount(MsBaseTable as any, { vOn: propsEvent, vBind: propsRes, }); @@ -81,7 +83,7 @@ describe('MS-Table', () => { await nextTick(); let content = wrapper.find('.arco-table-td-content').element.innerHTML; - expect(propsRes.value.data.length).toBe(2); + expect(propsRes.value.data.length).toBe(20); expect(content).toBe('e7bd7179-d63a-43a5-1a65-218473ee69ca'); setProps({}); diff --git a/frontend/src/api/modules/dashboard/index.ts b/frontend/src/api/modules/dashboard/index.ts deleted file mode 100644 index 9582492991..0000000000 --- a/frontend/src/api/modules/dashboard/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import MSR from '@/api/http/index'; -import type { TableData } from '@arco-design/web-vue/es/table/interface'; - -export interface ContentDataRecord { - x: string; - y: number; -} - -export function queryContentData() { - return MSR.get({ url: '/api/content-data' }); -} - -export interface PopularRecord { - key: number; - clickNumber: string; - title: string; - increases: number; -} - -export function queryPopularList(params: { type: string }) { - return MSR.get({ url: '/api/popular/list', params }); -} diff --git a/frontend/src/components/pure/ms-table/base-table.vue b/frontend/src/components/pure/ms-table/base-table.vue index 809c03abe5..d4c6c624ea 100644 --- a/frontend/src/components/pure/ms-table/base-table.vue +++ b/frontend/src/components/pure/ms-table/base-table.vue @@ -11,23 +11,27 @@ - +
+ +
+ + diff --git a/frontend/src/components/pure/ms-table/locale/en-US.ts b/frontend/src/components/pure/ms-table/locale/en-US.ts index 27899e7ae3..125f6c05f0 100644 --- a/frontend/src/components/pure/ms-table/locale/en-US.ts +++ b/frontend/src/components/pure/ms-table/locale/en-US.ts @@ -11,8 +11,8 @@ export default { moveTo: '移动到', copyTo: '复制到', related: '关联需求', - generate: '生成依赖关系', - add: '添加到公用用例库', + generateDep: '生成依赖关系', + addPublic: '添加到公用用例库', clear: 'clear', }, }, diff --git a/frontend/src/components/pure/ms-table/locale/zh-CN.ts b/frontend/src/components/pure/ms-table/locale/zh-CN.ts index 9c2954455f..6351c0242d 100644 --- a/frontend/src/components/pure/ms-table/locale/zh-CN.ts +++ b/frontend/src/components/pure/ms-table/locale/zh-CN.ts @@ -11,8 +11,8 @@ export default { moveTo: '移动到', copyTo: '复制到', related: '关联需求', - generate: '生成依赖关系', - add: '添加到公用用例库', + generateDep: '生成依赖关系', + addPublic: '添加到公用用例库', clear: '清空', }, }, diff --git a/frontend/src/components/pure/ms-table/useTable.ts b/frontend/src/components/pure/ms-table/useTable.ts index 07f58f2930..96df85d4bc 100644 --- a/frontend/src/components/pure/ms-table/useTable.ts +++ b/frontend/src/components/pure/ms-table/useTable.ts @@ -7,6 +7,7 @@ import { ApiTestListI } from '@/models/api-test'; import { TableData } from '@arco-design/web-vue'; import dayjs from 'dayjs'; import { QueryParams } from '@/models/common'; +import { useAppStore } from '@/store'; export interface Pagination { current: number; @@ -16,6 +17,7 @@ export interface Pagination { } type GetListFunc = (v: QueryParams) => Promise; +const appStore = useAppStore(); export default function useTbleProps(loadListFunc: GetListFunc, props?: Partial) { // 行选择 const rowSelection = { @@ -34,9 +36,11 @@ export default function useTbleProps(loadListFunc: GetListFunc, props?: Partial< columns: [] as MsTableColumn, pagination: { current: 1, - pageSize: 20, + pageSize: appStore.pageSize, total: 0, - showPageSize: true, + showPageSize: appStore.showPageSize, + showTotal: appStore.showTotal, + showJumper: appStore.showJumper, } as Pagination, rowKey: 'id', selectedKeys: [], @@ -48,6 +52,12 @@ export default function useTbleProps(loadListFunc: GetListFunc, props?: Partial< // 属性组 const propsRes = ref(defaultProps); + const oldPagination = ref({ + current: 1, + pageSize: 20, + total: 0, + showPageSize: true, + }); // 排序 const sortItem = ref({}); @@ -172,11 +182,11 @@ export default function useTbleProps(loadListFunc: GetListFunc, props?: Partial< // 选择触发 selectedChange: (arr: (string | number)[]) => { if (arr.length === 0) { - propsRes.value.pagination = defaultProps.pagination; + propsRes.value.pagination = oldPagination.value; } else { + oldPagination.value = propsRes.value.pagination as Pagination; propsRes.value.pagination = false; } - propsRes.value.selectedKeys = arr; }, change: (_data: MsTableData) => { diff --git a/frontend/src/components/pure/navbar/index.vue b/frontend/src/components/pure/navbar/index.vue index f490c2b3bc..e802cafce8 100644 --- a/frontend/src/components/pure/navbar/index.vue +++ b/frontend/src/components/pure/navbar/index.vue @@ -4,7 +4,6 @@ -
-
表格
- - 搜索