Commit da12da9d8caeba0e7732551cfbad9b0da3baaac4
1 parent
30c5fc63
perf(table): fixed code style
修复一些代码检查警告,并且为table的canResize属性添加不兼容场景警告 close: #1070
Showing
5 changed files
with
30 additions
and
10 deletions
src/components/Page/index.ts
@@ -5,3 +5,5 @@ import pageWrapper from './src/PageWrapper.vue'; | @@ -5,3 +5,5 @@ import pageWrapper from './src/PageWrapper.vue'; | ||
5 | 5 | ||
6 | export const PageFooter = withInstall(pageFooter); | 6 | export const PageFooter = withInstall(pageFooter); |
7 | export const PageWrapper = withInstall(pageWrapper); | 7 | export const PageWrapper = withInstall(pageWrapper); |
8 | + | ||
9 | +export const PageWrapperFixedHeightKey = 'PageWrapperFixedHeight'; |
src/components/Page/src/PageWrapper.vue
@@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
33 | </div> | 33 | </div> |
34 | </template> | 34 | </template> |
35 | <script lang="ts"> | 35 | <script lang="ts"> |
36 | - import type { CSSProperties, PropType } from 'vue'; | 36 | + import { CSSProperties, PropType, provide } from 'vue'; |
37 | 37 | ||
38 | import { defineComponent, computed, watch, ref, unref } from 'vue'; | 38 | import { defineComponent, computed, watch, ref, unref } from 'vue'; |
39 | import PageFooter from './PageFooter.vue'; | 39 | import PageFooter from './PageFooter.vue'; |
@@ -43,6 +43,7 @@ | @@ -43,6 +43,7 @@ | ||
43 | import { omit } from 'lodash-es'; | 43 | import { omit } from 'lodash-es'; |
44 | import { PageHeader } from 'ant-design-vue'; | 44 | import { PageHeader } from 'ant-design-vue'; |
45 | import { useContentHeight } from '/@/hooks/web/useContentHeight'; | 45 | import { useContentHeight } from '/@/hooks/web/useContentHeight'; |
46 | + import { PageWrapperFixedHeightKey } from '..'; | ||
46 | 47 | ||
47 | export default defineComponent({ | 48 | export default defineComponent({ |
48 | name: 'PageWrapper', | 49 | name: 'PageWrapper', |
@@ -68,6 +69,11 @@ | @@ -68,6 +69,11 @@ | ||
68 | const footerRef = ref(null); | 69 | const footerRef = ref(null); |
69 | const { prefixCls } = useDesign('page-wrapper'); | 70 | const { prefixCls } = useDesign('page-wrapper'); |
70 | 71 | ||
72 | + provide( | ||
73 | + PageWrapperFixedHeightKey, | ||
74 | + computed(() => props.fixedHeight) | ||
75 | + ); | ||
76 | + | ||
71 | const getIsContentFullHeight = computed(() => { | 77 | const getIsContentFullHeight = computed(() => { |
72 | return props.contentFullHeight; | 78 | return props.contentFullHeight; |
73 | }); | 79 | }); |
src/components/Table/src/BasicTable.vue
@@ -39,9 +39,10 @@ | @@ -39,9 +39,10 @@ | ||
39 | ColumnChangeParam, | 39 | ColumnChangeParam, |
40 | } from './types/table'; | 40 | } from './types/table'; |
41 | 41 | ||
42 | - import { defineComponent, ref, computed, unref, toRaw } from 'vue'; | 42 | + import { defineComponent, ref, computed, unref, toRaw, inject, watchEffect } from 'vue'; |
43 | import { Table } from 'ant-design-vue'; | 43 | import { Table } from 'ant-design-vue'; |
44 | import { BasicForm, useForm } from '/@/components/Form/index'; | 44 | import { BasicForm, useForm } from '/@/components/Form/index'; |
45 | + import { PageWrapperFixedHeightKey } from '/@/components/Page'; | ||
45 | import expandIcon from './components/ExpandIcon'; | 46 | import expandIcon from './components/ExpandIcon'; |
46 | import HeaderCell from './components/HeaderCell.vue'; | 47 | import HeaderCell from './components/HeaderCell.vue'; |
47 | import { InnerHandlers } from './types/table'; | 48 | import { InnerHandlers } from './types/table'; |
@@ -64,6 +65,7 @@ | @@ -64,6 +65,7 @@ | ||
64 | import { omit } from 'lodash-es'; | 65 | import { omit } from 'lodash-es'; |
65 | import { basicProps } from './props'; | 66 | import { basicProps } from './props'; |
66 | import { isFunction } from '/@/utils/is'; | 67 | import { isFunction } from '/@/utils/is'; |
68 | + import { warn } from '/@/utils/log'; | ||
67 | 69 | ||
68 | export default defineComponent({ | 70 | export default defineComponent({ |
69 | components: { | 71 | components: { |
@@ -104,6 +106,13 @@ | @@ -104,6 +106,13 @@ | ||
104 | return { ...props, ...unref(innerPropsRef) } as BasicTableProps; | 106 | return { ...props, ...unref(innerPropsRef) } as BasicTableProps; |
105 | }); | 107 | }); |
106 | 108 | ||
109 | + const isFixedHeightPage = inject(PageWrapperFixedHeightKey); | ||
110 | + watchEffect(() => { | ||
111 | + unref(isFixedHeightPage) && | ||
112 | + props.canResize && | ||
113 | + warn("[BasicTable] 'canRize' not worked with PageWrapper while 'fixedHeight' is true"); | ||
114 | + }); | ||
115 | + | ||
107 | const { getLoading, setLoading } = useLoading(getProps); | 116 | const { getLoading, setLoading } = useLoading(getProps); |
108 | const { | 117 | const { |
109 | getPaginationInfo, | 118 | getPaginationInfo, |
@@ -380,9 +389,9 @@ | @@ -380,9 +389,9 @@ | ||
380 | align-items: center; | 389 | align-items: center; |
381 | } | 390 | } |
382 | 391 | ||
383 | - .ant-table-tbody > tr.ant-table-row-selected td { | ||
384 | - //background-color: fade(@primary-color, 8%) !important; | ||
385 | - } | 392 | + //.ant-table-tbody > tr.ant-table-row-selected td { |
393 | + //background-color: fade(@primary-color, 8%) !important; | ||
394 | + //} | ||
386 | } | 395 | } |
387 | 396 | ||
388 | .ant-pagination { | 397 | .ant-pagination { |
src/components/Table/src/hooks/useTableForm.ts
@@ -21,9 +21,11 @@ export function useTableForm( | @@ -21,9 +21,11 @@ export function useTableForm( | ||
21 | }; | 21 | }; |
22 | }); | 22 | }); |
23 | 23 | ||
24 | - const getFormSlotKeys = computed(() => { | 24 | + const getFormSlotKeys: ComputedRef<string[]> = computed(() => { |
25 | const keys = Object.keys(slots); | 25 | const keys = Object.keys(slots); |
26 | - return keys.map((item) => (item.startsWith('form-') ? item : null)).filter(Boolean); | 26 | + return keys |
27 | + .map((item) => (item.startsWith('form-') ? item : null)) | ||
28 | + .filter((item) => !!item) as string[]; | ||
27 | }); | 29 | }); |
28 | 30 | ||
29 | function replaceFormSlotKey(key: string) { | 31 | function replaceFormSlotKey(key: string) { |
src/views/demo/table/FetchTable.vue
1 | <template> | 1 | <template> |
2 | - <div class="p-4"> | 2 | + <PageWrapper contentBackground contentClass="flex" dense contentFullHeight fixedHeight> |
3 | <BasicTable @register="registerTable"> | 3 | <BasicTable @register="registerTable"> |
4 | <template #toolbar> | 4 | <template #toolbar> |
5 | <a-button type="primary" @click="handleReloadCurrent"> 刷新当前页 </a-button> | 5 | <a-button type="primary" @click="handleReloadCurrent"> 刷新当前页 </a-button> |
6 | <a-button type="primary" @click="handleReload"> 刷新并返回第一页 </a-button> | 6 | <a-button type="primary" @click="handleReload"> 刷新并返回第一页 </a-button> |
7 | </template> | 7 | </template> |
8 | </BasicTable> | 8 | </BasicTable> |
9 | - </div> | 9 | + </PageWrapper> |
10 | </template> | 10 | </template> |
11 | <script lang="ts"> | 11 | <script lang="ts"> |
12 | import { defineComponent } from 'vue'; | 12 | import { defineComponent } from 'vue'; |
13 | import { BasicTable, useTable } from '/@/components/Table'; | 13 | import { BasicTable, useTable } from '/@/components/Table'; |
14 | import { getBasicColumns } from './tableData'; | 14 | import { getBasicColumns } from './tableData'; |
15 | + import { PageWrapper } from '/@/components/Page'; | ||
15 | 16 | ||
16 | import { demoListApi } from '/@/api/demo/table'; | 17 | import { demoListApi } from '/@/api/demo/table'; |
17 | export default defineComponent({ | 18 | export default defineComponent({ |
18 | - components: { BasicTable }, | 19 | + components: { BasicTable, PageWrapper }, |
19 | setup() { | 20 | setup() { |
20 | const [registerTable, { reload }] = useTable({ | 21 | const [registerTable, { reload }] = useTable({ |
21 | title: '远程加载示例', | 22 | title: '远程加载示例', |