feat:引入TreeSelect和IconSelect组件

This commit is contained in:
有来技术
2021-12-15 23:46:10 +08:00
parent abc24aef02
commit b12ae2b68c
95 changed files with 264 additions and 186 deletions

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 954 B

After

Width:  |  Height:  |  Size: 954 B

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 971 B

After

Width:  |  Height:  |  Size: 971 B

View File

Before

Width:  |  Height:  |  Size: 732 B

After

Width:  |  Height:  |  Size: 732 B

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 418 B

After

Width:  |  Height:  |  Size: 418 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 356 B

After

Width:  |  Height:  |  Size: 356 B

View File

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

View File

Before

Width:  |  Height:  |  Size: 818 B

After

Width:  |  Height:  |  Size: 818 B

View File

Before

Width:  |  Height:  |  Size: 627 B

After

Width:  |  Height:  |  Size: 627 B

View File

Before

Width:  |  Height:  |  Size: 347 B

After

Width:  |  Height:  |  Size: 347 B

View File

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 497 B

View File

Before

Width:  |  Height:  |  Size: 459 B

After

Width:  |  Height:  |  Size: 459 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 944 B

After

Width:  |  Height:  |  Size: 944 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 421 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 320 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 983 B

After

Width:  |  Height:  |  Size: 983 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 285 B

View File

Before

Width:  |  Height:  |  Size: 1017 B

After

Width:  |  Height:  |  Size: 1017 B

View File

Before

Width:  |  Height:  |  Size: 444 B

After

Width:  |  Height:  |  Size: 444 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 669 B

After

Width:  |  Height:  |  Size: 669 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 883 B

After

Width:  |  Height:  |  Size: 883 B

View File

Before

Width:  |  Height:  |  Size: 821 B

After

Width:  |  Height:  |  Size: 821 B

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 664 B

After

Width:  |  Height:  |  Size: 664 B

View File

Before

Width:  |  Height:  |  Size: 873 B

After

Width:  |  Height:  |  Size: 873 B

View File

Before

Width:  |  Height:  |  Size: 600 B

After

Width:  |  Height:  |  Size: 600 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 757 B

After

Width:  |  Height:  |  Size: 757 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 211 B

After

Width:  |  Height:  |  Size: 211 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 564 B

After

Width:  |  Height:  |  Size: 564 B

View File

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 563 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 679 B

After

Width:  |  Height:  |  Size: 679 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 655 B

After

Width:  |  Height:  |  Size: 655 B

View File

Before

Width:  |  Height:  |  Size: 597 B

After

Width:  |  Height:  |  Size: 597 B

View File

Before

Width:  |  Height:  |  Size: 787 B

After

Width:  |  Height:  |  Size: 787 B

View File

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 689 B

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 805 B

After

Width:  |  Height:  |  Size: 805 B

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 906 B

After

Width:  |  Height:  |  Size: 906 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 440 B

After

