mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 13:38:58 +08:00
feat: 树下拉treeSelect-输入框里计算最大标签数量
This commit is contained in:
parent
777f1fe300
commit
9425b7701e
@ -7,6 +7,7 @@
|
|||||||
:mouse-enter-delay="300"
|
:mouse-enter-delay="300"
|
||||||
>
|
>
|
||||||
<a-tree-select
|
<a-tree-select
|
||||||
|
ref="treeSelectRef"
|
||||||
v-model:model-value="selectValue"
|
v-model:model-value="selectValue"
|
||||||
v-model:input-value="inputValue"
|
v-model:input-value="inputValue"
|
||||||
:data="props.data"
|
:data="props.data"
|
||||||
@ -22,6 +23,7 @@
|
|||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
|
:max-tag-count="maxTagCount"
|
||||||
@input-value-change="handleInputValueChange"
|
@input-value-change="handleInputValueChange"
|
||||||
@popup-visible-change="handlePopupVisibleChange"
|
@popup-visible-change="handlePopupVisibleChange"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
@ -43,21 +45,53 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { MsTreeNodeData } from '@/components/business/ms-tree/types';
|
import type { MsTreeNodeData } from '@/components/business/ms-tree/types';
|
||||||
|
|
||||||
|
import useSelect from '@/hooks/useSelect';
|
||||||
import { filterTreeNode, findNodeByKey } from '@/utils';
|
import { filterTreeNode, findNodeByKey } from '@/utils';
|
||||||
|
|
||||||
import type { TreeFieldNames, TreeNodeData } from '@arco-design/web-vue';
|
import type { TreeFieldNames, TreeNodeData } from '@arco-design/web-vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = withDefaults(
|
||||||
data: TreeNodeData[];
|
defineProps<{
|
||||||
fieldNames?: TreeFieldNames;
|
data: TreeNodeData[];
|
||||||
disabled?: boolean;
|
fieldNames?: TreeFieldNames;
|
||||||
multiple?: boolean;
|
disabled?: boolean;
|
||||||
}>();
|
multiple?: boolean;
|
||||||
|
shouldCalculateMaxTag?: boolean;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
shouldCalculateMaxTag: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
const selectValue = defineModel<any>('modelValue', { required: true });
|
const selectValue = defineModel<any>('modelValue', { required: true });
|
||||||
|
|
||||||
const inputValue = ref('');
|
const inputValue = ref('');
|
||||||
const tempInputValue = ref('');
|
const tempInputValue = ref('');
|
||||||
|
|
||||||
|
const treeSelectRef = ref();
|
||||||
|
const { maxTagCount, calculateMaxTag } = useSelect({
|
||||||
|
selectRef: treeSelectRef,
|
||||||
|
selectVal: selectValue,
|
||||||
|
});
|
||||||
|
watch(
|
||||||
|
() => selectValue.value,
|
||||||
|
() => {
|
||||||
|
if (props.shouldCalculateMaxTag !== false && props.multiple) {
|
||||||
|
calculateMaxTag();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
watch(
|
||||||
|
() => props.data,
|
||||||
|
() => {
|
||||||
|
if (props.shouldCalculateMaxTag !== false && props.multiple) {
|
||||||
|
calculateMaxTag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const getTreeSelectTooltip = computed(() => {
|
const getTreeSelectTooltip = computed(() => {
|
||||||
return () => {
|
return () => {
|
||||||
let treeSelectTooltip = '';
|
let treeSelectTooltip = '';
|
||||||
|
@ -726,7 +726,6 @@
|
|||||||
multiple: true,
|
multiple: true,
|
||||||
treeCheckable: true,
|
treeCheckable: true,
|
||||||
treeCheckStrictly: true,
|
treeCheckStrictly: true,
|
||||||
maxTagCount: 1,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -818,7 +818,6 @@
|
|||||||
multiple: true,
|
multiple: true,
|
||||||
treeCheckable: true,
|
treeCheckable: true,
|
||||||
treeCheckStrictly: true,
|
treeCheckStrictly: true,
|
||||||
maxTagCount: 1,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1030,7 +1030,6 @@
|
|||||||
multiple: true,
|
multiple: true,
|
||||||
treeCheckable: true,
|
treeCheckable: true,
|
||||||
treeCheckStrictly: true,
|
treeCheckStrictly: true,
|
||||||
maxTagCount: 1,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user