✨(component): 新增radioGroup组件 disabled属性
This commit is contained in:
parent
eaa66f6d5a
commit
93cb391f68
@ -102,7 +102,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.layui-form-checked[lay-skin="primary"] i {
|
.layui-form-checked[lay-skin="primary"] i {
|
||||||
border-color: var(--global-checked-color) !important;
|
border-color: var(--global-checked-color);
|
||||||
background-color: var(--global-checked-color);
|
background-color: var(--global-checked-color);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
@ -136,3 +136,8 @@
|
|||||||
.layui-checkbox-disabled:hover i {
|
.layui-checkbox-disabled:hover i {
|
||||||
color: #fff !important;
|
color: #fff !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layui-checkbox-disabled .layui-icon-ok,.layui-checkbox-disabled .layui-icon-subtraction{
|
||||||
|
background-color: var(--global-neutral-color-3) !important;
|
||||||
|
border-color: var(--global-neutral-color-3) !important;
|
||||||
|
}
|
@ -27,7 +27,6 @@ const props = withDefaults(defineProps<LayCheckboxProps>(), {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const checkboxGroup: any = inject("checkboxGroup", {});
|
const checkboxGroup: any = inject("checkboxGroup", {});
|
||||||
const checkboxGroupDisabled: boolean = inject("checkboxGroupDisabled", false);
|
|
||||||
|
|
||||||
const isGroup = computed(() => {
|
const isGroup = computed(() => {
|
||||||
return (
|
return (
|
||||||
@ -93,10 +92,19 @@ const setArrayModelValue = function (checked: any) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleClick = function () {
|
const handleClick = function () {
|
||||||
if (!props.disabled&&!checkboxGroupDisabled) {
|
if (!ifDisabled.value) {
|
||||||
isChecked.value = !isChecked.value;
|
isChecked.value = !isChecked.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const ifDisabled = computed(() => {
|
||||||
|
if (props.disabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (checkboxGroup.hasOwnProperty('disabled')&&checkboxGroup.disabled.value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -105,8 +113,8 @@ const handleClick = function () {
|
|||||||
<div
|
<div
|
||||||
class="layui-unselect layui-form-checkbox"
|
class="layui-unselect layui-form-checkbox"
|
||||||
:class="{
|
:class="{
|
||||||
'layui-checkbox-disabled layui-disabled': disabled||checkboxGroupDisabled,
|
|
||||||
'layui-form-checked': isChecked,
|
'layui-form-checked': isChecked,
|
||||||
|
'layui-checkbox-disabled layui-disabled': ifDisabled,
|
||||||
}"
|
}"
|
||||||
:lay-skin="skin"
|
:lay-skin="skin"
|
||||||
>
|
>
|
||||||
|
@ -21,9 +21,9 @@ const props = withDefaults(defineProps<LayCheckboxGroupProps>(), {
|
|||||||
const emit = defineEmits(["update:modelValue", "change"]);
|
const emit = defineEmits(["update:modelValue", "change"]);
|
||||||
|
|
||||||
const modelValue = ref(props.modelValue);
|
const modelValue = ref(props.modelValue);
|
||||||
|
const disabled=ref(props.disabled)
|
||||||
|
provide("checkboxGroup", { name: "LayCheckboxGroup", modelValue: modelValue,disabled:disabled });
|
||||||
|
|
||||||
provide("checkboxGroup", { name: "LayCheckboxGroup", modelValue: modelValue });
|
|
||||||
provide("checkboxGroupDisabled",props.disabled)
|
|
||||||
watch(
|
watch(
|
||||||
() => modelValue,
|
() => modelValue,
|
||||||
(val) => {
|
(val) => {
|
||||||
@ -38,6 +38,11 @@ watch(
|
|||||||
(val) => (modelValue.value = val)
|
(val) => (modelValue.value = val)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.disabled,
|
||||||
|
(val) => (disabled.value = val)
|
||||||
|
);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -7,6 +7,7 @@ export default {
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import "./index.less";
|
import "./index.less";
|
||||||
|
import { disable } from '@umijs/ssr-darkreader';
|
||||||
|
|
||||||
export interface LayRadioProps {
|
export interface LayRadioProps {
|
||||||
modelValue?: string | boolean;
|
modelValue?: string | boolean;
|
||||||
@ -55,32 +56,33 @@ const isChecked = computed({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleClick = function () {
|
const handleClick = function () {
|
||||||
if (!props.disabled) {
|
if (!ifDisabled.value) {
|
||||||
isChecked.value = !isChecked.value;
|
isChecked.value = !isChecked.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const ifDisabled = computed(() => {
|
||||||
|
if (props.disabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (radioGroup.hasOwnProperty('disabled')&&radioGroup.disabled.value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<span class="layui-radio">
|
<span class="layui-radio">
|
||||||
<input type="radio" :value="value" :name="naiveName" />
|
<input type="radio" :value="value" :name="naiveName" />
|
||||||
<div
|
<div class="layui-unselect layui-form-radio" :class="{
|
||||||
class="layui-unselect layui-form-radio"
|
'layui-form-radioed': isChecked,
|
||||||
:class="{
|
'layui-radio-disabled layui-disabled': ifDisabled,
|
||||||
'layui-form-radioed': isChecked,
|
}" @click.stop="handleClick">
|
||||||
'layui-radio-disabled layui-disabled': disabled,
|
<i v-if="isChecked" class="layui-anim layui-icon layui-anim-scaleSpring"></i>
|
||||||
}"
|
<i v-else class="layui-icon layui-form-radioed"></i>
|
||||||
@click.stop="handleClick"
|
<span>
|
||||||
>
|
<slot>{{ label }}</slot>
|
||||||
<i v-if="isChecked" class="layui-anim layui-icon layui-anim-scaleSpring"
|
</span>
|
||||||
></i
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
v-else
|
|
||||||
class="layui-icon layui-form-radioed"
|
|
||||||
></i
|
|
||||||
>
|
|
||||||
<span><slot>{{label}}</slot></span>
|
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
@ -10,18 +10,22 @@ import { provide, ref, watch } from "vue";
|
|||||||
export interface LayRadioGroupProps {
|
export interface LayRadioGroupProps {
|
||||||
modelValue?: string | boolean;
|
modelValue?: string | boolean;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
disabled?:boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<LayRadioGroupProps>(), {});
|
const props = withDefaults(defineProps<LayRadioGroupProps>(), {
|
||||||
|
disabled:false
|
||||||
|
});
|
||||||
|
|
||||||
const emit = defineEmits(["update:modelValue", "change"]);
|
const emit = defineEmits(["update:modelValue", "change"]);
|
||||||
|
|
||||||
const modelValue = ref(props.modelValue);
|
const modelValue = ref(props.modelValue);
|
||||||
|
const disabled=ref(props.disabled)
|
||||||
provide("radioGroup", {
|
provide("radioGroup", {
|
||||||
name: "LayRadioGroup",
|
name: "LayRadioGroup",
|
||||||
modelValue: modelValue,
|
modelValue: modelValue,
|
||||||
naiveName: props.name,
|
naiveName: props.name,
|
||||||
|
disabled:disabled
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -37,6 +41,11 @@ watch(
|
|||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(val) => (modelValue.value = val)
|
(val) => (modelValue.value = val)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.disabled,
|
||||||
|
(val) => (disabled.value = val)
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -42,7 +42,7 @@ export default {
|
|||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<lay-checkbox name="like" value="1" v-model="checked2" >普通</lay-checkbox>
|
<lay-checkbox name="like" value="1" v-model="checked2">普通</lay-checkbox>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -134,7 +134,7 @@ export default {
|
|||||||
<template>
|
<template>
|
||||||
<lay-checkbox name="like" skin="primary" value="1" :disabled="disabled" v-model="checked6">禁用</lay-checkbox>
|
<lay-checkbox name="like" skin="primary" value="1" :disabled="disabled" v-model="checked6">禁用</lay-checkbox>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<lay-checkbox-group v-model="checkeds" disabled>
|
<lay-checkbox-group v-model="checkeds" :disabled="disabled">
|
||||||
<lay-checkbox name="like" skin="primary" value="1">写作</lay-checkbox>
|
<lay-checkbox name="like" skin="primary" value="1">写作</lay-checkbox>
|
||||||
<lay-checkbox name="like" skin="primary" value="2">画画</lay-checkbox>
|
<lay-checkbox name="like" skin="primary" value="2">画画</lay-checkbox>
|
||||||
<lay-checkbox name="like" skin="primary" value="3">运动</lay-checkbox>
|
<lay-checkbox name="like" skin="primary" value="3">运动</lay-checkbox>
|
||||||
@ -146,11 +146,8 @@ import { ref } from 'vue'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
const disabled = ref(true)
|
const disabled = ref(true)
|
||||||
|
|
||||||
const checked6 = ref(false);
|
const checked6 = ref(false);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
disabled,checked6
|
disabled,checked6
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,7 @@ export default {
|
|||||||
const change4 = function( current ) {
|
const change4 = function( current ) {
|
||||||
console.log("当前值:" + current)
|
console.log("当前值:" + current)
|
||||||
}
|
}
|
||||||
|
const disabled1=ref(false)
|
||||||
return {
|
return {
|
||||||
selected4,
|
selected4,
|
||||||
change4
|
change4
|
||||||
@ -142,6 +143,7 @@ export default {
|
|||||||
| label | 显示值 | -- |
|
| label | 显示值 | -- |
|
||||||
| value | 绑定值 | -- |
|
| value | 绑定值 | -- |
|
||||||
| v-model | 选中值 | -- |
|
| v-model | 选中值 | -- |
|
||||||
|
| disabled | 是否禁用 | `false` |
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@ -164,6 +166,7 @@ export default {
|
|||||||
| 属性 | 描述 | 默认值 |
|
| 属性 | 描述 | 默认值 |
|
||||||
| ------- | ------------- | ------ |
|
| ------- | ------------- | ------ |
|
||||||
| v-model | 选中值 | -- |
|
| v-model | 选中值 | -- |
|
||||||
|
| disabled | 是否整体禁用 | `false` |
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
<li>[新增] formItem 组件 label-width属性,用于控制宽度 by @SmallWai</li>
|
<li>[新增] formItem 组件 label-width属性,用于控制宽度 by @SmallWai</li>
|
||||||
<li>[优化] inputNumber 组件 禁用状态下的样式 by @SmallWai</li>
|
<li>[优化] inputNumber 组件 禁用状态下的样式 by @SmallWai</li>
|
||||||
<li>[优化] botton 组件 禁用状态下的icon hover样式 by @SmallWai</li>
|
<li>[优化] botton 组件 禁用状态下的icon hover样式 by @SmallWai</li>
|
||||||
<li>[新增] CheckboxGroup 组件 disabled属性 by @SmallWai</li>
|
<li>[新增] checkboxGroup 组件 disabled属性 by @SmallWai</li>
|
||||||
|
<li>[新增] radioGroup 组件 disabled属性 by @SmallWai</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user