diff --git a/CHANGELOG.md b/CHANGELOG.md index 3263a3e37b9fe6388628b2f6c1915ca7380dce5d..0ca81fdfa29f63e6c11f30c4604597b48d1dab70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Change - 卡片视图绘制为卡片样式 +- 卡片视图部件支持分页模式 ### Fixed diff --git a/src/control/data-view/data-view.scss b/src/control/data-view/data-view.scss index 4d3db9db70a4ea321a9b2ae396884a346953567f..204d4fed3eaa531f3e1cbb5d1da86176fa551607 100644 --- a/src/control/data-view/data-view.scss +++ b/src/control/data-view/data-view.scss @@ -3,6 +3,7 @@ $control-dataview: (text-color: getCssVar(color, text, 0), padding: getCssVar(spacing, base-tight) getCssVar(spacing, base), card-margin:getCssVar(spacing, base-tight), item-margin: calc( getCssVar(spacing, base, tight) / 2 ), + pagination-height: var(--van-pagination-height), ); @include b(control-dataview-item) { @@ -42,4 +43,17 @@ $control-dataview: (text-color: getCssVar(color, text, 0), @include e(item-col) { margin: getCssVar(control-dataview, item-margin) 0; } + + @include when(enable-page) { + .#{bem(control-dataview, content)} { + height: calc(100% - getCssVar(control-dataview, pagination-height)); + } + } + + @include e(load-more) { + @include flex(row, center, center); + height: getCssVar(control-dataview, pagination-height); + cursor: pointer; + color: getCssVar(color, link); + } } \ No newline at end of file diff --git a/src/control/data-view/data-view.tsx b/src/control/data-view/data-view.tsx index d66fe9d914104b0a016abc30164dc31a01a3ef57..e1156b1ef6c43386fab3b581325e40c1296218c2 100644 --- a/src/control/data-view/data-view.tsx +++ b/src/control/data-view/data-view.tsx @@ -1,12 +1,13 @@ import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; -import { defineComponent, PropType, ref, VNode } from 'vue'; +import { computed, defineComponent, PropType, ref, VNode } from 'vue'; import { IDEDataView, ILayoutPanel, IUIActionGroupDetail, } from '@ibiz/model-core'; -import './data-view.scss'; import { DataViewControlController } from '@ibiz-template/runtime'; +import { usePagination } from '../../util'; +import './data-view.scss'; export const DataViewControl = defineComponent({ name: 'IBizDataViewControl', @@ -24,6 +25,29 @@ export const DataViewControl = defineComponent({ const ns = useNamespace(`control-${c.model.controlType!.toLowerCase()}`); const active = ref([]); + // 是否可以加载更多 + const isLodeMoreDisabled = computed(() => { + if (c.model.enablePagingBar === true) { + return true; + } + if (c.model.pagingMode !== 2) { + return true; + } + return ( + c.state.items.length >= c.state.total || + c.state.isLoading || + c.state.total <= c.state.size + ); + }); + + const { onPageChange } = usePagination(c); + + // 是否显示数据伸缩图标 + // 如果未开启分组,并且加载模式为【加载更多】,并且已经加载过一次更多,则为 true + const showCollapseOrExpandIcon = computed(() => { + return !c.model.enableGroup && c.model.pagingMode === 3; + }); + // 绘制项布局面板 const renderPanelItem = (item: IData, modelData: ILayoutPanel): VNode => { const { context, params } = c; @@ -166,26 +190,76 @@ export const DataViewControl = defineComponent({ const renderMDContent = () => { const model: IDEDataView = c.model; return ( -