Commit 6fb7bd312585aad29060f307e7eeb8faba3e83d1
1 parent
88e9d1c0
【优化】能力统计图如果没有数据就不显示
Showing
2 changed files
with
61 additions
and
15 deletions
src/views/resume/femalestaff.vue
| ... | ... | @@ -102,8 +102,8 @@ |
| 102 | 102 | </div> |
| 103 | 103 | </div> |
| 104 | 104 | </div> |
| 105 | - <div class="bottom-panel flex1"> | |
| 106 | - <div class="panel"> | |
| 105 | + <div class="bottom-panel flex1" v-if="abilityEchart1VisibleComputed || abilityEchart2VisibleComputed || natureEchartVisibleComputed"> | |
| 106 | + <div class="panel" v-if="abilityEchart1VisibleComputed"> | |
| 107 | 107 | <div class="panel-title"> |
| 108 | 108 | <span>能力统计图</span> |
| 109 | 109 | <img src="/static/resume/female/resume11.png" alt="" /> |
| ... | ... | @@ -112,7 +112,7 @@ |
| 112 | 112 | <div id="echarts1"></div> |
| 113 | 113 | </div> |
| 114 | 114 | </div> |
| 115 | - <div class="panel"> | |
| 115 | + <div class="panel" v-if="abilityEchart2VisibleComputed"> | |
| 116 | 116 | <div class="panel-title"> |
| 117 | 117 | <span>能力统计图</span> |
| 118 | 118 | <img src="/static/resume/female/resume11.png" alt="" /> |
| ... | ... | @@ -121,7 +121,7 @@ |
| 121 | 121 | <div id="echarts2"></div> |
| 122 | 122 | </div> |
| 123 | 123 | </div> |
| 124 | - <div class="panel"> | |
| 124 | + <div class="panel" v-if="natureEchartVisibleComputed"> | |
| 125 | 125 | <div class="panel-title"> |
| 126 | 126 | <span>性格统计图</span> |
| 127 | 127 | <img src="/static/resume/female/resume12.png" alt="" /> |
| ... | ... | @@ -306,12 +306,27 @@ export default { |
| 306 | 306 | }, |
| 307 | 307 | ], |
| 308 | 308 | }, |
| 309 | - natureList: {}, | |
| 309 | + natureList: [], | |
| 310 | 310 | abilityList: [], |
| 311 | 311 | user: {}, |
| 312 | 312 | }; |
| 313 | 313 | }, |
| 314 | 314 | computed: { |
| 315 | + abilityEchart1VisibleComputed(){ | |
| 316 | + return this.abilityList.reduce((total,item)=>{ | |
| 317 | + return total + item.value; | |
| 318 | + },0)>0; | |
| 319 | + }, | |
| 320 | + abilityEchart2VisibleComputed(){ | |
| 321 | + return this.abilityList.length>6 && this.abilityList.slice(6).reduce((total,item)=>{ | |
| 322 | + return total + item.value; | |
| 323 | + },0)>0; | |
| 324 | + }, | |
| 325 | + natureEchartVisibleComputed(){ | |
| 326 | + return this.natureList.reduce((total,item)=>{ | |
| 327 | + return total + item.value; | |
| 328 | + },0)>0; | |
| 329 | + }, | |
| 315 | 330 | userDetail() { |
| 316 | 331 | let user = {...this.user}; |
| 317 | 332 | user.educationalExperience = JSON.parse(user.educationalExperience || '[]'); |
| ... | ... | @@ -378,7 +393,11 @@ export default { |
| 378 | 393 | this.initNengliEchart(); |
| 379 | 394 | }, |
| 380 | 395 | initXinggeEchart(list) { |
| 381 | - let myChart = echarts.init(document.getElementById("echarts3")); | |
| 396 | + let dom = document.getElementById("echarts3"); | |
| 397 | + if(!dom){ | |
| 398 | + return; | |
| 399 | + } | |
| 400 | + let myChart = echarts.init(dom); | |
| 382 | 401 | this.echartOption3.radar.indicator = list.map((t) => { |
| 383 | 402 | return { name: t.title, max: 100 }; |
| 384 | 403 | }); |
| ... | ... | @@ -387,8 +406,12 @@ export default { |
| 387 | 406 | console.log("this.echartOption3", this.echartOption3); |
| 388 | 407 | }, |
| 389 | 408 | initNengliEchart(list) { |
| 409 | + let dom = document.getElementById("echarts1"); | |
| 410 | + if(!dom){ | |
| 411 | + return; | |
| 412 | + } | |
| 390 | 413 | //第一个echart图 |
| 391 | - let myChart = echarts.init(document.getElementById("echarts1")); | |
| 414 | + let myChart = echarts.init(dom); | |
| 392 | 415 | let list1 = list.slice(0, 6); |
| 393 | 416 | this.echartOption1.xAxis[0].data = list1.map((t) => t.title); |
| 394 | 417 | this.echartOption1.series[0].data = list1.map((t) => t.value); | ... | ... |
src/views/resume/malestaff.vue
| ... | ... | @@ -82,8 +82,8 @@ |
| 82 | 82 | </div> |
| 83 | 83 | </div> |
| 84 | 84 | </div> |
| 85 | - <div class="bottom-panel flex1"> | |
| 86 | - <div class="panel"> | |
| 85 | + <div class="bottom-panel flex1" v-if="abilityEchart1VisibleComputed || abilityEchart2VisibleComputed || natureEchartVisibleComputed"> | |
| 86 | + <div class="panel" v-if="abilityEchart1VisibleComputed"> | |
| 87 | 87 | <div class="panel-title"> |
| 88 | 88 | <span>能力统计图</span> |
| 89 | 89 | <img src="/static/resume/male/resume11.png" alt="" /> |
| ... | ... | @@ -92,7 +92,7 @@ |
| 92 | 92 | <div id="echarts1"></div> |
| 93 | 93 | </div> |
| 94 | 94 | </div> |
| 95 | - <div class="panel"> | |
| 95 | + <div class="panel" v-if="abilityEchart2VisibleComputed"> | |
| 96 | 96 | <div class="panel-title"> |
| 97 | 97 | <span>能力统计图</span> |
| 98 | 98 | <img src="/static/resume/male/resume11.png" alt="" /> |
| ... | ... | @@ -101,7 +101,7 @@ |
| 101 | 101 | <div id="echarts2"></div> |
| 102 | 102 | </div> |
| 103 | 103 | </div> |
| 104 | - <div class="panel"> | |
| 104 | + <div class="panel" v-if="natureEchartVisibleComputed"> | |
| 105 | 105 | <div class="panel-title"> |
| 106 | 106 | <span>性格统计图</span> |
| 107 | 107 | <img src="/static/resume/male/resume12.png" alt="" /> |
| ... | ... | @@ -286,12 +286,27 @@ export default { |
| 286 | 286 | }, |
| 287 | 287 | ], |
| 288 | 288 | }, |
| 289 | - natureList: {}, | |
| 289 | + natureList: [], | |
| 290 | 290 | abilityList: [], |
| 291 | 291 | user: {}, |
| 292 | 292 | }; |
| 293 | 293 | }, |
| 294 | 294 | computed: { |
| 295 | + abilityEchart1VisibleComputed(){ | |
| 296 | + return this.abilityList.reduce((total,item)=>{ | |
| 297 | + return total + item.value; | |
| 298 | + },0)>0; | |
| 299 | + }, | |
| 300 | + abilityEchart2VisibleComputed(){ | |
| 301 | + return this.abilityList.length>6 && this.abilityList.slice(6).reduce((total,item)=>{ | |
| 302 | + return total + item.value; | |
| 303 | + },0)>0; | |
| 304 | + }, | |
| 305 | + natureEchartVisibleComputed(){ | |
| 306 | + return this.natureList.reduce((total,item)=>{ | |
| 307 | + return total + item.value; | |
| 308 | + },0)>0; | |
| 309 | + }, | |
| 295 | 310 | userDetail() { |
| 296 | 311 | let user = {...this.user}; |
| 297 | 312 | user.educationalExperience = JSON.parse(user.educationalExperience || '[]'); |
| ... | ... | @@ -358,17 +373,25 @@ export default { |
| 358 | 373 | this.initNengliEchart(); |
| 359 | 374 | }, |
| 360 | 375 | initXinggeEchart(list) { |
| 361 | - let myChart = echarts.init(document.getElementById("echarts3")); | |
| 376 | + let dom = document.getElementById("echarts3"); | |
| 377 | + if(!dom){ | |
| 378 | + return; | |
| 379 | + } | |
| 380 | + let myChart = echarts.init(dom); | |
| 381 | + if(myChart) | |
| 362 | 382 | this.echartOption3.radar.indicator = list.map((t) => { |
| 363 | 383 | return { name: t.title, max: 100 }; |
| 364 | 384 | }); |
| 365 | 385 | this.echartOption3.series[0].data[0].value = list.map((t) => t.value); |
| 366 | 386 | myChart.setOption(this.echartOption3); |
| 367 | - console.log("this.echartOption3", this.echartOption3); | |
| 368 | 387 | }, |
| 369 | 388 | initNengliEchart(list) { |
| 389 | + let dom = document.getElementById("echarts1"); | |
| 390 | + if(!dom){ | |
| 391 | + return; | |
| 392 | + } | |
| 370 | 393 | //第一个echart图 |
| 371 | - let myChart = echarts.init(document.getElementById("echarts1")); | |
| 394 | + let myChart = echarts.init(dom); | |
| 372 | 395 | let list1 = list.slice(0, 6); |
| 373 | 396 | this.echartOption1.xAxis[0].data = list1.map((t) => t.title); |
| 374 | 397 | this.echartOption1.series[0].data = list1.map((t) => t.value); | ... | ... |