kibanaItem.vue
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<template>
<div class="main">
<div id="edit">
</div>
<div id="result">
</div>
<el-button class="submit" @click="submit" :loading="loading">提交</el-button>
</div>
</template>
<script>
export default {
name: "item",
data() {
return {
loading:false,
editor: null,
result: null
}
},
created() {},
methods: {
setQuery(query){
console.log(query)
try {
this.editor.set(query);
}catch (e) {
console.log(query,e)
}
},
setResult(result){
console.log(result)
try {
this.result.set(result);
}catch (e) {
console.log(result,e)
}
},
getQuery(){
try {
return this.editor.get();
}catch (e) {
return false;
}
},
getResult(){
try {
return this.result.get();
}catch (e) {
return false;
}
},
submit(){
const data = {
json:this.editor.get()
};
console.log(data)
this.loading = true;
ajax().post('/kibana.result',data).then(res=>{
console.log(res)
this.loading = false;
this.result.set(res);
})
}
},
mounted() {
this.editor = new JSONEditor(document.getElementById("edit"), {
mode:"code",
enableSort: false,
enableTransform: false,
});
this.result = new JSONEditor(document.getElementById("result"), {
mode:"code",
enableSort: false,
enableTransform: false,
editable : false,
mainMenuBar : false
});
}
}
</script>
<style scoped>
.main{
display: flex;
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100vh;
}
#edit{
width: 50%;
}
#result{
width: 50%;
}
.submit{
position: absolute;
top: 2px;
left: calc(50% - 82px);
z-index: 9999;
width: 80px;
}
</style>