优化发布页默认输入与在线时间校验
This commit is contained in:
@@ -4,6 +4,7 @@ const props = withDefaults(
|
||||
options: Array<string | number>
|
||||
modelValue?: string | number
|
||||
activeValues?: Array<string | number>
|
||||
disabledValues?: Array<string | number>
|
||||
keyPrefix?: string
|
||||
compact?: boolean
|
||||
suffix?: string
|
||||
@@ -11,6 +12,7 @@ const props = withDefaults(
|
||||
{
|
||||
modelValue: undefined,
|
||||
activeValues: () => [],
|
||||
disabledValues: () => [],
|
||||
keyPrefix: '',
|
||||
compact: false,
|
||||
suffix: '',
|
||||
@@ -26,7 +28,12 @@ function isActive(value: string | number) {
|
||||
return props.activeValues.includes(value) || props.modelValue === value
|
||||
}
|
||||
|
||||
function isDisabled(value: string | number) {
|
||||
return props.disabledValues.includes(value)
|
||||
}
|
||||
|
||||
function selectValue(value: string | number) {
|
||||
if (isDisabled(value)) return
|
||||
emit('update:modelValue', value)
|
||||
emit('select', value)
|
||||
}
|
||||
@@ -39,7 +46,8 @@ function selectValue(value: string | number) {
|
||||
:key="`${keyPrefix}${option}`"
|
||||
type="button"
|
||||
class="chip"
|
||||
:class="{ active: isActive(option) }"
|
||||
:class="{ active: isActive(option), disabled: isDisabled(option) }"
|
||||
:disabled="isDisabled(option)"
|
||||
@click="selectValue(option)"
|
||||
>
|
||||
{{ option }}{{ suffix }}
|
||||
@@ -81,4 +89,11 @@ function selectValue(value: string | number) {
|
||||
background: #ff6a00;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.chip.disabled {
|
||||
border-color: #e5e7eb;
|
||||
background: #f3f4f6;
|
||||
color: #a8b0bd;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user