(all): 发布 1.2.2

This commit is contained in:
就眠儀式 2022-06-26 15:53:33 +08:00
parent fcb203c3b9
commit 98666c4ac1

View File

@ -1,23 +1,48 @@
<template> <template>
<lay-dropdown class="layui-cascader" ref="dropdownRef" :autoFitMinWidth="false" :updateAtScroll="true"> <lay-dropdown
<lay-input v-model="displayValue" readonly suffix-icon="layui-icon-down" :placeholder="placeholder" class="layui-cascader"
v-if="!slots.default"></lay-input> ref="dropdownRef"
:autoFitMinWidth="false"
:updateAtScroll="true"
>
<lay-input
v-model="displayValue"
readonly
suffix-icon="layui-icon-down"
:placeholder="placeholder"
v-if="!slots.default"
></lay-input>
<slot v-else></slot> <slot v-else></slot>
<template #content> <template #content>
<div class="layui-cascader-panel"> <div class="layui-cascader-panel">
<template v-for="(itemCol, index) in treeData"> <template v-for="(itemCol, index) in treeData">
<lay-scroll height="180px" class="layui-cascader-menu" :key="'cascader-menu' + index" <lay-scroll
v-if="itemCol.data.length"> height="180px"
<div class="layui-cascader-menu-item" v-for="(item, i) in itemCol.data" :key="index + i" class="layui-cascader-menu"
@click="selectBar(item, i, index)" :class="[ :key="'cascader-menu' + index"
v-if="itemCol.data.length"
>
<div
class="layui-cascader-menu-item"
v-for="(item, i) in itemCol.data"
:key="index + i"
@click="selectBar(item, i, index)"
:class="[
{ {
'layui-cascader-selected': itemCol.selectIndex === i, 'layui-cascader-selected': itemCol.selectIndex === i,
}, },
]"> ]"
<slot :name="item.slot" v-if="item.slot && slots[item.slot]"></slot> >
<slot
:name="item.slot"
v-if="item.slot && slots[item.slot]"
></slot>
<template v-else>{{ item.label }}</template> <template v-else>{{ item.label }}</template>
<i class="layui-icon layui-icon-right" v-if="item.children && item.children.length"></i> <i
class="layui-icon layui-icon-right"
v-if="item.children && item.children.length"
></i>
</div> </div>
</lay-scroll> </lay-scroll>
</template> </template>
@ -43,14 +68,14 @@ export interface LayCascaderProps {
modelValue?: string; modelValue?: string;
decollator?: string; decollator?: string;
placeholder?: string; placeholder?: string;
onlyLastLevel?: boolean onlyLastLevel?: boolean;
} }
const props = withDefaults(defineProps<LayCascaderProps>(), { const props = withDefaults(defineProps<LayCascaderProps>(), {
options: null, options: null,
modelValue: "", modelValue: "",
decollator: "/", decollator: "/",
placeholder: "", placeholder: "",
onlyLastLevel: false onlyLastLevel: false,
}); });
const emit = defineEmits(["update:modelValue", "change", "clear"]); const emit = defineEmits(["update:modelValue", "change", "clear"]);
@ -179,7 +204,9 @@ const selectBar = (item: any, selectIndex: number, parentIndex: number) => {
}) })
.join(` ${props.decollator} `); .join(` ${props.decollator} `);
} else { } else {
let _data = data.map((e: any) => { return e.label; }) let _data = data.map((e: any) => {
return e.label;
});
displayValue.value = _data[_data.length - 1]; displayValue.value = _data[_data.length - 1];
} }
let value = data let value = data