|
|
@ -5,47 +5,27 @@ import MdiStarIcon from '~icons/mdi/star' |
|
|
|
import MdiStarOutlineIcon from '~icons/mdi/star-outline' |
|
|
|
import MdiStarOutlineIcon from '~icons/mdi/star-outline' |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
|
modelValue?: string | number |
|
|
|
modelValue?: number |
|
|
|
readOnly?: boolean |
|
|
|
readOnly?: boolean |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const { modelValue: value, readOnly } = defineProps<Props>() |
|
|
|
const props = defineProps<Props>() |
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue']) |
|
|
|
const emit = defineEmits(['update:modelValue']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const vModel = useVModel(props, 'modelValue', emit) |
|
|
|
|
|
|
|
|
|
|
|
const column = inject(ColumnInj) |
|
|
|
const column = inject(ColumnInj) |
|
|
|
const isForm = inject(IsFormInj) |
|
|
|
const isForm = inject(IsFormInj) |
|
|
|
|
|
|
|
|
|
|
|
const ratingMeta = computed(() => { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
icon: { |
|
|
|
|
|
|
|
full: 'mdi-star', |
|
|
|
|
|
|
|
empty: 'mdi-star-outline', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
color: '#fcb401', |
|
|
|
|
|
|
|
max: 5, |
|
|
|
|
|
|
|
// ...(column?.meta || {}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
const localState = computed({ |
|
|
|
|
|
|
|
get: () => value, |
|
|
|
|
|
|
|
set: (val) => emit('update:modelValue', val), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="d-100 h-100" :class="{ 'nc-cell-hover-show': localState === 0 || !localState }"> |
|
|
|
<div class="d-100 h-100" :class="{ 'nc-cell-hover-show': vModel === 0 || !vModel }"> |
|
|
|
<v-rating v-model="localState" :length="ratingMeta.max" dense x-small :readonly="readOnly" clearable> |
|
|
|
<v-rating v-model="vModel" :length="5" dense x-small :readonly="readOnly" clearable> |
|
|
|
<!-- todo: use the proper slot --> |
|
|
|
|
|
|
|
<template #item="{ isFilled, click }"> |
|
|
|
<template #item="{ isFilled, click }"> |
|
|
|
<!-- todo : custom color and icon --> |
|
|
|
<MdiStarIcon v-if="isFilled" class="text-[#fcb40]" @click="click" /> |
|
|
|
<!-- <v-icon v-if="isFilled"- :size="15" :color="ratingMeta.color" @click="click"> --> |
|
|
|
<MdiStarOutlineIcon v-else class="text-[#fcb40]" @click="click" /> |
|
|
|
<MdiStarIcon v-if="isFilled" :class="`text-[${ratingMeta.color}]`" @click="click" /> |
|
|
|
|
|
|
|
<!-- </v-icon> --> |
|
|
|
|
|
|
|
<!-- <v-icon v-else :color="ratingMeta.color" :size="15" class="nc-cell-hover-show" @click="click"> --> |
|
|
|
|
|
|
|
<MdiStarOutlineIcon v-else :class="`text-[${ratingMeta.color}]`" @click="click" /> |
|
|
|
|
|
|
|
<!-- </v-icon> --> |
|
|
|
|
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</v-rating> |
|
|
|
</v-rating> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<style scoped></style> |
|
|
|
|
|
|
|