|
11 | 11 | <div class="search"> |
12 | 12 | <el-input |
13 | 13 | v-model="state.skey" |
14 | | - placeholder="请输入图标(类型、名称)" |
| 14 | + placeholder="请输入类型、名称、图标名" |
15 | 15 | class="input-with-select" |
16 | 16 | > |
17 | 17 | <template #append> |
|
36 | 36 | v-model:currentPage="state.currentPage" |
37 | 37 | :page-size="49" |
38 | 38 | layout="total, prev, pager, next" |
39 | | - :total="state.skey ? state.list.length : icons.length" |
| 39 | + :total="state.searchFlag ? state.searchList.length : icons.length" |
40 | 40 | > |
41 | 41 | </el-pagination> |
42 | 42 | </div> |
|
67 | 67 | const state = reactive({ |
68 | 68 | icon: {}, |
69 | 69 | list: [], |
| 70 | + searchList: [], |
70 | 71 | currentPage: 1, |
71 | 72 | currTotal: 49, |
72 | 73 | skey: '', |
| 74 | + searchFlag: false, |
73 | 75 | }); |
74 | 76 |
|
75 | 77 | onBeforeMount(async () => { |
|
95 | 97 | state.currentPage = val; |
96 | 98 | const start = val * 49 - 49; |
97 | 99 | const end = val * 49; |
98 | | - const iconArr = state.skey ? state.list : icons; |
| 100 | + const iconArr = state.skey ? state.searchList : icons; |
99 | 101 | state.list = iconArr.slice(start, end); |
100 | 102 | }; |
101 | 103 |
|
102 | 104 | const handleSearchIcon = () => { |
103 | | - if (!state.skey) state.list = icons.slice(0, 49); |
104 | | - else { |
| 105 | + state.currentPage = 1; |
| 106 | + state.currTotal = 49; |
| 107 | + if (!state.skey) { |
| 108 | + state.searchFlag = false; |
| 109 | + state.list = icons.slice(0, 49); |
| 110 | + } else { |
| 111 | + state.searchFlag = true; |
105 | 112 | let list = []; |
106 | 113 | icons.map((item) => { |
107 | | - if (item.title.indexOf(state.skey) !== -1 || item.name.indexOf(state.skey) !== -1) { |
| 114 | + if ( |
| 115 | + item.title.indexOf(state.skey) !== -1 || |
| 116 | + item.name.indexOf(state.skey) !== -1 || |
| 117 | + item.categoryCN.indexOf(state.skey) !== -1 |
| 118 | + ) { |
108 | 119 | list.push(item); |
109 | 120 | } |
110 | 121 | }); |
111 | | - state.list = list; |
| 122 | + state.searchList = list; |
| 123 | + state.list = state.searchList.slice(state.currentPage - 1, state.currTotal); |
112 | 124 | } |
113 | 125 | }; |
114 | 126 | </script> |
|
0 commit comments