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.

279 lines
9.1 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
  1. <template>
  2. <section>
  3. <el-dialog fullscreen :title="title" append-to-body modal-append-to-body width="80%" top="20px" :visible.sync="visible">
  4. <el-row :gutter="5" v-if="visible">
  5. <el-col :span="18">
  6. <div>
  7. <div class="main" id="testPlanCaseExecStatusDist"
  8. style="width:100%;height:600px;margin:0 auto;"></div>
  9. <div class="progress"></div>
  10. </div>
  11. </el-col>
  12. <el-col :span="6" class="border">
  13. <el-form :model="filters" class="padding">
  14. <el-form-item label="归属项目" >
  15. <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>
  16. <span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
  17. </el-form-item>
  18. <el-form-item label="归属产品" >
  19. <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>
  20. <span v-else>{{xmProductCpd.id}} <span v-if="xmProductCpd.productName"><br/>{{ xmProductCpd.productName }} </span> </span>
  21. </el-form-item>
  22. <el-form-item label="归属迭代" v-if="xmIteration && xmIteration.id">
  23. <span> {{xmIteration.id}}
  24. <span v-if="xmIteration.iterationName"><br/>{{ xmIteration.iterationName }} </span>
  25. </span>
  26. </el-form-item>
  27. <el-form-item label="归属迭代" v-else-if="filters.product && filters.product.id">
  28. <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>
  29. </el-form-item>
  30. <el-form-item label="测试计划" v-if="xmTestPlan && xmTestPlan.id">
  31. <span> {{xmTestPlan.id}}
  32. <span v-if="xmTestPlan.name"><br/>{{ xmTestPlan.name }} </span>
  33. </span>
  34. </el-form-item>
  35. <el-form-item label="测试计划" v-else-if="filters.product && filters.product.id">
  36. <span v-if="filters.testPlan">{{ filters.testPlan.name }}</span>
  37. <el-button v-if="filters.testPlan" type="text" @click="filters.testPlan=null" plain icon="el-icon-circle-close">清除</el-button>
  38. <el-button v-if="!filters.testPlan" type="text" @click="$refs['xmTestPlanSelectRef'].open()" plain>选择计划</el-button>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="primary" icon="el-icon-search" @click="searchXmTestPlanCaseExecStatusDist">查询</el-button>
  42. </el-form-item>
  43. </el-form>
  44. </el-col>
  45. </el-row>
  46. <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 >
  47. </el-dialog>
  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. return '测试用例执行结果数量分布'
  85. },
  86. /**0-未测,1-通过,2-受阻,3-忽略,4-失败 */
  87. legendCpd(){
  88. var itemId="testStepTcode";
  89. return this.dicts[itemId].map(i=>this.formatDict(itemId,i.id))
  90. },
  91. xmProductCpd(){
  92. if(this.xmTestPlan && this.xmTestPlan.id){
  93. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  94. }
  95. if(this.xmProduct && this.xmProduct.id){
  96. return this.xmProduct
  97. }
  98. return null;
  99. }
  100. },
  101. watch: {
  102. xmTestPlanCaseExecStatusDistsCpd(){
  103. this.drawCharts();
  104. }
  105. },
  106. data() {
  107. return {
  108. filters:{
  109. product:null,
  110. project:null,
  111. testPlan:null,
  112. iteration:null,
  113. testCasedb:null,
  114. },
  115. dicts:{testStepTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  116. load:{ list: false, edit: false, del: false, add: false },//查询中...
  117. dateRanger:[],
  118. maxTableHeight:300,
  119. visible:false,
  120. xmTestPlanCaseExecStatusDists:[],
  121. conditionBtnVisible:false,
  122. }//end return
  123. },//end data
  124. methods: {
  125. formatDict(itemId,val){
  126. var dict=this.dicts[itemId]
  127. if(dict){
  128. var item=dict.find(i=>i.id==val)
  129. if(item){
  130. return item.name
  131. }
  132. }
  133. return val;
  134. },
  135. drawCharts() {
  136. this.myChart = this.$echarts.init(document.getElementById("testPlanCaseExecStatusDist"));
  137. this.myChart.setOption(
  138. {
  139. title: {
  140. text: this.title,
  141. left: 'center'
  142. },
  143. tooltip: {
  144. trigger: 'item'
  145. },
  146. legend: {
  147. top:'5%',
  148. left: 'center',
  149. data:this.legendCpd,
  150. },
  151. series: [
  152. {
  153. type: 'pie',
  154. radius: '50%',
  155. data: this.xmTestPlanCaseExecStatusDistsCpd,
  156. emphasis: {
  157. itemStyle: {
  158. shadowBlur: 10,
  159. shadowOffsetX: 0,
  160. shadowColor: 'rgba(0, 0, 0, 0.5)'
  161. }
  162. },
  163. label: {
  164. show: true,
  165. position: 'center'
  166. },
  167. }
  168. ]
  169. }
  170. )
  171. },
  172. onXmQuestionSomeFieldsChange(fieldName,$event){
  173. this.xmTestPlanCaseExecStatusDists=[]
  174. },
  175. searchXmTestPlanCaseExecStatusDist(){
  176. var params={ }
  177. if(this.filters.product && this.filters.product.id){
  178. params.productId=this.filters.product.id
  179. }
  180. if(this.filters.project && this.filters.project.id){
  181. params.projectId=this.filters.project.id
  182. }
  183. if(this.filters.iteration && this.filters.iteration.id){
  184. params.linkIterationId=this.filters.iteration.id
  185. }
  186. if(this.filters.testPlan && this.filters.testPlan.id){
  187. params.planId=this.filters.testPlan.id
  188. }
  189. if(this.filters.testCasedb && this.filters.testCasedb.id){
  190. params.casedbId=this.filters.testCasedb.id
  191. }
  192. if(params.productId || params.projectId || params.planId || params.casedbId || params.linkIterationId){
  193. getXmTestPlanCaseExecStatusDist(params).then(res=>{
  194. this.xmTestPlanCaseExecStatusDists=res.data.data
  195. })
  196. }else{
  197. this.$message.error("请选择查询条件,项目、产品、迭代、测试计划最少选择一个")
  198. }
  199. },
  200. onProjectSelected(project){
  201. this.filters.project=project
  202. },
  203. onProjectClear(){
  204. this.filters.project=null
  205. },
  206. onProductSelected(product){
  207. this.filters.product=product
  208. },
  209. onProductClear(){
  210. this.filters.product=null
  211. },
  212. onIterationSelected(iteration){
  213. this.filters.iteration=iteration
  214. },
  215. onIterationClear(){
  216. this.filters.iteration=null
  217. },
  218. onXmTestPlanSelected(xmTestPlan){
  219. this.filters.testPlan=xmTestPlan
  220. },
  221. onXmTestPlanClear(){
  222. this.filters.testPlan=null
  223. },
  224. initData(){
  225. if(this.xmTestPlan){
  226. this.filters.testPlan=this.xmTestPlan
  227. }
  228. },
  229. sizeAutoChange(){
  230. this.myChart.resize();
  231. },
  232. open(params){
  233. this.visible=true;
  234. this.filters.testPlan=this.xmTestPlan
  235. this.filters.product=this.xmProduct
  236. this.filters.project=this.xmProject
  237. this.filters.iteration=this.xmIteration
  238. this.filters.testCasedb=this.xmTestCasedb
  239. this.searchXmTestPlanCaseExecStatusDist();
  240. }
  241. },//end method
  242. mounted() {
  243. initSimpleDicts('all',['testStepTcode'] ).then(res=>{
  244. this.dicts=res.data.data;
  245. })
  246. this.initData();
  247. }//end mounted
  248. }
  249. </script>
  250. <style scoped>
  251. .image {
  252. width: 100%;
  253. display: block;
  254. }
  255. </style>