Merge branch 'next' of https://gitee.com/layui/layui-vue into next

This commit is contained in:
就眠儀式 2022-06-21 16:09:58 +08:00
commit 41c1572df4
6 changed files with 159 additions and 65 deletions

View File

@ -10,24 +10,16 @@
} }
.layui-cascader .layui-cascader-panel { .layui-cascader .layui-cascader-panel {
position: absolute;
margin-top: 2px;
z-index: 899;
background-color: #fff;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #e4e7ed;
border-radius: 2px; border-radius: 2px;
box-shadow: 0 2px 12px #0000001a;
line-height: 26px; line-height: 26px;
color: #000c; color: #000c;
font-size: 14px; font-size: 14px;
white-space: nowrap; white-space: nowrap;
display: none; display: inline-flex;
} }
.layui-cascader-menu { .layui-cascader-menu {
border-right: 1px solid var(--global-neutral-color-3); border-right: 1px solid var(--global-neutral-color-3);
max-height: 360px;
overflow-y: scroll;
} }
.layui-cascader-menu:last-child { .layui-cascader-menu:last-child {
border-right: none; border-right: none;
@ -50,6 +42,6 @@
background-color: var(--global-checked-color); background-color: var(--global-checked-color);
color: white; color: white;
} }
.layui-cascader-open .layui-cascader-panel { .layui-dropdown-up > dl {
display: flex !important; min-width: unset;
} }

View File

@ -1,48 +1,45 @@
<template> <template>
<div <lay-dropdown class="layui-cascader" ref="dropdownRef">
class="layui-cascader" <lay-input
:class="[{ 'layui-cascader-open': open }]" v-model="displayValue"
ref="cascaderRef" readonly
> suffix-icon="layui-icon-down"
<div @click="open = !open"> :placeholder="placeholder"
<lay-input v-if="!slots.default"
v-model="displayValue" ></lay-input>
readonly <slot v-else></slot>
suffix-icon="layui-icon-down"
:placeholder="placeholder"
v-if="!slots.default"
></lay-input>
<slot v-else></slot>
</div>
<dl class="layui-cascader-panel layui-anim layui-anim-upbit"> <template #content>
<template v-for="(itemCol, index) in treeData"> <div class="layui-cascader-panel">
<ul <template v-for="(itemCol, index) in treeData">
class="layui-cascader-menu" <lay-scroll
:key="'cascader-menu' + index" height="180px"
v-if="itemCol.data.length" class="layui-cascader-menu"
> :key="'cascader-menu' + index"
<li v-if="itemCol.data.length"
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,
},
]"
> >
{{ item.label }} <div
<i class="layui-cascader-menu-item"
class="layui-icon layui-icon-right" v-for="(item, i) in itemCol.data"
v-if="item.children && item.children.length" :key="index + i"
></i> @click="selectBar(item, i, index)"
</li> :class="[
</ul> {
</template> 'layui-cascader-selected': itemCol.selectIndex === i,
</dl> },
</div> ]"
>
{{ item.label }}
<i
class="layui-icon layui-icon-right"
v-if="item.children && item.children.length"
></i>
</div>
</lay-scroll>
</template>
</div>
</template>
</lay-dropdown>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -54,7 +51,6 @@ export default {
<script setup lang="ts"> <script setup lang="ts">
import "./index.less"; import "./index.less";
import { ref, onMounted, watch, useSlots } from "vue"; import { ref, onMounted, watch, useSlots } from "vue";
import { onClickOutside } from "@vueuse/core";
export interface LayCascaderProps { export interface LayCascaderProps {
options?: Array<any> | null; options?: Array<any> | null;
modelValue?: string; modelValue?: string;
@ -199,15 +195,13 @@ const selectBar = (item: any, selectIndex: number, parentIndex: number) => {
.join(props.decollator); .join(props.decollator);
emit("update:modelValue", value); emit("update:modelValue", value);
emit("change", displayValue.value); emit("change", displayValue.value);
open.value = false; if (dropdownRef.value)
// @ts-ignore
dropdownRef.value.hide();
} }
}; };
const open = ref<boolean>(false);
const displayValue = ref<string | number | null>(null); const displayValue = ref<string | number | null>(null);
const slots = useSlots(); const slots = useSlots();
const cascaderRef = ref<null | HTMLElement>(); const dropdownRef = ref(null);
onClickOutside(cascaderRef, () => {
open.value = false;
});
</script> </script>

View File

