diff --git a/CHANGELOG.md b/CHANGELOG.md index 46e68191f55fb04270ef634a8e9094562d86a289..0f31e7f13a332758a50a65d8f84c7d9a20f808ce 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 1056f45f1851ff9c6911e586a7e71521bc695a01..0535e3c351e3b22459eaf6d1b4a77f4f3da3a3f3 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 33b2ea86ad18df5fc571ad8d782713342724a87e..86231dc187ea8d9f36309fc8fa608811f9d9e1f8 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 e562eb6c432fe2bed3d63d802a06e2dd3d701433..91294259e2c600222b48531734190043b75f3074 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 3e1f591d6727dfcd3fb5d4304febb14af8b494be..e382450ae6245972f88870e534e84b19e9eb2000 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 2b96d68e3f14719d2035dbfea85243b586c71ff8..2149c2362ce125111f9538f58cf850882c94bd54 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 a3822217f06339cb65b7616a01c0a61c5e0c7d90..bbb730ab38964eae485adc650715203fe3f7e683 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 65302883d58448b8e6862d272aac63ba4b97b23d..065652db06a5f2943368bec17d06eb3945ad6aa2 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 19fa7c8f0e0eb020788f501677cea8c0110c04fb..d13ea0445e1ac3b501973ded164ae38cfdcbf4d7 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);