houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-card shadow="never" class="aui-card--fill">
3     <div>
4       <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
5         <el-form-item>
6           <el-date-picker
7               v-model="dataForm.startTime"
8               type="datetime"
9               placeholder="选择开始时间"
10               value-format="yyyy-MM-dd HH:mm:ss"
11           >
12           </el-date-picker>
13         </el-form-item>
14         <el-form-item>
15           <el-date-picker
16               v-model="dataForm.endTime"
17               type="datetime"
18               placeholder="选择结束时间"
19               value-format="yyyy-MM-dd HH:mm:ss"
20           >
21           </el-date-picker>
22         </el-form-item>
23         <el-form-item>
24           <el-input v-model="dataForm.judgement" placeholder="评价" clearable></el-input>
25         </el-form-item>
26         <el-form-item>
27           <el-button @click="searchDataList()">查询</el-button>
28         </el-form-item>
29       </el-form>
30       <div class="chart-boday">
31         <bar-line :option="chartOption" style="height: 400px;"></bar-line>
32       </div>
33       <el-table
34           :data="dataList"
35           border
36           v-loading="dataListLoading"
37           style="width: 100%;">
38         <el-table-column
39             type="index"
40             align="center"
41             width="50"
42             label="序号"
43         >
44         </el-table-column>
45         <el-table-column
46             prop="dateTime"
47             header-align="center"
48             align="center"
49             label="日期时间"
50             min-width="200">
51         </el-table-column>
52         <el-table-column
53             prop="judgement"
54             header-align="center"
55             align="center"
56             label="评价"
57             min-width="100">
58         </el-table-column>
59         <el-table-column
60             prop="score"
61             header-align="center"
62             align="center"
63             label="分数"
64             min-width="100">
65           <template slot-scope="scope">
66             <span :class="getFenClass(scope.row.score)">
67                 {{scope.row.score}}
68               </span>
69           </template>
70         </el-table-column>
71         <el-table-column
72             prop="analysis"
73             header-align="center"
74             align="left"
75             label="分析"
76             min-width="500">
77         </el-table-column>
78       </el-table>
79       <el-pagination
80           @size-change="sizeChangeHandle"
81           @current-change="currentChangeHandle"
82           :current-page="pageIndex"
83           :page-sizes="[10, 20, 50, 100]"
84           :page-size="pageSize"
85           :total="totalPage"
86           layout="total, sizes, prev, pager, next, jumper">
87       </el-pagination>
88     </div>
89   </el-card>
90 </template>
91
92 <script>
93   import BarLine from "@/components/chart/bar-line.vue";
94   import {stringToJSON} from '@/utils/jsonUtils'
95
96   export default {
97     components: {BarLine},
98     data() {
99       return {
100         loading: false,
101         dataForm: {
102           startTime: '',
103           endTime: '',
104           judgement: ''
105         },
106         dataList: [],
107         pageIndex: 1,
108         pageSize: 10,
109         totalPage: 0,
110         dataListLoading: false,
111         dataListSelections: [],
112         chartOption: {},
113         chartData: {
114           xData: [],
115           sub_indicator_score: [],
116           analysis: '',
117           score: '',
118         }
119       }
120     },
121     mounted() {
122       this.getDataList()
123       this.getChartData()
124     },
125     methods: {
126       searchDataList() {
127         this.pageIndex = 1
128         this.getDataList()
129       },
130       getChartData() {
131         let that = this
132         this.loading = true
133         this.$http.get(`/iailab-ntt-model/api/model/model-result/list`, {
134           params: {
135             modelCode: 'storage_reliability',
136             lastHour: 24 * 7,
137             isAsc: true,
138             startDate: this.dataForm.startDate,
139             endDate: this.dataForm.endDate,
140           }
141         }).then(({data: res}) => {
142           this.loading = false
143           this.resetFields(this.chartData)
144           let xData = []
145           let subScoreDevice = []
146           let subScoreVolume = []
147           let subScoreState = []
148
149           res.data.forEach(function (item) {
150             xData.push(item.resultTime.toString().substr(0, 10))
151             let sub_indicator_score = stringToJSON(item.sub_indicator_score)
152             subScoreDevice.push(sub_indicator_score[0])
153             subScoreVolume.push(sub_indicator_score[1])
154             subScoreState.push(sub_indicator_score[2])
155             let series = [
156               {
157                 name: "设备可靠性",
158                 type: 'bar',
159                 data: subScoreDevice,
160               },
161               {
162                 name: "仓储与外运",
163                 type: 'bar',
164                 data: subScoreVolume,
165               },
166               {
167                 name: "仓可用状态",
168                 type: 'bar',
169                 data: subScoreState,
170               }
171             ]
172             this.chartOption = {
173               title: {
174                 text: '',
175               },
176               tooltip: {
177                 trigger: "axis"
178               },
179               legend: {
180                 data: ['设备可靠性', '仓储与外运', '仓可用状态'],
181                 right: '10%'
182               },
183               xAxis: {
184                 type: "category",
185                 data: xData,
186               },
187               yAxis: {
188                 type: 'value',
189                 min: 0,//最小
190                 max: 100,//最大
191               },
192               series: series
193             };
194           }, this)
195
196         })
197
198       },
199       resetFields(obj) {
200         for (let key in obj) {
201           if (obj[key] instanceof Array) {
202             obj[key] = []
203           } else if (obj[key] instanceof Object) {
204             this.resetFields(obj[key])
205           } else {
206             obj[key] = ''
207           }
208         }
209       },
210       // 获取数据列表
211       getDataList() {
212         this.dataListLoading = true
213         this.$http.get(`/iailab-ntt-model/api/model/model-result/list`, {})
214
215         this.$http({
216           url: '/iailab-ntt-model/any/store/page',
217           method: 'get',
218           params: this.$http.adornParams({
219             'modelId': '705a3452-0594-4aba-a49e-f77626bc1d78',
220             'page': this.pageIndex,
221             'limit': this.pageSize,
222             'startTime': this.dataForm.startTime,
223             'endTime': this.dataForm.endTime,
224             'judgement': this.dataForm.judgement
225           })
226         }).then(({data}) => {
227           if (data && data.code === 0) {
228             this.dataList = data.data.list
229             this.totalPage = data.data.total
230           } else {
231             this.dataList = []
232             this.totalPage = 0
233           }
234           this.dataListLoading = false
235         })
236       },
237       // 每页数
238       sizeChangeHandle(val) {
239         this.pageSize = val
240         this.pageIndex = 1
241         this.getDataList()
242       },
243       // 当前页
244       currentChangeHandle(val) {
245         this.pageIndex = val
246         this.getDataList()
247       },
248       // 多选
249       selectionChangeHandle(val) {
250         this.dataListSelections = val
251       },
252       getFenClass(fen) {
253         if (Number(fen) >= 60) {
254           return 'fen-nor';
255         } else {
256           return 'fen-low';
257         }
258
259       }
260     }
261   }
262 </script>
263 <style scoped>
264   .fen-low {
265     color: #F45354;
266     font-weight: 600;
267   }
268   .fen-nor {
269     color: #00c2ff;
270     font-weight: 600;
271   }
272 </style>