38
38
<span >
39
39
<brackets v-if =" node.type !== 'content'" :data =" node.content" @click =" handleBracketsClick" />
40
40
41
- <span
42
- v-else-if =" customFormatter"
43
- :class =" valueClass"
44
- v-html =" customFormatter(node.content)"
45
- />
46
41
<span
47
42
v-else
48
43
:class =" valueClass"
55
50
>
56
51
<input
57
52
v-if =" editable && editing"
58
- :value =" defaultFormatter(node.content) "
53
+ :value =" defaultValue "
59
54
@change =" handleInputChange"
60
55
:style =" {
61
56
padding: '3px 8px',
66
61
fontFamily: 'inherit',
67
62
}"
68
63
/>
69
- <template v-else >{{
70
- editable && editing ? undefined : defaultFormatter(node.content)
71
- }}</template >
64
+ <slot v-else name = " value " :node = " node " :defaultValue = " defaultValue " >{{
65
+ defaultValue
66
+ }}</slot >
72
67
</span >
73
68
74
69
<span v-if =" node.showComma" >,</span >
@@ -133,11 +128,6 @@ export default {
133
128
type: Boolean ,
134
129
default: true ,
135
130
},
136
- // custom formatter for values
137
- customValueFormatter: {
138
- type: Function ,
139
- default: null ,
140
- },
141
131
showIcon: {
142
132
type: Boolean ,
143
133
default: false ,
@@ -161,7 +151,6 @@ export default {
161
151
return ` vjs-value vjs-value__${ this .dataType } ` ;
162
152
},
163
153
164
- // 当前数据类型
165
154
dataType () {
166
155
return getDataType (this .node .content );
167
156
},
@@ -170,33 +159,24 @@ export default {
170
159
return this .showDoubleQuotes ? ` "${ this .node .key } "` : this .node .key ;
171
160
},
172
161
173
- // 当前的树是否支持选中功能
174
162
selectable () {
175
163
return (
176
164
this .pathSelectable (this .node .path , this .node .content ) && (this .isMultiple || this .isSingle )
177
165
);
178
166
},
179
167
180
- // 多选模式
181
168
isMultiple () {
182
169
return this .selectableType === ' multiple' ;
183
170
},
184
171
185
- // 单选模式
186
172
isSingle () {
187
173
return this .selectableType === ' single' ;
188
174
},
189
175
190
- customFormatter () {
191
- return this .customValueFormatter
192
- ? (data ) =>
193
- this .customValueFormatter ? .(
194
- data,
195
- this .node .key ,
196
- this .node .path ,
197
- this .defaultFormatter (data),
198
- )
199
- : null ;
176
+ defaultValue () {
177
+ const str = (this .node ? .content ?? ' ' ) + ' ' ;
178
+ const text = this .dataType === ' string' ? ` "${ str} "` : str;
179
+ return text;
200
180
},
201
181
},
202
182
methods: {
@@ -206,28 +186,6 @@ export default {
206
186
this .$emit (' value-change' , value, this .node .path );
207
187
},
208
188
209
- defaultFormatter (data ) {
210
- const str = data + ' ' ;
211
- const text = this .dataType === ' string' ? ` "${ str} "` : str;
212
- // if (this.editable && this.editing) {
213
- // return (
214
- // <input
215
- // value={text}
216
- // onChange={handleInputChange}
217
- // style={{
218
- // padding: '3px 8px',
219
- // border: '1px solid #eee',
220
- // boxShadow: 'none',
221
- // boxSizing: 'border-box',
222
- // borderRadius: 5,
223
- // fontFamily: 'inherit',
224
- // }}
225
- // />
226
- // );
227
- // }
228
- return text;
229
- },
230
-
231
189
handleIconClick () {
232
190
this .$emit (' icon-click' , ! this .collapsed , this .node .path );
233
191
},
0 commit comments