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.

315 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
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. top:"5%",
  170. right:"10px",
  171. feature: {
  172. dataView: { show: true, readOnly: false },
  173. saveAsImage: { show: true },
  174. }
  175. },
  176. calculable: true,
  177. legend: {
  178. top:'5%',
  179. left: 'center',
  180. data:this.legendCpd,
  181. },
  182. series: [
  183. {
  184. type: 'pie',
  185. radius: '50%',
  186. data: this.xmTestPlanCaseExecStatusDistsCpd,
  187. emphasis: {
  188. itemStyle: {
  189. shadowBlur: 10,
  190. shadowOffsetX: 0,
  191. shadowColor: 'rgba(0, 0, 0, 0.5)'
  192. }
  193. },
  194. label: {
  195. show: true,
  196. formatter:'{b}: {c} ({d}%)'
  197. },
  198. }
  199. ]
  200. }
  201. )
  202. },
  203. onXmQuestionSomeFieldsChange(fieldName,$event){
  204. this.xmTestPlanCaseExecStatusDists=[]
  205. },
  206. searchXmTestPlanCaseExecStatusDist(){
  207. var params={ }
  208. if(this.filters.product && this.filters.product.id){
  209. params.productId=this.filters.product.id
  210. }
  211. if(this.filters.project && this.filters.project.id){
  212. params.projectId=this.filters.project.id
  213. }
  214. if(this.filters.iteration && this.filters.iteration.id){
  215. params.linkIterationId=this.filters.iteration.id
  216. }
  217. if(this.filters.testPlan && this.filters.testPlan.id){
  218. params.planId=this.filters.testPlan.id
  219. }
  220. if(this.filters.testCasedb && this.filters.testCasedb.id){
  221. params.casedbId=this.filters.testCasedb.id
  222. }
  223. getXmTestPlanCaseExecStatusDist(params).then(res=>{
  224. this.xmTestPlanCaseExecStatusDists=res.data.data
  225. })
  226. },
  227. onProjectSelected(project){
  228. this.filters.project=project
  229. },
  230. onProjectClear(){
  231. this.filters.project=null
  232. },
  233. onProductSelected(product){
  234. this.filters.product=product
  235. },
  236. onProductClear(){
  237. this.filters.product=null
  238. },
  239. onIterationSelected(iteration){
  240. this.filters.iteration=iteration
  241. },
  242. onIterationClear(){
  243. this.filters.iteration=null
  244. },
  245. onXmTestPlanSelected(xmTestPlan){
  246. this.filters.testPlan=xmTestPlan
  247. },
  248. onXmTestPlanClear(){
  249. this.filters.testPlan=null
  250. },
  251. initData(){
  252. if(this.xmTestPlan){
  253. this.filters.testPlan=this.xmTestPlan
  254. }
  255. },
  256. sizeAutoChange(){
  257. this.myChart.resize();
  258. },
  259. open(){
  260. this.visible=true;
  261. this.filters.testPlan=this.xmTestPlan
  262. this.filters.product=this.xmProduct
  263. this.filters.project=this.xmProject
  264. this.filters.iteration=this.xmIteration
  265. this.filters.testCasedb=this.xmTestCasedb
  266. this.searchXmTestPlanCaseExecStatusDist();
  267. }
  268. },//end method
  269. mounted() {
  270. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  271. this.dicts=res.data.data;
  272. })
  273. this.initData();
  274. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.filtersRef.$el)
  275. //this.charts();
  276. this.open();
  277. }//end mounted
  278. }
  279. </script>
  280. <style scoped>
  281. .image {
  282. width: 100%;
  283. display: block;
  284. }
  285. </style>