diff --git a/src/control/form/form-detail/form-item/form-item.tsx b/src/control/form/form-detail/form-item/form-item.tsx index aef8d95f671c0567a3bfd302b6c78b36f9f34a27..19940a21c3ea84c1a778eac146aa1614488456fe 100644 --- a/src/control/form/form-detail/form-item/form-item.tsx +++ b/src/control/form/form-detail/form-item/form-item.tsx @@ -38,6 +38,7 @@ export const FormItem = defineComponent({ } // 编辑器内容 let editor = null; + const editMode = this.controller.editor?.model?.editorParams?.editMode; const editorProps = { style: this.controller.editor?.style, value: this.controller.value, @@ -46,7 +47,9 @@ export const FormItem = defineComponent({ disabled: this.controller.state.disabled, readonly: this.controller.state.readonly, onChange: this.onValueChange, - controlParams: this.controller.form.controlParams, + controlParams: editMode + ? { ...this.controller.form.controlParams, editmode: editMode } + : this.controller.form.controlParams, onFocus: (event: MouseEvent) => this.c.onFocus(event), onBlur: (event: MouseEvent) => this.c.onBlur(event), onEnter: (event: MouseEvent) => this.controller.onEnter(event), 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 fd145e334540f974139763af30b4d0d145789942..33b2ea86ad18df5fc571ad8d782713342724a87e 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 @@ -13,6 +13,7 @@ import { CodeListItem, useCalcOrMode, useCalcOrModeType, + useCodeListSelection, } from '@ibiz-template/runtime'; import { CheckBoxListEditorController } from '../checkbox-list-editor.controller'; @@ -45,7 +46,7 @@ export const IBizCheckboxList = defineComponent({ () => props.data, newVal => { c.loadCodeList(newVal).then(_codeList => { - items.value = _codeList; + items.value = c.handleCodeListAllItems(_codeList); }); }, { @@ -68,7 +69,7 @@ export const IBizCheckboxList = defineComponent({ const fn = (data: CodeListItem[] | undefined) => { if (data) { - items.value = data; + items.value = c.handleCodeListAllItems(data); } }; @@ -85,6 +86,10 @@ export const IBizCheckboxList = defineComponent({ emit, ); + const { getSelection, getSelectionValue } = useCodeListSelection( + c.allItemsValue, + ); + // 选中数组 const selectArray = computed({ get() { @@ -98,12 +103,24 @@ export const IBizCheckboxList = defineComponent({ codeList?.codeItemValueNumber, ); if (selectsArray) { + if (c.allItems) { + return getSelection([], selectsArray, items.value, items.value); + } return selectsArray; } } return []; }, set(val: Array) { + if (c.allItems) { + const selection = getSelection( + selectArray.value, + val, + items.value, + items.value, + ); + val = getSelectionValue(selection); + } let value: null | string | number | string[] | number[] = null; const { setSelectArray } = calcOrMode; value = setSelectArray(val, items.value, valueSeparator); diff --git a/src/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.tsx b/src/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.tsx index 3746e38a87cc500ee9bf635efaae8cd62cb102e6..9de30be0690e2702c392eeb56d8df6625bf303cd 100644 --- a/src/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.tsx +++ b/src/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.tsx @@ -16,7 +16,7 @@ import { useCodeListListen, } from '@ibiz-template/vue3-util'; import { OnClickOutsideResult, showTitle } from '@ibiz-template/core'; -import { CodeListItem } from '@ibiz-template/runtime'; +import { CodeListItem, useCodeListSelection } from '@ibiz-template/runtime'; import { DropDownListEditorController } from '../dropdown-list-editor.controller'; import './ibiz-dropdown.scss'; @@ -119,9 +119,12 @@ export const IBizDropdown = defineComponent({ } } isLoading.value = true; - const codeList = await c.loadCodeList(props.data!); + let codeList = await c.loadCodeList(props.data!); + if (c.multiple && !codeList.some(item => item.children)) { + codeList = c.handleCodeListAllItems(codeList); + } isLoadedCodeList.value = true; - if (c.blankItemName) { + if (c.blankItemName && !c.multiple) { items.value = [ { value: undefined, @@ -179,6 +182,10 @@ export const IBizDropdown = defineComponent({ return list.find(item => item.value === value); }; + const { getSelection, getSelectionValue } = useCodeListSelection( + c.allItemsValue, + ); + // 当前值 const curValue = computed({ get() { @@ -190,11 +197,27 @@ export const IBizDropdown = defineComponent({ return props.data[editorItems[0].id!]?.toString(); } if (props.value && typeof props.value === 'string') { + if (c.allItems && c.multiple && !hasChildren.value) { + return getSelection( + [], + props.value.split(','), + items.value as readonly CodeListItem[], + items.value as readonly CodeListItem[], + ).map(v => `${v}`); + } return c!.multiple ? props.value?.toString().split(',') : props.value.toString(); } if (props.value && Array.isArray(props.value)) { + if (c.allItems && c.multiple && !hasChildren.value) { + return getSelection( + [], + props.value, + items.value as readonly CodeListItem[], + items.value as readonly CodeListItem[], + ).map(v => `${v}`); + } return c!.multiple ? props.value : props.value.toString(); } return props.value?.toString(); @@ -206,6 +229,15 @@ export const IBizDropdown = defineComponent({ select = undefined; } if (Array.isArray(select)) { + if (c.allItems && c.multiple && !hasChildren.value) { + const selection = getSelection( + curValue.value as string[], + select, + items.value as readonly CodeListItem[], + items.value as readonly CodeListItem[], + ); + select = getSelectionValue(selection).map(v => `${v}`); + } let selectArr = null; if (select.length === 0) { selectArr = null; @@ -333,6 +365,10 @@ 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; } }; 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 638de9efbc7668e2fd2d35c1d483a984cb6c6704..2b96d68e3f14719d2035dbfea85243b586c71ff8 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 @@ -21,6 +21,7 @@ import { CodeListItem, useCalcOrMode, useCalcOrModeType, + useCodeListSelection, } from '@ibiz-template/runtime'; import { ListBoxEditorController } from '../list-box-editor.controller'; import { ListBoxPickerEditorController } from '../list-box-picker-editor.controller'; @@ -74,6 +75,10 @@ export const IBizListBox = defineComponent({ if (Object.is('LISTBOX', editorType)) { const controller = c as ListBoxEditorController; controller.loadCodeList(props.data).then(_codeList => { + if (multiple) { + items.value = controller.handleCodeListAllItems(_codeList); + return; + } items.value = _codeList; }); } else if (Object.is('LISTBOXPICKUP', editorType)) { @@ -94,6 +99,12 @@ export const IBizListBox = defineComponent({ const fn = (data: CodeListItem[] | undefined) => { if (data) { + if (Object.is('LISTBOX', editorType) && multiple) { + items.value = (c as ListBoxEditorController).handleCodeListAllItems( + data, + ); + return; + } items.value = data; } }; @@ -123,6 +134,12 @@ export const IBizListBox = defineComponent({ valueSeparator = codeList.valueSeparator; } + const { getSelection, getSelectionValue } = useCodeListSelection( + Object.is('LISTBOX', editorType) + ? (c as ListBoxEditorController).allItemsValue + : '', + ); + // 选中数组 const selectArray: Ref<(string | number)[]> = ref([]); @@ -144,6 +161,14 @@ export const IBizListBox = defineComponent({ ); if (arr) { selectsArray = arr; + if ((c as ListBoxEditorController).allItems) { + selectsArray = getSelection( + [], + selectsArray, + items.value as readonly CodeListItem[], + items.value as readonly CodeListItem[], + ); + } } } else if (editorType === 'LISTBOXPICKUP') { if (newVal !== '') { @@ -169,8 +194,17 @@ export const IBizListBox = defineComponent({ let _value; // 单多选 if (multiple) { - const values = [...value]; + let values = [...value]; if (Object.is('LISTBOX', editorType)) { + if ((c as ListBoxEditorController).allItems) { + const selection = getSelection( + selectArray.value, + values, + items.value as readonly CodeListItem[], + items.value as readonly CodeListItem[], + ); + values = getSelectionValue(selection); + } // 根据代码表模式对值进行计算 const { setSelectArray } = calcOrMode; _value = setSelectArray( diff --git a/src/editor/span/span/span.scss b/src/editor/span/span/span.scss index 6849581b69219d7a11a29cf40a7e6cf406a427e6..43c103404386fe8097a59a0e6843bfb456620188 100644 --- a/src/editor/span/span/span.scss +++ b/src/editor/span/span/span.scss @@ -28,4 +28,22 @@ padding: getCssVar(form-item, hover-edit-padding); } } +} + +@include b(form-item-container) { + @include m(left) { + @include b(span) { + padding-top: calc(getCssVar(spacing, base-tight) / 2); + padding-bottom: calc(getCssVar(spacing, base-tight) / 2); + line-height: normal; + } + } + + @include m(right) { + @include b(span) { + padding-top: calc(getCssVar(spacing, base-tight) / 2); + padding-bottom: calc(getCssVar(spacing, base-tight) / 2); + line-height: normal; + } + } } \ No newline at end of file