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.

289 lines
9.2 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
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="testPlanCaseUserDist"
  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="测试库" v-if="xmTestCasedb && xmTestCasedb.id" >
  15. <span >{{xmTestCasedb.id}} <span v-if="xmTestCasedb.name"><br/>{{ xmTestCasedb.name }} </span> </span>
  16. </el-form-item>
  17. <el-form-item label="归属项目" >
  18. <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>
  19. <span v-else>{{xmProject.id}} <span v-if="xmProject.name"><br/>{{ xmProject.name }} </span> </span>
  20. </el-form-item>
  21. <el-form-item label="归属产品" >
  22. <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>
  23. <span v-else>{{xmProductCpd.id}} <span v-if="xmProductCpd.productName"><br/>{{ xmProductCpd.productName }} </span> </span>
  24. </el-form-item>
  25. <el-form-item label="归属迭代" v-if="xmIteration && xmIteration.id">
  26. <span> {{xmIteration.id}}
  27. <span v-if="xmIteration.iterationName"><br/>{{ xmIteration.iterationName }} </span>
  28. </span>
  29. </el-form-item>
  30. <el-form-item label="归属迭代" v-else-if="filters.product && filters.product.id">
  31. <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>
  32. </el-form-item>
  33. <el-form-item label="测试计划" v-if="xmTestPlan && xmTestPlan.id">
  34. <span> {{xmTestPlan.id}}
  35. <span v-if="xmTestPlan.name"><br/>{{ xmTestPlan.name }} </span>
  36. </span>
  37. </el-form-item>
  38. <el-form-item label="测试计划" v-else-if="filters.product && filters.product.id">
  39. <span v-if="filters.testPlan">{{ filters.testPlan.name }}</span>
  40. <el-button v-if="filters.testPlan" type="text" @click="filters.testPlan=null" plain icon="el-icon-circle-close">清除</el-button>
  41. <el-button v-if="!filters.testPlan" type="text" @click="$refs['xmTestPlanSelectRef'].open()" plain>选择计划</el-button>
  42. </el-form-item>
  43. <el-form-item>
  44. <el-button type="primary" icon="el-icon-search" @click="searchXmTestPlanCaseUserDist">查询</el-button>
  45. </el-form-item>
  46. </el-form>
  47. </el-col>
  48. </el-row>
  49. <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 >
  50. </el-dialog>
  51. </section>
  52. </template>
  53. <script>
  54. import util from '@/common/js/util';//全局公共库
  55. import { initSimpleDicts } from '@/api/mdp/meta/item';//下拉框数据查询
  56. import { mapGetters } from 'vuex'
  57. import { getXmTestPlanCaseUserDist } from '@/api/xm/core/xmTestPlanCase';
  58. import XmProjectSelect from '@/views/xm/core/components/XmProjectSelect';//项目
  59. import XmProductSelect from '@/views/xm/core/components/XmProductSelect';//产品
  60. import XmIterationSelect from '@/views/xm/core/components/XmIterationSelect';//迭代选择界面
  61. import xmTestPlanSelect from '@/views/xm/core/xmTestPlan/XmTestPlanSelect';//计划选择器
  62. export default {
  63. components: {
  64. XmProjectSelect,XmProductSelect,XmIterationSelect,xmTestPlanSelect,
  65. },
  66. props:['xmProject','xmProduct','xmIteration','xmTestCasedb','xmTestPlan'],
  67. computed: {
  68. ...mapGetters([
  69. 'userInfo','roles'
  70. ]),
  71. hadExecCpd(){
  72. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  73. return []
  74. }else{
  75. return this.xmTestPlanCaseUserDists.map(i=>i.hadExec)
  76. }
  77. },
  78. notExecCpd(){
  79. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  80. return []
  81. }else{
  82. return this.xmTestPlanCaseUserDists.map(i=>i.notExec)
  83. }
  84. },
  85. legendCpd(){
  86. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  87. return []
  88. }else{
  89. return this.xmTestPlanCaseUserDists.map(i=>i.execUsername)
  90. }
  91. },
  92. xmTestPlanCaseUserDistsCpd(){
  93. if(!this.xmTestPlanCaseUserDists || this.xmTestPlanCaseUserDists.length==0){
  94. return []
  95. }else{
  96. var datas=[]
  97. this.xmTestPlanCaseUserDists.forEach(i=>{
  98. var data={}
  99. var itemId="testPlanTcode";
  100. data.name=this.formatDict(itemId,i.execStatus)
  101. data.value=i.totalCnt
  102. datas.push(data)
  103. })
  104. return datas;
  105. }
  106. },
  107. title(){
  108. return '测试用例执行结果数量分布'
  109. },
  110. xmProductCpd(){
  111. if(this.xmTestPlan && this.xmTestPlan.id){
  112. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  113. }
  114. if(this.xmProduct && this.xmProduct.id){
  115. return this.xmProduct
  116. }
  117. return null;
  118. }
  119. },
  120. watch: {
  121. xmTestPlanCaseUserDistsCpd(){
  122. this.drawCharts();
  123. }
  124. },
  125. data() {
  126. return {
  127. filters:{
  128. product:null,
  129. project:null,
  130. testPlan:null,
  131. iteration:null,
  132. testCasedb:null,
  133. },
  134. dicts:{testPlanTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  135. load:{ list: false, edit: false, del: false, add: false },//查询中...
  136. dateRanger:[],
  137. maxTableHeight:300,
  138. visible:false,
  139. xmTestPlanCaseUserDists:[],
  140. conditionBtnVisible:false,
  141. }//end return
  142. },//end data
  143. methods: {
  144. formatDict(itemId,val){
  145. var dict=this.dicts[itemId]
  146. if(dict){
  147. var item=dict.find(i=>i.id==val)
  148. if(item){
  149. return item.name
  150. }
  151. }
  152. return val;
  153. },
  154. drawCharts() {
  155. this.myChart = this.$echarts.init(document.getElementById("testPlanCaseUserDist"));
  156. this.myChart.setOption(
  157. {
  158. xAxis: {
  159. type: 'category',
  160. data: this.legendCpd
  161. },
  162. yAxis: {
  163. type: 'value'
  164. },
  165. series: [
  166. {
  167. name: '已执行',
  168. type: 'bar',
  169. barGap: 0,
  170. emphasis: {
  171. focus: 'series'
  172. },
  173. data: this.hadExecCpd
  174. },
  175. {
  176. name: '未执行',
  177. type: 'bar',
  178. emphasis: {
  179. focus: 'series'
  180. },
  181. data: this.notExecCpd
  182. },
  183. ]
  184. }
  185. )
  186. },
  187. searchXmTestPlanCaseUserDist(){
  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. getXmTestPlanCaseUserDist(params).then(res=>{
  205. this.xmTestPlanCaseUserDists=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(params){
  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.searchXmTestPlanCaseUserDist();
  248. }
  249. },//end method
  250. mounted() {
  251. initSimpleDicts('all',['testPlanTcode'] ).then(res=>{
  252. this.dicts=res.data.data;
  253. })
  254. this.initData();
  255. }//end mounted
  256. }
  257. </script>
  258. <style scoped>
  259. .image {
  260. width: 100%;
  261. display: block;
  262. }
  263. </style>