diff --git a/package.json b/package.json
index c2c1c799..c5494404 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"@chongchong/shared": "link:./shared",
"@lucide/vue": "^1.27.0",
"axios": "^1.18.1",
+ "dayjs": "^1.11.21",
"element-plus": "^2.14.3",
"pinia": "^4.0.2",
"sortablejs": "^1.15.7",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f9855f2d..88a48763 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -17,6 +17,9 @@ importers:
axios:
specifier: ^1.18.1
version: 1.18.1(debug@4.4.3)
+ dayjs:
+ specifier: ^1.11.21
+ version: 1.11.21
element-plus:
specifier: ^2.14.3
version: 2.14.3(vue@3.5.40(typescript@5.9.3))
diff --git a/src/main.ts b/src/main.ts
index 0ac17ad6..a0f43874 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,4 +1,5 @@
import { computed, createApp } from 'vue'
+import 'dayjs/locale/zh-cn'
import { createPinia } from 'pinia'
import { ElMessage, ElMessageBox } from 'element-plus'
import 'element-plus/es/components/message/style/css'
diff --git a/src/modules/finance/pages/FinanceCustomerArapView.vue b/src/modules/finance/pages/FinanceCustomerArapView.vue
index 03a73983..a6f28198 100644
--- a/src/modules/finance/pages/FinanceCustomerArapView.vue
+++ b/src/modules/finance/pages/FinanceCustomerArapView.vue
@@ -1,5 +1,5 @@
diff --git a/src/shared/components/DataTable.test.ts b/src/shared/components/DataTable.test.ts
index 6f285ecd..96ef7460 100644
--- a/src/shared/components/DataTable.test.ts
+++ b/src/shared/components/DataTable.test.ts
@@ -6,8 +6,8 @@ import LayoutPreferenceList from './LayoutPreferenceList.vue'
import { UI_PREFERENCE_SCOPE, preferenceStorageKey } from '@/shared/utils/uiLayoutPreference'
const TableStub = defineComponent({
- props: { border: Boolean, stripe: Boolean },
- template: '
',
+ props: { border: Boolean, stripe: Boolean, maxHeight: [String, Number] },
+ template: '
',
methods: { doLayout() {} },
})
const ColumnStub = defineComponent({
@@ -114,6 +114,20 @@ describe('DataTable column preferences', () => {
expect(plainTable.get('.table-stub').attributes()).toMatchObject({ 'data-border': 'false', 'data-stripe': 'false' })
})
+ it('keeps table bodies within the viewport by default and allows a custom height', () => {
+ const defaultTable = mountTable()
+ expect(defaultTable.get('.table-stub').attributes('data-max-height')).toBe('calc(100vh - 300px)')
+
+ const customTable = shallowMount(DataTable, {
+ props: { data: [], columns: configurableColumns, maxHeight: 420 },
+ global: {
+ stubs: { ElTable: TableStub, ElTableColumn: ColumnStub, ElButton: ButtonStub, ElPopover: PopoverStub },
+ directives: { loading: {} },
+ },
+ })
+ expect(customTable.get('.table-stub').attributes('data-max-height')).toBe('420')
+ })
+
it('uses key as the data property for ordinary columns only', () => {
const wrapper = shallowMount(DataTable, {
props: {
diff --git a/src/shared/components/DataTable.vue b/src/shared/components/DataTable.vue
index f063b0c8..510ed917 100644
--- a/src/shared/components/DataTable.vue
+++ b/src/shared/components/DataTable.vue
@@ -69,6 +69,7 @@ const props = withDefaults(defineProps<{
emptyText?: string
total?: number | string
pageSizes?: number[]
+ maxHeight?: string | number
preferenceKey?: string
columnSettingsMode?: 'auto' | 'show' | 'hide'
border?: boolean
@@ -78,6 +79,7 @@ const props = withDefaults(defineProps<{
emptyText: '暂无数据',
total: undefined,
pageSizes: () => [10, 20, 50, 100],
+ maxHeight: 'calc(100vh - 300px)',
columnSettingsMode: 'auto',
border: true,
stripe: true,
@@ -302,7 +304,7 @@ function setPage(value: number) {
-
+