File tree Expand file tree Collapse file tree 1 file changed +22
-13
lines changed
Expand file tree Collapse file tree 1 file changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ const AREA = {
3737 }
3838}
3939
40+ const TYPE = {
41+ all: ' all' ,
42+ code: ' code' ,
43+ text: ' text'
44+ }
45+
4046function isCode (value = ' ' ) {
4147 return / ^ \d {6,} $ / .test (value)
4248}
@@ -208,22 +214,25 @@ export default {
208214 },
209215 // 兼容旧的输出
210216 emitEvent () {
217+ const type = this .type
211218 let result
212219
213- if (this .type === ' all' ) {
214- result = this .values .map (item => {
215- const obj = {}
216- item .code && (obj[item .code ] = item .name )
217- return obj
218- })
219- }
220-
221- if (this .type === ' code' ) {
222- result = this .values .map (item => item .code )
223- }
220+ if (type === TYPE .all ) {
221+ result = this .values
222+ .map (item => {
223+ const obj = {}
224+ item .code && (obj[item .code ] = item .name )
225+ return obj
226+ })
227+ .filter (v => Object .keys (v).length )
228+ } else {
229+ if (type === TYPE .code ) {
230+ result = this .values .map (item => item .code )
231+ } else if (type === TYPE .text ) {
232+ result = this .values .map (item => item .name )
233+ }
224234
225- if (this .type === ' text' ) {
226- result = this .values .map (item => item .name )
235+ result = result .filter (v => v)
227236 }
228237
229238 result = result .slice (0 , + this .level + 1 )
You can’t perform that action at this time.
0 commit comments