feat: 优化 icons 选择器
This commit is contained in:
parent
035ba22f52
commit
c48607c123
@ -42,7 +42,14 @@
|
|||||||
<Select v-model="formData.permission_mark" allow-create placeholder="请选择" api="controllers" :query="{ module: formData.module }" v-else />
|
<Select v-model="formData.permission_mark" allow-create placeholder="请选择" api="controllers" :query="{ module: formData.module }" v-else />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="菜单Icon" prop="icon" v-if="!isAction">
|
<el-form-item label="菜单Icon" prop="icon" v-if="!isAction">
|
||||||
<el-input v-model="formData.icon" name="icon" clearable @click="open" />
|
<el-popover placement="right" :width="400" trigger="click">
|
||||||
|
<template #reference>
|
||||||
|
<el-input v-model="formData.icon" name="icon" clearable />
|
||||||
|
</template>
|
||||||
|
<div>
|
||||||
|
<Icons v-model="formData.icon" @close="closeSelectIcon" />
|
||||||
|
</div>
|
||||||
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属组件" prop="component" v-if="!isAction">
|
<el-form-item label="所属组件" prop="component" v-if="!isAction">
|
||||||
<Select v-model="formData.component" placeholder="请选择" allow-create api="components" :query="{ module: formData.module }" />
|
<Select v-model="formData.component" placeholder="请选择" allow-create api="components" :query="{ module: formData.module }" />
|
||||||
@ -92,10 +99,6 @@
|
|||||||
<el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
|
<el-button type="primary" @click="submitForm(form)">{{ $t('system.confirm') }}</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<Dialog v-model="visible" title="选择 Icon" width="1000px" destroy-on-close>
|
|
||||||
<Icons v-model="formData.icon" @close="closeSelectIcon" />
|
|
||||||
</Dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
@ -1,20 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="`grid ${grid} gap-y-6`">
|
<div class="h-84 pl-2 pr-2">
|
||||||
|
<div :class="`grid ${grid} gap-y-4 gap-x-4` + ' mt-3 h-72'">
|
||||||
<div v-for="icon in icons" :key="icon" class="flex justify-center hover:cursor-pointer" @click="selectIcon(icon)">
|
<div v-for="icon in icons" :key="icon" class="flex justify-center hover:cursor-pointer" @click="selectIcon(icon)">
|
||||||
<div v-if="modelValue === icon">
|
<div v-if="modelValue === icon">
|
||||||
<div class="flex justify-center w-full text-violet-700"><Icon :name="icon" /></div>
|
<div class="flex justify-center w-full text-violet-700"><Icon :name="icon" className="w-5 h-5" /></div>
|
||||||
<div class="text-sm text-violet-700">{{ icon }}</div>
|
<div class="text-[1px] text-violet-700">{{ icon }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="flex justify-center w-full"><Icon :name="icon" /></div>
|
<div class="flex justify-center w-full"><Icon :name="icon" className="w-5 h-5" /></div>
|
||||||
<div class="text-sm">{{ icon }}</div>
|
<div class="text-[1px]">{{ icon }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-center mt-6">
|
||||||
|
<el-pagination layout="prev,next" :page-size="limit" :total="total" prev-text="上一页" next-text="下一页" @next-click="handleNext" @prev-click="handlePrev" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -22,18 +30,38 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'grid-cols-5',
|
default: 'grid-cols-4',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emits = defineEmits(['update:modelValue', 'close'])
|
const emits = defineEmits(['update:modelValue', 'close'])
|
||||||
|
|
||||||
|
const limit = ref(16)
|
||||||
|
const icons = ref([])
|
||||||
|
const total = ref(0)
|
||||||
|
function getIcons(page = 1) {
|
||||||
|
const start = (page - 1) * limit.value
|
||||||
|
const end = start + limit.value
|
||||||
|
icons.value = constIcons.slice(start, end)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getIcons()
|
||||||
|
total.value = constIcons.length
|
||||||
|
})
|
||||||
|
const handleNext = value => {
|
||||||
|
getIcons(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePrev = value => {
|
||||||
|
getIcons(value)
|
||||||
|
}
|
||||||
const selectIcon = (icon: string) => {
|
const selectIcon = (icon: string) => {
|
||||||
emits('update:modelValue', icon)
|
emits('update:modelValue', icon)
|
||||||
emits('close')
|
emits('close')
|
||||||
}
|
}
|
||||||
// icons
|
// icons
|
||||||
const icons = [
|
const constIcons = [
|
||||||
'academic-cap',
|
'academic-cap',
|
||||||
'adjustments-horizontal',
|
'adjustments-horizontal',
|
||||||
'adjustments-vertical',
|
'adjustments-vertical',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user