@tongfun/tf-widget 0.1.13 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ # tf-icon-picker
2
+
3
+ 1. 参数
4
+ 1. width (Number) 选择图标区域宽度,默认值 400。
5
+ 2. placement (string) 选择图标展示区域,默认值 'bottom', 可选值: 'top', 'left', 'right', 'bottom'。
6
+ 3. hint (string) 展示图标选择标题。
7
+
8
+ 2.
@@ -0,0 +1,8 @@
1
+ import TfIconPicker from './src/tf-icon-picker'
2
+
3
+ /* istanbul ignore next */
4
+ TfIconPicker.install = function (Vue) {
5
+ Vue.component(TfIconPicker.name, TfIconPicker)
6
+ }
7
+
8
+ export default TfIconPicker
@@ -0,0 +1,266 @@
1
+ <template>
2
+ <div>
3
+ <el-popover
4
+ v-model="visible"
5
+ :placement="placement"
6
+ :width="width"
7
+ trigger="manual"
8
+ >
9
+ <div class="content-view">
10
+ <div class="search-box">
11
+ <svg-icon
12
+ v-if="selectIconClass"
13
+ :icon-class="selectIconClass.font_class"
14
+ />
15
+ <span v-if="selectIconClass">{{ selectIconClass.name }}</span>
16
+ <el-input
17
+ v-model="search"
18
+ size="mini"
19
+ style="width: 50%"
20
+ clearable
21
+ @clear="cleanSearch"
22
+ />
23
+ <el-button
24
+ size="mini"
25
+ @click="searchInfo"
26
+ >搜索</el-button>
27
+ </div>
28
+ <el-empty
29
+ v-if="!iconList || iconList.length === 0"
30
+ description="暂无数据!"
31
+ style="height: 270px;width: 100%"
32
+ />
33
+ <div
34
+ v-for="item in iconList"
35
+ :key="item.unicode_decimal"
36
+ class="icon-item"
37
+ @click="selectIcon(item)"
38
+ >
39
+ <el-tooltip
40
+ placement="top"
41
+ >
42
+ <div slot="content">
43
+ <span>图标名称: {{ item.name }}</span>
44
+ <br>
45
+ <br>
46
+ <span>class: {{ item.font_class }}</span>
47
+ </div>
48
+ <div class="icon-box">
49
+
50
+ <svg-icon
51
+ :icon-class="item.font_class"
52
+ />
53
+ <span :title="item.name">{{ item.name }}</span>
54
+ </div>
55
+ </el-tooltip>
56
+ </div>
57
+ <div class="paging">
58
+ <span>第 {{ pagination + 1 }} 页</span>
59
+ <el-pagination
60
+ small
61
+ background
62
+ layout="total, prev, next"
63
+ :total="total"
64
+ @current-change="handleCurrentChange"
65
+ />
66
+
67
+ <el-button
68
+ type="info"
69
+ size="mini"
70
+ @click="visible = false"
71
+ >取消</el-button>
72
+ <el-button
73
+ class="button"
74
+ size="mini"
75
+ @click="select"
76
+ >确定</el-button>
77
+ </div>
78
+ </div>
79
+ <el-button
80
+ slot="reference"
81
+ class="button"
82
+ :size="bottomSize"
83
+ @click="visible = !visible; selectIconClass = null"
84
+ >{{ hint }}</el-button>
85
+ </el-popover>
86
+ </div>
87
+ </template>
88
+
89
+ <script>
90
+ import axios from 'axios'
91
+ export default {
92
+ name: 'TfIconPicker',
93
+ props: {
94
+ width: {
95
+ default: 400,
96
+ type: Number
97
+ },
98
+ placement: {
99
+ default: 'bottom',
100
+ type: String
101
+ },
102
+ bottomSize: {
103
+ default: 'small',
104
+ type: String
105
+ },
106
+ hint: {
107
+ default: '选择图标',
108
+ type: String
109
+ }
110
+ },
111
+ data () {
112
+ return {
113
+ glyphsList: null,
114
+ allIconList: null,
115
+ pagination: 0,
116
+ iconList: null,
117
+ total: 0,
118
+ selectIconClass: null,
119
+ visible: false,
120
+ search: null
121
+ }
122
+ },
123
+ watch: {
124
+ pagination: {
125
+ handler: function (newValue) {
126
+ if (!this.glyphsList) return
127
+ this.iconList = this.allIconList.slice(newValue * 20, (newValue + 1) * 20)
128
+ },
129
+ immediate: true
130
+ }
131
+ },
132
+ created () {
133
+ axios.get('/icon-list.json').then((res) => {
134
+ if (res.status === 200) {
135
+ const { glyphs: glyphsList } = res.data
136
+ this.glyphsList = glyphsList.sort((a, b) => a.font_class - b.font_class)
137
+ this.allIconList = JSON.parse(JSON.stringify(this.glyphsList))
138
+ this.total = this.allIconList?.length
139
+ this.iconList = this.allIconList.slice(this.pagination * 20, (this.pagination + 1) * 20)
140
+ }
141
+ })
142
+ },
143
+ methods: {
144
+ handleCurrentChange (val) {
145
+ if (val - 1 > this.total / 20) return
146
+ this.pagination = val - 1
147
+ },
148
+ selectIcon (params) {
149
+ this.selectIconClass = params
150
+ },
151
+ searchInfo () {
152
+ this.pagination = 0
153
+ const glyphs = JSON.parse(JSON.stringify(this.glyphsList))
154
+ const iconArr = []
155
+ glyphs.forEach(item => {
156
+ const str = `${item.font_class}+${item.name}`.toLowerCase()
157
+ if (str.indexOf(this.search.toLowerCase()) !== -1) {
158
+ iconArr.push(item)
159
+ }
160
+ })
161
+ this.allIconList = iconArr
162
+ this.total = this.allIconList.length
163
+ if (iconArr.length > 20) {
164
+ this.iconList = this.allIconList.slice(this.pagination * 20, (this.pagination + 1) * 20).sort((a, b) => a.font_class - b.font_class)
165
+ } else {
166
+ this.iconList = iconArr.sort((a, b) => a.font_class - b.font_class)
167
+ }
168
+ },
169
+ cleanSearch () {
170
+ this.pagination = 0
171
+ this.allIconList = JSON.parse(JSON.stringify(this.glyphsList))
172
+ this.total = this.allIconList?.length
173
+ this.iconList = this.allIconList.slice(this.pagination * 20, (this.pagination + 1) * 20)
174
+ },
175
+ select () {
176
+ if (this.selectIconClass) {
177
+ this.$emit('selectIcon', JSON.parse(JSON.stringify(this.selectIconClass)))
178
+ } else {
179
+ this.$message.error('未选择图标')
180
+ }
181
+ this.selectIconClass = null
182
+ this.visible = false
183
+ }
184
+ }
185
+ }
186
+ </script>
187
+
188
+ <style lang="less" scoped>
189
+ .content-view {
190
+ min-height: 300px;
191
+ display: flex;
192
+ justify-content: left;
193
+ align-items: center;
194
+ flex-wrap: wrap;
195
+ align-content: flex-start;
196
+ .search-box {
197
+ width: 100%;
198
+ display: flex;
199
+ justify-content: left;
200
+ align-items: center;
201
+ gap: 0 10px;
202
+ color: red;
203
+ .svg-icon {
204
+ height: 20px;
205
+ width: 20px;
206
+ }
207
+ }
208
+ .icon-item {
209
+ width: 20%;
210
+ height: 60px;
211
+ display: flex;
212
+ margin-top: 10px;
213
+ align-items: center;
214
+ justify-content: center;
215
+ .icon-box {
216
+ box-sizing: border-box;
217
+ padding: 5px 0;
218
+ border-radius: 2px;
219
+ border: 1px solid #eeeeee;
220
+ display: inherit;
221
+ flex-direction: column;
222
+ justify-content: space-between;
223
+ align-items: center;
224
+ width: 60px;
225
+ height: 100%;
226
+ color: #666666;
227
+ &:hover {
228
+ color: #2a90e9;
229
+ box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
230
+ }
231
+ .svg-icon {
232
+ height: 25px;
233
+ width: 25px;
234
+ }
235
+ span {
236
+ line-height: 1;
237
+ box-sizing: border-box;
238
+ padding: 0 2px;
239
+ text-align: center;
240
+ width: 60px;
241
+ display: inline-block;
242
+ white-space: nowrap;
243
+ overflow: hidden;
244
+ text-overflow: ellipsis;
245
+ cursor: pointer;
246
+ font-size: 12px;
247
+ }
248
+ }
249
+ }
250
+ .paging {
251
+ display: flex;
252
+ justify-content: right;
253
+ align-items: center;
254
+ margin-top: 10px;
255
+ height: 20px;
256
+ width: 100%;
257
+ }
258
+ }
259
+ .button {
260
+ opacity: 1;
261
+ background: #0c4c8e;
262
+ border-radius: 2px;
263
+ font-weight: 700;
264
+ color: #FFFFFF;
265
+ }
266
+ </style>
@@ -97,7 +97,6 @@ export default {
97
97
  watch: {
98
98
  $route: {
99
99
  handler: function (newValue) {
100
- console.log(this.routeBase)
101
100
  if (newValue && newValue.matched[0]?.meta.base === this.routeBase) {
102
101
  const { meta, path, name, params, query } = newValue
103
102
  if (!path) return
@@ -49,14 +49,6 @@ export default {
49
49
  thirdCacheArr: []
50
50
  }
51
51
  },
52
- watch: {
53
- routeBase: {
54
- handler: function (newValue) {
55
- console.log(newValue)
56
- },
57
- immediate: true
58
- }
59
- },
60
52
  methods: {
61
53
  changeMenuState (state) {
62
54
  this.menuState = state
@@ -55,6 +55,7 @@
55
55
  :table-data="pageData.commonTableData"
56
56
  :table-layout="pageData.commonTableLayout"
57
57
  :paging="pageData.paging"
58
+ :head-name="pageData.headName"
58
59
  :total-data="pageData.totalData"
59
60
  :single-select="true"
60
61
  :quick-filter-data="pageData.quickFilterData"
@@ -254,11 +255,15 @@ export default {
254
255
  },
255
256
  deep: true
256
257
  },
257
- tableId (newVal, oldVal) {
258
- if (oldVal !== newVal) {
259
- this.DetermineWhetherTheTableidTasChanged = true
260
- this.pageData.tableId = newVal
261
- }
258
+ tableId: {
259
+ handler (newVal, oldVal) {
260
+ if (oldVal !== newVal && newVal) {
261
+ this.DetermineWhetherTheTableidTasChanged = true
262
+ this.pageData.tableId = newVal
263
+ this.initTable()
264
+ }
265
+ },
266
+ immediate: true
262
267
  },
263
268
  dialogVisible (newVal) {
264
269
  if (!this.DetermineWhetherTheTableidTasChanged) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tongfun/tf-widget",
3
- "version": "0.1.13",
3
+ "version": "0.1.18",
4
4
  "description": "tf-widget",
5
5
  "main": "lib/tf-widget.umd.js",
6
6
  "private": false,
package/postinstall.js CHANGED
@@ -1,10 +1,10 @@
1
-
2
- const BANNER = '\u001B[96mThank you for using tf-widget for polyfilling JavaScript standard library!\u001B[0m\n\n' +
3
- '\u001B[96mWe need the best of you! Come and join us\n\n' +
4
- '\u001B[96mWe are waiting for you\n'
5
-
6
- function showBanner () {
7
- console.log(BANNER)
8
- }
9
-
10
- showBanner()
1
+
2
+ const BANNER = '\u001B[96mThank you for using tf-widget for polyfilling JavaScript standard library!\u001B[0m\n\n' +
3
+ '\u001B[96mWe need the best of you! Come and join us\n\n' +
4
+ '\u001B[96mWe are waiting for you\n'
5
+
6
+ function showBanner () {
7
+ console.log(BANNER)
8
+ }
9
+
10
+ showBanner()
package/src/index.js CHANGED
@@ -4,12 +4,14 @@ import SvgIcon from '../package/svg-icon'
4
4
  import TfLayout from '../package/tf-layout'
5
5
  import TDataList from '../package/t-data-list'
6
6
  import Tinput from '../package/t-input'
7
+ import TfIconPicker from '../package/tf-icon-picker'
7
8
  const components = [
8
9
  TfWidget,
9
10
  SvgIcon,
10
11
  TfLayout,
11
12
  TDataList,
12
- Tinput
13
+ Tinput,
14
+ TfIconPicker
13
15
  ]
14
16
 
15
17
  const install = function (Vue) {
@@ -24,5 +26,6 @@ export default {
24
26
  SvgIcon,
25
27
  TfLayout,
26
28
  TDataList,
27
- Tinput
29
+ Tinput,
30
+ TfIconPicker
28
31
  }
@@ -1 +0,0 @@
1
- .el-popover .context-list .list-item[data-v-fcd31cd8]{display:flex;margin:1px 0;padding:2px 8px;justify-content:space-between}.el-popover .context-list .list-item[data-v-fcd31cd8]:hover{background-color:#e7ebfd}.el-popover .context-list .list-item-active[data-v-fcd31cd8]{color:#3b68fc;background-color:#e7ebfd}.el-popover .context-list[data-v-fcd31cd8] .el-input .el-input__inner{height:30px}.el-popover .context-list[data-v-fcd31cd8]:last-child{margin-top:4px;width:100%;display:flex;justify-content:space-between}.el-popover .header-input[data-v-fcd31cd8]{margin-top:5px}.el-popover .filter-icon[data-v-fcd31cd8]{outline:none;width:15px;height:15px;cursor:pointer}