Width:  |  Height:  |  Size: 440 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,83 @@
<template>
<div class="icon-body">
<el-input
v-model="iconName"
style="position: relative;"
clearable
placeholder="请输入图标名称"
@clear="filterIcons"
@input="filterIcons"
>
<template #suffix><i class="el-icon-search el-input__icon" /></template>
</el-input>
<div class="icon-list">
<div v-for="(item, index) in iconList" :key="index" @click="selectedIcon(item)">
<svg-icon color="#999" :icon-class="item" style="height: 30px;width: 16px;margin-right: 5px" />
<span>{{ item }}</span>
</div>
</div>
</div>
</template>
<script setup>
import {defineEmits, ref} from "vue";
import SvgIcon from '@/components/SvgIcon/index.vue';
let icons = []
const modules = import.meta.glob('../../assets/icons/svg/*.svg');
for (const path in modules) {
const p = path.split('assets/icons/svg/')[1].split('.svg')[0];
icons.push(p);
}
const iconList = ref(icons);
const iconName = ref('');
const emit = defineEmits(['selected']);
function filterIcons() {
iconList.value = icons
if (iconName.value) {
iconList.value = icons.filter(item => item.indexOf(iconName.value) !== -1)
}
}
function selectedIcon(name) {
emit('selected', name)
document.body.click()
}
function reset() {
iconName.value = ''
iconList.value = icons
}
defineExpose({
reset
})
</script>
<style lang='scss' scoped>
.icon-body {
width: 100%;
padding: 10px;
.icon-list {
height: 200px;
overflow-y: scroll;
div {
height: 30px;
line-height: 30px;
margin-bottom: -5px;
cursor: pointer;
width: 33%;
float: left;
}
span {
display: inline-block;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
}
}
</style>

View File

@@ -1,195 +1,155 @@
<template> <template>
<el-select <div class="el-tree-select">
v-model="valueTitle" <el-select
:clearable="clearable" style="width: 100%"
@clear="clearHandle" v-model="valueId"
:placeholder="placeholder" ref="treeSelect"
> :filterable="true"
<el-option :clearable="true"
:value="valueTitle" @clear="clearHandle"
:label="valueTitle" :filter-method="selectFilterData"
class="options" :placeholder="placeholder"
> >
<el-tree <el-option :value="valueId" :label="valueTitle">
id="tree-option" <el-tree
ref="selectTree" id="tree-option"
:accordion="accordion" ref="selectTree"
:data="options" :accordion="accordion"
:props="treeProps" :data="options"
:node-key="treeProps.value" :props="state.props"
:default-expanded-keys="defaultExpandedKey" :node-key="state.props.value"
@node-click="handleNodeClick" :expand-on-click-node="false"
:disabled="disabled" :default-expanded-keys="defaultExpandedKey"
/> :filter-node-method="filterNode"
</el-option> @node-click="handleNodeClick"
</el-select> ></el-tree>
</el-option>
</el-select>
</div>
</template> </template>
<script lang="ts"> <script setup>
import { defineComponent, reactive, toRefs, nextTick, onMounted, getCurrentInstance, PropType, watch } from 'vue' import {defineEmits, ref, getCurrentInstance ,nextTick,onMounted,computed,watch} from "vue";
const { proxy } = getCurrentInstance();
interface TreeProps { const state = defineProps({
value: number /* 配置项 */
label: string
children: string
}
export default defineComponent({
name: 'ElTreeSelect',
props: { props: {
placeholder: { type: Object,
type: [String,Number], default: () => {
default: '' return {
}, value: 'id', // ID字段名
user: { label: 'label', // 显示名称
type: Boolean, children: 'children' // 子级字段名
default: false
},
// 选项列表数据(一维数组)
originOptions: { type: Array, required: true },
// 选项列表数据(树形结构的对象数组)
options: { type: Array, required: true },
// 初始值
defalut: { type: [String,Number], default: null },
// 可清空选项
clearable: { type: Boolean, default: true },
// 自动收起
accordion: { type: Boolean, default: false },
treeProps: {
type: Object as PropType<TreeProps>,
default: () => {
return {
value: 'menuId',
label: 'menuName',
children: 'children'
}
} }
},
disabled: {
type: Boolean, default: false
} }
}, },
emits: ['callBack'], /* 自动收起 */
setup(props, ctx) { accordion: {
const instance = getCurrentInstance() as any type: Boolean,
const state = reactive({ default: () => {
valueId: 0, return false
valueTitle: '',
defaultExpandedKey: Array<number>()
})
// 初始化滚动条
const initScroll = () => {
nextTick(() => {
const scrollWrap = document.querySelectorAll('.el-scrollbar .el-select-dropdown__wrap')[0] as any
const scrollBar = document.querySelectorAll('.el-scrollbar .el-scrollbar__bar') as any
scrollWrap.style.cssText = 'margin: 0px; max-height: none; overflow: hidden;'
scrollBar.forEach((ele: any) => {
ele.style.width = 0
})
})
}
// 清空选中样式
const clearSelected = () => {
const allNode = document.querySelectorAll('#tree-option .el-tree-node')
allNode.forEach((element) => element.classList.remove('is-current'))
}
const initHandle = () => {
initScroll()
}
// 处理默认值并显示
const defaultValue = () => {
if (props.defalut !== null) {
const deafaultModels = props.originOptions.filter((item: any) => {
return item[props.treeProps.value] === props.defalut
})
if (deafaultModels.length > 0) {
state.valueId = props.defalut
state.valueTitle = (deafaultModels[0] as any)[props.treeProps.label]
} else {
if (!props.user) {
state.valueId = 0
state.valueTitle = '主类目'
} else {
state.valueId = 0
state.valueTitle = ''
}
}
instance.ctx.$refs.selectTree.setCurrentKey(props.defalut)
state.defaultExpandedKey = [props.defalut] as number[]
}
}
onMounted(() => {
initHandle()
})
watch(() => props.options, () => {
if (props.options) {
defaultValue()
}
})
// 更新数据
const updateData = (value: any, label: any) => {
state.valueTitle = label
state.valueId = value
state.defaultExpandedKey = []
ctx.emit('callBack', value)
}
// 点击节点调用
const handleNodeClick = (node: any) => {
updateData(node[props.treeProps.value], node[props.treeProps.label])
}
// 清除选中
const clearHandle = () => {
updateData(null, null)
clearSelected()
}
return {
...toRefs(state),
handleNodeClick,
clearHandle
} }
},
/**当前双向数据绑定的值 */
value: {
type: [String, Number],
default: ''
},
/**当前的数据 */
options: {
type: Array,
default: () => []
},
/**输入框内部的文字 */
placeholder: {
type: String,
default: ''
} }
}) })
const emit = defineEmits(['update:value']);
const valueId = computed({
get: () => state.value,
set: (val) => {
emit('update:value', val)
}
});
const valueTitle = ref('');
const defaultExpandedKey = ref([]);
function initHandle() {
nextTick(() => {
const selectedValue = valueId.value;
if(selectedValue !== null && typeof (selectedValue) !== "undefined"){
const node = proxy.$refs.selectTree.getNode(selectedValue)
if (node) {
valueTitle.value = node.data[state.props.label]
proxy.$refs.selectTree.setCurrentKey(selectedValue) // 设置默认选中
defaultExpandedKey.value = [selectedValue] // 设置默认展开
}else{
clearHandle()
}
}
})
}
function handleNodeClick(node) {
valueTitle.value = node[state.props.label]
valueId.value = node[state.props.value];
defaultExpandedKey.value = [];
proxy.$refs.treeSelect.blur()
selectFilterData('')
}
function selectFilterData(val) {
proxy.$refs.selectTree.filter(val)
}
function filterNode(value, data) {
if (!value) return true
return data[state.props['label']].indexOf(value) !== -1
}
function clearHandle() {
valueTitle.value = ''
valueId.value = ''
defaultExpandedKey.value = [];
clearSelected()
}
function clearSelected() {
const allNode = document.querySelectorAll('#tree-option .el-tree-node')
allNode.forEach((element) => element.classList.remove('is-current'))
}
onMounted(() => {
initHandle()
})
watch(valueId, () => {
initHandle();
})
</script> </script>
<style scoped> <style lang='scss' scoped>
.el-select.el-select--medium{ .el-scrollbar .el-scrollbar__view .el-select-dropdown__item {
width: 100%; padding: 0;
background-color: #fff;
height: auto;
} }
.el-scrollbar .el-scrollbar__view .el-select-dropdown__item {
height: auto;
max-height: 274px;
padding: 0;
overflow: hidden;
overflow-y: auto;
}
.el-select-dropdown__item.selected { .el-select-dropdown__item.selected {
font-weight: normal; font-weight: normal;
} }
ul li :deep(.el-tree .el-tree-node__content) {
ul li .el-tree .el-tree-node__content {
height: auto; height: auto;
padding: 0 20px; padding: 0 20px;
box-sizing: border-box;
} }
.el-tree-node__label {
font-weight: normal; :deep(.el-tree-node__content:hover),
:deep(.el-tree-node__content:active),
:deep(.is-current > div:first-child),
:deep( .el-tree-node__content:focus ){
background-color: mix(#fff, #409EFF, 90%);
color: #409EFF;
} }
.el-tree :deep(.is-current .el-tree-node__label) { </style>
color: #409eff;
font-weight: 700;
}
.el-tree :deep(.is-current .el-tree-node__children .el-tree-node__label) {
color: #606266;
font-weight: normal;
}
</style>

View File

@@ -83,12 +83,10 @@
:rules="state.rules" :rules="state.rules"
label-width="80px"> label-width="80px">
<el-form-item label="父级菜单" prop="parentId"> <el-form-item label="父级菜单" prop="parentId">
<treeselect <tree-select
placeholder="请选择父级菜单" v-model:value="state.formData.parentId"
v-model="state.formData.parentId"
:multiple="false"
:options="state.menuOptions" :options="state.menuOptions"
:defaultExpandLevel="1" placeholder="选择上级菜单"
/> />
</el-form-item> </el-form-item>
@@ -115,7 +113,30 @@
</el-form-item> </el-form-item>
<el-form-item label="菜单图标"> <el-form-item label="菜单图标">
<el-input v-model="state.formData.icon" placeholder="请输入图标" maxlength="50"/>
<el-popover
placement="bottom-start"
:width="540"
v-model:visible="showChooseIcon"
trigger="click"
@show="showSelectIcon"
>
<icon-select ref="iconSelectRef" @selected="selected"/>
<template #reference>
<el-input v-model="state.formData.icon" placeholder="点击选择图标" readonly>
<template #prefix>
<svg-icon
v-if="state.formData.icon"
:icon-class="state.formData.icon"
class="el-input__icon"
style="height: 40px;width: 16px;"
color="#999"
/>
<i v-else class="el-icon-search el-input__icon"/>
</template>
</el-input>
</template>
</el-popover>
</el-form-item> </el-form-item>
<el-form-item label="状态"> <el-form-item label="状态">
@@ -150,12 +171,15 @@ import {Search, Plus, Edit, Refresh, Delete} from '@element-plus/icons'
import {ElForm, ElMessage, ElMessageBox} from "element-plus"; import {ElForm, ElMessage, ElMessageBox} from "element-plus";
import {defineEmits, reactive, ref, unref, onMounted, getCurrentInstance} from "vue"; import {defineEmits, reactive, ref, unref, onMounted, getCurrentInstance} from "vue";
import Treeselect from 'vue3-treeselect'
import 'vue3-treeselect/dist/vue3-treeselect.css'
import SvgIcon from '@/components/SvgIcon/index.vue'; import SvgIcon from '@/components/SvgIcon/index.vue';
const emit = defineEmits(['menuClick']) import TreeSelect from '@/components/TreeSelect/index.vue';
import IconSelect from '@/components/IconSelect/index.vue';
const emit = defineEmits(['menuClick'])
const showChooseIcon = ref(false);
const iconSelectRef = ref(null);
const state = reactive({ const state = reactive({
loading: true, loading: true,
// 选中ID数组 // 选中ID数组
@@ -180,7 +204,7 @@ const state = reactive({
parentId: 0, parentId: 0,
name: undefined, name: undefined,
visible: 1, visible: 1,
icon: undefined, icon: '',
sort: 1, sort: 1,
component: 'Layout', component: 'Layout',
path: undefined path: undefined
@@ -220,7 +244,7 @@ function handleQuery() {
function loadTreeSelectMenuOptions() { function loadTreeSelectMenuOptions() {
const menuOptions: any[] = [] const menuOptions: any[] = []
listTreeSelectMenus().then(response => { listTreeSelectMenus().then(response => {
const menuOption = {id: 0, label: '', children: response.data} const menuOption = {id: 0, label: '顶级菜单', children: response.data}
menuOptions.push(menuOption) menuOptions.push(menuOption)
state.menuOptions = menuOptions state.menuOptions = menuOptions
}) })
@@ -268,6 +292,7 @@ function handleUpdate(row: any) {
} }
const dataForm = ref(ElForm) const dataForm = ref(ElForm)
function submitForm() { function submitForm() {
const form = unref(dataForm) const form = unref(dataForm)
form.validate((valid: any) => { form.validate((valid: any) => {
@@ -296,7 +321,7 @@ function resetForm() {
parentId: 0, parentId: 0,
name: undefined, name: undefined,
visible: 1, visible: 1,
icon: undefined, icon: '',
sort: 1, sort: 1,
component: 'Layout', component: 'Layout',
path: undefined path: undefined
@@ -323,6 +348,17 @@ function handleDelete(row: any) {
) )
} }
function showSelectIcon() {
(iconSelectRef as any).value.reset();
showChooseIcon.value = true;
}
function selected(name: string) {
state.formData.icon = name;
showChooseIcon.value = false;
}
onMounted(() => { onMounted(() => {
handleQuery() handleQuery()
}) })

View File

@@ -12,12 +12,11 @@ export default ({command, mode}: ConfigEnv): UserConfig => {
return ( return (
{ {
plugins: [ plugins: [
vue(), vue(),
viteSvgIcons({ viteSvgIcons({
// 指定需要缓存的图标文件夹 // 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], iconDirs: [path.resolve(process.cwd(), 'src/assets/icons/svg')],
// 指定symbolId格式 // 指定symbolId格式
symbolId: 'icon-[dir]-[name]', symbolId: 'icon-[dir]-[name]',
}) })