You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

312 lines
10 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <section>
  3. <el-row :gutter="5" >
  4. <el-col :span="18">
  5. <div>
  6. <div class="main" id="testPlanCaseExecStatusDist"
  7. :style="{width:'100%',height:(maxTableHeight>600?600:maxTableHeight)+'px',overflow: 'hidden'}"></div>
  8. <div class="progress"></div>
  9. </div>
  10. </el-col>
  11. <el-col :span="6" class="border">
  12. <el-form :model="filters" class="padding" :style="{width:'100%',maxHeight:maxTableHeight+'px',overflow: 'auto'}" ref="filtersRef">
  13. <el-form-item label="测试库" v-if="xmTestCasedb && xmTestCasedb.id" >
  14. <span >{{xmTestCasedb.id}} <span v-if="xmTestCasedb.name"><br/>{{ xmTestCasedb.name }} </span> </span>
  15. </el-form-item>
  16. <el-form-item label="归属项目" >
  17. <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>
  18. <span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
  19. </el-form-item>
  20. <el-form-item label="归属产品" >
  21. <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>
  22. <span v-else>{{xmProductCpd.id}} <span v-if="xmProductCpd.productName"><br/>{{ xmProductCpd.productName }} </span> </span>
  23. </el-form-item>
  24. <el-form-item label="归属迭代" v-if="xmIteration && xmIteration.id">
  25. <span> {{xmIteration.id}}
  26. <span v-if="xmIteration.iterationName"><br/>{{ xmIteration.iterationName }} </span>
  27. </span>
  28. </el-form-item>
  29. <el-form-item label="归属迭代" v-else-if="filters.product && filters.product.id">
  30. <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>
  31. </el-form-item>
  32. <el-form-item label="测试计划" v-if="xmTestPlan && xmTestPlan.id">
  33. <span> {{xmTestPlan.id}}
  34. <span v-if="xmTestPlan.name"><br/>{{ xmTestPlan.name }} </span>
  35. </span>
  36. </el-form-item>
  37. <el-form-item label="测试计划" v-else-if="filters.product && filters.product.id">
  38. <span v-if="filters.testPlan">{{ filters.testPlan.name }}</span>
  39. <el-button v-if="filters.testPlan" type="text" @click="filters.testPlan=null" plain icon="el-icon-circle-close">清除</el-button>
  40. <el-button v-if="!filters.testPlan" type="text" @click="$refs['xmTestPlanSelectRef'].open()" plain>选择计划</el-button>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="primary" icon="el-icon-search" @click="searchXmTestPlanCaseExecStatusDist">查询</el-button>
  44. </el-form-item>
  45. </el-form>
  46. </el-col>
  47. </el-row>
  48. <xm-test-plan-select ref="xmTestPlanSelectRef" :casedb-id="xmTestCasedb?xmTestCasedb.id:null" :product-id="xmProduct?xmProduct.id:null" :project-id="xmProject?xmProject.id:null" placeholder="迭代" @select="onXmTestPlanSelected" @clear="onXmTestPlanClear"></xm-test-plan-select >
  49. </section>
  50. </template>
  51. <script>
  52. import util from '@/common/js/util';//全局公共库
  53. import { initSimpleDicts } from '@/api/mdp/meta/item';//下拉框数据查询
  54. import { mapGetters } from 'vuex'
  55. import { getXmTestPlanCaseExecStatusDist } from '@/api/xm/core/xmTestPlanCase';
  56. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//项目
  57. import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//产品
  58. import XmIterationSelect from '@/views/xm/core/components/XmIterationSelect';//迭代选择界面
  59. import xmTestPlanSelect from '@/views/xm/core/xmTestPlan/XmTestPlanSelect';//计划选择器
  60. export default {
  61. components: {
  62. XmProjectSelect,XmProductSelect,XmIterationSelect,xmTestPlanSelect,
  63. },
  64. props:['xmProject','xmProduct','xmIteration','xmTestCasedb','xmTestPlan'],
  65. computed: {
  66. ...mapGetters([
  67. 'userInfo','roles'
  68. ]),
  69. xmTestPlanCaseExecStatusDistsCpd(){
  70. if(!this.xmTestPlanCaseExecStatusDists || this.xmTestPlanCaseExecStatusDists.length==0){
  71. return []
  72. }else{
  73. var datas=[]
  74. this.xmTestPlanCaseExecStatusDists.forEach(i=>{
  75. var data={}
  76. var itemId="testStepTcode";
  77. data.name=this.formatDict(itemId,i.execStatus)
  78. data.value=i.totalCnt
  79. datas.push(data)
  80. })
  81. return datas;
  82. }
  83. },
  84. title(){
  85. var preName=""
  86. if(this.filters.testPlan && this.filters.testPlan.id){
  87. preName=`测试计划【${this.filters.testPlan.name}`
  88. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  89. preName=`测试库【${this.filters.testCasedb.name}`
  90. }else if(this.filters.iteration && this.filters.iteration.id){
  91. preName=`迭代【${this.filters.iteration.iterationName}`
  92. }else if(this.filters.project && this.filters.project.id){
  93. if(this.filters.project.name){
  94. preName=`项目【${this.filters.project.name}`
  95. }else{
  96. preName=`项目【${this.filters.project.id}`
  97. }
  98. }else if(this.filters.product && this.filters.product.id){
  99. if(this.filters.product.productName){
  100. preName=`产品【${this.filters.product.productName}`
  101. }else{
  102. preName=`产品【${this.filters.product.id}`
  103. }
  104. }
  105. return preName+ '测试用例执行结果数量分布'
  106. },
  107. /**0-未测,1-通过,2-受阻,3-忽略,4-失败 */
  108. legendCpd(){
  109. var itemId="testStepTcode";
  110. return this.dicts[itemId].map(i=>this.formatDict(itemId,i.id))
  111. },
  112. xmProductCpd(){
  113. if(this.xmTestPlan && this.xmTestPlan.id){
  114. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  115. }
  116. if(this.xmProduct && this.xmProduct.id){
  117. return this.xmProduct
  118. }
  119. return null;
  120. }
  121. },
  122. watch: {
  123. xmTestPlanCaseExecStatusDistsCpd(){
  124. this.drawCharts();
  125. }
  126. },
  127. data() {
  128. return {
  129. filters:{
  130. product:null,
  131. project:null,
  132. testPlan:null,
  133. iteration:null,
  134. testCasedb:null,
  135. },
  136. dicts:{testStepTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  137. load:{ list: false, edit: false, del: false, add: false },//查询中...
  138. dateRanger:[],
  139. maxTableHeight:300,
  140. visible:false,
  141. xmTestPlanCaseExecStatusDists:[],
  142. conditionBtnVisible:false,
  143. }//end return
  144. },//end data
  145. methods: {
  146. formatDict(itemId,val){
  147. var dict=this.dicts[itemId]
  148. if(dict){
  149. var item=dict.find(i=>i.id==val)
  150. if(item){
  151. return item.name
  152. }
  153. }
  154. return val;
  155. },
  156. drawCharts() {
  157. this.myChart = this.$echarts.init(document.getElementById("testPlanCaseExecStatusDist"));
  158. this.myChart.setOption(
  159. {
  160. title: {
  161. text: this.title,
  162. left: 'center'
  163. },
  164. tooltip: {
  165. trigger: 'item',
  166. },
  167. toolbox: {
  168. show: true,
  169. right:"20px",
  170. feature: {
  171. dataView: { show: true, readOnly: false },
  172. saveAsImage: { show: true },
  173. }
  174. },
  175. calculable: true,
  176. legend: {
  177. top:'5%',
  178. left: 'center',
  179. data:this.legendCpd,
  180. },
  181. series: [
  182. {
  183. type: 'pie',
  184. radius: '50%',
  185. data: this.xmTestPlanCaseExecStatusDistsCpd,
  186. emphasis: {
  187. itemStyle: {
  188. shadowBlur: 10,
  189. shadowOffsetX: 0,
  190. shadowColor: 'rgba(0, 0, 0, 0.5)'
  191. }
  192. },
  193. label: {
  194. show: true,
  195. formatter:'{b}: {c} ({d}%)'
  196. },
  197. }
  198. ]
  199. }
  200. )
  201. },
  202. onXmQuestionSomeFieldsChange(fieldName,$event){
  203. this.xmTestPlanCaseExecStatusDists=[]
  204. },
  205. searchXmTestPlanCaseExecStatusDist(){
  206. var params={ }
  207. if(this.filters.product && this.filters.product.id){
  208. params.productId=this.filters.product.id
  209. }
  210. if(this.filters.project && this.filters.project.id){
  211. params.projectId=this.filters.project.id
  212. }
  213. if(this.filters.iteration && this.filters.iteration.id){
  214. params.linkIterationId=this.filters.iteration.id
  215. }
  216. if(this.filters.testPlan && this.filters.testPlan.id){
  217. params.planId=this.filters.testPlan.id
  218. }
  219. if(this.filters.testCasedb && this.filters.testCasedb.id){
  220. params.casedbId=this.filters.testCasedb.id
  221. }
  222. getXmTestPlanCaseExecStatusDist(params).then(res=>{
  223. this.xmTestPlanCaseExecStatusDists=res.data.data
  224. })
  225. },
  226. onProjectSelected(project){
  227. this.filters.project=project
  228. },
  229. onProjectClear(){
  230. this.filters.project=null
  231. },
  232. onProductSelected(product){
  233. this.filters.product=product
  234. },
  235. onProductClear(){
  236. this.filters.product=null
  237. },
  238. onIterationSelected(iteration){
  239. this.filters.iteration=iteration
  240. },
  241. onIterationClear(){
  242. this.filters.iteration=null
  243. },
  244. onXmTestPlanSelected(xmTestPlan){
  245. this.filters.testPlan=xmTestPlan
  246. },
  247. onXmTestPlanClear(){
  248. this.filters.testPlan=null
  249. },
  250. initData(){
  251. if(this.xmTestPlan){
  252. this.filters.testPlan=this.xmTestPlan
  253. }
  254. },
  255. sizeAutoChange(){
  256. this.myChart.resize();
  257. },
  258. open(){
  259. this.visible=true;
  260. this.filters.testPlan=this.xmTestPlan
  261. this.filters.product=this.xmProduct
  262. this.filters.project=this.xmProject
  263. this.filters.iteration=this.xmIteration
  264. this.filters.testCasedb=this.xmTestCasedb
  265. this.searchXmTestPlanCaseExecStatusDist();
  266. }
  267. },//end method
  268. mounted() {
  269. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  270. this.dicts=res.data.data;
  271. })
  272. this.initData();
  273. this.open();
  274. }//end mounted
  275. }
  276. </script>
  277. <style scoped>
  278. .image {
  279. width: 100%;
  280. display: block;
  281. }
  282. </style>