mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
feat: ✨ 兼容字节系小程序
This commit is contained in:
parent
4b0af7a6ce
commit
0e97a1452d
@ -3,76 +3,76 @@
|
|||||||
<wd-toast></wd-toast>
|
<wd-toast></wd-toast>
|
||||||
<demo-block hor="0" title="基础用法" transparent>
|
<demo-block hor="0" title="基础用法" transparent>
|
||||||
<wd-tabbar bordered @change="handleChange" v-model="tabbar0">
|
<wd-tabbar bordered @change="handleChange" v-model="tabbar0">
|
||||||
<wd-tabbar-item title="首页" icon="home"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="首页" icon="home"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="分类" icon="cart"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="分类" icon="cart"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="我的" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="我的" icon="user"></wd-tabbar-item>
|
||||||
</wd-tabbar>
|
</wd-tabbar>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block hor="0" title="通过名称匹配" transparent>
|
<demo-block hor="0" title="通过名称匹配" transparent>
|
||||||
<wd-tabbar bordered @change="handleChange" v-model="tabbar1">
|
<wd-tabbar bordered @change="handleChange" v-model="tabbar1">
|
||||||
<wd-tabbar-item name="home" title="首页" icon="home"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" name="home" title="首页" icon="home"></wd-tabbar-item>
|
||||||
<wd-tabbar-item name="cart" title="分类" icon="cart"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" name="cart" title="分类" icon="cart"></wd-tabbar-item>
|
||||||
<wd-tabbar-item name="setting" title="设置" icon="setting"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" name="setting" title="设置" icon="setting"></wd-tabbar-item>
|
||||||
<wd-tabbar-item name="user" title="我的" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" name="user" title="我的" icon="user"></wd-tabbar-item>
|
||||||
</wd-tabbar>
|
</wd-tabbar>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block hor="0" title="徽标提示" transparent>
|
<demo-block hor="0" title="徽标提示" transparent>
|
||||||
<wd-tabbar v-model="tabbar2" @change="handleChange">
|
<wd-tabbar v-model="tabbar2" @change="handleChange">
|
||||||
<wd-tabbar-item is-dot :value="2" title="点状" icon="home"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" is-dot :value="2" title="点状" icon="home"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="2" icon="cart" title="分类"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="2" icon="cart" title="分类"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="30" title="我的" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="30" title="我的" icon="user"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="200" title="最大值" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="200" title="最大值" icon="user"></wd-tabbar-item>
|
||||||
</wd-tabbar>
|
</wd-tabbar>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
<demo-block hor="0" title="悬浮标签栏" transparent>
|
<demo-block hor="0" title="悬浮标签栏" transparent>
|
||||||
<wd-tabbar shape="round" v-model="tabbar3" @change="handleChange">
|
<wd-tabbar shape="round" v-model="tabbar3" @change="handleChange">
|
||||||
<wd-tabbar-item title="首页" is-dot :value="2" icon="home"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="首页" is-dot :value="2" icon="home"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="分类" :value="2" icon="cart"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="分类" :value="2" icon="cart"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="相册" :value="30" icon="photo"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="相册" :value="30" icon="photo"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="我的" :value="200" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="我的" :value="200" icon="user"></wd-tabbar-item>
|
||||||
</wd-tabbar>
|
</wd-tabbar>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block hor="0" title="自定义图标" transparent>
|
<demo-block hor="0" title="自定义图标" transparent>
|
||||||
<wd-tabbar v-model="tabbar4" @change="handleChange">
|
<wd-tabbar v-model="tabbar4" @change="handleChange">
|
||||||
<wd-tabbar-item :value="2" title="首页" icon="home"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="2" title="首页" icon="home"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="2" icon="cart" title="分类">
|
<wd-tabbar-item style="flex: 1" :value="2" icon="cart" title="分类">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<wd-img round height="40rpx" width="40rpx" src="https://img.yzcdn.cn/vant/cat.jpeg"></wd-img>
|
<wd-img round height="40rpx" width="40rpx" src="https://img.yzcdn.cn/vant/cat.jpeg"></wd-img>
|
||||||
</template>
|
</template>
|
||||||
</wd-tabbar-item>
|
</wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="3" title="我的" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="3" title="我的" icon="user"></wd-tabbar-item>
|
||||||
</wd-tabbar>
|
</wd-tabbar>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block hor="0" title="自定义颜色" transparent>
|
<demo-block hor="0" title="自定义颜色" transparent>
|
||||||
<wd-tabbar v-model="tabbar5" @change="handleChange" active-color="#ee0a24" inactive-color="#7d7e80">
|
<wd-tabbar v-model="tabbar5" @change="handleChange" active-color="#ee0a24" inactive-color="#7d7e80">
|
||||||
<wd-tabbar-item is-dot :value="2" title="点状" icon="home"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" is-dot :value="2" title="点状" icon="home"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="2" icon="cart" title="分类"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="2" icon="cart" title="分类"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="30" title="我的" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="30" title="我的" icon="user"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="200" title="最大值" icon="photo"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="200" title="最大值" icon="photo"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="10" title="客服" icon="chat"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="10" title="客服" icon="chat"></wd-tabbar-item>
|
||||||
</wd-tabbar>
|
</wd-tabbar>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
<demo-block hor="0" title="监听切换事件" transparent>
|
<demo-block hor="0" title="监听切换事件" transparent>
|
||||||
<wd-tabbar v-model="tabbar6" @change="handleChange1" active-color="#ee0a24" inactive-color="#7d7e80">
|
<wd-tabbar v-model="tabbar6" @change="handleChange1" active-color="#ee0a24" inactive-color="#7d7e80">
|
||||||
<wd-tabbar-item title="首页" icon="home"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="首页" icon="home"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="分类" icon="cart"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="分类" icon="cart"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="我的" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="我的" icon="user"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="相册" icon="photo"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="相册" icon="photo"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="客服" icon="chat"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="客服" icon="chat"></wd-tabbar-item>
|
||||||
</wd-tabbar>
|
</wd-tabbar>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block hor="0" title="固定底部" transparent>
|
<demo-block hor="0" title="固定底部" transparent>
|
||||||
<wd-tabbar fixed v-model="tabbar7" @change="handleChange" bordered safeAreaInsetBottom placeholder>
|
<wd-tabbar fixed v-model="tabbar7" @change="handleChange" bordered safeAreaInsetBottom placeholder>
|
||||||
<wd-tabbar-item :value="2" is-dot title="首页" icon="home"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="2" is-dot title="首页" icon="home"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="分类" icon="cart"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="分类" icon="cart"></wd-tabbar-item>
|
||||||
<wd-tabbar-item title="我的" icon="user"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" title="我的" icon="user"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="200" title="相册" icon="photo"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="200" title="相册" icon="photo"></wd-tabbar-item>
|
||||||
<wd-tabbar-item :value="10" title="客服" icon="chat"></wd-tabbar-item>
|
<wd-tabbar-item style="flex: 1" :value="10" title="客服" icon="chat"></wd-tabbar-item>
|
||||||
</wd-tabbar>
|
</wd-tabbar>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
</page-wraper>
|
</page-wraper>
|
||||||
@ -101,4 +101,8 @@ function handleChange1({ value }: { value: string }) {
|
|||||||
:deep(.page-wraper) {
|
:deep(.page-wraper) {
|
||||||
background: #f6f6f6;
|
background: #f6f6f6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(wd-tabbar-item) {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export function useCell() {
|
|||||||
const { parent: cellGroup, index } = useParent(CELL_GROUP_KEY)
|
const { parent: cellGroup, index } = useParent(CELL_GROUP_KEY)
|
||||||
|
|
||||||
const border = computed(() => {
|
const border = computed(() => {
|
||||||
return cellGroup && cellGroup.props.border && index.value
|
return cellGroup.value && cellGroup.value.props.border && index.value
|
||||||
})
|
})
|
||||||
|
|
||||||
return { border }
|
return { border }
|
||||||
|
|||||||
@ -6,7 +6,8 @@ import {
|
|||||||
type InjectionKey,
|
type InjectionKey,
|
||||||
type VNodeNormalizedChildren,
|
type VNodeNormalizedChildren,
|
||||||
type ComponentPublicInstance,
|
type ComponentPublicInstance,
|
||||||
type ComponentInternalInstance
|
type ComponentInternalInstance,
|
||||||
|
onMounted
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
|
|
||||||
// 小程序端不支持从vue导出的isVNode方法,参考uni-mp-vue的实现
|
// 小程序端不支持从vue导出的isVNode方法,参考uni-mp-vue的实现
|
||||||
@ -92,18 +93,24 @@ export function useChildren<
|
|||||||
internalChildren.splice(index, 1)
|
internalChildren.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
provide(
|
// #ifdef MP-TOUTIAO
|
||||||
key,
|
onMounted(() => {
|
||||||
Object.assign(
|
// #endif
|
||||||
{
|
provide(
|
||||||
link,
|
key,
|
||||||
unlink,
|
Object.assign(
|
||||||
children: publicChildren,
|
{
|
||||||
internalChildren
|
link,
|
||||||
},
|
unlink,
|
||||||
value
|
children: publicChildren,
|
||||||
|
internalChildren
|
||||||
|
},
|
||||||
|
value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
// #ifdef MP-TOUTIAO
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -6,7 +6,10 @@ import {
|
|||||||
type InjectionKey,
|
type InjectionKey,
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
type ComponentPublicInstance,
|
type ComponentPublicInstance,
|
||||||
type ComponentInternalInstance
|
type ComponentInternalInstance,
|
||||||
|
onMounted,
|
||||||
|
type Ref,
|
||||||
|
reactive
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
|
|
||||||
type ParentProvide<T> = T & {
|
type ParentProvide<T> = T & {
|
||||||
@ -16,26 +19,33 @@ type ParentProvide<T> = T & {
|
|||||||
internalChildren: ComponentInternalInstance[]
|
internalChildren: ComponentInternalInstance[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useParent<T>(key: InjectionKey<ParentProvide<T>>) {
|
type UseParentResult<T> = {
|
||||||
const parent = inject(key, null)
|
parent: Ref<ParentProvide<T> | null>
|
||||||
|
index: Ref<number>
|
||||||
if (parent) {
|
}
|
||||||
const instance = getCurrentInstance()!
|
|
||||||
const { link, unlink, internalChildren } = parent
|
export function useParent<T>(key: InjectionKey<ParentProvide<T>>): UseParentResult<T> {
|
||||||
|
const result: UseParentResult<T> = {
|
||||||
link(instance)
|
parent: ref(null),
|
||||||
onUnmounted(() => unlink(instance))
|
index: ref<number>(-1)
|
||||||
|
}
|
||||||
const index = computed(() => internalChildren.indexOf(instance))
|
// #ifdef MP-TOUTIAO
|
||||||
|
onMounted(() => {
|
||||||
return {
|
// #endif
|
||||||
parent,
|
result.parent.value = inject(key, null)
|
||||||
index
|
|
||||||
}
|
if (result.parent.value) {
|
||||||
}
|
const instance = getCurrentInstance()!
|
||||||
|
const { link, unlink, internalChildren } = result.parent.value
|
||||||
return {
|
|
||||||
parent: null,
|
link(instance)
|
||||||
index: ref(-1)
|
onUnmounted(() => unlink(instance))
|
||||||
}
|
|
||||||
|
result.index.value = computed(() => internalChildren.indexOf(instance)).value
|
||||||
|
}
|
||||||
|
// #ifdef MP-TOUTIAO
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@ -343,8 +343,8 @@ const { parent: form } = useParent(FORM_KEY)
|
|||||||
|
|
||||||
// 表单校验错误信息
|
// 表单校验错误信息
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -353,8 +353,8 @@ const errorMessage = computed(() => {
|
|||||||
// 是否展示必填
|
// 是否展示必填
|
||||||
const isRequired = computed(() => {
|
const isRequired = computed(() => {
|
||||||
let formRequired = false
|
let formRequired = false
|
||||||
if (form && form.props.rules) {
|
if (form.value && form.value.props.rules) {
|
||||||
const rules = form.props.rules
|
const rules = form.value.props.rules
|
||||||
for (const key in rules) {
|
for (const key in rules) {
|
||||||
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
||||||
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
||||||
|
|||||||
@ -110,8 +110,8 @@ const isBorder = computed(() => {
|
|||||||
const { parent: form } = useParent(FORM_KEY)
|
const { parent: form } = useParent(FORM_KEY)
|
||||||
|
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -120,8 +120,8 @@ const errorMessage = computed(() => {
|
|||||||
// 是否展示必填
|
// 是否展示必填
|
||||||
const isRequired = computed(() => {
|
const isRequired = computed(() => {
|
||||||
let formRequired = false
|
let formRequired = false
|
||||||
if (form && form.props.rules) {
|
if (form.value && form.value.props.rules) {
|
||||||
const rules = form.props.rules
|
const rules = form.value.props.rules
|
||||||
for (const key in rules) {
|
for (const key in rules) {
|
||||||
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
||||||
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
||||||
|
|||||||
@ -75,8 +75,8 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
const { parent: checkboxGroup, index } = useParent(CHECKBOX_GROUP_KEY)
|
const { parent: checkboxGroup, index } = useParent(CHECKBOX_GROUP_KEY)
|
||||||
|
|
||||||
const isChecked = computed(() => {
|
const isChecked = computed(() => {
|
||||||
if (checkboxGroup) {
|
if (checkboxGroup.value) {
|
||||||
return checkboxGroup.props.modelValue.indexOf(props.modelValue) > -1
|
return checkboxGroup.value.props.modelValue.indexOf(props.modelValue) > -1
|
||||||
} else {
|
} else {
|
||||||
return props.modelValue === props.trueValue
|
return props.modelValue === props.trueValue
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ const isFirst = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const isLast = computed(() => {
|
const isLast = computed(() => {
|
||||||
const children = isDef(checkboxGroup) ? checkboxGroup.children : []
|
const children = isDef(checkboxGroup.value) ? checkboxGroup.value.children : []
|
||||||
return index.value === children.length - 1
|
return index.value === children.length - 1
|
||||||
})
|
})
|
||||||
const { proxy } = getCurrentInstance() as any
|
const { proxy } = getCurrentInstance() as any
|
||||||
@ -96,7 +96,7 @@ watch(
|
|||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
() => {
|
() => {
|
||||||
// 组合使用走这个逻辑
|
// 组合使用走这个逻辑
|
||||||
if (checkboxGroup) {
|
if (checkboxGroup.value) {
|
||||||
checkName()
|
checkName()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,16 +111,16 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const innerShape = computed(() => {
|
const innerShape = computed(() => {
|
||||||
if (!props.shape && checkboxGroup && checkboxGroup.props.shape) {
|
if (!props.shape && checkboxGroup.value && checkboxGroup.value.props.shape) {
|
||||||
return checkboxGroup.props.shape
|
return checkboxGroup.value.props.shape
|
||||||
} else {
|
} else {
|
||||||
return props.shape
|
return props.shape
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerCheckedColor = computed(() => {
|
const innerCheckedColor = computed(() => {
|
||||||
if (!props.checkedColor && checkboxGroup && checkboxGroup.props.checkedColor) {
|
if (!props.checkedColor && checkboxGroup.value && checkboxGroup.value.props.checkedColor) {
|
||||||
return checkboxGroup.props.checkedColor
|
return checkboxGroup.value.props.checkedColor
|
||||||
} else {
|
} else {
|
||||||
return props.checkedColor
|
return props.checkedColor
|
||||||
}
|
}
|
||||||
@ -128,16 +128,16 @@ const innerCheckedColor = computed(() => {
|
|||||||
|
|
||||||
const innerDisabled = computed(() => {
|
const innerDisabled = computed(() => {
|
||||||
let innerDisabled = props.disabled
|
let innerDisabled = props.disabled
|
||||||
if (checkboxGroup) {
|
if (checkboxGroup.value) {
|
||||||
if (
|
if (
|
||||||
// max 生效时,group 已经选满,禁止其它节点再选中。
|
// max 生效时,group 已经选满,禁止其它节点再选中。
|
||||||
(checkboxGroup.props.max && checkboxGroup.props.modelValue.length >= checkboxGroup.props.max && !isChecked.value) ||
|
(checkboxGroup.value.props.max && checkboxGroup.value.props.modelValue.length >= checkboxGroup.value.props.max && !isChecked.value) ||
|
||||||
// min 生效时,group 选中的节点数量仅满足最小值,禁止取消已选中的节点。
|
// min 生效时,group 选中的节点数量仅满足最小值,禁止取消已选中的节点。
|
||||||
(checkboxGroup.props.min && checkboxGroup.props.modelValue.length <= checkboxGroup.props.min && isChecked.value) ||
|
(checkboxGroup.value.props.min && checkboxGroup.value.props.modelValue.length <= checkboxGroup.value.props.min && isChecked.value) ||
|
||||||
// 只要子节点自己要求 disabled,那就 disabled。
|
// 只要子节点自己要求 disabled,那就 disabled。
|
||||||
props.disabled === true ||
|
props.disabled === true ||
|
||||||
// 父节点要求全局 disabled,子节点没吱声,那就 disabled。
|
// 父节点要求全局 disabled,子节点没吱声,那就 disabled。
|
||||||
(checkboxGroup.props.disabled && props.disabled === null)
|
(checkboxGroup.value.props.disabled && props.disabled === null)
|
||||||
) {
|
) {
|
||||||
innerDisabled = true
|
innerDisabled = true
|
||||||
}
|
}
|
||||||
@ -146,24 +146,24 @@ const innerDisabled = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const innerInline = computed(() => {
|
const innerInline = computed(() => {
|
||||||
if (checkboxGroup && checkboxGroup.props.inline) {
|
if (checkboxGroup.value && checkboxGroup.value.props.inline) {
|
||||||
return checkboxGroup.props.inline
|
return checkboxGroup.value.props.inline
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerCell = computed(() => {
|
const innerCell = computed(() => {
|
||||||
if (checkboxGroup && checkboxGroup.props.cell) {
|
if (checkboxGroup.value && checkboxGroup.value.props.cell) {
|
||||||
return checkboxGroup.props.cell
|
return checkboxGroup.value.props.cell
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerSize = computed(() => {
|
const innerSize = computed(() => {
|
||||||
if (!props.size && checkboxGroup && checkboxGroup.props.size) {
|
if (!props.size && checkboxGroup.value && checkboxGroup.value.props.size) {
|
||||||
return checkboxGroup.props.size
|
return checkboxGroup.value.props.size
|
||||||
} else {
|
} else {
|
||||||
return props.size
|
return props.size
|
||||||
}
|
}
|
||||||
@ -182,9 +182,9 @@ const emit = defineEmits(['change', 'update:modelValue'])
|
|||||||
* @param myName 自己的标识符
|
* @param myName 自己的标识符
|
||||||
*/
|
*/
|
||||||
function checkName() {
|
function checkName() {
|
||||||
checkboxGroup &&
|
checkboxGroup.value &&
|
||||||
checkboxGroup.children &&
|
checkboxGroup.value.children &&
|
||||||
checkboxGroup.children.forEach((child: any) => {
|
checkboxGroup.value.children.forEach((child: any) => {
|
||||||
if (child.$.uid !== proxy.$.uid && child.modelValue === props.modelValue) {
|
if (child.$.uid !== proxy.$.uid && child.modelValue === props.modelValue) {
|
||||||
console.error(`The checkbox's bound value: ${props.modelValue} has been used`)
|
console.error(`The checkbox's bound value: ${props.modelValue} has been used`)
|
||||||
}
|
}
|
||||||
@ -196,11 +196,11 @@ function checkName() {
|
|||||||
function toggle() {
|
function toggle() {
|
||||||
if (innerDisabled.value) return
|
if (innerDisabled.value) return
|
||||||
// 复选框单独使用时点击反选,并且在checkbox上触发change事件
|
// 复选框单独使用时点击反选,并且在checkbox上触发change事件
|
||||||
if (checkboxGroup) {
|
if (checkboxGroup.value) {
|
||||||
emit('change', {
|
emit('change', {
|
||||||
value: !isChecked.value
|
value: !isChecked.value
|
||||||
})
|
})
|
||||||
checkboxGroup.changeSelectState(props.modelValue)
|
checkboxGroup.value.changeSelectState(props.modelValue)
|
||||||
} else {
|
} else {
|
||||||
const newVal = props.modelValue === props.trueValue ? props.falseValue : props.trueValue
|
const newVal = props.modelValue === props.trueValue ? props.falseValue : props.trueValue
|
||||||
emit('update:modelValue', newVal)
|
emit('update:modelValue', newVal)
|
||||||
|
|||||||
@ -283,8 +283,8 @@ const { parent: form } = useParent(FORM_KEY)
|
|||||||
|
|
||||||
// 表单校验错误信息
|
// 表单校验错误信息
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -293,8 +293,8 @@ const errorMessage = computed(() => {
|
|||||||
// 是否展示必填
|
// 是否展示必填
|
||||||
const isRequired = computed(() => {
|
const isRequired = computed(() => {
|
||||||
let formRequired = false
|
let formRequired = false
|
||||||
if (form && form.props.rules) {
|
if (form.value && form.value.props.rules) {
|
||||||
const rules = form.props.rules
|
const rules = form.value.props.rules
|
||||||
for (const key in rules) {
|
for (const key in rules) {
|
||||||
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
||||||
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<!--
|
<!--
|
||||||
* @Author: weisheng
|
* @Author: weisheng
|
||||||
* @Date: 2023-06-13 11:34:35
|
* @Date: 2023-06-13 11:34:35
|
||||||
* @LastEditTime: 2024-01-03 21:59:39
|
* @LastEditTime: 2024-01-21 20:56:59
|
||||||
* @LastEditors: weisheng
|
* @LastEditors: weisheng
|
||||||
* @Description:
|
* @Description:
|
||||||
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-col/wd-col.vue
|
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-col/wd-col.vue
|
||||||
@ -46,8 +46,8 @@ const style = ref<string>('')
|
|||||||
const { parent: row } = useParent(ROW_KEY)
|
const { parent: row } = useParent(ROW_KEY)
|
||||||
|
|
||||||
const gutter = computed(() => {
|
const gutter = computed(() => {
|
||||||
if (row) {
|
if (row.value) {
|
||||||
return row.props.gutter || 0
|
return row.value.props.gutter || 0
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,8 +74,8 @@ const contentStyle = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const selected = computed(() => {
|
const selected = computed(() => {
|
||||||
if (collapse) {
|
if (collapse.value) {
|
||||||
return collapse.props.modelValue
|
return collapse.value.props.modelValue
|
||||||
} else {
|
} else {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@ -142,16 +142,16 @@ function handleClick() {
|
|||||||
}
|
}
|
||||||
if (isPromise(response)) {
|
if (isPromise(response)) {
|
||||||
response.then(() => {
|
response.then(() => {
|
||||||
collapse && collapse.toggle(name, !expanded.value)
|
collapse.value && collapse.value.toggle(name, !expanded.value)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
collapse && collapse.toggle(name, !expanded.value)
|
collapse.value && collapse.value.toggle(name, !expanded.value)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
collapse && collapse.toggle(name, !expanded.value)
|
collapse.value && collapse.value.toggle(name, !expanded.value)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
collapse && collapse.toggle(name, !expanded.value)
|
collapse.value && collapse.value.toggle(name, !expanded.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -397,8 +397,8 @@ const { parent: form } = useParent(FORM_KEY)
|
|||||||
|
|
||||||
// 表单校验错误信息
|
// 表单校验错误信息
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -407,8 +407,8 @@ const errorMessage = computed(() => {
|
|||||||
// 是否展示必填
|
// 是否展示必填
|
||||||
const isRequired = computed(() => {
|
const isRequired = computed(() => {
|
||||||
let formRequired = false
|
let formRequired = false
|
||||||
if (form && form.props.rules) {
|
if (form.value && form.value.props.rules) {
|
||||||
const rules = form.props.rules
|
const rules = form.value.props.rules
|
||||||
for (const key in rules) {
|
for (const key in rules) {
|
||||||
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
||||||
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
||||||
|
|||||||
@ -155,16 +155,16 @@ function choose(index: number) {
|
|||||||
// 外部关闭弹出框
|
// 外部关闭弹出框
|
||||||
function close() {
|
function close() {
|
||||||
showPop.value = false
|
showPop.value = false
|
||||||
dropMenu && dropMenu.fold()
|
dropMenu.value && dropMenu.value.fold()
|
||||||
}
|
}
|
||||||
|
|
||||||
const positionStyle = computed(() => {
|
const positionStyle = computed(() => {
|
||||||
let style: string = ''
|
let style: string = ''
|
||||||
if (showPop.value && dropMenu) {
|
if (showPop.value && dropMenu.value) {
|
||||||
style =
|
style =
|
||||||
dropMenu.props.direction === 'down'
|
dropMenu.value.props.direction === 'down'
|
||||||
? `top: calc(var(--window-top) + ${dropMenu.offset.value}px); bottom: 0;`
|
? `top: calc(var(--window-top) + ${dropMenu.value.offset.value}px); bottom: 0;`
|
||||||
: `top: 0; bottom: calc(var(--window-bottom) + ${dropMenu.offset.value}px)`
|
: `top: 0; bottom: calc(var(--window-bottom) + ${dropMenu.value.offset.value}px)`
|
||||||
} else {
|
} else {
|
||||||
style = ''
|
style = ''
|
||||||
}
|
}
|
||||||
@ -174,11 +174,11 @@ const positionStyle = computed(() => {
|
|||||||
function open() {
|
function open() {
|
||||||
showWrapper.value = true
|
showWrapper.value = true
|
||||||
showPop.value = true
|
showPop.value = true
|
||||||
if (dropMenu) {
|
if (dropMenu.value) {
|
||||||
modal.value = Boolean(dropMenu.props.modal)
|
modal.value = Boolean(dropMenu.value.props.modal)
|
||||||
duration.value = Number(dropMenu.props.duration)
|
duration.value = Number(dropMenu.value.props.duration)
|
||||||
closeOnClickModal.value = Boolean(dropMenu.props.closeOnClickModal)
|
closeOnClickModal.value = Boolean(dropMenu.value.props.closeOnClickModal)
|
||||||
position.value = dropMenu.props.direction === 'down' ? 'top' : 'bottom'
|
position.value = dropMenu.value.props.direction === 'down' ? 'top' : 'bottom'
|
||||||
}
|
}
|
||||||
|
|
||||||
emit('open')
|
emit('open')
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<!--
|
<!--
|
||||||
* @Author: weisheng
|
* @Author: weisheng
|
||||||
* @Date: 2023-12-14 11:21:58
|
* @Date: 2023-12-14 11:21:58
|
||||||
* @LastEditTime: 2024-01-03 21:50:52
|
* @LastEditTime: 2024-01-21 20:59:59
|
||||||
* @LastEditors: weisheng
|
* @LastEditors: weisheng
|
||||||
* @Description:
|
* @Description:
|
||||||
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-form-item/wd-form-item.vue
|
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-form-item/wd-form-item.vue
|
||||||
@ -61,15 +61,15 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
const { parent: form, index } = useParent(FORM_KEY)
|
const { parent: form, index } = useParent(FORM_KEY)
|
||||||
|
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const border = computed(() => {
|
const border = computed(() => {
|
||||||
if (index.value > 0 && form && form.props.border) {
|
if (index.value > 0 && form.value && form.value.props.border) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -90,8 +90,8 @@ const border = ref<boolean>(true)
|
|||||||
const { parent: grid } = useParent(GRID_KEY)
|
const { parent: grid } = useParent(GRID_KEY)
|
||||||
|
|
||||||
const childCount = computed(() => {
|
const childCount = computed(() => {
|
||||||
if (isDef(grid) && isDef(grid.children)) {
|
if (isDef(grid.value) && isDef(grid.value.children)) {
|
||||||
return grid.children.length
|
return grid.value.children.length
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -102,12 +102,14 @@ const emit = defineEmits(['itemclick'])
|
|||||||
watch(
|
watch(
|
||||||
() => childCount.value,
|
() => childCount.value,
|
||||||
() => {
|
() => {
|
||||||
if (!grid) return
|
if (!grid.value) return
|
||||||
const width = grid.props.column ? 100 / grid.props.column + '%' : 100 / (childCount.value || 1) + '%'
|
const width = grid.value.props.column ? 100 / grid.value.props.column + '%' : 100 / (childCount.value || 1) + '%'
|
||||||
// 单独定义间隔
|
// 单独定义间隔
|
||||||
const gutterStyle = grid.props.gutter ? `padding:${grid.props.gutter}px ${grid.props.gutter}px 0 0; background-color: transparent;` : ''
|
const gutterStyle = grid.value.props.gutter
|
||||||
|
? `padding:${grid.value.props.gutter}px ${grid.value.props.gutter}px 0 0; background-color: transparent;`
|
||||||
|
: ''
|
||||||
// 单独定义正方形
|
// 单独定义正方形
|
||||||
const squareStyle = grid.props.square ? `background-color:transparent; padding-bottom: 0; padding-top:${width}` : ''
|
const squareStyle = grid.value.props.square ? `background-color:transparent; padding-bottom: 0; padding-top:${width}` : ''
|
||||||
style.value = `width: ${width}; ${squareStyle || gutterStyle}`
|
style.value = `width: ${width}; ${squareStyle || gutterStyle}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -121,27 +123,29 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if (!grid) return
|
if (!grid.value) return
|
||||||
const children = grid.children
|
const children = grid.value.children
|
||||||
const width = grid.props.column ? 100 / grid.props.column + '%' : 100 / children.length + '%'
|
const width = grid.value.props.column ? 100 / grid.value.props.column + '%' : 100 / children.length + '%'
|
||||||
// 单独定义间隔
|
// 单独定义间隔
|
||||||
const gutterStyle = grid.props.gutter ? `padding:${grid.props.gutter}px ${grid.props.gutter}px 0 0; background-color: transparent;` : ''
|
const gutterStyle = grid.value.props.gutter
|
||||||
|
? `padding:${grid.value.props.gutter}px ${grid.value.props.gutter}px 0 0; background-color: transparent;`
|
||||||
|
: ''
|
||||||
// 单独定义正方形
|
// 单独定义正方形
|
||||||
const squareStyle = grid.props.square ? `background-color:transparent; padding-bottom: 0; padding-top:${width}` : ''
|
const squareStyle = grid.value.props.square ? `background-color:transparent; padding-bottom: 0; padding-top:${width}` : ''
|
||||||
// 间隔+正方形
|
// 间隔+正方形
|
||||||
gutterContentStyle.value =
|
gutterContentStyle.value =
|
||||||
grid.props.gutter && grid.props.square
|
grid.value.props.gutter && grid.value.props.square
|
||||||
? `right: ${grid.props.gutter}px; bottom:${grid.props.gutter}px;height: auto; background-color: ${grid.props.bgColor}`
|
? `right: ${grid.value.props.gutter}px; bottom:${grid.value.props.gutter}px;height: auto; background-color: ${grid.value.props.bgColor}`
|
||||||
: `background-color: ${grid.props.bgColor}`
|
: `background-color: ${grid.value.props.bgColor}`
|
||||||
|
|
||||||
border.value = Boolean(grid.props.border)
|
border.value = Boolean(grid.value.props.border)
|
||||||
square.value = Boolean(grid.props.square)
|
square.value = Boolean(grid.value.props.square)
|
||||||
gutter.value = Number(grid.props.gutter)
|
gutter.value = Number(grid.value.props.gutter)
|
||||||
style.value = `width: ${width}; ${squareStyle || gutterStyle}`
|
style.value = `width: ${width}; ${squareStyle || gutterStyle}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function click() {
|
function click() {
|
||||||
if (grid && !grid.props.clickable) return
|
if (grid.value && !grid.value.props.clickable) return
|
||||||
const { url, linkType } = props
|
const { url, linkType } = props
|
||||||
emit('itemclick')
|
emit('itemclick')
|
||||||
if (url) {
|
if (url) {
|
||||||
|
|||||||
@ -206,8 +206,8 @@ watch(
|
|||||||
const { parent: form } = useParent(FORM_KEY)
|
const { parent: form } = useParent(FORM_KEY)
|
||||||
|
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -216,8 +216,8 @@ const errorMessage = computed(() => {
|
|||||||
// 是否展示必填
|
// 是否展示必填
|
||||||
const isRequired = computed(() => {
|
const isRequired = computed(() => {
|
||||||
let formRequired = false
|
let formRequired = false
|
||||||
if (form && form.props.rules) {
|
if (form.value && form.value.props.rules) {
|
||||||
const rules = form.props.rules
|
const rules = form.value.props.rules
|
||||||
for (const key in rules) {
|
for (const key in rules) {
|
||||||
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
||||||
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
||||||
|
|||||||
@ -288,8 +288,8 @@ const { parent: form } = useParent(FORM_KEY)
|
|||||||
|
|
||||||
// 表单校验错误信息
|
// 表单校验错误信息
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -298,8 +298,8 @@ const errorMessage = computed(() => {
|
|||||||
// 是否展示必填
|
// 是否展示必填
|
||||||
const isRequired = computed(() => {
|
const isRequired = computed(() => {
|
||||||
let formRequired = false
|
let formRequired = false
|
||||||
if (form && form.props.rules) {
|
if (form.value && form.value.props.rules) {
|
||||||
const rules = form.props.rules
|
const rules = form.value.props.rules
|
||||||
for (const key in rules) {
|
for (const key in rules) {
|
||||||
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
||||||
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
||||||
|
|||||||
@ -58,56 +58,56 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
const { parent: radioGroup } = useParent(RADIO_GROUP_KEY)
|
const { parent: radioGroup } = useParent(RADIO_GROUP_KEY)
|
||||||
|
|
||||||
const isChecked = computed(() => {
|
const isChecked = computed(() => {
|
||||||
if (radioGroup) {
|
if (radioGroup.value) {
|
||||||
return props.value === radioGroup.props.modelValue
|
return props.value === radioGroup.value.props.modelValue
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerShape = computed(() => {
|
const innerShape = computed(() => {
|
||||||
if (!props.shape && radioGroup && radioGroup.props.shape) {
|
if (!props.shape && radioGroup.value && radioGroup.value.props.shape) {
|
||||||
return radioGroup.props.shape
|
return radioGroup.value.props.shape
|
||||||
} else {
|
} else {
|
||||||
return props.shape
|
return props.shape
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerCheckedColor = computed(() => {
|
const innerCheckedColor = computed(() => {
|
||||||
if (!props.checkedColor && radioGroup && radioGroup.props.checkedColor) {
|
if (!props.checkedColor && radioGroup.value && radioGroup.value.props.checkedColor) {
|
||||||
return radioGroup.props.checkedColor
|
return radioGroup.value.props.checkedColor
|
||||||
} else {
|
} else {
|
||||||
return props.checkedColor
|
return props.checkedColor
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerDisabled = computed(() => {
|
const innerDisabled = computed(() => {
|
||||||
if ((props.disabled === null || props.disabled === undefined) && radioGroup && radioGroup.props.disabled) {
|
if ((props.disabled === null || props.disabled === undefined) && radioGroup.value && radioGroup.value.props.disabled) {
|
||||||
return radioGroup.props.disabled
|
return radioGroup.value.props.disabled
|
||||||
} else {
|
} else {
|
||||||
return props.disabled
|
return props.disabled
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerInline = computed(() => {
|
const innerInline = computed(() => {
|
||||||
if ((props.inline === null || props.inline === undefined) && radioGroup && radioGroup.props.inline) {
|
if ((props.inline === null || props.inline === undefined) && radioGroup.value && radioGroup.value.props.inline) {
|
||||||
return radioGroup.props.inline
|
return radioGroup.value.props.inline
|
||||||
} else {
|
} else {
|
||||||
return props.inline
|
return props.inline
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerSize = computed(() => {
|
const innerSize = computed(() => {
|
||||||
if (!props.size && radioGroup && radioGroup.props.size) {
|
if (!props.size && radioGroup.value && radioGroup.value.props.size) {
|
||||||
return radioGroup.props.size
|
return radioGroup.value.props.size
|
||||||
} else {
|
} else {
|
||||||
return props.size
|
return props.size
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const innerCell = computed(() => {
|
const innerCell = computed(() => {
|
||||||
if ((props.cell === null || props.cell === undefined) && radioGroup && radioGroup.props.cell) {
|
if ((props.cell === null || props.cell === undefined) && radioGroup.value && radioGroup.value.props.cell) {
|
||||||
return radioGroup.props.cell
|
return radioGroup.value.props.cell
|
||||||
} else {
|
} else {
|
||||||
return props.cell
|
return props.cell
|
||||||
}
|
}
|
||||||
@ -126,8 +126,8 @@ watch(
|
|||||||
*/
|
*/
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
const { value } = props
|
const { value } = props
|
||||||
if (!innerDisabled.value && radioGroup && value !== null && value !== undefined) {
|
if (!innerDisabled.value && radioGroup.value && value !== null && value !== undefined) {
|
||||||
radioGroup.updateValue(value)
|
radioGroup.value.updateValue(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -264,8 +264,8 @@ const { parent: form } = useParent(FORM_KEY)
|
|||||||
|
|
||||||
// 表单校验错误信息
|
// 表单校验错误信息
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -274,8 +274,8 @@ const errorMessage = computed(() => {
|
|||||||
// 是否展示必填
|
// 是否展示必填
|
||||||
const isRequired = computed(() => {
|
const isRequired = computed(() => {
|
||||||
let formRequired = false
|
let formRequired = false
|
||||||
if (form && form.props.rules) {
|
if (form.value && form.value.props.rules) {
|
||||||
const rules = form.props.rules
|
const rules = form.value.props.rules
|
||||||
for (const key in rules) {
|
for (const key in rules) {
|
||||||
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
||||||
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
||||||
|
|||||||
@ -79,7 +79,7 @@ const { parent: sidebar } = useParent(SIDEBAR_KEY)
|
|||||||
|
|
||||||
const active = computed(() => {
|
const active = computed(() => {
|
||||||
let active: boolean = false
|
let active: boolean = false
|
||||||
if (sidebar && sidebar.props.modelValue === props.value) {
|
if (sidebar.value && sidebar.value.props.modelValue === props.value) {
|
||||||
active = true
|
active = true
|
||||||
}
|
}
|
||||||
return active
|
return active
|
||||||
@ -87,12 +87,12 @@ const active = computed(() => {
|
|||||||
|
|
||||||
const prefix = computed(() => {
|
const prefix = computed(() => {
|
||||||
let prefix: boolean = false
|
let prefix: boolean = false
|
||||||
if (sidebar) {
|
if (sidebar.value) {
|
||||||
let activeIndex: number = sidebar.children.findIndex((c: any) => {
|
let activeIndex: number = sidebar.value.children.findIndex((c: any) => {
|
||||||
return c.value === sidebar.props.modelValue
|
return c.value === sidebar.value!.props.modelValue
|
||||||
})
|
})
|
||||||
|
|
||||||
let currentIndex: number = sidebar.children.findIndex((c: any) => {
|
let currentIndex: number = sidebar.value.children.findIndex((c: any) => {
|
||||||
return c.value === props.value
|
return c.value === props.value
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -105,12 +105,12 @@ const prefix = computed(() => {
|
|||||||
|
|
||||||
const suffix = computed(() => {
|
const suffix = computed(() => {
|
||||||
let suffix: boolean = false
|
let suffix: boolean = false
|
||||||
if (sidebar) {
|
if (sidebar.value) {
|
||||||
let activeIndex: number = sidebar.children.findIndex((c: any) => {
|
let activeIndex: number = sidebar.value.children.findIndex((c: any) => {
|
||||||
return c.value === sidebar.props.modelValue
|
return c.value === sidebar.value!.props.modelValue
|
||||||
})
|
})
|
||||||
|
|
||||||
let currentIndex: number = sidebar.children.findIndex((c: any) => {
|
let currentIndex: number = sidebar.value.children.findIndex((c: any) => {
|
||||||
return c.value === props.value
|
return c.value === props.value
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ function handleClick() {
|
|||||||
if (props.disabled) {
|
if (props.disabled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sidebar && sidebar.setChange(props.value, props.label)
|
sidebar.value && sidebar.value.setChange(props.value, props.label)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -83,8 +83,8 @@ const styles = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const canAlignCenter = computed(() => {
|
const canAlignCenter = computed(() => {
|
||||||
if (isDef(steps)) {
|
if (isDef(steps.value)) {
|
||||||
const { vertical, alignCenter } = steps.props
|
const { vertical, alignCenter } = steps.value.props
|
||||||
return Boolean(!vertical && alignCenter)
|
return Boolean(!vertical && alignCenter)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -92,35 +92,35 @@ const canAlignCenter = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const vertical = computed(() => {
|
const vertical = computed(() => {
|
||||||
if (isDef(steps)) {
|
if (isDef(steps.value)) {
|
||||||
return Boolean(steps.props.vertical)
|
return Boolean(steps.value.props.vertical)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const dot = computed(() => {
|
const dot = computed(() => {
|
||||||
if (isDef(steps)) {
|
if (isDef(steps.value)) {
|
||||||
return Boolean(steps.props.dot)
|
return Boolean(steps.value.props.dot)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const childrenLength = computed(() => {
|
const childrenLength = computed(() => {
|
||||||
if (isDef(steps)) {
|
if (isDef(steps.value)) {
|
||||||
return Number(steps.children.length)
|
return Number(steps.value.children.length)
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function getStyles() {
|
function getStyles() {
|
||||||
if (steps) {
|
if (steps.value) {
|
||||||
const { vertical, space } = steps.props
|
const { vertical, space } = steps.value.props
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
return space ? `height: ${space}` : ''
|
return space ? `height: ${space}` : ''
|
||||||
} else {
|
} else {
|
||||||
return `width: ${space || 100 / steps.children.length + '%'}`
|
return `width: ${space || 100 / steps.value.children.length + '%'}`
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
@ -131,8 +131,8 @@ function getCurrentStatus(index: number) {
|
|||||||
return props.status
|
return props.status
|
||||||
}
|
}
|
||||||
|
|
||||||
if (steps) {
|
if (steps.value) {
|
||||||
const { active } = steps.props
|
const { active } = steps.value.props
|
||||||
if (Number(active) > index) {
|
if (Number(active) > index) {
|
||||||
return 'finished'
|
return 'finished'
|
||||||
} else if (Number(active) === index) {
|
} else if (Number(active) === index) {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ const { parent: tabs, index } = useParent(TABS_KEY)
|
|||||||
|
|
||||||
// 激活项下标
|
// 激活项下标
|
||||||
const activeIndex = computed(() => {
|
const activeIndex = computed(() => {
|
||||||
return isDef(tabs) ? tabs.state.activeIndex : 0
|
return isDef(tabs.value) ? tabs.value.state.activeIndex : 0
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@ -85,8 +85,8 @@ function checkName(self) {
|
|||||||
if (myName === undefined || myName === null || myName === '') {
|
if (myName === undefined || myName === null || myName === '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tabs &&
|
tabs.value &&
|
||||||
tabs.children.forEach((child: any) => {
|
tabs.value.children.forEach((child: any) => {
|
||||||
if (child.$.uid !== self.$.uid && child.name === myName) {
|
if (child.$.uid !== self.$.uid && child.name === myName) {
|
||||||
console.error(`The tab's bound value: ${myName} has been used`)
|
console.error(`The tab's bound value: ${myName} has been used`)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,12 +74,12 @@ const { parent: tabbar, index } = useParent(TABBAR_KEY)
|
|||||||
|
|
||||||
const textStyle = computed(() => {
|
const textStyle = computed(() => {
|
||||||
const style: CSSProperties = {}
|
const style: CSSProperties = {}
|
||||||
if (tabbar) {
|
if (tabbar.value) {
|
||||||
if (active.value && tabbar.props.activeColor) {
|
if (active.value && tabbar.value.props.activeColor) {
|
||||||
style['color'] = tabbar.props.activeColor
|
style['color'] = tabbar.value.props.activeColor
|
||||||
}
|
}
|
||||||
if (!active.value && tabbar.props.inactiveColor) {
|
if (!active.value && tabbar.value.props.inactiveColor) {
|
||||||
style['color'] = tabbar.props.inactiveColor
|
style['color'] = tabbar.value.props.inactiveColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,8 +88,9 @@ const textStyle = computed(() => {
|
|||||||
|
|
||||||
const active = computed(() => {
|
const active = computed(() => {
|
||||||
const name = isDef(props.name) ? props.name : index.value
|
const name = isDef(props.name) ? props.name : index.value
|
||||||
if (tabbar) {
|
|
||||||
if (tabbar.props.modelValue === name) {
|
if (tabbar.value) {
|
||||||
|
if (tabbar.value.props.modelValue === name) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -104,7 +105,7 @@ const active = computed(() => {
|
|||||||
*/
|
*/
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
const name: string | number = isDef(props.name) ? props.name : index.value
|
const name: string | number = isDef(props.name) ? props.name : index.value
|
||||||
tabbar && tabbar.setChange({ name })
|
tabbar.value && tabbar.value.setChange({ name })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@ -200,8 +200,8 @@ const { parent: form } = useParent(FORM_KEY)
|
|||||||
|
|
||||||
// 表单校验错误信息
|
// 表单校验错误信息
|
||||||
const errorMessage = computed(() => {
|
const errorMessage = computed(() => {
|
||||||
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
if (form.value && props.prop && form.value.errorMessages && form.value.errorMessages[props.prop]) {
|
||||||
return form.errorMessages[props.prop]
|
return form.value.errorMessages[props.prop]
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -210,8 +210,8 @@ const errorMessage = computed(() => {
|
|||||||
// 是否展示必填
|
// 是否展示必填
|
||||||
const isRequired = computed(() => {
|
const isRequired = computed(() => {
|
||||||
let formRequired = false
|
let formRequired = false
|
||||||
if (form && form.props.rules) {
|
if (form.value && form.value.props.rules) {
|
||||||
const rules = form.props.rules
|
const rules = form.value.props.rules
|
||||||
for (const key in rules) {
|
for (const key in rules) {
|
||||||
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
if (Object.prototype.hasOwnProperty.call(rules, key) && key === props.prop && Array.isArray(rules[key])) {
|
||||||
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user