From f7e8fa4e8cde774fd8358294f9132a1ff3f763ea Mon Sep 17 00:00:00 2001 From: ShineKOT <1917095344@qq.com> Date: Thu, 6 Feb 2025 14:11:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A1=A8=E7=B1=BB=E7=BC=96=E8=BE=91=E5=99=A8=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A1=A8=E5=8F=98=E6=9B=B4=E5=90=8E=E7=BB=AD?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++ .../grid-field-column/grid-field-column.tsx | 6 +-- .../ibiz-checkbox-list/ibiz-checkbox-list.tsx | 6 +-- .../ibiz-dropdown/ibiz-dropdown.tsx | 47 +++++++++++-------- .../ibiz-virtualized-list.tsx | 47 +++++++++++-------- .../list-box/ibiz-list-box/ibiz-list-box.tsx | 2 +- .../ibiz-radio/ibiz-radio.tsx | 6 +-- src/editor/span/span/span.tsx | 6 +-- src/editor/text-box/input/input.tsx | 4 +- 9 files changed, 68 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e68191f..0f31e7f13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ ## [Unreleased] +### Fixed + +- 修复代码表类编辑器监听代码表变更后续处理异常 + ## [0.7.38-alpha.54] - 2025-01-23 ### Added diff --git a/src/control/grid/grid-column/grid-field-column/grid-field-column.tsx b/src/control/grid/grid-column/grid-field-column/grid-field-column.tsx index 1056f45f1..0535e3c35 100644 --- a/src/control/grid/grid-column/grid-field-column/grid-field-column.tsx +++ b/src/control/grid/grid-column/grid-field-column/grid-field-column.tsx @@ -1,7 +1,6 @@ import { ILayoutPanel, IPanel, IUIActionGroupDetail } from '@ibiz/model-core'; import { computed, defineComponent, Ref, ref, VNode, watch } from 'vue'; import { useNamespace, useCodeListListen } from '@ibiz-template/vue3-util'; -import './grid-field-column.scss'; import { CodeListItem, GridFieldColumnController, @@ -10,6 +9,7 @@ import { } from '@ibiz-template/runtime'; import { isNotNil } from 'ramda'; import { showTitle } from '@ibiz-template/core'; +import './grid-field-column.scss'; export const GridFieldColumn = defineComponent({ name: 'IBizGridFieldColumn', @@ -150,9 +150,7 @@ export const GridFieldColumn = defineComponent({ } const fn = (data: CodeListItem[] | undefined) => { - if (data) { - codeListItems.value = data; - } + if (data) codeListItems.value = data; }; useCodeListListen( diff --git a/src/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.tsx b/src/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.tsx index 33b2ea86a..86231dc18 100644 --- a/src/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.tsx +++ b/src/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.tsx @@ -8,7 +8,6 @@ import { useAutoFocusBlur, } from '@ibiz-template/vue3-util'; import { isNil } from 'ramda'; -import './ibiz-checkbox-list.scss'; import { CodeListItem, useCalcOrMode, @@ -16,6 +15,7 @@ import { useCodeListSelection, } from '@ibiz-template/runtime'; import { CheckBoxListEditorController } from '../checkbox-list-editor.controller'; +import './ibiz-checkbox-list.scss'; export const IBizCheckboxList = defineComponent({ name: 'IBizCheckboxList', @@ -68,9 +68,7 @@ export const IBizCheckboxList = defineComponent({ ); const fn = (data: CodeListItem[] | undefined) => { - if (data) { - items.value = c.handleCodeListAllItems(data); - } + if (data) items.value = c.handleCodeListAllItems(data); }; useCodeListListen(c.model.appCodeListId, c.context.srfappid, fn); diff --git a/src/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.tsx b/src/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.tsx index e562eb6c4..91294259e 100644 --- a/src/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.tsx +++ b/src/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.tsx @@ -114,22 +114,19 @@ export const IBizDropdown = defineComponent({ return list; }; - // 加载代码表数据与后续操作 - const loadCodeList = async () => { - if (c.model.appCodeListId) { - const app = ibiz.hub.getApp(c.context.srfappid); - const codeListModel = app.codeList.getCodeList(c.model.appCodeListId); - if (codeListModel) { - codeItemValueNumber.value = - codeListModel.codeItemValueNumber || false; - } - } - isLoading.value = true; - let codeList = await c.loadCodeList(props.data!); + /** + * 加载代码表后续处理 + * + * @param {readonly} codeList + * @param {*} CodeListItem + * @param {*} [] + */ + const afterLoadCodeList = (codeList: readonly CodeListItem[]) => { + items.value = []; + codeListItems.value = []; if (c.multiple && !codeList.some(item => item.children)) { codeList = c.handleCodeListAllItems(codeList); } - isLoadedCodeList.value = true; if (c.blankItemName && !c.multiple) { items.value = [ { @@ -149,6 +146,22 @@ export const IBizDropdown = defineComponent({ break; } } + }; + + // 加载代码表数据 + const loadCodeList = async () => { + if (c.model.appCodeListId) { + const app = ibiz.hub.getApp(c.context.srfappid); + const codeListModel = app.codeList.getCodeList(c.model.appCodeListId); + if (codeListModel) { + codeItemValueNumber.value = + codeListModel.codeItemValueNumber || false; + } + } + isLoading.value = true; + const codeList = await c.loadCodeList(props.data!); + afterLoadCodeList(codeList); + isLoadedCodeList.value = true; isLoading.value = false; }; @@ -403,13 +416,7 @@ export const IBizDropdown = defineComponent({ }; const fn = (data: CodeListItem[] | undefined) => { - if (data) { - if (c.multiple && !data.some(item => item.children)) { - items.value = c.handleCodeListAllItems(data); - return; - } - items.value = data; - } + if (data) afterLoadCodeList(data); }; useCodeListListen(c.model.appCodeListId, c.context.srfappid, fn); diff --git a/src/editor/dropdown-list/ibiz-virtualized-list/ibiz-virtualized-list.tsx b/src/editor/dropdown-list/ibiz-virtualized-list/ibiz-virtualized-list.tsx index 3e1f591d6..e382450ae 100644 --- a/src/editor/dropdown-list/ibiz-virtualized-list/ibiz-virtualized-list.tsx +++ b/src/editor/dropdown-list/ibiz-virtualized-list/ibiz-virtualized-list.tsx @@ -91,22 +91,19 @@ export const IBizVirtualizedList = defineComponent({ return list; }; - // 加载代码表数据与后续操作 - const loadCodeList = async () => { - if (c.model.appCodeListId) { - const app = ibiz.hub.getApp(c.context.srfappid); - const codeListModel = app.codeList.getCodeList(c.model.appCodeListId); - if (codeListModel) { - codeItemValueNumber.value = - codeListModel.codeItemValueNumber || false; - } - } - isLoading.value = true; - let codeList = await c.loadCodeList(props.data!); + /** + * 加载代码表后续处理 + * + * @param {readonly} codeList + * @param {*} CodeListItem + * @param {*} [] + */ + const afterLoadCodeList = (codeList: readonly CodeListItem[]) => { + items.value = []; + codeListItems.value = []; if (c.multiple && !codeList.some(item => item.children)) { codeList = c.handleCodeListAllItems(codeList); } - isLoadedCodeList.value = true; if (c.blankItemName && !c.multiple) { items.value = [ { @@ -126,6 +123,22 @@ export const IBizVirtualizedList = defineComponent({ break; } } + }; + + // 加载代码表数据与后续操作 + const loadCodeList = async () => { + if (c.model.appCodeListId) { + const app = ibiz.hub.getApp(c.context.srfappid); + const codeListModel = app.codeList.getCodeList(c.model.appCodeListId); + if (codeListModel) { + codeItemValueNumber.value = + codeListModel.codeItemValueNumber || false; + } + } + isLoading.value = true; + const codeList = await c.loadCodeList(props.data!); + afterLoadCodeList(codeList); + isLoadedCodeList.value = true; isLoading.value = false; }; @@ -363,13 +376,7 @@ export const IBizVirtualizedList = defineComponent({ }; const fn = (data: CodeListItem[] | undefined) => { - if (data) { - if (c.multiple && !data.some(item => item.children)) { - items.value = c.handleCodeListAllItems(data); - return; - } - items.value = data; - } + if (data) afterLoadCodeList(data); }; useCodeListListen(c.model.appCodeListId, c.context.srfappid, fn); diff --git a/src/editor/list-box/ibiz-list-box/ibiz-list-box.tsx b/src/editor/list-box/ibiz-list-box/ibiz-list-box.tsx index 2b96d68e3..2149c2362 100644 --- a/src/editor/list-box/ibiz-list-box/ibiz-list-box.tsx +++ b/src/editor/list-box/ibiz-list-box/ibiz-list-box.tsx @@ -16,7 +16,6 @@ import { useAutoFocusBlur, } from '@ibiz-template/vue3-util'; import { isNil } from 'ramda'; -import './ibiz-list-box.scss'; import { CodeListItem, useCalcOrMode, @@ -25,6 +24,7 @@ import { } from '@ibiz-template/runtime'; import { ListBoxEditorController } from '../list-box-editor.controller'; import { ListBoxPickerEditorController } from '../list-box-picker-editor.controller'; +import './ibiz-list-box.scss'; export const IBizListBox = defineComponent({ name: 'IBizListBox', diff --git a/src/editor/radio-button-list/ibiz-radio/ibiz-radio.tsx b/src/editor/radio-button-list/ibiz-radio/ibiz-radio.tsx index a3822217f..bbb730ab3 100644 --- a/src/editor/radio-button-list/ibiz-radio/ibiz-radio.tsx +++ b/src/editor/radio-button-list/ibiz-radio/ibiz-radio.tsx @@ -8,10 +8,10 @@ import { useCodeListListen, useAutoFocusBlur, } from '@ibiz-template/vue3-util'; -import './ibiz-radio.scss'; import { notNilEmpty } from 'qx-util'; import { CodeListItem } from '@ibiz-template/runtime'; import { RadioButtonListEditorController } from '../radio-button-list.controller'; +import './ibiz-radio.scss'; export const IBizRadio = defineComponent({ name: 'IBizRadio', @@ -65,9 +65,7 @@ export const IBizRadio = defineComponent({ ); const fn = (data: CodeListItem[] | undefined) => { - if (data) { - items.value = data; - } + if (data) items.value = data; }; useCodeListListen(c.model.appCodeListId, c.context.srfappid, fn); diff --git a/src/editor/span/span/span.tsx b/src/editor/span/span/span.tsx index 65302883d..065652db0 100644 --- a/src/editor/span/span/span.tsx +++ b/src/editor/span/span/span.tsx @@ -5,7 +5,6 @@ import { useNamespace, useCodeListListen, } from '@ibiz-template/vue3-util'; -import './span.scss'; import { CodeListItem } from '@ibiz-template/runtime'; import { isNil } from 'ramda'; import { @@ -17,6 +16,7 @@ import { import dayjs from 'dayjs'; import customParseFormat from 'dayjs/plugin/customParseFormat'; import { SpanEditorController } from '../span-editor.controller'; +import './span.scss'; dayjs.extend(customParseFormat); @@ -154,9 +154,7 @@ export const IBizSpan = defineComponent({ } const fn = (data: CodeListItem[] | undefined) => { - if (data) { - items.value = data; - } + if (data) items.value = data; }; useCodeListListen(c.model.appCodeListId, c.context.srfappid, fn); diff --git a/src/editor/text-box/input/input.tsx b/src/editor/text-box/input/input.tsx index 19fa7c8f0..d13ea0445 100644 --- a/src/editor/text-box/input/input.tsx +++ b/src/editor/text-box/input/input.tsx @@ -351,9 +351,7 @@ export const IBizInput = defineComponent({ } const fn = (data: CodeListItem[] | undefined) => { - if (data) { - items.value = data; - } + if (data) items.value = data; }; useCodeListListen(c.model.appCodeListId, c.context.srfappid, fn); -- Gitee