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.

336 lines
11 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
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="testPlanCaseUserDist"
  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="searchXmTestPlanCaseUserDist">查询</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 { getXmTestPlanCaseUserDist } 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. hadExecCpd(){
  70. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  71. return []
  72. }else{
  73. return this.xmTestPlanCaseUserDists.map(i=>i.hadExec)
  74. }
  75. },
  76. notExecCpd(){
  77. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  78. return []
  79. }else{
  80. return this.xmTestPlanCaseUserDists.map(i=>i.notExec)
  81. }
  82. },
  83. legendCpd(){
  84. if(!this.xmTestPlanCaseUserDists ||this.xmTestPlanCaseUserDists.length==0){
  85. return []
  86. }else{
  87. return this.xmTestPlanCaseUserDists.map(i=>i.execUsername)
  88. }
  89. },
  90. xmTestPlanCaseUserDistsCpd(){
  91. if(!this.xmTestPlanCaseUserDists || this.xmTestPlanCaseUserDists.length==0){
  92. return []
  93. }else{
  94. var datas=[]
  95. this.xmTestPlanCaseUserDists.forEach(i=>{
  96. var data={}
  97. var itemId="testPlanTcode";
  98. data.name=this.formatDict(itemId,i.execStatus)
  99. data.value=i.totalCnt
  100. datas.push(data)
  101. })
  102. return datas;
  103. }
  104. },
  105. title(){
  106. var preName=""
  107. if(this.filters.testPlan && this.filters.testPlan.id){
  108. preName=`测试计划【${this.filters.testPlan.name}`
  109. }else if(this.filters.testCasedb && this.filters.testCasedb.id){
  110. preName=`测试库【${this.filters.testCasedb.name}`
  111. }else if(this.filters.iteration && this.filters.iteration.id){
  112. preName=`迭代【${this.filters.iteration.iterationName}`
  113. }else if(this.filters.project && this.filters.project.id){
  114. if(this.filters.project.name){
  115. preName=`项目【${this.filters.project.name}`
  116. }else{
  117. preName=`项目【${this.filters.project.id}`
  118. }
  119. }else if(this.filters.product && this.filters.product.id){
  120. if(this.filters.product.productName){
  121. preName=`产品【${this.filters.product.productName}`
  122. }else{
  123. preName=`产品【${this.filters.product.id}`
  124. }
  125. }
  126. return preName+ '测试用例执行结果数量分布'
  127. },
  128. xmProductCpd(){
  129. if(this.xmTestPlan && this.xmTestPlan.id){
  130. return {id:this.xmTestPlan.productId,productName:this.xmTestPlan.productName}
  131. }
  132. if(this.xmProduct && this.xmProduct.id){
  133. return this.xmProduct
  134. }
  135. return null;
  136. }
  137. },
  138. watch: {
  139. xmTestPlanCaseUserDistsCpd(){
  140. this.drawCharts();
  141. }
  142. },
  143. data() {
  144. return {
  145. filters:{
  146. product:null,
  147. project:null,
  148. testPlan:null,
  149. iteration:null,
  150. testCasedb:null,
  151. },
  152. dicts:{testPlanTcode:[]},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
  153. load:{ list: false, edit: false, del: false, add: false },//查询中...
  154. dateRanger:[],
  155. maxTableHeight:300,
  156. visible:false,
  157. xmTestPlanCaseUserDists:[],
  158. conditionBtnVisible:false,
  159. }//end return
  160. },//end data
  161. methods: {
  162. formatDict(itemId,val){
  163. var dict=this.dicts[itemId]
  164. if(dict){
  165. var item=dict.find(i=>i.id==val)
  166. if(item){
  167. return item.name
  168. }
  169. }
  170. return val;
  171. },
  172. drawCharts() {
  173. this.myChart = this.$echarts.init(document.getElementById("testPlanCaseUserDist"));
  174. this.myChart.setOption(
  175. {
  176. title: {
  177. text: this.title,
  178. left: 'center'
  179. },
  180. tooltip: {
  181. trigger: 'item',
  182. },
  183. barMaxWidth: 100,
  184. toolbox: {
  185. show: true,
  186. right:"20px",
  187. feature: {
  188. dataView: { show: true, readOnly: false },
  189. magicType: { show: true, type: ['line', 'bar'] },
  190. saveAsImage: { show: true }
  191. }
  192. },
  193. calculable: true,
  194. legend: {
  195. top:'5%',
  196. left: 'center',
  197. data: ['已执行', '未执行']
  198. },
  199. xAxis: {
  200. type: 'category',
  201. data: this.legendCpd
  202. },
  203. yAxis: {
  204. type: 'value'
  205. },
  206. series: [
  207. {
  208. name: '已执行',
  209. type: 'bar',
  210. data: this.hadExecCpd,
  211. label:{
  212. show: true,
  213. },
  214. },
  215. {
  216. name: '未执行',
  217. type: 'bar',
  218. data: this.notExecCpd,
  219. label:{
  220. show: true,
  221. },
  222. },
  223. ]
  224. }
  225. )
  226. },
  227. searchXmTestPlanCaseUserDist(){
  228. var params={ }
  229. if(this.filters.product && this.filters.product.id){
  230. params.productId=this.filters.product.id
  231. }
  232. if(this.filters.project && this.filters.project.id){
  233. params.projectId=this.filters.project.id
  234. }
  235. if(this.filters.iteration && this.filters.iteration.id){
  236. params.linkIterationId=this.filters.iteration.id
  237. }
  238. if(this.filters.testPlan && this.filters.testPlan.id){
  239. params.planId=this.filters.testPlan.id
  240. }
  241. if(this.filters.testCasedb && this.filters.testCasedb.id){
  242. params.casedbId=this.filters.testCasedb.id
  243. }
  244. getXmTestPlanCaseUserDist(params).then(res=>{
  245. this.xmTestPlanCaseUserDists=res.data.data
  246. })
  247. },
  248. onProjectSelected(project){
  249. this.filters.project=project
  250. },
  251. onProjectClear(){
  252. this.filters.project=null
  253. },
  254. onProductSelected(product){
  255. this.filters.product=product
  256. },
  257. onProductClear(){
  258. this.filters.product=null
  259. },
  260. onIterationSelected(iteration){
  261. this.filters.iteration=iteration
  262. },
  263. onIterationClear(){
  264. this.filters.iteration=null
  265. },
  266. onXmTestPlanSelected(xmTestPlan){
  267. this.filters.testPlan=xmTestPlan
  268. },
  269. onXmTestPlanClear(){
  270. this.filters.testPlan=null
  271. },
  272. initData(){
  273. if(this.xmTestPlan){
  274. this.filters.testPlan=this.xmTestPlan
  275. }
  276. },
  277. sizeAutoChange(){
  278. this.myChart.resize();
  279. },
  280. open(){
  281. this.visible=true;
  282. this.filters.testPlan=this.xmTestPlan
  283. this.filters.product=this.xmProduct
  284. this.filters.project=this.xmProject
  285. this.filters.iteration=this.xmIteration
  286. this.filters.testCasedb=this.xmTestCasedb
  287. this.searchXmTestPlanCaseUserDist();
  288. }
  289. },//end method
  290. mounted() {
  291. initSimpleDicts('all',['testPlanTcode'] ).then(res=>{
  292. this.dicts=res.data.data;
  293. })
  294. this.initData();
  295. this.open();
  296. }//end mounted
  297. }
  298. </script>
  299. <style scoped>
  300. .image {
  301. width: 100%;
  302. display: block;
  303. }
  304. </style>