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.

292 lines
9.3 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
  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:600px;margin:0 auto;"></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">
  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. return '测试用例执行结果数量分布'
  86. },
  87. /**0-未测,1-通过,2-受阻,3-忽略,4-失败 */
  88. legendCpd(){
  89. var itemId="testStepTcode";
  90. return this.dicts[itemId].map(i=>this.formatDict(itemId,i.id))
  91. },
  92. xmProductCpd(){
  93. if(this.xmTestPlan && this.xmTestPlan.id){
  94. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  95. }
  96. if(this.xmProduct && this.xmProduct.id){
  97. return this.xmProduct
  98. }
  99. return null;
  100. }
  101. },
  102. watch: {
  103. xmTestPlanCaseExecStatusDistsCpd(){
  104. this.drawCharts();
  105. }
  106. },
  107. data() {
  108. return {
  109. filters:{
  110. product:null,
  111. project:null,
  112. testPlan:null,
  113. iteration:null,
  114. testCasedb:null,
  115. },
  116. dicts:{testStepTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  117. load:{ list: false, edit: false, del: false, add: false },//查询中...
  118. dateRanger:[],
  119. maxTableHeight:300,
  120. visible:false,
  121. xmTestPlanCaseExecStatusDists:[],
  122. conditionBtnVisible:false,
  123. }//end return
  124. },//end data
  125. methods: {
  126. formatDict(itemId,val){
  127. var dict=this.dicts[itemId]
  128. if(dict){
  129. var item=dict.find(i=>i.id==val)
  130. if(item){
  131. return item.name
  132. }
  133. }
  134. return val;
  135. },
  136. drawCharts() {
  137. this.myChart = this.$echarts.init(document.getElementById("testPlanCaseExecStatusDist"));
  138. this.myChart.setOption(
  139. {
  140. title: {
  141. text: this.title,
  142. left: 'center'
  143. },
  144. tooltip: {
  145. trigger: 'item',
  146. formatter:'{b} {c}个 {d}%',
  147. },
  148. toolbox: {
  149. show: true,
  150. feature: {
  151. dataView: { show: true, readOnly: false },
  152. magicType: { show: true, type: ['line', 'bar'] },
  153. restore: { show: true },
  154. saveAsImage: { show: true }
  155. }
  156. },
  157. calculable: true,
  158. legend: {
  159. top:'5%',
  160. left: 'center',
  161. data:this.legendCpd,
  162. },
  163. series: [
  164. {
  165. type: 'pie',
  166. radius: '50%',
  167. data: this.xmTestPlanCaseExecStatusDistsCpd,
  168. emphasis: {
  169. itemStyle: {
  170. shadowBlur: 10,
  171. shadowOffsetX: 0,
  172. shadowColor: 'rgba(0, 0, 0, 0.5)'
  173. }
  174. },
  175. label: {
  176. show: true,
  177. formatter:'{b} {c}个 {d}%',
  178. },
  179. }
  180. ]
  181. }
  182. )
  183. },
  184. onXmQuestionSomeFieldsChange(fieldName,$event){
  185. this.xmTestPlanCaseExecStatusDists=[]
  186. },
  187. searchXmTestPlanCaseExecStatusDist(){
  188. var params={ }
  189. if(this.filters.product && this.filters.product.id){
  190. params.productId=this.filters.product.id
  191. }
  192. if(this.filters.project && this.filters.project.id){
  193. params.projectId=this.filters.project.id
  194. }
  195. if(this.filters.iteration && this.filters.iteration.id){
  196. params.linkIterationId=this.filters.iteration.id
  197. }
  198. if(this.filters.testPlan && this.filters.testPlan.id){
  199. params.planId=this.filters.testPlan.id
  200. }
  201. if(this.filters.testCasedb && this.filters.testCasedb.id){
  202. params.casedbId=this.filters.testCasedb.id
  203. }
  204. getXmTestPlanCaseExecStatusDist(params).then(res=>{
  205. this.xmTestPlanCaseExecStatusDists=res.data.data
  206. })
  207. },
  208. onProjectSelected(project){
  209. this.filters.project=project
  210. },
  211. onProjectClear(){
  212. this.filters.project=null
  213. },
  214. onProductSelected(product){
  215. this.filters.product=product
  216. },
  217. onProductClear(){
  218. this.filters.product=null
  219. },
  220. onIterationSelected(iteration){
  221. this.filters.iteration=iteration
  222. },
  223. onIterationClear(){
  224. this.filters.iteration=null
  225. },
  226. onXmTestPlanSelected(xmTestPlan){
  227. this.filters.testPlan=xmTestPlan
  228. },
  229. onXmTestPlanClear(){
  230. this.filters.testPlan=null
  231. },
  232. initData(){
  233. if(this.xmTestPlan){
  234. this.filters.testPlan=this.xmTestPlan
  235. }
  236. },
  237. sizeAutoChange(){
  238. this.myChart.resize();
  239. },
  240. open(){
  241. this.visible=true;
  242. this.filters.testPlan=this.xmTestPlan
  243. this.filters.product=this.xmProduct
  244. this.filters.project=this.xmProject
  245. this.filters.iteration=this.xmIteration
  246. this.filters.testCasedb=this.xmTestCasedb
  247. this.searchXmTestPlanCaseExecStatusDist();
  248. }
  249. },//end method
  250. mounted() {
  251. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  252. this.dicts=res.data.data;
  253. })
  254. this.initData();
  255. this.open();
  256. }//end mounted
  257. }
  258. </script>
  259. <style scoped>
  260. .image {
  261. width: 100%;
  262. display: block;
  263. }
  264. </style>