@@ -5,20 +5,52 @@ import { Search } from '@element-plus/icons';
55import { ref } from ' vue' ;
66const activeNames = ref (1 );
77const inputValue = ref (' ' );
8+ const iconList = reactive ([... defaultIcons]);
9+ // 管理图元弹框显隐
10+ const dialogTableVisible = ref (false );
11+
12+ const showList = computed (() => iconList .filter ((i ) => i .show ));
13+
14+ // 拖拽进行画布绘制
815function dragPen (data , e ) {
916 const json = JSON .stringify (data);
1017 e .dataTransfer .setData (' meta2d' , json);
1118}
19+
20+ /**
21+ * 搜索功能
22+ */
23+ let searchList = reactive ([]);
24+ function doSearch (value ) {
25+ value = value .trim (); // 清除空格
26+ searchList = []; // 重置表格
27+ if (value) {
28+ // 输入有值
29+ // 遍历搜索
30+ showList .value .forEach ((item ) => {
31+ searchList .push (... item .list .filter ((i ) => i .name .includes (value)));
32+ });
33+ } else {
34+ searchList = []; // 设置为空
35+ }
36+ }
1237 </script >
1338
1439<template >
1540 <div class =" icons" >
1641 <div class =" icon_search" >
17- <el-input v-model =" inputValue" size =" small" placeholder =" 搜索图元" :prefix-icon =" Search" />
42+ <el-input v-model =" inputValue" size =" small" placeholder =" 搜索图元" :prefix-icon =" Search" @input =" doSearch" class =" search_input" />
43+ <div class =" icon_search_container" >
44+ <div class =" icon_item" v-for =" (item, index) in searchList" :key =" index" draggable =" true" @dragstart =" dragPen(item.data, $event)" :index =" index" :title =" item.name" >
45+ <i v-if =" item.icon" class =" icon-size" :class =" item.icon" ></i >
46+ <img v-else-if =" item.image" :src =" item.image" />
47+ <div v-else-if =" item.svg" v-html =" item.svg" ></div >
48+ </div >
49+ </div >
1850 </div >
1951 <div class =" icon_list" >
2052 <el-collapse v-model =" activeNames" >
21- <template v-for =" (icons , index ) in defaultIcons " :key =" index " >
53+ <template v-for =" (icons , index ) in showList " :key =" index " >
2254 <el-collapse-item :title =" icons.name" :name =" index.toString()" >
2355 <div class =" icon_container" >
2456 <div class =" icon_item" v-for =" (item, index) in icons.list" :key =" index" draggable =" true" @dragstart =" dragPen(item.data, $event)" :index =" index" >
@@ -33,8 +65,13 @@ function dragPen(data, e) {
3365 </el-collapse >
3466 </div >
3567 <div class =" icon_manage" >
36- <el-button > 管理图元 </el-button >
68+ <el-button @click = " dialogTableVisible = !dialogTableVisible " > 管理图元 </el-button >
3769 </div >
70+ <el-dialog v-model =" dialogTableVisible" title =" 图元库管理" center align-center >
71+ <div class =" icon_manage_container" >
72+ <div class =" icon_manage_item" v-for =" (item, index) in iconList" :key =" index" ><el-switch v-model =" item.show" />{{ item.name }}</div >
73+ </div >
74+ </el-dialog >
3875 </div >
3976</template >
4077
@@ -59,20 +96,18 @@ img {
5996}
6097
6198.icon_search {
62- height : 50 px ;
99+ max- height : 400 px ;
63100 display : flex ;
101+ flex-direction : column ;
64102 justify-content : center ;
65103 align-items : center ;
66- padding : 0 10px ;
67104}
68105.icon_list {
69106 padding : 5px 10px ;
70107 overflow : auto ;
71108 flex : 1 ;
72109}
73- .W-10 {
74- width : 100px ;
75- }
110+
76111.icon_manage {
77112 border-top : 1px solid #eee ;
78113 display : flex ;
@@ -83,29 +118,77 @@ img {
83118.icon_container {
84119 display : flex ;
85120 justify-content : flex-start ;
121+ overflow : auto ;
86122 flex-wrap : wrap ;
87123 align-content : center ;
88124}
125+ .icon_search_container {
126+ padding : 0 10px ;
127+ max-height : 200px ;
128+ overflow : auto ;
129+ display : flex ;
130+ flex-wrap : wrap ;
131+ }
89132.icon_item {
90133 padding : 5px ;
91134 cursor : pointer ;
92135}
136+ img {
137+ width : 25px ;
138+ height : 25px ;
139+ }
140+ .icon_search_container ::-webkit-scrollbar ,
93141.icon_list ::-webkit-scrollbar {
94142 /* 滚动条整体样式*/
95143 width : 10px ; /* 高宽分别对应横竖滚动条的尺寸*/
96144 height : 1px ;
97145}
146+ .icon_search_container ::-webkit-scrollbar-thumb ,
98147.icon_list ::-webkit-scrollbar-thumb {
99148 /* 滚动条里面小方块*/
100149 border-radius : 10px ;
101150 height : 20px ;
102151 -webkit-box-shadow : inset 0 0 5px rgba (0 , 0 , 0 , 0.2 );
103152 background : #4e4e4e ;
104153}
154+ .icon_search_container ::-webkit-scrollbar-track ,
105155.icon_list ::-webkit-scrollbar-track {
106156 /* 滚动条里面轨道*/
107157 -webkit-box-shadow : inset 0 0 5px rgba (0 , 0 , 0 , 0.2 );
108158 border-radius : 10px ;
109159 background : #ffffff ;
110160}
161+ .search_input {
162+ padding : 10px 10px ;
163+ }
164+ .icon_search_container ::-webkit-scrollbar {
165+ /* 滚动条整体样式*/
166+ width : 10px ; /* 高宽分别对应横竖滚动条的尺寸*/
167+ height : 1px ;
168+ }
169+ .icon_search_container ::-webkit-scrollbar-thumb {
170+ /* 滚动条里面小方块*/
171+ border-radius : 10px ;
172+ height : 20px ;
173+ -webkit-box-shadow : inset 0 0 5px rgba (0 , 0 , 0 , 0.2 );
174+ background : #4e4e4e ;
175+ }
176+ .icon_search_container ::-webkit-scrollbar-track {
177+ /* 滚动条里面轨道*/
178+ -webkit-box-shadow : inset 0 0 5px rgba (0 , 0 , 0 , 0.2 );
179+ border-radius : 10px ;
180+ background : #ffffff ;
181+ }
182+
183+ .icon_manage_container {
184+ display : flex ;
185+ justify-content : center ;
186+ align-content : center ;
187+ flex-direction : column ;
188+ overflow : auto ;
189+ }
190+ .icon_manage_item {
191+ display : flex ;
192+ justify-content : space-between ;
193+ }
111194 </style >
0 commit comments