14
14
v-bind:style =" {width:pannerStyle.w}"
15
15
></div >
16
16
<div class =" tools" >
17
- <JdIImportor />
18
- <JdlFormEditor />
19
- <JdlExeutor />
17
+ <a href =" #" class =" upload-input" >
18
+ <i class =" el-icon-upload" ></i >
19
+ <input type =" file" @change =" importHandle" />
20
+ </a >
20
21
<a href =" javascript:void(0);" @click =" downHandle" >
21
22
<i class =" el-icon-download" ></i >
22
23
</a >
23
24
<a href =" javascript:void(0);" @click =" delHandle" >
24
25
<i class =" el-icon-delete" ></i >
25
26
</a >
27
+ <JdlFormEditor />
28
+ <JdlExeutor />
26
29
</div >
27
30
</div >
28
31
</template >
@@ -49,13 +52,11 @@ import "codemirror/addon/edit/matchbrackets";
49
52
import " codemirror/addon/hint/show-hint" ;
50
53
import " codemirror/addon/scroll/simplescrollbars" ;
51
54
52
- import JdIImportor from " ./JdIImportor/JdIImportor.vue" ;
53
55
import JdlFormEditor from " ./JdlFormEditor/JdlFormEditor.vue" ;
54
56
import JdlExeutor from " ./JdlExeutor/JdlExeutor.vue" ;
55
57
export default {
56
58
name: " jdlstudio" ,
57
59
components: {
58
- JdIImportor,
59
60
JdlFormEditor,
60
61
JdlExeutor
61
62
},
@@ -213,6 +214,25 @@ export default {
213
214
},
214
215
handleClose () {
215
216
this .settingdialogVisiable = false ;
217
+ },
218
+ importHandle (event ) {
219
+ let file = event .target .files [0 ];
220
+ var reader = new FileReader ();
221
+ reader .readAsText (file, " UTF-8" );
222
+ reader .onload = e => {
223
+ let data = e .currentTarget .result ;
224
+ this .$store .commit (" setFilename" , file .name );
225
+ if (_ .endsWith (file .name , " .json" )) {
226
+ console .log (data);
227
+ }
228
+ if (_ .endsWith (file .name , " .jdl" )) {
229
+ this .$store .commit (" setEditorValue" , data);
230
+ // data->jdlobject
231
+ data = data .replace (/ \/\/ [^ \n\r ] * / gm , " " );
232
+ let jdlObject = parser .parse (data);
233
+ this .$store .commit (" setJdlObject" , jdlObject);
234
+ }
235
+ };
216
236
}
217
237
}
218
238
};
@@ -377,4 +397,24 @@ export default {
377
397
font-size : 25px ;
378
398
margin : 0 10px ;
379
399
}
400
+ .el-upload-list {
401
+ display : none ;
402
+ }
403
+ .upload-input {
404
+ position : relative ;
405
+ padding : 2px 2px ;
406
+ overflow : hidden ;
407
+ text-decoration : none ;
408
+ text-indent : 0 ;
409
+ line-height : 20px ;
410
+ }
411
+ .upload-input input {
412
+ position : absolute ;
413
+ font-size : 100px ;
414
+ left : 0 ;
415
+ top : 0 ;
416
+ width : 20px ;
417
+ height : 20px ;
418
+ opacity : 0 ;
419
+ }
380
420
</style >
0 commit comments