Main.vue
4.9 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<template>
<v-app>
<v-toolbar>
<v-toolbar-title>당뇨질환 검사 가이드 시스템</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items>
<v-btn flat @click="currentView='Main'">메인</v-btn>
<v-btn flat @click="currentView='DataSeat'">DataSeat</v-btn>
<v-btn flat @click="currentView='Model'">Model</v-btn>
</v-toolbar-items>
</v-toolbar>
<v-container v-if="currentView=='DataSeat'">
<v-layout>
<v-flex>
<v-subheader>분류 코드</v-subheader>
<v-data-table
:headers="[
{text:'code',value:'BunCd'},
{text:'name',value:'Name'}
]"
:items="buncode">
<template slot="items" slot-scope="props">
<td>{{ props.item.BunCd }}</td>
<td>{{ props.item.Name }}</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
<v-layout>
<v-flex>
<v-subheader>pre-processing data</v-subheader>
<v-data-table
:headers="[
{text:'code',value:'code'},
{text:'name',value:'name'},
{text:'vaule',value:'value'}
]"
:items="normalRange">
<template slot="items" slot-scope="props">
<td>{{props.item.code}}</td>
<td>{{props.item.name}}</td>
<td>{{props.item.value}}</td>
</template>
</v-data-table>
</v-flex>
</v-layout>
</v-container>
<v-container fluid v-if="currentView=='Model'">
<img src="http://13.125.207.44/model.png" alt="" />
</v-container>
<v-container v-if="currentView=='Main'">
<v-layout row>
<v-flex sm2>
<v-subheader>검사결과</v-subheader>
</v-flex>
<v-flex sm8 >
<file-input v-model="filename" @formData="formData"/>
<v-btn @click.native="uploadFiles">predict</v-btn>
</v-flex>
</v-layout>
<v-layout>
<v-flex v-show="!initial && !isPredicting">
<v-list>
<template v-for="(item, index) in insJson" >
<v-list-tile :key="index">
<v-list-tile-content>
{{"검사명 : " +item.name + ", 검사결과 : " + item.value}}
</v-list-tile-content>
</v-list-tile>
</template>
</v-list>
</v-flex>
</v-layout>
<v-layout>
<v-flex >
<v-subheader>예측결과</v-subheader>
<div v-show="!initial &&!isPredicting" style="font-size:30px;">
{{probList[0]? (probList[0].buncode + " (" + 100*(probList[0].prob) + " %) "):''}}
</div>
<v-progress-circular v-show="isPredicting" :size="50" indeterminate color="primary"></v-progress-circular>
</v-flex>
</v-layout>
</v-container>
<v-container fluid>
<v-layout v-if="!initial &&!isPredicting">
<v-flex xs6>
<v-card>
<v-card-media
:src="'http://13.125.207.44/top3_bar_plot.png?'+Math.random()"
height="700px"
contain>
</v-card-media>
</v-card>
</v-flex>
<v-flex xs6>
<v-card>
<v-card-media
:src="'http://13.125.207.44/total_bar_plot.png?'+Math.random()"
height="700px"
contain>
</v-card-media>
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-app>
</template>
<script>
import fileInput from './file-input.vue'
export default {
name: 'Main',
components:{fileInput},
data () {
return {
currentView: 'Main',
filename: '',
formDatas: null,
insJson: [],
probList: [],
isPredicting: false,
initial:true,
buncode: require('../assets/buncode.json'),
normalRange: require('../assets/normal_value_delete_version_utf8.csv')
}
},
methods:{
formData(form){
this.formDatas = form[0];
},
uploadFiles(){
this.formDatas.forEach((val)=>{
this.readTextFile(val);
})
},
readTextFile(file){
var reader = new FileReader();
reader.onload = (e)=> {
var text = reader.result;
this.insJson=JSON.parse(text);
}
reader.readAsText(file);
}
},
watch:{
insJson(prev){
this.probList=[];
this.isPredicting=true;
fetch('http://13.125.207.44/getPredict',{
method:'POST',
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(this.insJson)
})
.then((res)=>res.json())
.then((json)=>{
let tmp1 = json.ret1.split('|');
let tmp2 = json.res2.split('|');
for(let i=0;i<tmp1.length;i++){
this.probList.push({
code:tmp2[i],
prob:Number(tmp1[i]),
buncode:tmp2[i].split(',').map((code)=>this.buncode.find((val)=>val.BunCd==code).Name).join(',')
});
}
this.probList.sort((a,b)=> (b.prob-a.prob));
this.isPredicting=false;
this.initial=false;
})
}
}
}
</script>
<style scoped>
</style>