|
|
@ -35,7 +35,8 @@ const picked = ref(formState.value.meta.color || enumColor.light[0]) |
|
|
|
|
|
|
|
|
|
|
|
// set default value |
|
|
|
// set default value |
|
|
|
formState.value.meta = { |
|
|
|
formState.value.meta = { |
|
|
|
icons: { |
|
|
|
iconIdx: 0, |
|
|
|
|
|
|
|
icon: { |
|
|
|
full: 'mdi-star', |
|
|
|
full: 'mdi-star', |
|
|
|
empty: 'mdi-star-outline', |
|
|
|
empty: 'mdi-star-outline', |
|
|
|
}, |
|
|
|
}, |
|
|
@ -43,22 +44,36 @@ formState.value.meta = { |
|
|
|
max: 5, |
|
|
|
max: 5, |
|
|
|
...formState.value.meta, |
|
|
|
...formState.value.meta, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// antdv doesn't support object as value |
|
|
|
|
|
|
|
// use iconIdx as value and update back in watch |
|
|
|
|
|
|
|
const iconIdx = iconList.findIndex( |
|
|
|
|
|
|
|
(ele) => ele.full === formState.value.meta.icon.full && ele.empty === formState.value.meta.icon.empty, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formState.value.meta.iconIdx = iconIdx === -1 ? 0 : iconIdx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
|
|
|
() => formState.value.meta.iconIdx, |
|
|
|
|
|
|
|
(v) => { |
|
|
|
|
|
|
|
formState.value.meta.icon = iconList[v] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<a-row> |
|
|
|
<a-row> |
|
|
|
<a-col :span="12"> |
|
|
|
<a-col :span="12"> |
|
|
|
<a-form-item label="Icon"> |
|
|
|
<a-form-item label="Icon"> |
|
|
|
<a-select v-model:value="formState.meta.icon" size="small" class="w-52"> |
|
|
|
<a-select v-model:value="formState.meta.iconIdx" size="small" class="w-52"> |
|
|
|
<!-- FIXME: antdv doesn't support object as value --> |
|
|
|
<a-select-option v-for="(icon, i) of iconList" :key="i" :value="i"> |
|
|
|
<a-select-option v-for="(icon, i) of iconList" :key="i" :value="icon"> |
|
|
|
|
|
|
|
<component |
|
|
|
<component |
|
|
|
:is="getMdiIcon(icon.full)" |
|
|
|
:is="getMdiIcon(icon.full)" |
|
|
|
|
|
|
|
class="mx-1" |
|
|
|
:style="{ |
|
|
|
:style="{ |
|
|
|
color: formState.meta.color, |
|
|
|
color: formState.meta.color, |
|
|
|
}" |
|
|
|
}" |
|
|
|
/> |
|
|
|
/> |
|
|
|
{{ ' ' }} |
|
|
|
|
|
|
|
<component |
|
|
|
<component |
|
|
|
:is="getMdiIcon(icon.empty)" |
|
|
|
:is="getMdiIcon(icon.empty)" |
|
|
|
:style="{ |
|
|
|
:style="{ |
|
|
|