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,8 +102,8 @@ | ||
| 102 | </div> | 102 | </div> |
| 103 | </div> | 103 | </div> |
| 104 | </div> | 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 | <div class="panel-title"> | 107 | <div class="panel-title"> |
| 108 | <span>能力统计图</span> | 108 | <span>能力统计图</span> |
| 109 | <img src="/static/resume/female/resume11.png" alt="" /> | 109 | <img src="/static/resume/female/resume11.png" alt="" /> |
| @@ -112,7 +112,7 @@ | @@ -112,7 +112,7 @@ | ||
| 112 | <div id="echarts1"></div> | 112 | <div id="echarts1"></div> |
| 113 | </div> | 113 | </div> |
| 114 | </div> | 114 | </div> |
| 115 | - <div class="panel"> | 115 | + <div class="panel" v-if="abilityEchart2VisibleComputed"> |
| 116 | <div class="panel-title"> | 116 | <div class="panel-title"> |
| 117 | <span>能力统计图</span> | 117 | <span>能力统计图</span> |
| 118 | <img src="/static/resume/female/resume11.png" alt="" /> | 118 | <img src="/static/resume/female/resume11.png" alt="" /> |
| @@ -121,7 +121,7 @@ | @@ -121,7 +121,7 @@ | ||
| 121 | <div id="echarts2"></div> | 121 | <div id="echarts2"></div> |
| 122 | </div> | 122 | </div> |
| 123 | </div> | 123 | </div> |
| 124 | - <div class="panel"> | 124 | + <div class="panel" v-if="natureEchartVisibleComputed"> |
| 125 | <div class="panel-title"> | 125 | <div class="panel-title"> |
| 126 | <span>性格统计图</span> | 126 | <span>性格统计图</span> |
| 127 | <img src="/static/resume/female/resume12.png" alt="" /> | 127 | <img src="/static/resume/female/resume12.png" alt="" /> |
| @@ -306,12 +306,27 @@ export default { | @@ -306,12 +306,27 @@ export default { | ||
| 306 | }, | 306 | }, |
| 307 | ], | 307 | ], |
| 308 | }, | 308 | }, |
| 309 | - natureList: {}, | 309 | + natureList: [], |
| 310 | abilityList: [], | 310 | abilityList: [], |
| 311 | user: {}, | 311 | user: {}, |
| 312 | }; | 312 | }; |
| 313 | }, | 313 | }, |
| 314 | computed: { | 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 | userDetail() { | 330 | userDetail() { |
| 316 | let user = {...this.user}; | 331 | let user = {...this.user}; |
| 317 | user.educationalExperience = JSON.parse(user.educationalExperience || '[]'); | 332 | user.educationalExperience = JSON.parse(user.educationalExperience || '[]'); |
| @@ -378,7 +393,11 @@ export default { | @@ -378,7 +393,11 @@ export default { | ||
| 378 | this.initNengliEchart(); | 393 | this.initNengliEchart(); |
| 379 | }, | 394 | }, |
| 380 | initXinggeEchart(list) { | 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 | this.echartOption3.radar.indicator = list.map((t) => { | 401 | this.echartOption3.radar.indicator = list.map((t) => { |
| 383 | return { name: t.title, max: 100 }; | 402 | return { name: t.title, max: 100 }; |
| 384 | }); | 403 | }); |
| @@ -387,8 +406,12 @@ export default { | @@ -387,8 +406,12 @@ export default { | ||
| 387 | console.log("this.echartOption3", this.echartOption3); | 406 | console.log("this.echartOption3", this.echartOption3); |
| 388 | }, | 407 | }, |
| 389 | initNengliEchart(list) { | 408 | initNengliEchart(list) { |
| 409 | + let dom = document.getElementById("echarts1"); | ||
| 410 | + if(!dom){ | ||
| 411 | + return; | ||
| 412 | + } | ||
| 390 | //第一个echart图 | 413 | //第一个echart图 |
| 391 | - let myChart = echarts.init(document.getElementById("echarts1")); | 414 | + let myChart = echarts.init(dom); |
| 392 | let list1 = list.slice(0, 6); | 415 | let list1 = list.slice(0, 6); |
| 393 | this.echartOption1.xAxis[0].data = list1.map((t) => t.title); | 416 | this.echartOption1.xAxis[0].data = list1.map((t) => t.title); |
| 394 | this.echartOption1.series[0].data = list1.map((t) => t.value); | 417 | this.echartOption1.series[0].data = list1.map((t) => t.value); |
src/views/resume/malestaff.vue
| @@ -82,8 +82,8 @@ | @@ -82,8 +82,8 @@ | ||
| 82 | </div> | 82 | </div> |
| 83 | </div> | 83 | </div> |
| 84 | </div> | 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 | <div class="panel-title"> | 87 | <div class="panel-title"> |
| 88 | <span>能力统计图</span> | 88 | <span>能力统计图</span> |
| 89 | <img src="/static/resume/male/resume11.png" alt="" /> | 89 | <img src="/static/resume/male/resume11.png" alt="" /> |
| @@ -92,7 +92,7 @@ | @@ -92,7 +92,7 @@ | ||
| 92 | <div id="echarts1"></div> | 92 | <div id="echarts1"></div> |
| 93 | </div> | 93 | </div> |
| 94 | </div> | 94 | </div> |
| 95 | - <div class="panel"> | 95 | + <div class="panel" v-if="abilityEchart2VisibleComputed"> |
| 96 | <div class="panel-title"> | 96 | <div class="panel-title"> |
| 97 | <span>能力统计图</span> | 97 | <span>能力统计图</span> |
| 98 | <img src="/static/resume/male/resume11.png" alt="" /> | 98 | <img src="/static/resume/male/resume11.png" alt="" /> |
| @@ -101,7 +101,7 @@ | @@ -101,7 +101,7 @@ | ||
| 101 | <div id="echarts2"></div> | 101 | <div id="echarts2"></div> |
| 102 | </div> | 102 | </div> |
| 103 | </div> | 103 | </div> |
| 104 | - <div class="panel"> | 104 | + <div class="panel" v-if="natureEchartVisibleComputed"> |
| 105 | <div class="panel-title"> | 105 | <div class="panel-title"> |
| 106 | <span>性格统计图</span> | 106 | <span>性格统计图</span> |
| 107 | <img src="/static/resume/male/resume12.png" alt="" /> | 107 | <img src="/static/resume/male/resume12.png" alt="" /> |
| @@ -286,12 +286,27 @@ export default { | @@ -286,12 +286,27 @@ export default { | ||
| 286 | }, | 286 | }, |
| 287 | ], | 287 | ], |
| 288 | }, | 288 | }, |
| 289 | - natureList: {}, | 289 | + natureList: [], |
| 290 | abilityList: [], | 290 | abilityList: [], |
| 291 | user: {}, | 291 | user: {}, |
| 292 | }; | 292 | }; |
| 293 | }, | 293 | }, |
| 294 | computed: { | 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 | userDetail() { | 310 | userDetail() { |
| 296 | let user = {...this.user}; | 311 | let user = {...this.user}; |
| 297 | user.educationalExperience = JSON.parse(user.educationalExperience || '[]'); | 312 | user.educationalExperience = JSON.parse(user.educationalExperience || '[]'); |
| @@ -358,17 +373,25 @@ export default { | @@ -358,17 +373,25 @@ export default { | ||
| 358 | this.initNengliEchart(); | 373 | this.initNengliEchart(); |
| 359 | }, | 374 | }, |
| 360 | initXinggeEchart(list) { | 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 | this.echartOption3.radar.indicator = list.map((t) => { | 382 | this.echartOption3.radar.indicator = list.map((t) => { |
| 363 | return { name: t.title, max: 100 }; | 383 | return { name: t.title, max: 100 }; |
| 364 | }); | 384 | }); |
| 365 | this.echartOption3.series[0].data[0].value = list.map((t) => t.value); | 385 | this.echartOption3.series[0].data[0].value = list.map((t) => t.value); |
| 366 | myChart.setOption(this.echartOption3); | 386 | myChart.setOption(this.echartOption3); |
| 367 | - console.log("this.echartOption3", this.echartOption3); | ||
| 368 | }, | 387 | }, |
| 369 | initNengliEchart(list) { | 388 | initNengliEchart(list) { |
| 389 | + let dom = document.getElementById("echarts1"); | ||
| 390 | + if(!dom){ | ||
| 391 | + return; | ||
| 392 | + } | ||
| 370 | //第一个echart图 | 393 | //第一个echart图 |
| 371 | - let myChart = echarts.init(document.getElementById("echarts1")); | 394 | + let myChart = echarts.init(dom); |
| 372 | let list1 = list.slice(0, 6); | 395 | let list1 = list.slice(0, 6); |
| 373 | this.echartOption1.xAxis[0].data = list1.map((t) => t.title); | 396 | this.echartOption1.xAxis[0].data = list1.map((t) => t.title); |
| 374 | this.echartOption1.series[0].data = list1.map((t) => t.value); | 397 | this.echartOption1.series[0].data = list1.map((t) => t.value); |