houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <div class="mod-prod-eval-system">
3     <div class="eval-system-left">
4       <el-card class="box-card">
5         <div style="height: 500px;">
6           <div style="text-align: center; background: #F2F3F5;margin-top: 10px;">
7             <el-button type="text" v-if="$hasPermission('analysis:evaluate:update')" icon="el-icon-edit" @click="updateSystemWeight()">修改权重</el-button>
8           </div>
9           <div ref="chartPie1" style="width: 100%; height: 400px;"></div>
10         </div>
11       </el-card>
12     </div>
13     <div class="eval-system-mid">
14       <el-card class="box-card">
15   <el-tabs :tab-position="systemWeight" style="height: 50px;" @tab-click="handleClick">
16     <el-tab-pane label="数量"></el-tab-pane>
17     <el-tab-pane label="质量"></el-tab-pane>
18     <el-tab-pane label="生产消耗"></el-tab-pane>
19     <el-tab-pane label="过程控制"></el-tab-pane>
20     <el-tab-pane label="管理"></el-tab-pane>
21   </el-tabs>
22         <div>
23           <el-form :inline="true" :model="dataForm">
24             <el-form-item>
25               <el-input v-model="dataForm.name" placeholder="指标名称" clearable></el-input>
26             </el-form-item>
27             <el-form-item>
28               <el-button @click="getDataList()">{{ $t('query') }}</el-button>
29             </el-form-item>
30             <el-form-item>
31               <el-button type="primary"  v-if="$hasPermission('analysis:evaluate:update')" @click="addOrUpdateHandle(dataForm.pid)">{{ $t('add') }}
32               </el-button>
33             </el-form-item>
34             <el-form-item>
35               <el-button type="danger"  v-if="$hasPermission('analysis:evaluate:update')" @click="deleteHandle()">{{ $t('deleteBatch')}}
36               </el-button>
37             </el-form-item>
38             <el-form-item>
39               <el-button v-if="!updateWeightView && $hasPermission('analysis:evaluate:update')" @click="updateWeight()">修改权重
40               </el-button>
41             </el-form-item>
42             <el-form-item>
43               <el-button v-if="updateWeightView && $hasPermission('analysis:evaluate:update')" @click="commitUpdateWeight()">确认修改
44               </el-button>
45             </el-form-item>
46           </el-form>
47           <el-table
48               v-loading="dataListLoading"
49               :data="dataList"
50               border
51               @selection-change="dataListSelectionChangeHandle"
52               @sort-change="dataListSortChangeHandle"
53               height="350px"
54               style="width: 100%;">
55             <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
56             <el-table-column prop="code" :label="$t('evaluateIndex.code')" header-align="center"
57                              align="center"></el-table-column>
58             <el-table-column prop="evaluateIndex" :label="$t('evaluateIndex.name')" header-align="center"
59                              align="center"></el-table-column>
60             <el-table-column prop="weight" :label="$t('evaluateIndex.weight')" header-align="center"
61                              align="center">
62               <template slot-scope="scope">
63                 <el-input-number size="mini" v-model="scope.row.weight" :disabled="!updateWeightView"></el-input-number>&nbsp;&nbsp;&nbsp;%
64                 <el-slider size="mini" v-model="scope.row.weight" :disabled="!updateWeightView" style="margin-top: -5px; margin-bottom: -5px;"></el-slider>
65               </template>
66             </el-table-column>
67             <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="160">
68               <template slot-scope="scope">
69                 <el-button type="text" size="small" v-if="$hasPermission('analysis:evaluate:update')"
70                            @click="addOrUpdateHandle(dataForm.pid,scope.row.id)">{{ $t('update') }}
71                 </el-button>
72                 <el-button type="text" size="small" v-if="$hasPermission('analysis:evaluate:update')"
73                            @click="deleteHandle(scope.row.id)">{{ $t('delete') }}
74                 </el-button>
75               </template>
76             </el-table-column>
77           </el-table>
78           <el-pagination
79               :current-page="page"
80               :page-sizes="[10, 20, 50, 100]"
81               :page-size="limit"
82               :total="total"
83               layout="total, sizes, prev, pager, next, jumper"
84               @size-change="pageSizeChangeHandle"
85               @current-change="pageCurrentChangeHandle">
86           </el-pagination>
87           <div ref="chartPie2" style="width: 100%; height: 300px;"></div>
88         </div>
89       </el-card>
90       <!-- 弹窗, 编辑评价指标体系权重 -->
91       <update-system-weight v-if="updateSystemWeightVisible" ref="updateSystemWeight"></update-system-weight>
92       <!-- 弹窗, 新增 / 修改 -->
93       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
94     </div>
95   </div>
96 </template>
97
98 <script>
99   import mixinViewModule from '@/mixins/view-module'
100   import updateSystemWeight from "./update-system-weight";
101   import AddOrUpdate from './index-evaluate-system-add-or-update'
102
103   export default {
104     mixins: [mixinViewModule],
105     data() {
106       return {
107         mixinViewModuleOptions: {
108           getDataListURL: '/iailab-ntt-model/index/evaluate/page',
109           getDataListIsPage: true,
110           deleteURL: '/iailab-ntt-model/index/evaluate',
111           deleteIsBatch: true
112         },
113         updateSystemWeightVisible: false,
114         updateWeightView: false,
115         systemWeight:'',
116         dataForm: {
117           pid:"1"
118         },
119         chartData:[],
120         charLegend:[],
121         systemChartData:[],
122         systemCharLegend:[],
123         dataList: [],
124         chartPie1:{},
125         chartPie2:{},
126       }
127     },
128     components:{
129         updateSystemWeight,
130         AddOrUpdate
131     },
132     mounted() {
133       this.getPie1()
134       this.getPie2()
135     },
136     methods: {
137     // 新增 / 修改
138     addOrUpdateHandle(pid,id) {
139       this.addOrUpdateVisible = true;
140       this.$nextTick(() => {
141         this.$refs.addOrUpdate.init(pid,id);
142       });
143     },
144       updateSystemWeight(){
145           this.updateSystemWeightVisible = true;
146           this.$nextTick(() => {
147           this.$refs.updateSystemWeight.init();
148         });
149       },
150       updateWeight(){
151           this.updateWeightView = true;
152       },
153       commitUpdateWeight(){
154         var sum=0
155         for (var i = 0; i < this.dataList.length; i++) {
156             sum += this.dataList[i].weight;
157             console.log(sum)
158           }
159         if(sum==100){
160           this.$http.post('/iailab-ntt-model/index/evaluate/updataWeight', this.dataList).then(({ data: res }) => {
161             if (res.code==null || res.code !== 0) {
162                 return this.$message.error(res.msg)
163               }
164               this.$message({
165                 message: this.$t('prompt.success'),
166                 type: 'success',
167                 duration: 500,
168               })
169               this.updateWeightView = false;
170               this.getDataList();
171           }).catch(() => {})
172         }else{
173           this.$alert('各权重之和必须为100%', {
174             confirmButtonText: '确定',
175           });
176           }
177       },
178       handleClick(tab, event){
179         if(tab.label=="数量"){
180           this.dataForm.pid=1
181           this.getPie2();
182           this.getDataList()
183         }else if(tab.label=="质量"){
184           this.dataForm.pid=2
185           this.getPie2();
186           this.getDataList()
187       }else if(tab.label=="生产消耗"){
188           this.dataForm.pid=3
189           this.getPie2();
190           this.getDataList()
191       }else if(tab.label=="过程控制"){
192           this.dataForm.pid=4
193           this.getPie2();
194           this.getDataList()
195       }else if(tab.label=="管理"){
196           this.dataForm.pid=5
197           this.getPie2();
198           this.getDataList()
199       }
200       },
201       getPie1() {
202         this.$http.get(`/iailab-ntt-model/index/evaluate/chart/0`).then(({data: res}) => {
203           if (res.code !== 0) {
204             return this.$message.error(res.msg)
205           }
206           this.systemChartData=res.data.series[0].data[0]
207           this.systemCharLegend=res.data.legend
208         this.chartPie1 = this.$echarts.init(this.$refs.chartPie1);
209         let option = {
210           tooltip: {
211             trigger: 'item'
212           },
213           legend: {
214             bottom: 0,
215             left: 'left',
216             orient: 'vertical',
217             data: this.systemCharLegend
218           },
219           series: [
220             {
221               name: '指标体系权重',
222               type: 'pie',
223               radius: ['40%', '70%'],
224               avoidLabelOverlap: false,
225               label: {
226                 show: false,
227                 position: 'center'
228               },
229               emphasis: {
230                 label: {
231                   show: true,
232                   fontSize: 40,
233                   fontWeight: 'bold'
234                 }
235               },
236               labelLine: {
237                 show: false
238               },
239               data: this.systemChartData
240             }
241           ]
242         };
243         this.chartPie1.setOption(option)
244         }).catch(() => {
245         })
246       },
247       getPie2() {
248         this.$http.get(`/iailab-ntt-model/index/evaluate/chart/${this.dataForm.pid}`).then(({data: res}) => {
249           if (res.code !== 0) {
250             return this.$message.error(res.msg)
251           }
252           this.chartData=res.data.series[0].data[0]
253           this.charLegend=res.data.legend
254         this.chartPie2 = this.$echarts.init(this.$refs.chartPie2);
255         let option = {
256           tooltip: {
257             trigger: 'item'
258           },
259           legend: {
260             bottom: 0,
261             left: 'left',
262             orient: 'vertical',
263             data: this.charLegend
264           },
265           series: [
266             {
267               name: '指标权重',
268               type: 'pie',
269               radius: ['40%', '70%'],
270               avoidLabelOverlap: false,
271               emphasis: {
272                 label: {
273                   show: true,
274                   fontSize: 40,
275                   fontWeight: 'bold'
276                 }
277               },
278               data: this.chartData,
279               emphasis: {
280                 itemStyle: {
281                   shadowBlur: 10,
282                   shadowOffsetX: 0,
283                   shadowColor: 'rgba(0, 0, 0, 0.5)'
284                 }
285               }
286             }
287           ]
288         };
289         console.log(option)
290         this.chartPie2.setOption(option)
291         }).catch(() => {
292         })
293       }
294     }
295   };
296 </script>
297 <style>
298   .scrollable-container {
299     overflow: auto;
300     width: 100%;
301     margin: -10px;
302     height: calc(calc(100vh - 48px - 38px - 35px - 100px));
303
304   }
305
306   .box-card {
307     width: 100%;
308     height: 100%;
309   }
310
311   .eval-system-right {
312     width: 18%;
313     height: 100%;
314   }
315
316   .eval-system-mid {
317     width: 82%;
318     height: 100%;
319   }
320
321   .eval-system-left {
322     width: 18%;
323     height: 100%;
324     padding-right: 10px;
325   }
326
327   .mod-prod-eval-system {
328     width: 100%;
329     height: calc(calc(100vh - 48px - 38px - 35px));
330     display: flex;
331     flex-direction: row;
332   }
333 </style>