1414 v-bind:style =" {width:pannerStyle.w}"
1515 ></div >
1616 <div class =" tools" >
17- <el-col :span =" 6" >
18- <el-upload
19- ref =" upload"
20- action =" #"
21- :file-list =" fileList"
22- :on-change =" importHandle"
23- :auto-upload =" false"
24- >
25- <a href =" #" >
26- <i class =" el-icon-upload" ></i >
27- </a >
28- </el-upload >
29- </el-col >
30- <el-col :span =" 18" >
31- <a href =" javascript:void(0);" @click =" addHandle" >
32- <i class =" el-icon-plus" ></i >
33- </a >
34- <a href =" javascript:void(0);" @click =" downHandle" >
35- <i class =" el-icon-download" ></i >
36- </a >
37- <a href =" javascript:void(0);" @click =" delHandle" >
38- <i class =" el-icon-delete" ></i >
39- </a >
40- </el-col >
17+ <JdIImportor />
18+ <JdlFormEditor />
19+ <JdlExeutor />
20+ <a href =" javascript:void(0);" @click =" downHandle" >
21+ <i class =" el-icon-download" ></i >
22+ </a >
23+ <a href =" javascript:void(0);" @click =" delHandle" >
24+ <i class =" el-icon-delete" ></i >
25+ </a >
4126 </div >
4227 </div >
4328</template >
4429<script >
45- import Vue from " vue" ;
4630import { mapState , mapGetters } from " vuex" ;
4731import CodeMirror from " ./lib/codemirror/codemirror.custom" ;
4832import nomnoml from " ./lib/nomnoml/nomnoml.custom" ;
4933import skanaar from " ./lib/nomnoml/shannar.custom" ;
34+ import parser from " jhipster-core/lib/dsl/api" ;
5035
5136import " codemirror/theme/base16-dark.css" ;
5237import " codemirror/lib/codemirror.css" ;
@@ -58,15 +43,22 @@ import "./css/solarized.jdl.css";
5843
5944import _ from " lodash" ;
6045import saveAs from " file-saver" ;
61- import parser from " jhipster-core/lib/dsl/api" ;
6246
6347import " codemirror/addon/selection/active-line" ;
6448import " codemirror/addon/edit/matchbrackets" ;
6549import " codemirror/addon/hint/show-hint" ;
6650import " codemirror/addon/scroll/simplescrollbars" ;
6751
52+ import JdIImportor from " ./JdIImportor/JdIImportor.vue" ;
53+ import JdlFormEditor from " ./JdlFormEditor/JdlFormEditor.vue" ;
54+ import JdlExeutor from " ./JdlExeutor/JdlExeutor.vue" ;
6855export default {
6956 name: " jdlstudio" ,
57+ components: {
58+ JdIImportor,
59+ JdlFormEditor,
60+ JdlExeutor
61+ },
7062 data () {
7163 return {
7264 cmOptions: {
@@ -84,7 +76,6 @@ export default {
8476 },
8577 scrollbarStyle: " simple"
8678 },
87-
8879 canvasElement: {},
8980 canvasStyle: {
9081 t: 0 ,
@@ -104,13 +95,13 @@ export default {
10495 x: 0 ,
10596 y: 0
10697 },
107- mouseDownPoint: false ,
108- fileList: []
98+ mouseDownPoint: false
10999 };
110100 },
111101 computed: {
112102 ... mapState ({
113103 code : state => state .jdl .code ,
104+ filename : state => state .jdl .filename ,
114105 editor : state => state .jdl .editor
115106 }),
116107 ... mapGetters ({
@@ -129,6 +120,9 @@ export default {
129120 );
130121 // 更新editor
131122 this .$store .commit (" setEditor" , editor);
123+ // 更新jdlObject
124+ let jdlObject = parser .parse (this .editorValue );
125+ this .$store .commit (" setJdlObject" , jdlObject);
132126
133127 this .vm = skanaar .vector ;
134128 window .addEventListener (
@@ -176,9 +170,6 @@ export default {
176170 let scale = superSampling * Math .exp (this .zoomLevel / 10 );
177171 let model = nomnoml .draw (this .canvasElement , this .editorValue , scale);
178172 this .positionCanvas (this .canvasElement , superSampling, this .offset );
179- // save context
180-
181- // save file
182173 } catch (e) {
183174 console .error (e);
184175 }
@@ -210,30 +201,11 @@ export default {
210201 this .mouseDownPoint = false ;
211202 this .pannerStyle .w = " 45%" ;
212203 },
213- importHandle (file , fileList ) {
214- var reader = new FileReader ();
215- reader .readAsText (file .raw , " UTF-8" );
216- reader .onload = e => {
217- let data = e .currentTarget .result ;
218- if (_ .endsWith (file .name , " .json" )) {
219- console .log (data);
220- }
221- if (_ .endsWith (file .name , " .jdl" )) {
222- this .$store .commit (" setEditorValue" , data);
223- // data->jdlobject
224- data = data .replace (/ \/\/ [^ \n\r ] * / gm , " " );
225- let jdlObject = parser .parse (data);
226- this .$store .commit (" setJdlObject" , jdlObject);
227- }
228- this .fileList = [];
229- };
230- },
231- addHandle () {},
232204 downHandle () {
233205 let blob = new Blob ([this .editorValue ], {
234206 type: " text/plain;charset=utf-8"
235207 });
236- saveAs (blob, this .settings . baseName + " .jdl " );
208+ saveAs (blob, this .filename );
237209 },
238210 delHandle () {
239211 this .$store .commit (" setEditorValue" , " " );
@@ -405,28 +377,4 @@ export default {
405377 font-size : 25px ;
406378 margin : 0 10px ;
407379}
408- .el-upload-list {
409- display : none ;
410- }
411- .el-form-item__label {
412- color : #fdf6e3 ;
413- font-weight : 600 ;
414- }
415- .el-form-item a {
416- color : #fdf6e3 ;
417- }
418- .el-input--mini .el-input__inner {
419- background : rgb (0 , 0 , 0 , 0 );
420- border : 1px solid rgb (40 , 44 , 52 );
421- color : aliceblue ;
422- }
423- .el-dialog__body {
424- padding : 10px 20px ;
425- }
426- .el-dialog__headerbtn {
427- position : absolute ;
428- top : 10px ;
429- right : 10px ;
430- font-size : 20px ;
431- }
432380 </style >
0 commit comments