<template>
|
<div>
|
<el-tabs v-model="activeName" type="card">
|
<el-tab-pane v-for="item in ranges" :label="item" :name="item"> </el-tab-pane>
|
</el-tabs>
|
<div class="proList">
|
<el-card class="card-style" shadow="hover">
|
<el-descriptions v-loading="loading">
|
<el-descriptions-item label="总出现次数">{{ curProList.length }}</el-descriptions-item>
|
<!-- <el-descriptions-item label="复现率">{{ repeteRate }}%</el-descriptions-item> -->
|
</el-descriptions>
|
<!-- <el-descriptions v-loading="loading" column="3">
|
<div v-for="pro in curProList">
|
<el-descriptions-item>{{ pro.problemname }}</el-descriptions-item>
|
<el-descriptions-item label="任务名称">{{ pro._stName }}</el-descriptions-item>
|
<el-descriptions-item>
|
<el-button link type="primary" @click="info(pro)">详情</el-button>
|
</el-descriptions-item>
|
</div>
|
</el-descriptions> -->
|
<el-table :data="curProList" style="width: 100%">
|
<el-table-column type="index" width="50" />
|
<el-table-column prop="problemname" label="问题"/>
|
<el-table-column prop="_time" label="时间" width="250" />
|
<el-table-column label="操作" width="180">
|
<template v-slot="scope">
|
<el-button link type="primary" @click="info(scope.row)">详情</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-card>
|
<el-dialog
|
title="预览"
|
v-model="proAddOrUpdDialogVisible"
|
:before-close="proAddOrUpdDialogClose"
|
width="80%"
|
>
|
<CompProblemAddOrUpd
|
v-if="proAddOrUpdDialogVisible"
|
:subtask="subtask"
|
:topTask="topTask"
|
:problem="previewPro"
|
:readonly="true"
|
ref="compProblemAddOrUpdRef"
|
/>
|
</el-dialog>
|
</div>
|
</div>
|
</template>
|
<script>
|
import CompProblemAddOrUpd from './CompProblemAddOrUpd.vue';
|
import taskApi from '@/api/fysp/taskApi';
|
import { useCloned } from '@vueuse/core';
|
export default {
|
computed: {
|
// repeteRate() {
|
// return this.curProList.length !== 0 ? (this.curProList.length - 1) / this.subtaskCount * 1.0 : 0
|
// },
|
},
|
props: {
|
problem: {
|
type: Object,
|
default: () => {}
|
},
|
topTask: {
|
type: Object,
|
default: () => {
|
return {};
|
}
|
},
|
subtask: {
|
type: Object,
|
default: () => {
|
return {};
|
}
|
}
|
},
|
watch: {
|
activeName: {
|
handler(newObj, oldObj) {
|
this.handleClick();
|
}
|
}
|
},
|
components: {
|
CompProblemAddOrUpd
|
},
|
mounted() {
|
|
this.deepCopyPro = useCloned(this.problem).cloned.value;
|
this.getRecentPros();
|
},
|
data() {
|
return {
|
proAddOrUpdDialogVisible: false,
|
previewPro: {},
|
// 加载统计信息
|
loading: false,
|
// 时间和问题对象列表
|
timeProMap: new Map(),
|
curProList: [],
|
activeName: '近三个月',
|
ranges: ['近三个月', '近半年', '近一年'],
|
deepCopyPro: {}
|
};
|
},
|
methods: {
|
// 转换为北京时间
|
convertTime(time) {
|
time.setHours(time.getHours);
|
return time;
|
},
|
// 打开详情页面
|
info(pro) {
|
this.previewPro = pro;
|
this.proAddOrUpdDialogVisible = true;
|
},
|
// 关闭详情弹窗
|
proAddOrUpdDialogClose() {
|
this.proAddOrUpdDialogVisible = false;
|
},
|
// 切换时间范围
|
handleClick() {
|
this.getRecentPros();
|
},
|
updateSubtask() {},
|
generateQueryParam() {
|
// 今天的日期
|
const today = new Date();
|
// 三个月前
|
const threeMonthsAgo = new Date(today);
|
threeMonthsAgo.setMonth(today.getMonth() - 3);
|
// 计算半年前的日期
|
const sixMonthsAgo = new Date(today);
|
sixMonthsAgo.setMonth(today.getMonth() - 6);
|
// 计算一年前的日期
|
const oneYearAgo = new Date(today);
|
oneYearAgo.setFullYear(today.getFullYear() - 1);
|
|
return {
|
startTime:
|
this.activeName === '近三个月'
|
? this.$fm.formatYMDH(threeMonthsAgo)
|
: this.activeName === '近半年'
|
? this.$fm.formatYMDH(sixMonthsAgo)
|
: this.$fm.formatYMDH(oneYearAgo),
|
endTime: this.$fm.formatYMDH(today),
|
sceneId: this.deepCopyPro.sguid
|
};
|
},
|
/**
|
* 获取近期情况
|
* */
|
async getRecentPros() {
|
this.loading = true;
|
this.subtaskCount = 0
|
// 获取子任务列表
|
await taskApi.getSubtaskByScene(this.generateQueryParam()).then((subtasks) => {
|
this.curProList = [];
|
if (subtasks) {
|
subtasks.forEach((subtask) => {
|
// 获取问题列表
|
this.getProBySubtask(subtask);
|
});
|
}
|
});
|
// 额外处理
|
this.curProList.sort((o1, o2) => o2.getTime() - o1.getTime());
|
this.loading = false;
|
},
|
// 根据子任务获取里面的问题列表
|
async getProBySubtask(subtask) {
|
taskApi.getProBySubtask(subtask.stGuid).then((pros) => {
|
if (pros) {
|
pros.forEach((pro) => {
|
if (pro.ptguid == this.deepCopyPro.ptguid) {
|
pro._stName = subtask.stName;
|
pro._time = this.$fm.formatYM(subtask.stPlanTime)
|
this.curProList.push(pro);
|
}
|
});
|
}
|
});
|
}
|
}
|
};
|
</script>
|
<style scoped>
|
.problem-style {
|
margin-bottom: 10px;
|
}
|
</style>
|