1414 v-bind:style =" {width:pannerStyle.w}"
1515 ></div >
1616 <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 >
2021 <a href =" javascript:void(0);" @click =" downHandle" >
2122 <i class =" el-icon-download" ></i >
2223 </a >
2324 <a href =" javascript:void(0);" @click =" delHandle" >
2425 <i class =" el-icon-delete" ></i >
2526 </a >
27+ <JdlFormEditor />
28+ <JdlExeutor />
2629 </div >
2730 </div >
2831</template >
@@ -49,13 +52,11 @@ import "codemirror/addon/edit/matchbrackets";
4952import " codemirror/addon/hint/show-hint" ;
5053import " codemirror/addon/scroll/simplescrollbars" ;
5154
52- import JdIImportor from " ./JdIImportor/JdIImportor.vue" ;
5355import JdlFormEditor from " ./JdlFormEditor/JdlFormEditor.vue" ;
5456import JdlExeutor from " ./JdlExeutor/JdlExeutor.vue" ;
5557export default {
5658 name: " jdlstudio" ,
5759 components: {
58- JdIImportor,
5960 JdlFormEditor,
6061 JdlExeutor
6162 },
@@ -213,6 +214,25 @@ export default {
213214 },
214215 handleClose () {
215216 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+ };
216236 }
217237 }
218238};
@@ -377,4 +397,24 @@ export default {
377397 font-size : 25px ;
378398 margin : 0 10px ;
379399}
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+ }
380420 </style >
0 commit comments