|
|
@@ -232,13 +232,47 @@
|
|
|
url
|
|
|
})
|
|
|
},
|
|
|
- getPerillPJ(){
|
|
|
- this.$api.get('/core/teammember/que/questionnaireStats').then(res=>{
|
|
|
- if(res.data.code!==0) return
|
|
|
- this.perillPJ = res.data.data||{};
|
|
|
- this.perillPJ.sum = this.perillPJ?.participated || 0;
|
|
|
- })
|
|
|
- },
|
|
|
+ getPerillPJ(){
|
|
|
+ this.$api.get('/core/teammember/que/questionnaireStats').then(res=>{
|
|
|
+ if(res.data.code!==0) return
|
|
|
+ const stats = res.data.data||{};
|
|
|
+ const hasUsableStats = stats.participated !== undefined
|
|
|
+ && stats.received !== undefined
|
|
|
+ && stats.created !== undefined
|
|
|
+ && (Number(stats.participated||0) > 0
|
|
|
+ || Number(stats.received||0) > 0
|
|
|
+ || Number(stats.created||0) > 0);
|
|
|
+ if(hasUsableStats){
|
|
|
+ this.perillPJ = Object.assign({}, stats, {sum:Number(stats.participated||0)});
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.loadPerillStatsFallback();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ loadPerillStatsFallback(){
|
|
|
+ Promise.all([
|
|
|
+ this.$api.get('/core/teammember/que/listByUser'),
|
|
|
+ this.$api.get('/core/teammember/que/personalList',{teamName:''}),
|
|
|
+ this.$api.get('/core/teammember/que/createList',{teamName:''})
|
|
|
+ ]).then(([participatedRes, receivedRes, createdRes])=>{
|
|
|
+ const uniqueTaskCount = response => {
|
|
|
+ const result = response && response.data && response.data.code===0
|
|
|
+ ? response.data.data : [];
|
|
|
+ return new Set((result||[]).map(item =>
|
|
|
+ item.teamQuestionnaireId || item.team_questionnaire_id || item.id
|
|
|
+ ).filter(Boolean)).size;
|
|
|
+ };
|
|
|
+ const participated = uniqueTaskCount(participatedRes);
|
|
|
+ this.perillPJ = {
|
|
|
+ participated,
|
|
|
+ received:uniqueTaskCount(receivedRes),
|
|
|
+ created:uniqueTaskCount(createdRes),
|
|
|
+ sum:participated
|
|
|
+ };
|
|
|
+ }).catch(()=>{
|
|
|
+ this.perillPJ = {participated:0,received:0,created:0,sum:0};
|
|
|
+ });
|
|
|
+ },
|
|
|
getPerillBG(){
|
|
|
this.$api.get('/core/report/reportStats').then(res=>{
|
|
|
if(res.data.code!==0) return
|