@ -38,3 +38,16 @@
padding: 0 10px; padding: 0 10px;
color: #fff; color: #fff;
} }
.lay-progress-circle {
position: relative;
display: inline-block;
width: 120px;
height: 120px;
text-align: center;
}
.lay-progress-circle__text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

View File

@ -15,6 +15,7 @@ export interface LayProgressProps {
size?: string; size?: string;
showText?: boolean; showText?: boolean;
text?: string; text?: string;
circle?: boolean;
} }
const props = defineProps<LayProgressProps>(); const props = defineProps<LayProgressProps>();
@ -27,10 +28,78 @@ const styles = computed(() => {
}, },
]; ];
}); });
const getStrokeDasharray = computed(() => {
let percent;
if (typeof props.percent == "string") {
percent = parseInt(props.percent);
} else {
percent = props.percent;
}
return `${percent * 31.4}` + "px 3140px";
});
const getCircleColor = computed(() => {
let color;
switch (props.theme) {
case "red":
color = "#ff5722";
break;
case "orange":
color = "#ffb800";
break;
case "green":
color = "#009688";
break;
case "cyan":
color = "#2f4056";
break;
case "blue":
color = "#1e9fff";
break;
case "black":
color = "#393d49";
break;
case "gray":
color = "#fafafa";
break;
default:
color = "var(--global-checked-color)";
break;
}
color = props.color ? props.color : color;
return color;
});
</script> </script>
<template> <template>
<div class="layui-progress" :class="'layui-progress-' + size"> <template v-if="circle">
<div class="lay-progress-circle">
<svg viewBox="0 0 1060 1060">
<path
d="M 530 530 m 0, -500 a 500, 500 0 1, 1 0, 1000 a 500, 500 0 1, 1 0, -1000"
style="
fill: none;
stroke-width: 50px;
stroke: var(--global-neutral-color-3);
"
></path>
<path
d="M 530 530 m 0, -500 a 500, 500 0 1, 1 0, 1000 a 500, 500 0 1, 1 0, -1000"
style="
stroke-width: 51px;
fill: none;
stroke-linecap: round;
"
:style="{ strokeDasharray: getStrokeDasharray,stroke:getCircleColor }"
></path>
</svg>
<div class="lay-progress-circle__text" v-if="showText">
{{ text ? text : percent + "%" }}
</div>
</div>
</template>
<div class="layui-progress" :class="'layui-progress-' + size" v-else>
<div <div
class="layui-progress-bar" class="layui-progress-bar"
:class="'layui-bg-' + theme" :class="'layui-bg-' + theme"

View File

@ -13,7 +13,7 @@
::: demo 使用 `lay-cascader` 标签创建级联选择器 ::: demo 使用 `lay-cascader` 标签创建级联选择器
<template> <template>
<lay-cascader :options="options" v-model="value" placeholder="点我试一试"></lay-cascader> <lay-cascader :options="options" v-model="value" placeholder="点我试一试" style="width:250px"></lay-cascader>
<br> <br>
<span>输出的值:{{value}}</span> <span>输出的值:{{value}}</span>
</template> </template>
@ -297,7 +297,7 @@ const options = [
::: :::
::: demo 使用 `decollator` 属性 自定义分割符号 ::: demo 使用 `decollator` 属性 自定义分割符号
<template> <template>
<lay-cascader :options="options" v-model="value1" decollator="-" placeholder="我可以自定义分割符号"></lay-cascader> <lay-cascader :options="options" v-model="value1" decollator="-" placeholder="我可以自定义分割符号" style="width:250px"></lay-cascader>
<br> <br>
<span>输出的值:{{value1}}</span> <span>输出的值:{{value1}}</span>
</template> </template>

View File

@ -119,6 +119,31 @@ export default {
::: :::
::: title 环形进度条
:::
::: demo
<template>
<lay-progress percent="70" circle :show-text="showText" style="margin-right:10px"></lay-progress>
<lay-progress percent="60" circle :show-text="showText" text="销售量"></lay-progress>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const showText = ref(true)
return {
showText
}
}
}
</script>
:::
::: title Progress 属性 ::: title Progress 属性
::: :::
@ -131,7 +156,8 @@ export default {
| size | 尺寸 | `big` | | size | 尺寸 | `big` |
| text | 提示 | -- | | text | 提示 | -- |
| color | 颜色 | -- | | color | 颜色 | -- |
| showText | 展示描述 | -- | | showText | 展示描述 | -- |
|circle | 环形进度条| 默认为 `false` |
::: :::