From 2083389c23a2030248c543881e878266b44b9268 Mon Sep 17 00:00:00 2001 From: zhf <1204297681@qq.com> Date: Sat, 7 Oct 2023 19:40:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=B1=9E=E6=80=A7=E6=9C=AA=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/control/grid/grid/grid.tsx | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e153019a1..4fc2a14e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - markdown 编辑器,表单项更新后未回填 - 修复树表格视图工具栏点击新建报错 +- 修复表格部件排序属性未正确设置异常 ### PackageUpgrade diff --git a/src/control/grid/grid/grid.tsx b/src/control/grid/grid/grid.tsx index 02ac12220..d7646235e 100644 --- a/src/control/grid/grid/grid.tsx +++ b/src/control/grid/grid/grid.tsx @@ -2,6 +2,8 @@ import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; import { defineComponent, h, + onMounted, + onUnmounted, PropType, resolveComponent, VNode, @@ -160,6 +162,32 @@ export const GridControl = defineComponent({ const { renderPopover } = useRowEditPopover(tableRef, c); + const setSortFiled = () => { + if (!tableRef.value) { + return; + } + const { prop, order } = defaultSort.value; + const fieldColumn = Object.values(c.fieldColumns).find( + item => item.model.appDEFieldId === prop, + ); + if (fieldColumn) { + tableRef.value.store.commit('sort', { + prop: fieldColumn.model.codeName, + order, + init: true, + }); + c.evt.off('onLoadSuccess', setSortFiled); + } + }; + + onMounted(() => { + c.evt.on('onLoadSuccess', setSortFiled); + }); + + onUnmounted(() => { + c.evt.off('onLoadSuccess', setSortFiled); + }); + return { c, ns, @@ -192,7 +220,7 @@ export const GridControl = defineComponent({ ]} controller={this.c} > - {this.c.state.isLoaded && ( + { - )} + } {enablePagingBar && (