Skip to content

Commit 453f37a

Browse files
author
jxw
committed
split main component,formeditor,exeutor
1 parent a6ce468 commit 453f37a

File tree

4 files changed

+139
-0
lines changed

4 files changed

+139
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<template>
2+
<a href="#" class="upload-input">
3+
<i class="el-icon-upload"></i>
4+
<input type="file" @change="importHandle" />
5+
</a>
6+
</template>
7+
<script>
8+
import parser from "jhipster-core/lib/dsl/api";
9+
export default {
10+
name: "JdIImportor",
11+
data() {
12+
return {
13+
fileList: []
14+
};
15+
},
16+
methods: {
17+
importHandle(event) {
18+
let file = event.target.files[0];
19+
var reader = new FileReader();
20+
reader.readAsText(file, "UTF-8");
21+
reader.onload = e => {
22+
let data = e.currentTarget.result;
23+
this.$store.commit("setFilename", file.name);
24+
if (_.endsWith(file.name, ".json")) {
25+
console.log(data);
26+
}
27+
if (_.endsWith(file.name, ".jdl")) {
28+
this.$store.commit("setEditorValue", data);
29+
//data->jdlobject
30+
data = data.replace(/\/\/[^\n\r]*/gm, "");
31+
let jdlObject = parser.parse(data);
32+
this.$store.commit("setJdlObject", jdlObject);
33+
}
34+
this.fileList = [];
35+
};
36+
}
37+
}
38+
};
39+
</script>
40+
<style>
41+
.el-upload-list {
42+
display: none;
43+
}
44+
.upload-input {
45+
position: relative;
46+
padding: 2px 2px;
47+
overflow: hidden;
48+
text-decoration: none;
49+
text-indent: 0;
50+
line-height: 20px;
51+
}
52+
.upload-input input {
53+
position: absolute;
54+
font-size: 100px;
55+
left: 0;
56+
top: 0;
57+
width: 20px;
58+
height: 20px;
59+
opacity: 0;
60+
}
61+
</style>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Vue from "vue";
2+
import axios from "axios";
3+
export default {};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<a href="javascript:void(0);" @click="executeHandle">
3+
<i class="el-icon-caret-right"></i>
4+
</a>
5+
</template>
6+
<script>
7+
import { mapGetters } from "vuex";
8+
export default {
9+
computed: {
10+
...mapGetters({
11+
editorValue: "editorValue"
12+
})
13+
},
14+
methods: {
15+
executeHandle() {
16+
console.log(this.editorValue);
17+
}
18+
}
19+
};
20+
</script>
21+
<style>
22+
</style>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<template>
2+
<a href="javascript:void(0);" @click="addHandle">
3+
<i class="el-icon-plus"></i>
4+
</a>
5+
</template>
6+
<script>
7+
import Vue from "vue";
8+
import { mapState, mapGetters } from "vuex";
9+
import parser from "jhipster-core/lib/dsl/api";
10+
11+
import ElementUI from "element-ui";
12+
Vue.use(ElementUI);
13+
14+
export default {
15+
computed: {
16+
...mapState({
17+
jdlObject: state => state.jdl.jdlObject
18+
}),
19+
...mapGetters({
20+
editorValue: "editorValue"
21+
})
22+
},
23+
mounted() {},
24+
methods: {
25+
addHandle() {
26+
console.log(this.jdlObject, this.editorValue);
27+
}
28+
}
29+
};
30+
</script>
31+
<style>
32+
.el-form-item__label {
33+
color: #fdf6e3;
34+
font-weight: 600;
35+
}
36+
.el-form-item a {
37+
color: #fdf6e3;
38+
}
39+
.el-input--mini .el-input__inner {
40+
background: rgb(0, 0, 0, 0);
41+
border: 1px solid rgb(40, 44, 52);
42+
color: aliceblue;
43+
}
44+
.el-dialog__body {
45+
padding: 10px 20px;
46+
}
47+
.el-dialog__headerbtn {
48+
position: absolute;
49+
top: 10px;
50+
right: 10px;
51+
font-size: 20px;
52+
}
53+
</style>

0 commit comments

Comments
 (0)