From 2e746b1defaba8fe2633419ed3916e9b6f193bed Mon Sep 17 00:00:00 2001 From: zhf <1204297681@qq.com> Date: Fri, 16 Aug 2024 19:54:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E4=BB=A3=E7=A0=81=E8=A1=A8?= =?UTF-8?q?=E7=B1=BB=E7=BC=96=E8=BE=91=E5=99=A8=E6=94=AF=E6=8C=81allItems?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E9=A1=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ibiz-checkbox-list/ibiz-checkbox-list.tsx | 21 +++++++++- .../ibiz-dropdown/ibiz-dropdown.tsx | 42 +++++++++++++++++-- .../list-box/ibiz-list-box/ibiz-list-box.tsx | 36 +++++++++++++++- 3 files changed, 93 insertions(+), 6 deletions(-) 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 fd145e334..33b2ea86a 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 3746e38a8..9de30be06 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 638de9efb..2b96d68e3 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( -- Gitee From 225a978d06e6aa4f39cd58679a82eb524fc0cfee Mon Sep 17 00:00:00 2001 From: zhf <1204297681@qq.com> Date: Mon, 19 Aug 2024 20:55:29 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E8=A1=A8=E5=8D=95=E9=A1=B9?= =?UTF-8?q?=E8=AF=86=E5=88=ABeditMode=E7=BC=96=E8=BE=91=E5=99=A8=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/control/form/form-detail/form-item/form-item.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 aef8d95f6..19940a21c 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), -- Gitee From defd973cf9d0f6898df0a2a3fc67426fef72f43c Mon Sep 17 00:00:00 2001 From: zhf <1204297681@qq.com> Date: Mon, 19 Aug 2024 20:56:07 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E5=8D=95?= =?UTF-8?q?span=E7=BC=96=E8=BE=91=E5=99=A8=E6=96=87=E6=9C=AC=E6=9C=AA?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/span/span/span.scss | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/editor/span/span/span.scss b/src/editor/span/span/span.scss index 6849581b6..43c103404 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 -- Gitee