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.

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