Browse Source

优化

master
陈裕财 3 years ago
parent
commit
ba69fd139e
  1. 2
      src/api/xm/core/xmTestCase.js
  2. 25
      src/api/xm/rpt.js
  3. 2
      src/views/xm/rpt/product/menuSort.vue
  4. 22
      src/views/xm/rpt/product/questionSort.vue
  5. 11
      src/views/xm/rpt/reportIndex.vue
  6. 342
      src/views/xm/rpt/testCase/testCaseSort.vue

2
src/api/xm/core/xmTestCase.js

@ -30,6 +30,8 @@ export const addXmTestCase = params => { return axios.post(`${base}/xm/core/xmTe
//批量修改某些字段
export const editSomeFieldsXmTestCase = params => { return axios.post(`${base}/xm/core/xmTestCase/editSomeFields`, params); };
//测试用例排行榜
export const getXmTestCaseSort = params => { return axios.get(`${base}/xm/core/xmTestCase/getXmTestCaseSort`, { params: params }); };
/**-------------------------前端mng|add|edit界面公共函数---------------请写在下面----------------------------------------------- */

25
src/api/xm/rpt.js

@ -0,0 +1,25 @@
//格式化柱状图底部名称太长换行
export const formatterLabel = (params) => {
var newParamsName = ''
const paramsNameNumber = params.length
const provideNumber = 4 // 单行显示文字个数
const rowNumber = Math.ceil(paramsNameNumber / provideNumber)
if (paramsNameNumber > provideNumber) {
for (let p = 0; p < rowNumber; p++) {
var tempStr = ''
var start = p * provideNumber
var end = start + provideNumber
if (p === rowNumber - 1) {
tempStr = params.substring(start, paramsNameNumber)
} else {
tempStr = params.substring(start, end) + '\n'
}
newParamsName += tempStr
}
} else {
newParamsName = params
}
return newParamsName
};

2
src/views/xm/rpt/product/menuSort.vue

@ -10,7 +10,7 @@
<el-col :span="6" class="border">
<el-form :model="filters" class="padding" :style="{width:'100%',maxHeight:maxTableHeight+'px',overflow: 'auto'}" ref="filtersRef">
<el-form-item label="分组属性">
<el-select v-model="groupBy" @change="onXmMenuSomeFieldsChange('groupBy',$event)" clearable>
<el-select v-model="groupBy" @change="onXmMenuSomeFieldsChange('groupBy',$event)">
<el-option v-for="i in this.groupBys" :label="i.name" :key="i.id" :value="i.id"></el-option>
</el-select>
</el-form-item>

22
src/views/xm/rpt/product/questionSort.vue

@ -10,7 +10,7 @@
<el-col :span="6" class="border">
<el-form :model="filters" class="padding" :style="{width:'100%',maxHeight:maxTableHeight+'px',overflow: 'auto'}" ref="filtersRef">
<el-form-item label="分组属性">
<el-select v-model="groupBy" @change="onXmQuestionSomeFieldsChange('groupBy',$event)" clearable>
<el-select v-model="groupBy" @change="onXmQuestionSomeFieldsChange('groupBy',$event)">
<el-option v-for="i in this.groupBys" :label="i.name" :key="i.id" :value="i.id"></el-option>
</el-select>
</el-form-item>
@ -97,6 +97,7 @@
import { initSimpleDicts } from '@/api/mdp/meta/item';//
import { mapGetters } from 'vuex'
import {formatterLabel} from '@/api/xm/rpt.js';//
import { getXmQuestionSort } from '@/api/xm/core/xmQuestion';
import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//
@ -255,7 +256,10 @@
calculable: true,
xAxis: {
type: 'category',
data: this.legendCpd
data: this.legendCpd,
axisLabel: {
formatter: formatterLabel
}
},
yAxis: {
type: 'value'
@ -340,7 +344,19 @@
params.orderBy = orderBys.join(",");
}
getXmQuestionSort(params).then(res=>{
this.xmQuestionSorts=res.data.data
var data=res.data.data
if(data){
data.sort((a,b)=>{
if(a.value<b.value){
return 1
}else if(a.value>b.value){
return -1
}else{
return 0
}
})
}
this.xmQuestionSorts=data
})
},

11
src/views/xm/rpt/reportIndex.vue

@ -82,6 +82,10 @@
<xm-test-plan-case-user-dist v-if="showRptRef=='xmTestPlanCaseUserDist'" :category="filters.category" ref="xmTestPlanCaseUserDist" :xm-product="xmProduct" :xm-project="xmProject" :xm-test-casedb="xmTestCasedb" :xm-test-plan="xmTestPlan" :xm-iteration="xmIteration"></xm-test-plan-case-user-dist>
<xm-test-day-times-calc v-if="showRptRef=='xmTestDayTimesCalc'" :category="filters.category" ref="xmTestDayTimesCalc" :xm-product="xmProduct" :xm-project="xmProject" :xm-test-casedb="xmTestCasedb" :xm-test-plan="xmTestPlan" :xm-iteration="xmIteration"></xm-test-day-times-calc>
<xm-test-case-to-plan-calc v-if="showRptRef=='xmTestCaseToPlanCalc'" :category="filters.category" ref="xmTestCaseToPlanCalc" :xm-product="xmProduct" :xm-project="xmProject" :xm-test-casedb="xmTestCasedb" :xm-test-plan="xmTestPlan" :xm-iteration="xmIteration"></xm-test-case-to-plan-calc>
<xm-test-case-sort key="xmTestCaseSort" v-if="showRptRef=='xmTestCaseSort'" :category="filters.category" ref="xmTestCaseSort" :xm-product="xmProduct" :xm-project="xmProject" :xm-test-casedb="xmTestCasedb" :xm-iteration="xmIteration"/>
<xm-test-case-sort key="xmTestCaseCuserSort" v-if="showRptRef=='xmTestCaseCuserSort'" init-group-by="cuserid" :category="filters.category" ref="xmTestCaseSort" :xm-product="xmProduct" :xm-project="xmProject" :xm-test-casedb="xmTestCasedb" :xm-iteration="xmIteration"/>
<xm-test-case-sort key="xmTestCaseFuncSort" v-if="showRptRef=='xmTestCaseFuncSort'" init-group-by="func_id" :category="filters.category" ref="xmTestCaseSort" :xm-product="xmProduct" :xm-project="xmProject" :xm-test-casedb="xmTestCasedb" :xm-iteration="xmIteration"/>
<xm-test-case-sort key="xmTestCaseMenuSort" v-if="showRptRef=='xmTestCaseMenuSort'" init-group-by="menu_id" :category="filters.category" ref="xmTestCaseSort" :xm-product="xmProduct" :xm-project="xmProject" :xm-test-casedb="xmTestCasedb" :xm-iteration="xmIteration"/>
<!--企业级报表-->
<xm-branch-question-day-trend v-if="showRptRef=='xmBranchQuestionDayTrend'" :category="filters.category" ref="xmBranchQuestionDayTrend" :xm-product="xmProduct" :xm-project="xmProject" :xm-iteration="xmIteration"></xm-branch-question-day-trend>
@ -135,6 +139,7 @@
import xmTestPlanCaseUserDist from './testPlan/testPlanCaseUserDist'
import xmTestDayTimesCalc from './testPlan/testDayTimesCalc'
import xmTestCaseToPlanCalc from './testPlan/testCaseToPlanCalc'
import xmTestCaseSort from './testCase/testCaseSort'
import xmIterationMenuDayTrend from './iteration/menuDayTrend'
@ -168,7 +173,8 @@
xmTestPlanCaseExecStatusDist,xmTestPlanCaseUserDist,xmQuestionRetestDist,xmQuestionStateDist,
xmQuestionAskUserSort,xmQuestionHandlerUserSort,xmQuestionFuncSort,xmQuestionMenuSort,xmTestDayTimesCalc,xmTestCaseToPlanCalc,
xmBranchWorkItemDayList,xmBranchQuestionDayTrend,xmBranchQuestionDayAccumulate,xmBranchMenuDayTrend,xmBranchMenuDayAccumulate
xmBranchWorkItemDayList,xmBranchQuestionDayTrend,xmBranchQuestionDayAccumulate,xmBranchMenuDayTrend,xmBranchMenuDayAccumulate,
xmTestCaseSort,
},
props:['xmProduct','xmIteration','xmProject','xmTestCasedb','xmTestPlan','category'],
@ -253,6 +259,9 @@
//
{isChecked:false,rptName:'测试用例规划分析',category:'测试级,项目级,产品级,迭代级,企业级',ref:'xmTestCaseToPlanCalc',desc:'显示用例被规划到测试计划中的次数统计',img:pieSimple },
{isChecked:false,rptName:'测试用例需求覆盖分析',category:'测试级,项目级,产品级,迭代级,企业级',ref:'xmTestCaseMenuSort',desc:'统计测试用例需求覆盖情况',img:bar },
{isChecked:false,rptName:'测试用例模块覆盖分析',category:'测试级,项目级,产品级,迭代级,企业级',ref:'xmTestCaseFuncSort',desc:'统计测试用例覆盖各个模块的情况',img:bar },
{isChecked:false,rptName:'测试用例负责人排行榜',category:'测试级,项目级,产品级,迭代级,企业级',ref:'xmTestCaseCuserSort',desc:'统计测试团队每个人负责的测试用例数并进行排序',img:bar },
{isChecked:false,rptName:'测试用例执行状态分布',category:'测试级,项目级,产品级,迭代级,企业级',ref:'xmTestPlanCaseExecStatusDist',desc:'按测试用例执行结果统计,通过、失败、忽略、阻塞',img:pieSimple },
{isChecked:false,rptName:'测试用例执行用户分布',category:'测试级,项目级,产品级,迭代级,企业级',ref:'xmTestPlanCaseUserDist',desc:'统计测试用例负责人用例执行情况',img:bar },

342
src/views/xm/rpt/testCase/testCaseSort.vue

@ -0,0 +1,342 @@
<template>
<section>
<el-row :gutter="5" >
<el-col :span="18">
<div>
<div class="echart-box" id="testCaseSort"></div>
<div class="progress"></div>
</div>
</el-col>
<el-col :span="6" class="border">
<el-form :model="filters" class="padding" :style="{width:'100%',maxHeight:maxTableHeight+'px',overflow: 'auto'}" ref="filtersRef">
<el-form-item label="分组属性">
<el-select v-model="groupBy">
<el-option v-for="i in this.groupBys" :label="i.name" :key="i.id" :value="i.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="测试库" v-if="xmTestCasedb && xmTestCasedb.id" >
<span >{{xmTestCasedb.id}} <span v-if="xmTestCasedb.name"><br/>{{ xmTestCasedb.name }} </span> </span>
</el-form-item>
<el-form-item label="归属项目" >
<xm-project-select v-if="!xmProject" ref="xmProjectSelect" style="display:inline;" :auto-select="false" :link-product-id="xmProductCpd?xmProductCpd.id:null" @row-click="onProjectSelected" @clear="onProjectClear"></xm-project-select>
<span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
</el-form-item>
<el-form-item label="归属产品" >
<xm-product-select v-if="!xmProductCpd || !xmProductCpd.id" ref="xmProductSelect" style="display:inline;" :auto-select="false" :link-project-id="xmProject?xmProject.id:null" @row-click="onProductSelected" :iterationId="xmTestPlan?xmTestPlan.id:null" @clear="onProductClear"></xm-product-select>
<span v-else>{{xmProductCpd.id}} <span v-if="xmProductCpd.productName"><br/>{{ xmProductCpd.productName }} </span> </span>
</el-form-item>
<el-form-item label="归属迭代" v-if="xmIteration && xmIteration.id">
<span> {{xmIteration.id}}
<span v-if="xmIteration.iterationName"><br/>{{ xmIteration.iterationName }} </span>
</span>
</el-form-item>
<el-form-item label="归属迭代" v-else-if="filters.product && filters.product.id">
<xm-iteration-select ref="xmIterationSelect" :auto-select="false" :product-id="filters.product?filters.product.id:null" :link-project-id="xmProject?xmProject.id:null" placeholder="迭代" @row-click="onIterationSelected" @clear="onIterationClear"></xm-iteration-select>
</el-form-item>
<el-form-item label="用例状态" prop="caseStatus">
<el-select v-model="filters.caseStatus" clearable>
<el-option v-for="i in this.dicts.caseStatus" :label="i.name" :key="i.id" :value="i.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="用例类型" prop="caseType" >
<el-select v-model="filters.bugType" clearable>
<el-option v-for="i in this.dicts.bugType" :label="i.name" :key="i.id" :value="i.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="测试方式" prop="testType">
<el-select v-model="filters.testType" clearable>
<el-option v-for="i in this.dicts.testType" :label="i.name" :key="i.id" :value="i.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="优先级" prop="cpriority" >
<el-select v-model="filters.cpriority" clearable>
<el-option v-for="i in dicts.priority" :label="i.name" :key="i.id" :value="i.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="searchXmTestCaseSort">查询</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
</section>
</template>
<script>
import util from '@/common/js/util';//
import {formatterLabel} from '@/api/xm/rpt.js';//
import { initSimpleDicts } from '@/api/mdp/meta/item';//
import { mapGetters } from 'vuex'
import { getXmTestCaseSort } from '@/api/xm/core/xmTestCase';
import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//
import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//
import XmIterationSelect from '@/views/xm/core/components/XmIterationSelect';//
export default {
components: {
XmProjectSelect,XmProductSelect,XmIterationSelect
},
props:['xmProject','xmProduct','xmIteration','xmTestCasedb','initGroupBy'],
computed: {
...mapGetters([
'userInfo','roles'
]),
xmTestCaseSortCpd(){
if(this.xmTestCaseSort.length==0){
return []
}else{
return this.xmTestCaseSort.map(i=>i.value)
}
},
legendCpd(){
if(this.xmTestCaseSort.length==0){
return []
}else{
return this.xmTestCaseSort.map(i=>i.name)
}
},
title(){
var preName=""
if(this.filters.testCasedb && this.filters.testCasedb.id){
preName=`测试库【${this.filters.testCasedb.name}`
}else if(this.filters.iteration && this.filters.iteration.id){
preName=`迭代【${this.filters.iteration.iterationName}`
}else if(this.filters.project && this.filters.project.id){
if(this.filters.project.name){
preName=`项目【${this.filters.project.name}`
}else{
preName=`项目【${this.filters.project.id}`
}
}else if(this.filters.product && this.filters.product.id){
if(this.filters.product.productName){
preName=`产品【${this.filters.product.productName}`
}else{
preName=`产品【${this.filters.product.id}`
}
}
return preName+ this.groupBys.find(i=>i.id==this.groupBy).name+'排行榜'
},
xmProductCpd(){
if(this.xmIteration && this.xmIteration.id && this.xmIteration.productId){
return {id:this.xmIteration.productId,productName:this.xmIteration.productName}
}
if(this.xmTestCasedb && this.xmTestCasedb.id && this.xmTestCasedb.productId){
return {id:this.xmTestCasedb.productId,productName:this.xmTestCasedb.productName}
}
if(this.xmProduct && this.xmProduct.id){
return this.xmProduct
}
return null;
}
},
watch: {
xmTestCaseSortCpd(){
this.drawCharts();
}
},
data() {
return {
filters:{
product:null,
project:null,
iteration:null,
testCasedb:null,
caseStatus:'',
testType:'',
cpriority:'',
caseType:'',
},
groupBy:'menu_id',
groupBys:[
{id:'menu_id', name:'故事'},
{id:'cuserid', name:'负责人'},
{id:'func_id', name:'模块'},
],
dicts:{testPlanTcode:[]},// params=[{categoryId:'0001',itemCode:'sex'}] {'sex':[{optionValue:'1',optionName:'',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'',seqOrder:'2',fp:'',isDefault:'0'}]}
load:{ list: false, edit: false, del: false, add: false },//...
dateRanger:[],
maxTableHeight:300,
visible:false,
xmTestCaseSort:[],
conditionBtnVisible:false,
}//end return
},//end data
methods: {
formatDict(itemId,val){
var dict=this.dicts[itemId]
if(dict){
var item=dict.find(i=>i.id==val)
if(item){
return item.name
}
}
return val;
},
drawCharts() {
this.myChart = this.$echarts.init(document.getElementById("testCaseSort"));
this.myChart.setOption(
{
title: {
text: this.title,
left: 'center',
},
tooltip: {
trigger: 'axis',
},
barMaxWidth: 100,
toolbox: {
show: true,
top:"5%",
top:"5%",
right:"10px",
feature: {
dataView: { show: true, readOnly: false },
magicType: { show: true, type: ['line', 'bar'] },
saveAsImage: { show: true }
}
},
calculable: true,
xAxis: {
type: 'category',
data: this.legendCpd,
axisLabel: {
formatter: formatterLabel
}
},
yAxis: {
type: 'value'
},
series: [
{
data: this.xmTestCaseSortCpd,
type: 'bar',
label:{
show: true,
},
}
]
}
)
},
searchXmTestCaseSort(){
var params={ }
if(this.filters.product && this.filters.product.id){
params.productId=this.filters.product.id
}
if(this.filters.project && this.filters.project.id){
params.projectId=this.filters.project.id
}
if(this.filters.iteration && this.filters.iteration.id){
params.iterationId=this.filters.iteration.id
}
if(this.filters.testCasedb && this.filters.testCasedb.id){
params.casedbId=this.filters.testCasedb.id
}
if(this.filters.testType){
params.testType=this.filters.testType
}
if(this.filters.caseType){
params.caseType=this.filters.caseType
}
if(this.filters.caseStatus){
params.caseStatus=this.filters.caseStatus
}
if(this.filters.cpriority){
params.cpriority=this.filters.cpriority
}
params.groupBy=this.groupBy;
getXmTestCaseSort(params).then(res=>{
var data=res.data.data
if(data){
data.sort((a,b)=>{
if(a.value<b.value){
return 1
}else if(a.value>b.value){
return -1
}else{
return 0
}
})
}
this.xmTestCaseSort=data
})
},
onProjectSelected(project){
this.filters.project=project
},
onProjectClear(){
this.filters.project=null
},
onProductSelected(product){
this.filters.product=product
},
onProductClear(){
this.filters.product=null
},
onIterationSelected(iteration){
this.filters.iteration=iteration
},
onIterationClear(){
this.filters.iteration=null
},
initData(){
},
sizeAutoChange(){
this.myChart.resize();
},
open(){
this.visible=true;
if(this.initGroupBy){
this.groupBy=this.initGroupBy
}
this.filters.product=this.xmProduct
this.filters.project=this.xmProject
this.filters.iteration=this.xmIteration
this.filters.testCasedb=this.xmTestCasedb
this.searchXmTestCaseSort();
}
},//end method
mounted() {
initSimpleDicts('all',['caseStatus','testType','priority','bugType'] ).then(res=>{
this.dicts=res.data.data;
})
this.initData();
this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
//this.charts();
this.open();
}//end mounted
}
</script>
<style scoped>
.image {
width: 100%;
display: block;
}
</style>
Loading…
Cancel
Save